1 6 7 package SOFA.SOFAnet.Repository; 8 9 import java.io.*; 10 import java.util.*; 11 12 18 public class InputTriggers extends StorageBase 19 { 20 21 22 public InputTriggers(File baseDir) 23 { 24 super(baseDir, "it", true); 25 init(); 26 } 27 28 protected StorageItem newItem(String name, File file) 29 { 30 return new InputTrigger(name, file); 31 } 32 33 40 public InputTrigger getInputTrigger(String name) 41 { 42 return (InputTrigger)map.get(name); 43 } 44 45 51 public boolean deleteInputTrigger(String name) 52 { 53 synchronized (map) 54 { 55 InputTrigger inputTrigger = (InputTrigger)map.remove(name); 56 if (inputTrigger != null) 57 { 58 inputTrigger.deleteFromStorage(); 59 return true; 60 } 61 else return false; 62 } 63 } 64 65 92 public InputTrigger addInputTrigger(String name, 93 boolean customizableName, 94 int source, 95 int bundleType, 96 String description, 97 boolean autoDelete, 98 BundleNameFilter bundleFilter, 99 NodeNameFilter nodeFilter, 100 Date validFrom, 101 Date validTo, 102 String contractID, 103 String contractRule, 104 int actions, 105 int asNoLicences, ShareGroups asShareGroups, 107 NodeNameFilter asNodeFilter, 108 boolean asEquality, 109 OutputTrigger alpOutputTrigger, 110 NodeNameLicList apNodeNameLicList, 111 NodeNameList apoNodeNameList) 112 { 113 synchronized (map) 114 { 115 if (customizableName || name == null) 116 { 117 if (name == null || name.length() == 0) 118 { 119 name = "auto"; 120 Random random = new Random(); 121 for (int i = 0; i < 10; i++) name += Integer.toString(random.nextInt(16), 16); 122 } 123 124 String postfix = ""; 125 for (int i = 0; ; i++) 126 { 127 if (map.get(name + postfix) == null) 128 { 129 name += postfix; 130 break; 131 } 132 postfix = Integer.toString(i + 1); 133 } 134 } 135 else 136 { 137 if (map.get(name) != null) return null; 138 } 139 140 InputTrigger inputTrigger = new InputTrigger(name, new File(baseDir, name + ".it")); 141 inputTrigger.setSource(source); 142 inputTrigger.setBundleType(bundleType); 143 inputTrigger.setDescription(description); 144 inputTrigger.setAutoDelete(autoDelete); 145 inputTrigger.setBundleFilter(bundleFilter); 146 inputTrigger.setNodeFilter(nodeFilter); 147 inputTrigger.setValidFrom(validFrom); 148 inputTrigger.setValidTo(validTo); 149 inputTrigger.setContract(contractID, contractRule); 150 inputTrigger.setActions(actions); 151 inputTrigger.setAsNoLicences(asNoLicences); 152 inputTrigger.setAsShareGroups(asShareGroups); 153 inputTrigger.setAsNodeFilter(asNodeFilter); 154 inputTrigger.setAsEquality(asEquality); 155 inputTrigger.setAlpOutputTrigger(alpOutputTrigger); 156 inputTrigger.setApNodeNameLicList(apNodeNameLicList); 157 inputTrigger.setApoNodeNameList(apoNodeNameList); 158 159 inputTrigger.saveToStorage(); 160 map.put(name, inputTrigger); 161 return inputTrigger; 162 } 163 } 164 } 165 | Popular Tags |