1 package de.webman.acl; 2 3 import com.teamkonzept.lib.ConfigurationManager; 4 import com.teamkonzept.lib.TKException; 5 import com.teamkonzept.lib.TKVector; 6 import de.webman.acl.db.*; 7 import de.webman.acl.resolver.ResolverFactory; 8 import com.teamkonzept.webman.mainint.WebmanExceptionHandler; 9 10 17 public class EventFactory 18 extends ObjectFactoryBase 19 implements ObjectFactory 20 { 21 22 24 26 29 private static EventFactory SINGLETON = null; 30 31 32 34 37 private EventFactory () 38 { 39 super(); 40 } 41 42 43 45 51 public static synchronized final EventFactory getInstance () 52 throws TKException 53 { 54 if (SINGLETON == null) 55 { 56 SINGLETON = new EventFactory(); 57 SINGLETON.configurationChanged(); 58 ConfigurationManager.getInstance() 59 .registerConfigurationListener(SINGLETON, 60 PROPERTY_GROUP_NAME); 61 } 62 63 return SINGLETON; 64 } 65 66 67 69 74 public final ObjectDBInterface getDBInterface () 75 { 76 return EventDBInterface.getInstance(); 77 } 78 79 85 public final ObjectDBData getDBData (Integer id) 86 { 87 return new EventDBData(id, null); 88 } 89 90 96 public final ObjectDBData getDBData (WMObject object) 97 { 98 return new EventDBData((Event) object); 99 } 100 101 107 public final WMObject buildObject (ObjectDBData data) 108 { 109 return new Event((EventDBData) data); 110 } 111 112 113 115 121 public final TKVector getEvents () 122 throws TKException 123 { 124 return getObjects(); 125 } 126 127 134 public final Event getEvent (Integer id) 135 throws TKException 136 { 137 return (Event) getObject(id); 138 } 139 140 147 public final Event getEvent (String name) 148 throws TKException 149 { 150 Event event = null; 151 152 try 153 { 154 EventDBData data = new EventDBData(null, name); 156 data.setQuery(EventDBInterface.WM_EVENT_SELECT_BY_NAME); 157 data.setPrototype(new ObjectCollectionDBData(null, 158 null, 159 EventDBInterface.PRIMARY_KEY_NAME, 160 null)); 161 162 TKVector id = getObjectIDs(data); 164 165 if (id != null && id.size() == 1) 166 { 167 event = (Event) getObject((Integer ) id.firstElement()); 168 } 169 } 170 catch (Exception x) 171 { 172 throw WebmanExceptionHandler.getException(x); 173 } 174 175 return event; 176 } 177 178 185 public final TKVector getEventProxies (Integer policy) 186 throws TKException 187 { 188 TKVector proxies = null; 189 190 try 191 { 192 EventDBData data = new EventDBData((Integer ) null, null); 194 data.setQuery(EventDBInterface.WM_EVENT_SELECT_BY_POLICY); 195 data.setPrototype(new ObjectCollectionDBData(PolicyDBInterface.PRIMARY_KEY_NAME, 196 policy, 197 EventDBInterface.PRIMARY_KEY_NAME, 198 null)); 199 200 proxies = getObjectIDs(data); 202 } 203 catch (Exception x) 204 { 205 throw WebmanExceptionHandler.getException(x); 206 } 207 208 return proxies; 209 } 210 211 222 public final TKVector getEventProxies (Integer login, 223 Integer context, 224 Integer type, 225 Integer reference, 226 boolean access) 227 throws TKException 228 { 229 TKVector proxies = null; 230 231 try 232 { 233 EventDBData data = new EventDBData((Integer ) null, null); 235 data.setQuery(EventDBInterface.WM_EVENT_SELECT_BY_POLICY_ATTRIBUTES); 236 data.setPrototype(new EventCollectionDBData(login, 237 context, 238 type, 239 reference, 240 access 241 ? PolicyDBInterface.MODE_ALLOW 242 : PolicyDBInterface.MODE_DENY)); 243 244 proxies = getObjectIDs(data); 246 } 247 catch (Exception x) 248 { 249 throw WebmanExceptionHandler.getException(x); 250 } 251 252 return proxies; 253 } 254 255 262 public final Event createEvent (String name) 263 throws TKException 264 { 265 return (Event) createObject(new EventDBData(null, name)); 266 } 267 268 274 public final void modifyEvent (Event event) 275 throws TKException 276 { 277 if (event.isModifiedAssociations()) 278 { 279 ResolverFactory.getInstance().removeResolvers(); 280 } 281 282 modifyObject(event); 283 } 284 285 291 public final void deleteEvent (Event event) 292 throws TKException 293 { 294 ResolverFactory.getInstance().removeResolvers(); 295 296 deleteObject(event); 297 } 298 299 } 300 | Popular Tags |