1 21 package ist.coach.itut_q816Components; 22 23 import ist.coach.coachEmfCommon.Utils; 24 import ist.coach.coachEmfCommon.ExceptionMessages; 25 import ist.coach.coachEmfCommon.DeleteErrorInfoTypeImpl; 26 import ist.coach.coachEmfCommon.ApplicationErrorInfoTypeImpl; 27 28 import intt.itu.itut_x780.UIDType; 29 import intt.itu.itut_x780.ApplicationError; 30 import intt.itu.itut_x780.DeleteError; 31 import intt.itu.itut_x780.ManagedObject_F; 32 33 import org.omg.CosNaming.NameComponent ; 34 35 39 public class TerminatorServiceProviderMonolithicImpl 40 extends org.omg.CORBA.LocalObject 41 implements CCM_TerminatorServiceProvider, 42 intt.itu.itut_q816.CCM_TerminatorService, 43 org.omg.Components.SessionComponent 44 { 45 53 private CCM_TerminatorServiceProvider_Context the_context_; 54 intt.itu.itut_q816.ContainmentComponent c_admin = null; 55 intt.itu.itut_q816.Containment c_query = null; 56 57 65 public 66 TerminatorServiceProviderMonolithicImpl() 67 { 68 the_context_ = null; 69 } 70 86 public CCM_TerminatorServiceProvider_Context 87 getContext() 88 { 89 return the_context_; 90 } 91 105 public void 106 configuration_complete() 107 throws org.omg.Components.InvalidConfiguration 108 { 109 if ((c_admin = the_context_.get_connection_containment_admin()) == null) 113 throw new org.omg.Components.InvalidConfiguration(); 114 115 if ((c_query = the_context_.get_connection_containment_query()) == null) 116 throw new org.omg.Components.InvalidConfiguration(); 117 System.err.println("TerminatorServiceProvider configuration completed..."); 118 } 119 135 public void 136 set_session_context(org.omg.Components.SessionContext context) 137 throws org.omg.Components.CCMException 138 { 139 the_context_ = (CCM_TerminatorServiceProvider_Context)context; 140 } 141 151 public void 152 ccm_activate() 153 throws org.omg.Components.CCMException 154 { 155 } 159 169 public void 170 ccm_passivate() 171 throws org.omg.Components.CCMException 172 { 173 } 177 187 public void 188 ccm_remove() 189 throws org.omg.Components.CCMException 190 { 191 } 195 206 public intt.itu.itut_q816.CCM_TerminatorService 207 get_terminator() 208 { 209 return this; 210 } 211 222 public void 223 deleteByName(org.omg.CosNaming.NameComponent [] name) 224 throws intt.itu.itut_x780.ApplicationError, intt.itu.itut_x780.DeleteError 225 { 226 230 String name_str = Utils.name2string(name); 231 String facade_name = Utils.name2facade(name_str); 232 233 if (facade_name.length() == 0) { 234 ApplicationErrorInfoTypeImpl error_code = 235 new ApplicationErrorInfoTypeImpl(); 236 error_code.error = new UIDType( 237 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 238 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 239 error_code.details = ExceptionMessages.root_delete_error; 240 241 System.err.println("Terminator: Root Object can not be deleted!"); 242 throw new ApplicationError(error_code); 243 } 244 System.err.println("deleteByName called for " + name_str + " of " + 245 facade_name); 246 247 248 249 250 ist.coach.itut_q816Components. 251 TerminatorServiceProviderPackage.target_facadesConnection [] facades = 252 the_context_.get_connections_target_facades(); 253 254 int i = 0; 255 org.omg.CosNaming.NameComponent [] facade_name_comp; 256 for(i = 0; i < facades.length; i++) { 257 facade_name_comp = facades[i].objref.nameGet(); 258 System.err.println("TerminatorService>Examining facade " + 259 Utils.name2string(facade_name_comp)); 260 261 int len = facade_name_comp.length; 262 if (len > 0 && 263 facade_name_comp[len - 1].kind.equals(facade_name)) 264 265 break; 266 } 267 268 if (i >= facades.length) { 269 270 ApplicationErrorInfoTypeImpl error_code = 271 new ApplicationErrorInfoTypeImpl(); 272 error_code.error = new UIDType( 273 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 274 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 275 error_code.details = ExceptionMessages.facade_not_exists_error; 276 277 System.err.println("Terminator: Could not locate the facade!"); 278 throw new ApplicationError(error_code); 279 } 280 281 ManagedObject_F facade = facades[i].objref; 282 283 short objectDeletePolicy = facade.deletePolicyGet(name); 284 285 org.omg.CosNaming.NameComponent [][] contained_objects = null; 286 switch (objectDeletePolicy) { 287 288 case intt.itu.itut_x780.notDeletable.value: 289 290 System.err.println("notDeletable policy holds"); 291 292 DeleteErrorInfoTypeImpl error_code = 293 new DeleteErrorInfoTypeImpl(); 294 error_code.error = new UIDType( 295 intt.itu.itut_x780.DeleteErrorConst.moduleName.value, 296 intt.itu.itut_x780.DeleteErrorConst.notDeletable.value); 297 error_code.details = name_str + ExceptionMessages.manager_delete_error; 298 throw new DeleteError(error_code); 299 300 case intt.itu.itut_x780.deleteOnlyIfNoContainedObjects.value: 301 302 System.err.println("deleteOnlyIfNoContainedObjects policy holds"); 303 304 contained_objects = c_query.getContained(name); 305 306 if (contained_objects.length > 0) { 307 308 DeleteErrorInfoTypeImpl error_contained = 309 new DeleteErrorInfoTypeImpl(); 310 error_contained.error = new UIDType( 311 intt.itu.itut_x780.DeleteErrorConst.moduleName.value, 312 intt.itu.itut_x780.DeleteErrorConst.containsObjects.value); 313 error_contained.details = ExceptionMessages.contains_object_error + 314 ".\n " + name_str + " contains " + 315 contained_objects.length + " children"; 316 throw new DeleteError(error_contained); 317 } 318 319 delete(name, facade); 320 return; 322 323 case intt.itu.itut_x780.deleteContainedObjects.value: 324 325 System.err.println("deleteContainedObjects policy holds"); 326 327 contained_objects = c_query.getContained(name); 328 329 if (contained_objects.length == 0) { 330 delete(name, facade); 331 return; 333 } 334 335 for(int j = 0; j < contained_objects.length; j++) { 336 deleteByName(contained_objects[j]); 337 } 338 delete(name, facade); 339 return; 341 342 default: return; 344 } 345 } 346 347 public void delete(org.omg.CosNaming.NameComponent [] name, 348 intt.itu.itut_x780.ManagedObject_F facade) 349 throws intt.itu.itut_x780.ApplicationError, intt.itu.itut_x780.DeleteError 350 { 351 352 facade.destroy(name); 354 c_admin.removeName(name); 356 System.err.println("delete: Successfully removed object " + 358 Utils.name2string(name) + " from its facade and containment service!"); 359 } 360 361 } 362 | Popular Tags |