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.CreateErrorInfoTypeImpl; 27 import ist.coach.coachEmfCommon.ApplicationErrorInfoTypeImpl; 28 29 import intt.itu.itut_x780.UIDType; 30 import intt.itu.itut_x780.ApplicationError; 31 import intt.itu.itut_x780.CreateError; 32 import intt.itu.itut_x780.DeleteError; 33 34 38 public class ContainmentServiceProviderMonolithicImpl 39 extends org.omg.CORBA.LocalObject 40 implements CCM_ContainmentServiceProvider, 41 intt.itu.itut_q816.CCM_Containment, 42 intt.itu.itut_q816.CCM_ContainmentComponent, 43 org.omg.Components.SessionComponent 44 { 45 53 private CCM_ContainmentServiceProvider_Context the_context_; 54 55 56 57 private java.util.Hashtable tree; 61 62 private java.util.Hashtable reverse_tree; 65 66 String _local_root = null; 67 75 public 76 ContainmentServiceProviderMonolithicImpl() 77 { 78 the_context_ = null; 79 tree = new java.util.Hashtable (); 80 reverse_tree = new java.util.Hashtable (); 81 } 82 98 public CCM_ContainmentServiceProvider_Context 99 getContext() 100 { 101 return the_context_; 102 } 103 117 public void 118 configuration_complete() 119 throws org.omg.Components.InvalidConfiguration 120 { 121 125 126 System.err.println("Local Root = " + _local_root); 127 if (_local_root != null && _local_root.length() > 0) 128 tree.put(_local_root, new java.util.Vector ()); 129 130 133 134 System.err.println("ContainmentServiceProvider configuration completed..."); 135 } 136 152 public void 153 set_session_context(org.omg.Components.SessionContext context) 154 throws org.omg.Components.CCMException 155 { 156 the_context_ = (CCM_ContainmentServiceProvider_Context)context; 157 } 158 168 public void 169 ccm_activate() 170 throws org.omg.Components.CCMException 171 { 172 } 176 186 public void 187 ccm_passivate() 188 throws org.omg.Components.CCMException 189 { 190 } 194 204 public void 205 ccm_remove() 206 throws org.omg.Components.CCMException 207 { 208 } 212 223 public intt.itu.itut_q816.CCM_Containment 224 get_containment_query() 225 { 226 return this; 227 } 228 234 public intt.itu.itut_q816.CCM_ContainmentComponent 235 get_containment_admin() 236 { 237 return this; 238 } 239 240 243 public java.lang.String 244 local_root() { 245 return _local_root; 249 } 250 251 254 public void 255 local_root(java.lang.String val) 256 { 257 _local_root = val; 261 if (! tree.contains(_local_root)) 262 tree.put(_local_root, new java.util.Vector ()); 263 } 264 265 276 public boolean 277 exists(org.omg.CosNaming.NameComponent [] name) 278 throws intt.itu.itut_x780.ApplicationError 279 { 280 284 if (tree.containsKey(Utils.name2string(name))) 285 return true; 286 else 287 return false; 288 289 } 290 296 public org.omg.CosNaming.NameComponent [][] 297 getContained(org.omg.CosNaming.NameComponent [] name) 298 throws intt.itu.itut_x780.ApplicationError 299 { 300 306 org.omg.CosNaming.NameComponent [][] contained_objects = 307 new org.omg.CosNaming.NameComponent [0][0]; 308 309 String name_str = Utils.name2string(name); 310 if (tree.containsKey(name_str)) { 311 java.util.Vector contained_vector = (java.util.Vector ) tree.get(name_str); 312 313 contained_objects = 314 new org.omg.CosNaming.NameComponent [contained_vector.size()][0]; 315 316 for(int i = 0; i < contained_vector.size(); i++) { 317 318 String child_name = (String ) contained_vector.elementAt(i); 319 320 if (child_name == null || child_name.length() == 0) 321 System.err.println("Note that a NULL child found!"); 322 else { 323 contained_objects[i] = Utils.string2name(child_name); 324 } 325 } 326 } 327 return contained_objects; 330 331 } 332 338 public org.omg.CosNaming.NameComponent [][] 339 getContainedByKind(org.omg.CosNaming.NameComponent [] name, java.lang.String kind) 340 throws intt.itu.itut_x780.ApplicationError 341 { 342 org.omg.CosNaming.NameComponent [][] contained_objects = 346 new org.omg.CosNaming.NameComponent [0][0]; 347 String name_str = Utils.name2string(name); 348 349 if (! tree.containsKey(name_str)) { 350 ApplicationErrorInfoTypeImpl error_code = 351 new ApplicationErrorInfoTypeImpl(); 352 error_code.error = new UIDType( 353 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 354 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 355 error_code.details = ExceptionMessages.root_delete_error; 356 357 throw new ApplicationError(error_code); 358 } 359 java.util.Vector contained_vector = (java.util.Vector ) tree.get(name_str); 360 361 java.util.Vector contained_by_kind_vector = new java.util.Vector (); 362 String child_str; 363 for (int i = 0; i < contained_vector.size(); i++) { 364 child_str = (String ) contained_vector.elementAt(i); 365 366 if (kind.equals(Utils.name2kind(child_str))) { 367 contained_by_kind_vector.add(child_str); 368 } 369 370 } 371 contained_objects = new org.omg.CosNaming.NameComponent [ 372 contained_by_kind_vector.size()][0]; 373 374 for(int j = 0; j < contained_by_kind_vector.size(); j++) { 375 376 child_str = (String ) contained_by_kind_vector.elementAt(j); 377 378 if (child_str == null || child_str.length() == 0) 379 System.err.println("NULL child found!"); 380 else 381 contained_objects[j] = Utils.string2name(child_str); 382 } 383 384 return contained_objects; 385 } 386 398 public void 399 registerLocalRoot(org.omg.CosNaming.NameComponent [] name, 400 org.omg.CosNaming.NamingContext localRoot) 401 throws intt.itu.itut_x780.ApplicationError 402 { 403 _local_root = Utils.name2string(name); 407 if (! tree.contains(_local_root)) 408 tree.put(_local_root, new java.util.Vector ()); 409 } 410 416 public void 417 unregisterLocalRoot(org.omg.CosNaming.NameComponent [] name) 418 throws intt.itu.itut_x780.ApplicationError 419 { 420 } 424 430 public void 431 addName(org.omg.CosNaming.NameComponent [] name, 432 org.omg.CosNaming.NameComponent [] superior) 433 throws intt.itu.itut_x780.ApplicationError, intt.itu.itut_x780.CreateError 434 { 435 java.util.Vector children = new java.util.Vector (); 439 String name_str = Utils.name2string(name); 440 String superior_str = Utils.name2string(superior); 441 442 if (tree.containsKey(superior_str)) { 443 children = (java.util.Vector ) tree.get(superior_str); 444 } 445 else { 446 CreateErrorInfoTypeImpl error_code = new CreateErrorInfoTypeImpl(); 447 error_code.error = new UIDType( 448 intt.itu.itut_x780.CreateErrorConst.moduleName.value, 449 intt.itu.itut_x780.CreateErrorConst.badName.value); 450 error_code.details = ExceptionMessages.parent_object_error; 451 throw new ApplicationError(error_code); 452 } 453 454 if (tree.containsKey(name_str)) { 455 CreateErrorInfoTypeImpl error_code = new CreateErrorInfoTypeImpl(); 456 error_code.error = new UIDType( 457 intt.itu.itut_x780.CreateErrorConst.moduleName.value, 458 intt.itu.itut_x780.CreateErrorConst.duplicateName.value); 459 460 error_code.details = name_str + ExceptionMessages.not_exists_error; 461 throw new CreateError(error_code); 462 463 } 464 else 465 tree.put(name_str, new java.util.Vector ()); 466 467 468 if (! children.contains(name_str)) { 469 children.add(name_str); 470 tree.put(superior_str, children); 471 reverse_tree.put(name_str, superior_str); 472 } 473 } 474 480 public void 481 removeName(org.omg.CosNaming.NameComponent [] name) 482 throws intt.itu.itut_x780.ApplicationError, intt.itu.itut_x780.DeleteError 483 { 484 if (name.length <= 1) { 488 ApplicationErrorInfoTypeImpl error_code = 489 new ApplicationErrorInfoTypeImpl(); 490 error_code.error = new UIDType( 491 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 492 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 493 error_code.details = ExceptionMessages.root_delete_error; 494 495 throw new ApplicationError(error_code); 496 } 497 498 String name_str = Utils.name2string(name); 499 500 if (!tree.containsKey(name_str)) { 501 ApplicationErrorInfoTypeImpl error_code = 502 new ApplicationErrorInfoTypeImpl(); 503 error_code.error = new UIDType( 504 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 505 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 506 error_code.details = name_str + ExceptionMessages.not_exists_error; 507 508 throw new ApplicationError(error_code); 509 } 510 511 java.util.Vector children = (java.util.Vector ) tree.get(name_str); 512 513 516 if (children != null && children.size() > 0) { 517 DeleteErrorInfoTypeImpl error_code = 518 new DeleteErrorInfoTypeImpl(); 519 error_code.error = new UIDType( 520 intt.itu.itut_x780.DeleteErrorConst.moduleName.value, 521 intt.itu.itut_x780.DeleteErrorConst.containsObjects.value); 522 error_code.details = name_str + ExceptionMessages.contains_object_error; 523 524 throw new DeleteError(error_code); 525 } 526 527 tree.remove(name_str); 528 String superior = (String ) reverse_tree.remove(name_str); 529 530 if (superior == null) 531 return; 532 533 java.util.Vector superior_children = (java.util.Vector ) tree.get(superior); 534 if (superior_children.contains(name_str)) { 535 superior_children.remove(name_str); 536 tree. put(superior, superior_children); 537 } 540 541 } 542 543 } 544 | Popular Tags |