1 21 package ist.coach.coachEmfClientComponents.ManagedObjectClientComposition; 22 23 import intt.itu.itut_x780.*; 24 import intt.itu.itut_q816.*; 25 import intt.itu.itut_x780.CreateErrorConst.*; 26 import intt.itu.itut_x780.ApplicationErrorConst.*; 27 import intt.itu.itut_x780.DeleteErrorConst.*; 28 import intt.itu.itut_m3120.ManagedElementFactory; 29 import intt.itu.itut_m3120.ManagedElementFactoryHelper; 30 import intt.itu.itut_m3120.ManagedElement_F; 31 import intt.itu.itut_m3120.ManagedElement_FHelper; 32 33 import ist.coach.coachEmfCommon.Utils; 34 import ist.coach.coachEmsMib.IpNodeFactory; 35 import ist.coach.coachEmsMib.*; 36 37 import ist.coach.coachEmfServicesComponents.AlarmChannelProvider; 38 import ist.coach.coachEmfServicesComponents.BasicLogProviderHome; 39 import ist.coach.coachEmfServicesComponents.BasicLogProviderHomeHelper; 40 import ist.coach.coachEmfServicesComponents.BasicLogProvider; 41 import ist.coach.coachEmfServices.EmfBasicLog.BasicLog; 42 import ist.coach.coachEmfClientComponents.ManagedObjectClientPackage.basic_logsConnection; 43 import ist.coach.coachEmfServices.EmfBasicLog.LogRecord; 44 46 import ist.coach.coachEmfClientComponents.InvokeSetData; 47 import ist.coach.coachEmfClientComponents.ManagedObjectClient; 48 import ist.coach.coachEmfClientComponents.ManagedObjectClientHelper; 49 import java.util.Hashtable ; 50 import java.util.Vector ; 51 import java.util.Enumeration ; 52 53 import java.text.DateFormat ; 54 55 import org.omg.CosNaming.NameComponent ; 56 import ist.coach.coachEmfClientComponents.gui.GuiMaster; 57 61 public class ManagedObjectClientImpl 62 extends ist.coach.coachEmfClientComponents.ManagedObjectClientComposition.ManagedObjectClient_impl 63 implements ist.coach.coachEmfClientComponents.gui.GuiMaster 64 { 65 71 72 ist.coach.itut_q816Components.ChannelFinderProvider channel_finder = null; 73 ist.coach.coachEmfClientComponents.gui.GuiClient ui_client = null; 74 private String name_; 75 private String ems_root_; 76 private String root_id_, root_kind_; 77 org.omg.CosNaming.NamingContext root_context; 78 79 80 ManagedObjectClient myself = null; 82 83 Hashtable alarmProviders; 84 Hashtable logProviders; 85 Vector subscribed_log_events; 86 Thread child_thread = null; 87 88 96 public 97 ManagedObjectClientImpl() 98 { 99 alarmProviders = new Hashtable (); 100 subscribed_log_events = new Vector (); 101 } 102 121 public void 122 configuration_complete() 123 throws org.omg.Components.InvalidConfiguration 124 { 125 try { 131 org.omg.CORBA.ORB orb = 132 org.objectweb.ccm.CORBA.TheORB.getORB(); 133 134 org.omg.CORBA.Object obj = 135 orb.resolve_initial_references("NameService"); 136 root_context = org.omg.CosNaming.NamingContextHelper.narrow(obj); 137 } 138 catch(Exception e_c) { 139 System.err.println("Exception caught will resolving naming service: " 140 + e_c.getMessage()); 141 e_c.printStackTrace(); 142 } 143 144 subscribed_log_events.add(GuiMaster.INFO_LOG); 145 subscribed_log_events.add(GuiMaster.ERROR_LOG); 146 subscribed_log_events.add(GuiMaster.WARNING_LOG); 147 148 155 216 NameComponent [] channel_finder_name = new NameComponent [3]; 220 channel_finder_name[0] = new NameComponent (root_id_, root_kind_); 221 channel_finder_name[1] = new NameComponent ("emf", "services"); 222 channel_finder_name[2] = new NameComponent ("", "ChannelFinderService"); 224 225 try { 226 org.omg.CORBA.Object obj = 227 root_context.resolve(channel_finder_name); 228 channel_finder = ist.coach.itut_q816Components.ChannelFinderProviderHelper.narrow(obj); 229 230 if (channel_finder != null) { 231 232 ChannelInfoType[] available_channels = channel_finder.provide_query().list(); 233 234 org.omg.CORBA.Object myself_o; 235 myself_o = ((org.omg.Components.SessionContext) get_context()).get_CCM_object(); 236 myself = ManagedObjectClientHelper.narrow(myself_o); 237 238 AlarmChannelProvider alarm_channel_provider = null; 239 for (int i = 0; i < available_channels.length; i++) { 240 241 if (available_channels[i].channel != null) { 242 alarm_channel_provider = 243 ist.coach.coachEmfServicesComponents.AlarmChannelProviderHelper.narrow( 244 available_channels[i].channel); 245 246 if (alarm_channel_provider == null) { 247 System.err.println("alarm_channel_provider is null"); 248 continue; 249 } 250 251 String [] eventTypes = alarm_channel_provider.eventTypes(); 252 System.err.println("eventTypes.length = " + eventTypes.length); 253 254 Vector alarmTypeV = new Vector (); 255 for (int j = 0; j < eventTypes.length; j++) { 256 add_alarm_provider(alarm_channel_provider, eventTypes[j]); 259 subscribe_alarm(eventTypes[j]); 260 261 } 262 263 } 264 } 265 } 266 else 267 System.err.println("Client> ChannelFinder reference is null..."); 268 } 269 catch(Exception e) { 270 System.err.println("Client> Could not locate ChannelFinder so that to " + 271 " subscribe to alarms!"); 272 System.err.println("Message: " + e.getMessage()); 273 e.printStackTrace(); 274 } 275 276 child_thread = new Thread ( ui_client = new ist.coach.coachEmfClientComponents.gui.GuiClient(name_, ems_root_, 281 this)); 282 System.err.println("Client configuration completed..."); 284 } 285 299 public void 300 ccm_remove() 301 throws org.omg.Components.CCMException 302 { 303 ui_client.dispose(); 308 if (child_thread != null) { 309 child_thread.stop(); 310 } 311 312 } 313 314 public void add_alarm_provider(AlarmChannelProvider alarm_channel_provider, 315 String alarmType) { 316 317 318 Vector alarmTypeV = new Vector (); 319 320 if (alarmProviders.containsKey(alarmType)) 321 alarmTypeV = (Vector ) alarmProviders.remove(alarmType); 322 323 AlarmSubscriptionInfo alarm_channel_provider_record; 324 int alarmTypeV_size = alarmTypeV.size(); 325 326 for(int i = 0; i < alarmTypeV_size; i++) { 327 alarm_channel_provider_record = (AlarmSubscriptionInfo) alarmTypeV.get(i); 328 if (alarm_channel_provider_record.alarm_channel_provider.channelId().equals( 329 alarm_channel_provider.channelId())) 330 alarmTypeV.removeElementAt(i); 331 } 332 alarm_channel_provider_record = new AlarmSubscriptionInfo(alarm_channel_provider, null); 333 alarmTypeV.add(alarm_channel_provider_record); 334 335 alarmProviders.put(alarmType, alarmTypeV); 336 338 } 339 340 public void subscribe_alarm(String alarmType) { 341 342 343 if (! alarmProviders.containsKey(alarmType)) 344 return; 345 346 Vector alarmTypeV = new Vector (); 347 alarmTypeV = (Vector ) alarmProviders.get(alarmType); 348 349 int alarmTypeV_size = alarmTypeV.size(); 350 351 AlarmChannelProvider alarm_channel_provider = null; 352 org.omg.Components.Cookie ck = null; 353 354 AlarmSubscriptionInfo alarm_channel_provider_record; 355 356 for(int i = 0; i < alarmTypeV_size; i++) { 357 358 alarm_channel_provider_record = (AlarmSubscriptionInfo) alarmTypeV.get(i); 359 alarm_channel_provider = alarm_channel_provider_record.alarm_channel_provider; 360 361 try { 362 if (alarmType.equals(GuiMaster.OBJECT_CREATION_ALARM)) { 363 ck = alarm_channel_provider.subscribe_objectCreation_alarm( 364 myself.get_consumer_object_creation_alarm()); 365 } 366 else 367 if (alarmType.equals(GuiMaster.OBJECT_DELETION_ALARM)) { 368 ck = alarm_channel_provider.subscribe_objectDeletion_alarm( 369 myself.get_consumer_object_deletion_alarm()); 370 } 371 else 372 if (alarmType.equals(GuiMaster.STATE_CHANGED_ALARM)) { 373 ck = alarm_channel_provider.subscribe_stateChanged_alarm( 374 myself.get_consumer_state_changed_alarm()); 375 } 376 else 377 if (alarmType.equals(GuiMaster.OPERATIONAL_ALARM)) { 378 ck = alarm_channel_provider.subscribe_operational_alarm( 379 myself.get_consumer_operational_violation_alarm()); 380 } 381 else 382 if (alarmType.equals(GuiMaster.HEARTBEAT_ALARM)) { 383 ck = alarm_channel_provider.subscribe_heartbeat_event( 384 myself.get_consumer_heartbeat_alarm()); 385 } 386 else 387 if (alarmType.equals(GuiMaster.CHANNEL_CHANGE_ALARM)) { 388 ck = alarm_channel_provider.subscribe_channelChange_event( 389 myself.get_consumer_channel_change_alarm()); 390 } 391 } 392 catch(org.omg.Components.ExceededConnectionLimit ex1) { 393 System.err.println("org.omg.Components.ExceededConnectionLimit caught " + 394 ex1.getMessage()); 395 } 396 397 if (ck == null) { 398 System.err.println("Subscription cookie of " + alarmType + 399 " is NULL!"); 400 continue; 401 } 402 403 AlarmSubscriptionInfo info = new AlarmSubscriptionInfo( 404 alarm_channel_provider, ck); 405 406 alarmTypeV = (Vector ) alarmProviders.remove(alarmType); 407 alarmTypeV.removeElementAt(i); 408 alarmTypeV.add(info); 409 410 alarmProviders.put(alarmType, alarmTypeV); 411 System.err.println("Subscription for " + alarmType + " finished!"); 412 } 413 } 414 415 public void unsubscribe_alarm(String alarmType) { 416 417 if (! alarmProviders.containsKey(alarmType)) 418 return; 419 420 Vector alarmTypeV = new Vector (); 421 alarmTypeV = (Vector ) alarmProviders.get(alarmType); 422 423 int alarmTypeV_size = alarmTypeV.size(); 424 425 AlarmChannelProvider alarm_channel_provider = null; 426 org.omg.Components.Cookie ck = null; 427 428 AlarmSubscriptionInfo alarm_channel_provider_record; 429 org.omg.Components.Cookie cookie = null; 430 431 for(int i = 0; i < alarmTypeV_size; i++) { 432 433 alarm_channel_provider_record = (AlarmSubscriptionInfo) alarmTypeV.get(i); 434 alarm_channel_provider = alarm_channel_provider_record.alarm_channel_provider; 435 cookie = alarm_channel_provider_record.cookie; 436 437 if (cookie == null) 438 continue; 439 440 try { 441 if (alarmType.equals(GuiMaster.OBJECT_CREATION_ALARM)) { 442 alarm_channel_provider.unsubscribe_objectCreation_alarm(cookie); 443 } 444 else 445 if (alarmType.equals(GuiMaster.OBJECT_DELETION_ALARM)) { 446 alarm_channel_provider.unsubscribe_objectDeletion_alarm(cookie); 447 } 448 else 449 if (alarmType.equals(GuiMaster.STATE_CHANGED_ALARM)) { 450 alarm_channel_provider.unsubscribe_stateChanged_alarm(cookie); 451 } 452 else 453 if (alarmType.equals(GuiMaster.OPERATIONAL_ALARM)) { 454 alarm_channel_provider.unsubscribe_operational_alarm(cookie); 455 } 456 else 457 if (alarmType.equals(GuiMaster.HEARTBEAT_ALARM)) { 458 alarm_channel_provider.unsubscribe_heartbeat_event(cookie); 459 } 460 else 461 if (alarmType.equals(GuiMaster.CHANNEL_CHANGE_ALARM)) { 462 alarm_channel_provider.unsubscribe_channelChange_event(cookie); 463 } 464 465 } 466 catch(org.omg.Components.InvalidConnection ex1) {} 467 } 468 } 469 470 public void set_heartbeat_period(short period) { 471 472 NameComponent [] heartbeat_name =new NameComponent [3]; 473 heartbeat_name[0] = new NameComponent (root_id_, root_kind_); 474 heartbeat_name[1] = new NameComponent ("emf", "services"); 475 heartbeat_name[2] = new NameComponent ("", "HeartbeatService"); 477 478 try { 479 org.omg.CORBA.Object obj = root_context.resolve(heartbeat_name); 480 481 ist.coach.itut_q816Components.HeartbeatProvider heartbeat_provider = 482 ist.coach.itut_q816Components.HeartbeatProviderHelper.narrow(obj); 483 484 heartbeat_provider.provide_admin().periodSet(period); 485 } 486 catch(Exception e) { 487 System.err.println("Client: set_heartbeat_period> Caught Exception " + 488 e.getMessage()); 489 e.printStackTrace(System.err); 490 } 491 } 492 493 public String [] get_all_logs() { 494 495 logProviders = new Hashtable (); 496 497 basic_logsConnection[] connected_logs = get_context().get_connections_basic_logs(); 498 String [] connected_logs_str = new String [connected_logs.length]; 499 500 for(int i = 0; i < connected_logs.length; i++) { 501 connected_logs_str[i] = connected_logs[i].objref.get_display_name(); 502 System.err.println("ManagedObjectClient> " + connected_logs_str[i] + " Log found..."); 503 logProviders.put(connected_logs_str[i], 504 connected_logs[i].objref); 505 } 506 507 508 return connected_logs_str; 509 } 510 511 public ist.coach.coachEmfServices.EmfBasicLog.LogRecord[] retrieve_logs( 512 String log_name, long from_time, int how_many) { 513 514 ist.coach.coachEmfServices.EmfBasicLog.LogRecord[] records = 515 new ist.coach.coachEmfServices.EmfBasicLog.LogRecord[0]; 516 517 if (! logProviders.containsKey(log_name)) 518 return records; 519 520 BasicLog requested_log = (BasicLog) logProviders.get(log_name); 521 ist.coach.coachEmfServices.EmfBasicLog.IteratorHolder iteratorH = 522 new ist.coach.coachEmfServices.EmfBasicLog.IteratorHolder(); 523 524 records = requested_log.retrieve(from_time, how_many, iteratorH); 525 System.err.println("ManagedObjectClientImpl> retrieved_logs = " + records.length); 526 return records; 527 } 528 529 public synchronized void subscribe_log(String logType) { 530 if (! subscribed_log_events.contains(logType)) 531 subscribed_log_events.add(logType); 532 } 533 534 public synchronized void unsubscribe_log(String logType) { 535 if (subscribed_log_events.contains(logType)) 536 subscribed_log_events.remove(logType); 537 } 538 539 544 550 public void 551 push(ist.coach.itut_q816Components.ChannelChangeEvent event) 552 { 553 AlarmChannelProvider alarm_channel_provider = 557 ist.coach.coachEmfServicesComponents.AlarmChannelProviderHelper.narrow( 558 event.channelInfo.channel); 559 560 String [] eventTypes = alarm_channel_provider.eventTypes(); 561 String display_types_str = new String (); 562 for (int j = 0; j < eventTypes.length; j++) { 563 add_alarm_provider(alarm_channel_provider, eventTypes[j]); 564 display_types_str += eventTypes[j]; 565 if (j < eventTypes.length - 1) 566 display_types_str += ", "; 567 568 } 569 String [] sourceClasses = alarm_channel_provider.sourceClasses(); 570 String display_source_str = new String (); 571 for (int j = 0; j < sourceClasses.length; j++) { 572 display_source_str += sourceClasses[j]; 573 if (j < sourceClasses.length - 1) 574 display_source_str += ", "; 575 } 576 if (event.channelModification == ChannelModificationType.ChannelCreate) { 577 578 for (int j = 0; j < eventTypes.length; j++) 579 add_alarm_provider(alarm_channel_provider, eventTypes[j]); 580 581 ui_client.print_alarm("", 582 ist.coach.coachEmfClientComponents.gui.GuiMessages.channel_change_alarm, 583 "ChannelFinder", event.channelInfo.channelID, "", 584 "Create: " + display_types_str + " events will be served from " + display_source_str + " sources"); 585 } 586 else 587 if (event.channelModification == ChannelModificationType.ChannelUpdate) { 588 ui_client.print_alarm("", 589 ist.coach.coachEmfClientComponents.gui.GuiMessages.channel_change_alarm, 590 "ChannelFinder", event.channelInfo.channelID, "", 591 "Modify: " + display_types_str + " events will be served from " + display_source_str + " sources"); 592 } 593 else 594 if (event.channelModification == ChannelModificationType.ChannelDelete) { 595 ui_client.print_alarm("", 596 ist.coach.coachEmfClientComponents.gui.GuiMessages.channel_change_alarm, 597 "ChannelFinder", event.channelInfo.channelID, "", 598 "Remove: " + display_types_str + " events will not be served from " + display_source_str + " sources"); 599 } 600 605 } 606 607 608 614 public java.lang.String 615 name() 616 { 617 return name_; 621 } 622 623 626 public void 627 name(java.lang.String val) 628 { 629 633 name_ = val; 634 if (ui_client != null) 635 ui_client.set_name(name_); 636 System.err.println("Name is set to " + name_); 637 } 638 639 642 public java.lang.String 643 ems_root() 644 { 645 return ems_root_; 649 } 650 651 654 public void 655 ems_root(java.lang.String val) 656 { 657 661 ems_root_ = val; 662 System.err.println("EMS Root is set to " + ems_root_); 663 } 664 665 668 public java.lang.String 669 root_id() 670 { 671 return root_id_; 675 } 676 677 680 public void 681 root_id(java.lang.String val) 682 { 683 687 root_id_ = val; 688 System.err.println("EMS Root ID is set to " + root_id_); 689 } 690 691 694 public java.lang.String 695 root_kind() 696 { 697 return root_kind_; 701 } 702 703 706 public void 707 root_kind(java.lang.String val) 708 { 709 713 root_kind_ = val; 714 System.err.println("EMS Root Kind is set to " + root_kind_); 715 } 716 722 public void print(String msg) { 723 System.err.print(msg); 726 } 727 728 public void println(String msg) { 729 System.err.println(msg); 731 } 732 733 public String createByManager(String object_class, 734 String [] param_names, 735 Object [] values, 736 String parent_key_val) { 737 738 NameComponent [] parent_object_key = Utils.string2name(parent_key_val); 739 String new_object_key = (values != null && values.length > 0) ? 740 (String ) values[0] : new String (); 741 742 746 try { 747 748 NameComponent [] factoryfinder_name =new NameComponent [3]; 749 factoryfinder_name[0] = new NameComponent (root_id_, root_kind_); 750 factoryfinder_name[1] = new NameComponent ("emf", "services"); 751 factoryfinder_name[2] = new NameComponent ("", "FactoryFinder"); 753 754 org.omg.CORBA.Object obj = root_context.resolve(factoryfinder_name); 755 756 ist.coach.itut_q816Components.FactoryFinderProvider factory_finder = 757 ist.coach.itut_q816Components.FactoryFinderProviderHelper.narrow(obj); 758 759 ManagedObjectFactory mobject_f = factory_finder.provide_query().find( 760 object_class + "Factory"); 761 762 768 769 772 String nameBinding = object_class + "_" 773 + Utils.name2kind(parent_key_val); 774 System.err.println("Name Binding is " + nameBinding); 775 776 if (mobject_f == null) { 777 System.err.println("Factory Object was null!!"); 778 return new String (); 779 } 780 781 NameComponent [] new_name = null; 782 784 785 if (object_class.equals("ManagedObject")) { 786 new_name = mobject_f.create_base(nameBinding, 787 parent_object_key, new_object_key); 788 } 789 else 790 if (object_class.equals("ManagedElement")) { 791 792 ManagedElementFactory element_factory = 793 ManagedElementFactoryHelper.narrow(mobject_f); 794 795 String userLabel = new String (); 796 if (values.length > 1 && values[1] != null) 797 userLabel = (String ) values[1]; 798 System.err.print("userLabel = " + userLabel + ", "); 799 800 String vendorName = new String (); 801 if (values.length > 2 && values[2] != null) 802 vendorName = (String ) values[2]; 803 System.err.print("vendorName = " + vendorName + ", "); 804 805 String version = new String (); 806 if (values.length > 3 && values[3] != null) 807 version = (String ) values[3]; 808 System.err.print("version = " + version + ", "); 809 810 String locationName = new String (); 811 if (values.length > 4 && values[4] != null) 812 locationName = (String ) values[4]; 813 System.err.println("locationName = " + locationName); 814 815 new_name = element_factory.create(nameBinding, 816 parent_object_key, 817 new_object_key, 818 new String [0], 819 intt.itu.itut_x780.AdministrativeStateType.locked, 820 userLabel, 821 vendorName, 822 version, 823 locationName 824 ); 825 826 } 827 else 828 if (object_class.equals("IpNode")) { 829 830 IpNodeFactory ipnode_factory = IpNodeFactoryHelper.narrow( 831 mobject_f); 832 833 String domainName = new String (); 834 if (values.length > 1 && values[1] != null) 835 domainName = (String ) values[1]; 836 System.err.print("domainName = " + domainName + ", "); 837 838 String hostname = new String (); 839 if (values.length > 2 && values[2] != null) 840 hostname = (String ) values[2]; 841 System.err.print("hostname = " + hostname + ", "); 842 843 byte[] managementIPAddress = new byte[0]; 844 if (values.length > 3 && values[3] != null) 845 managementIPAddress = ((String ) values[3]).getBytes(); 846 System.err.print("managementIPAddress = " + values[3] + ", "); 847 848 int supportedSnmpVersions = 0; 849 if (values.length > 4 && values[4] != null) 850 supportedSnmpVersions = Integer.parseInt((String ) values[4]); 851 System.err.println("supportedSnmpVersions = " + supportedSnmpVersions); 852 853 String userLabel = new String (); 854 if (values.length > 5 && values[5] != null) 855 userLabel = (String ) values[5]; 856 System.err.print("userLabel = " + userLabel + ", "); 857 858 String vendorName = new String (); 859 if (values.length > 6 && values[6] != null) 860 vendorName = (String ) values[6]; 861 System.err.print("vendorName = " + vendorName + ", "); 862 863 String version = new String (); 864 if (values.length > 7 && values[7] != null) 865 version = (String ) values[7]; 866 System.err.print("version = " + version + ", "); 867 868 String locationName = new String (); 869 if (values.length > 8 && values[8] != null) 870 locationName = (String ) values[8]; 871 System.err.println("locationName = " + locationName); 872 873 int snmpPort = 0; 874 if (values.length > 9 && values[9] != null) 875 snmpPort = Integer.parseInt((String ) values[9]); 876 System.err.print("snmpPort = " + snmpPort + ", "); 877 878 String sysName = new String (); 879 if (values.length > 10 && values[10] != null) 880 sysName = (String ) values[10]; 881 System.err.print("sysName = " + values[10] + ", "); 882 883 String sysContact = new String (); 884 if (values.length > 11 && values[11] != null) 885 sysContact = (String ) values[11]; 886 System.err.println("sysContact = " + values[11]); 887 888 System.err.println("Client>Ready to invoke create on IpNodeFactory..."); 890 new_name = ipnode_factory.create(nameBinding, 891 parent_object_key, 892 new_object_key, 893 new String [0], 894 domainName, 895 hostname, 896 managementIPAddress, 897 supportedSnmpVersions, 898 intt.itu.itut_x780.AdministrativeStateType.locked, 899 userLabel, 900 vendorName, 901 version, 902 locationName, 903 snmpPort, 904 sysName, 905 sysContact 906 ); 907 908 } 909 if (new_name != null && new_name.length > 0) { 910 new_object_key = Utils.name2string(new_name); 911 } 912 else 913 new_object_key = new String (); 914 } 915 catch(CreateError create_e) { 916 treat_create_exceptions(create_e); 917 new_object_key = new String (); 918 } 919 catch(ApplicationError appl_e) { 920 treat_application_exceptions(appl_e); 921 new_object_key = new String (); 922 } 923 catch(Exception e_c) { 924 System.err.println("Exception caught: " + e_c.getMessage()); 925 e_c.printStackTrace(); 926 new_object_key = new String (); 927 } 928 929 return new_object_key; 930 } 931 932 public boolean removeByManager(String name) { 933 934 if (name == null || name.length() == 0) 935 return false; 936 937 try { 938 NameComponent [] terminator_name = new NameComponent [3]; 939 terminator_name[0] = new NameComponent (root_id_, root_kind_); 940 terminator_name[1] = new NameComponent ("emf", "services"); 941 terminator_name[2] = new NameComponent ("", "TerminatorService"); 943 944 org.omg.CORBA.Object obj = root_context.resolve(terminator_name); 945 946 ist.coach.itut_q816Components.TerminatorServiceProvider terminator = 947 ist.coach.itut_q816Components.TerminatorServiceProviderHelper.narrow(obj); 948 949 if (terminator != null) { 950 terminator.provide_terminator().deleteByName(Utils.string2name(name)); 951 return true; 952 } 953 954 } 955 catch(DeleteError delete_e) { 956 treat_delete_exceptions(delete_e); 957 return false; 958 } 959 catch(ApplicationError appl_e) { 960 treat_application_exceptions(appl_e); 961 return false; 962 } 963 catch(Exception e_c) { 964 System.err.println("Exception caught: " + e_c.getMessage()); 965 e_c.printStackTrace(); 966 return false; 967 } 968 return false; 969 970 } 971 972 public ManagedObjectValueType attributesGet(String object_class, 973 String object_key, 974 String []attributes) { 975 976 977 System.err.println("\n--->attributesGet is called for " + object_key + 978 " of type " + object_class); 979 980 ManagedObjectValueType attributes_values = null; 981 NameComponent [] facade_name = new NameComponent [2]; 982 try { 983 if (object_key == null || object_key.length() == 0) 984 return null; 985 986 facade_name[0] = new NameComponent (root_id_, root_kind_); 988 facade_name[1] = 989 new NameComponent ("", Utils.name2facade(object_key)); 991 992 org.omg.CORBA.Object obj = root_context.resolve(facade_name); 994 995 997 intt.itu.itut_x780.ManagedObject_F mobject_f = 998 intt.itu.itut_x780.ManagedObject_FHelper.narrow(obj); 999 1002 if (mobject_f == null) { 1003 System.err.println("Facade object can not be found!"); 1004 return null; 1005 } 1006 1007 NameComponent [] obj_name = Utils.string2name(object_key); 1008 1009 attributes_values = (ManagedObjectValueType) mobject_f.attributesGet( 1010 Utils.string2name(object_key), 1011 new intt.itu.itut_x780.StringSetTypeHolder(attributes)); 1012 1013 } 1014 catch(ApplicationError appl_e) { 1015 treat_application_exceptions(appl_e); 1016 } 1017 catch(Exception e_c) { 1018 System.err.println("Exception caught>" 1019 + Utils.name2string(facade_name) + 1020 ": " + e_c.getMessage()); 1021 e_c.printStackTrace(); 1022 } 1023 1024 return attributes_values; 1025 } 1026 1027 public String [] getContained(String superior) { 1028 1029 String [] subordinates = new String [0]; 1031 try { 1032 1033 NameComponent [] c_query = new NameComponent [3]; 1034 c_query[0] = new NameComponent (root_id_, root_kind_); 1036 c_query[1] = new NameComponent ("emf", "services"); 1037 c_query[2] = new NameComponent ("", "ContainmentService"); 1038 org.omg.CORBA.Object obj = root_context.resolve(c_query); 1039 1040 ist.coach.itut_q816Components.ContainmentServiceProvider containment = 1041 ist.coach.itut_q816Components.ContainmentServiceProviderHelper.narrow(obj); 1042 1043 if (containment != null) { 1044 NameComponent [][] children = 1045 containment.provide_containment_query().getContained( 1046 Utils.string2name(superior)); 1047 1049 if (children != null && children.length > 0) { 1050 subordinates = new String [children.length]; 1051 for(int i = 0; i < subordinates.length; i++) 1052 subordinates[i] = Utils.name2string(children[i]); 1053 } 1054 } 1055 } 1056 catch(Exception e_c) { 1057 System.err.println("Exception caught: " + e_c.getMessage()); 1058 e_c.printStackTrace(); 1059 } 1060 1061 return subordinates; 1062 } 1063 1064 public boolean setAttributes(String object_key, Vector set_data) { 1065 1066 System.err.println("setAttributes is called on " + object_key + 1067 " of type " + Utils.name2kind(object_key)); 1068 1069 if (object_key == null || object_key.length() == 0) 1070 return false; 1071 1072 String objectkind = Utils.name2kind(object_key); 1073 NameComponent [] facade_name = new NameComponent [2]; 1074 try { 1075 facade_name[0] = new NameComponent (root_id_, root_kind_); 1076 facade_name[1] = 1078 new NameComponent ("", Utils.name2facade(object_key)); 1079 org.omg.CORBA.Object obj = root_context.resolve(facade_name); 1080 1081 if (objectkind.equals("ManagedElement")) { 1082 1083 ManagedElement_F facade = ManagedElement_FHelper.narrow(obj); 1084 Enumeration set_operations = set_data.elements(); 1085 while(set_operations.hasMoreElements()) { 1086 InvokeSetData set_method = (InvokeSetData) set_operations.nextElement(); 1087 set_method.methodName.invoke(facade, set_method.methodArguments); 1088 } 1089 } 1090 else 1091 if (objectkind.equals("IpNode")) { 1092 1093 IpNode_F facade = IpNode_FHelper.narrow(obj); 1094 Enumeration set_operations = set_data.elements(); 1095 while(set_operations.hasMoreElements()) { 1096 InvokeSetData set_method = (InvokeSetData) set_operations.nextElement(); 1097 set_method.methodName.invoke(facade, set_method.methodArguments); 1098 } 1099 } 1100 else 1101 if (objectkind.equals("LogicalInterface")) { 1102 LogicalInterface_F facade = LogicalInterface_FHelper.narrow(obj); 1103 Enumeration set_operations = set_data.elements(); 1104 while(set_operations.hasMoreElements()) { 1105 InvokeSetData set_method = (InvokeSetData) set_operations.nextElement(); 1106 set_method.methodName.invoke(facade, set_method.methodArguments); 1107 } 1108 } 1109 else 1110 if (objectkind.equals("SnmpProtocolMonitor")) { 1111 SnmpProtocolMonitor_F facade = SnmpProtocolMonitor_FHelper.narrow(obj); 1112 Enumeration set_operations = set_data.elements(); 1113 while(set_operations.hasMoreElements()) { 1114 InvokeSetData set_method = (InvokeSetData) set_operations.nextElement(); 1115 set_method.methodName.invoke(facade, set_method.methodArguments); 1116 } 1117 } 1118 1119 1120 } 1121 catch(Exception e_c) { 1126 System.err.println("Exception caught>" 1127 + Utils.name2string(facade_name) + 1128 ": " + e_c.getMessage()); 1129 e_c.printStackTrace(); 1130 return false; 1131 } 1132 return true; 1133 } 1134 1135 1136 public void treat_create_exceptions(CreateError create_e) { 1137 System.err.println("Client caught exception during create operation:"); 1138 switch(create_e.info.error.value) { 1139 case intt.itu.itut_x780.CreateErrorConst.duplicateName.value : 1140 System.err.println("Object already exists"); 1141 System.err.println(create_e.info.details); 1142 break; 1143 case intt.itu.itut_x780.CreateErrorConst.invalidNameBinding.value : 1144 System.err.println("InvalidNameBinding has been provided"); 1145 System.err.println(create_e.info.details); 1146 break; 1147 case intt.itu.itut_x780.CreateErrorConst.badName.value : 1148 System.err.println("Bad Name"); 1149 System.err.println(create_e.info.details); 1150 break; 1151 default: 1152 System.err.println(create_e.info.details); 1153 } 1154 ui_client.showCreateError(create_e.info.details); 1155 } 1156 1157 public void treat_delete_exceptions(DeleteError delete_e) { 1158 System.err.println("Client caught exception during remove operation"); 1159 switch(delete_e.info.error.value) { 1160 case intt.itu.itut_x780.DeleteErrorConst.notDeletable.value : 1161 System.err.println("Element can not be deleted by the manager"); 1162 System.err.println(delete_e.info.details); 1163 break; 1164 case intt.itu.itut_x780.DeleteErrorConst.containsObjects.value : 1165 System.err.println("Element contains children and thus can not be deleted"); 1166 System.err.println(delete_e.info.details); 1167 break; 1168 default: 1169 System.err.println(delete_e.info.details); 1170 } 1171 ui_client.showDeleteError(delete_e.info.details); 1172 1173 } 1174 1175 public void treat_application_exceptions(ApplicationError appl_e) { 1176 System.err.println("Application exception caught:"); 1177 switch(appl_e.info.error.value) { 1178 case intt.itu.itut_x780.ApplicationErrorConst.objectNotFound.value : 1179 System.err.println("Object Not Found"); 1180 System.err.println(appl_e.info.details); 1181 break; 1182 case intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value : 1183 System.err.println("Invalid Parameter"); 1184 System.err.println(appl_e.info.details); 1185 break; 1186 default: 1187 System.err.println(appl_e.info.details); 1188 } 1189 ui_client.showAttributesError(appl_e.info.details); 1190 } 1191 1192 1193private class AlarmSubscriptionInfo { 1194 1195 org.omg.Components.Cookie cookie; 1196 AlarmChannelProvider alarm_channel_provider; 1197 1198 AlarmSubscriptionInfo(AlarmChannelProvider alarm_channel_provider, 1199 org.omg.Components.Cookie cookie) { 1200 1201 this.alarm_channel_provider = alarm_channel_provider; 1202 this.cookie = cookie; 1203 } 1204} 1205} 1206 | Popular Tags |