1 21 package ist.coach.coachEmfClientComponents; 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 39 import java.util.Hashtable ; 40 import java.util.Vector ; 41 import java.util.Enumeration ; 42 43 import java.text.DateFormat ; 44 45 import org.omg.CosNaming.NameComponent ; 46 import ist.coach.coachEmfClientComponents.gui.GuiMaster; 47 51 public class ManagedObjectClientMonolithicImpl 52 extends org.omg.CORBA.LocalObject 53 implements CCM_ManagedObjectClient, 54 org.omg.Components.SessionComponent, 55 ist.coach.coachEmfClientComponents.gui.GuiMaster 56 { 57 65 private CCM_ManagedObjectClient_Context the_context_ = null; 66 67 68 ist.coach.itut_q816Components.ChannelFinderProvider channel_finder = null; 69 ist.coach.coachEmfClientComponents.gui.GuiClient ui_client = null; 70 private String name_; 71 org.omg.CosNaming.NamingContext root_context; 72 73 ManagedObjectClient myself = null; 75 76 Hashtable alarmProviders; 77 78 79 87 public 88 ManagedObjectClientMonolithicImpl() 89 { 90 alarmProviders = new Hashtable (); 91 } 92 108 public CCM_ManagedObjectClient_Context 109 getContext() 110 { 111 return the_context_; 112 } 113 127 public void 128 configuration_complete() 129 throws org.omg.Components.InvalidConfiguration 130 { 131 System.err.println("Client configuration called..."); 132 try { 137 org.omg.CORBA.ORB orb = 138 org.objectweb.ccm.CORBA.TheORB.getORB(); 139 140 org.omg.CORBA.Object obj = 141 orb.resolve_initial_references("NameService"); 142 root_context = org.omg.CosNaming.NamingContextHelper.narrow(obj); 143 } 144 catch(Exception e_c) { 145 System.err.println("Exception caught will resolving naming service: " 146 + e_c.getMessage()); 147 e_c.printStackTrace(); 148 } 149 150 NameComponent [] channel_finder_name = new NameComponent [2]; 154 channel_finder_name[0] = new NameComponent ("coach", "ist"); 155 channel_finder_name[1] = new NameComponent ("", "ChannelFinderService"); 156 157 try { 158 org.omg.CORBA.Object obj = 159 root_context.resolve(channel_finder_name); 160 channel_finder = ist.coach.itut_q816Components.ChannelFinderProviderHelper.narrow(obj); 161 162 if (channel_finder != null) { 163 164 ChannelInfoType[] available_channels = channel_finder.provide_query().list(); 165 166 org.omg.CORBA.Object myself_o; 167 myself_o = ((org.omg.Components.SessionContext) the_context_).get_CCM_object(); 168 myself = ManagedObjectClientHelper.narrow(myself_o); 169 170 AlarmChannelProvider alarm_channel_provider = null; 171 for (int i = 0; i < available_channels.length; i++) { 172 173 if (available_channels[i].channel != null) { 174 alarm_channel_provider = 175 ist.coach.coachEmfServicesComponents.AlarmChannelProviderHelper.narrow( 176 available_channels[i].channel); 177 178 if (alarm_channel_provider == null) { 179 System.err.println("alarm_channel_provider is null"); 180 continue; 181 } 182 183 String [] eventTypes = alarm_channel_provider.eventTypes(); 184 System.err.println("eventTypes.length = " + eventTypes.length); 185 186 Vector alarmTypeV = new Vector (); 187 for (int j = 0; j < eventTypes.length; j++) { 188 add_alarm_provider(alarm_channel_provider, eventTypes[j]); 191 subscribe_alarm(eventTypes[j]); 192 193 } 194 195 } 196 } 197 } 198 else 199 System.err.println("Client> ChannelFinder reference is null..."); 200 } 201 catch(Exception e) { 202 System.err.println("Client> Could not locate ChannelFinder so that to " + 203 " subscribe to alarms!"); 204 System.err.println("Message: " + e.getMessage()); 205 e.printStackTrace(); 206 } 207 208 new Thread (ui_client = new ist.coach.coachEmfClientComponents.gui.GuiClient(name_, this)); 213 System.err.println("Client configuration completed..."); 215 } 216 232 public void 233 set_session_context(org.omg.Components.SessionContext context) 234 throws org.omg.Components.CCMException 235 { 236 the_context_ = (CCM_ManagedObjectClient_Context)context; 237 } 238 248 public void 249 ccm_activate() 250 throws org.omg.Components.CCMException 251 { 252 } 256 266 public void 267 ccm_passivate() 268 throws org.omg.Components.CCMException 269 { 270 } 274 284 public void 285 ccm_remove() 286 throws org.omg.Components.CCMException 287 { 288 ui_client.dispose(); 293 294 } 295 296 public void add_alarm_provider(AlarmChannelProvider alarm_channel_provider, 297 String alarmType) { 298 299 300 Vector alarmTypeV = new Vector (); 301 302 if (alarmProviders.containsKey(alarmType)) 303 alarmTypeV = (Vector ) alarmProviders.remove(alarmType); 304 305 AlarmSubscriptionInfo alarm_channel_provider_record; 306 int alarmTypeV_size = alarmTypeV.size(); 307 308 for(int i = 0; i < alarmTypeV_size; i++) { 309 alarm_channel_provider_record = (AlarmSubscriptionInfo) alarmTypeV.get(i); 310 if (alarm_channel_provider_record.alarm_channel_provider.channelId().equals( 311 alarm_channel_provider.channelId())) 312 alarmTypeV.removeElementAt(i); 313 } 314 alarm_channel_provider_record = new AlarmSubscriptionInfo(alarm_channel_provider, null); 315 alarmTypeV.add(alarm_channel_provider_record); 316 317 alarmProviders.put(alarmType, alarmTypeV); 318 320 } 321 322 public void subscribe_alarm(String alarmType) { 323 324 325 if (! alarmProviders.containsKey(alarmType)) 326 return; 327 328 Vector alarmTypeV = new Vector (); 329 alarmTypeV = (Vector ) alarmProviders.get(alarmType); 330 331 int alarmTypeV_size = alarmTypeV.size(); 332 333 AlarmChannelProvider alarm_channel_provider = null; 334 org.omg.Components.Cookie ck = null; 335 336 AlarmSubscriptionInfo alarm_channel_provider_record; 337 338 for(int i = 0; i < alarmTypeV_size; i++) { 339 340 alarm_channel_provider_record = (AlarmSubscriptionInfo) alarmTypeV.get(i); 341 alarm_channel_provider = alarm_channel_provider_record.alarm_channel_provider; 342 343 try { 344 if (alarmType.equals(GuiMaster.OBJECT_CREATION_ALARM)) { 345 ck = alarm_channel_provider.subscribe_objectCreation_alarm( 346 myself.get_consumer_object_creation_alarm()); 347 } 348 else 349 if (alarmType.equals(GuiMaster.OBJECT_DELETION_ALARM)) { 350 ck = alarm_channel_provider.subscribe_objectDeletion_alarm( 351 myself.get_consumer_object_deletion_alarm()); 352 } 353 else 354 if (alarmType.equals(GuiMaster.STATE_CHANGED_ALARM)) { 355 ck = alarm_channel_provider.subscribe_stateChanged_alarm( 356 myself.get_consumer_state_changed_alarm()); 357 } 358 else 359 if (alarmType.equals(GuiMaster.OPERATIONAL_ALARM)) { 360 ck = alarm_channel_provider.subscribe_operational_alarm( 361 myself.get_consumer_operational_violation_alarm()); 362 } 363 else 364 if (alarmType.equals(GuiMaster.HEARTBEAT_ALARM)) { 365 ck = alarm_channel_provider.subscribe_heartbeat_event( 366 myself.get_consumer_heartbeat_alarm()); 367 } 368 else 369 if (alarmType.equals(GuiMaster.CHANNEL_CHANGE_ALARM)) { 370 ck = alarm_channel_provider.subscribe_channelChange_event( 371 myself.get_consumer_channel_change_alarm()); 372 } 373 } 374 catch(org.omg.Components.ExceededConnectionLimit ex1) { 375 System.err.println("org.omg.Components.ExceededConnectionLimit caught " + 376 ex1.getMessage()); 377 } 378 379 if (ck == null) { 380 System.err.println("Subscription cookie of " + alarmType + 381 " is NULL!"); 382 continue; 383 } 384 385 AlarmSubscriptionInfo info = new AlarmSubscriptionInfo( 386 alarm_channel_provider, ck); 387 388 alarmTypeV = (Vector ) alarmProviders.remove(alarmType); 389 alarmTypeV.removeElementAt(i); 390 alarmTypeV.add(info); 391 392 alarmProviders.put(alarmType, alarmTypeV); 393 System.err.println("Subscription for " + alarmType + " finished!"); 394 } 395 } 396 397 public void unsubscribe_alarm(String alarmType) { 398 399 if (! alarmProviders.containsKey(alarmType)) 400 return; 401 402 Vector alarmTypeV = new Vector (); 403 alarmTypeV = (Vector ) alarmProviders.get(alarmType); 404 405 int alarmTypeV_size = alarmTypeV.size(); 406 407 AlarmChannelProvider alarm_channel_provider = null; 408 org.omg.Components.Cookie ck = null; 409 410 AlarmSubscriptionInfo alarm_channel_provider_record; 411 org.omg.Components.Cookie cookie = null; 412 413 for(int i = 0; i < alarmTypeV_size; i++) { 414 415 alarm_channel_provider_record = (AlarmSubscriptionInfo) alarmTypeV.get(i); 416 alarm_channel_provider = alarm_channel_provider_record.alarm_channel_provider; 417 cookie = alarm_channel_provider_record.cookie; 418 419 if (cookie == null) 420 continue; 421 422 try { 423 if (alarmType.equals(GuiMaster.OBJECT_CREATION_ALARM)) { 424 alarm_channel_provider.unsubscribe_objectCreation_alarm(cookie); 425 } 426 else 427 if (alarmType.equals(GuiMaster.OBJECT_DELETION_ALARM)) { 428 alarm_channel_provider.unsubscribe_objectDeletion_alarm(cookie); 429 } 430 else 431 if (alarmType.equals(GuiMaster.STATE_CHANGED_ALARM)) { 432 alarm_channel_provider.unsubscribe_stateChanged_alarm(cookie); 433 } 434 else 435 if (alarmType.equals(GuiMaster.OPERATIONAL_ALARM)) { 436 alarm_channel_provider.unsubscribe_operational_alarm(cookie); 437 } 438 else 439 if (alarmType.equals(GuiMaster.HEARTBEAT_ALARM)) { 440 alarm_channel_provider.unsubscribe_heartbeat_event(cookie); 441 } 442 else 443 if (alarmType.equals(GuiMaster.CHANNEL_CHANGE_ALARM)) { 444 alarm_channel_provider.unsubscribe_channelChange_event(cookie); 445 } 446 447 } 448 catch(org.omg.Components.InvalidConnection ex1) {} 449 } 450 } 451 452 public void set_heartbeat_period(short period) { 453 454 NameComponent [] heartbeat_name =new NameComponent [2]; 455 heartbeat_name[0] = new NameComponent ("coach", "ist"); 456 heartbeat_name[1] = new NameComponent ("", "HeartbeatService"); 457 458 try { 459 org.omg.CORBA.Object obj = root_context.resolve(heartbeat_name); 460 461 ist.coach.itut_q816Components.HeartbeatProvider heartbeat_provider = 462 ist.coach.itut_q816Components.HeartbeatProviderHelper.narrow(obj); 463 464 heartbeat_provider.provide_admin().periodSet(period); 465 } 466 catch(Exception e) { 467 System.err.println("Client: set_heartbeat_period> Caught Exception " + 468 e.getMessage()); 469 e.printStackTrace(System.err); 470 } 471 } 472 473 484 public void 485 push_object_creation_alarm(ist.coach.itut_q816Components.ObjectCreation event) 486 { 487 System.err.println("---->ObjectCreation received: "); 491 System.err.println("Source Object Name = " + Utils.name2string(event.source)); 492 System.err.println("Source Object Type = " + event.sourceClass); 493 System.err.println("Notification Id = " + String.valueOf( 494 event.notificationIdentifier)); 495 System.err.println("Time = " + String.valueOf(event.eventTime.time)); 496 497 java.util.Date event_date = new java.util.Date (event.eventTime.time); 498 DateFormat df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT); 499 String time_str = df.format(event_date); 500 501 ui_client.print_alarm(time_str, 502 ist.coach.coachEmfClientComponents.gui.GuiMessages.object_creation_alarm, 503 Utils.name2string(event.source), event.sourceClass, 504 String.valueOf(event.notificationIdentifier), " "); 505 } 506 512 public void 513 push_object_deletion_alarm(ist.coach.itut_q816Components.ObjectDeletion event) 514 { 515 System.err.println("---->ObjectDeletion received: "); 519 System.err.println("Source Object Name = " + Utils.name2string(event.source)); 520 System.err.println("Source Object Type = " + event.sourceClass); 521 System.err.println("Notification Id = " + event.notificationIdentifier); 522 523 java.util.Date event_date = new java.util.Date (event.eventTime.time); 524 DateFormat df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT); 525 String time_str = df.format(event_date); 526 527 528 ui_client.print_alarm(time_str, 529 ist.coach.coachEmfClientComponents.gui.GuiMessages.object_deletion_alarm, 530 Utils.name2string(event.source), event.sourceClass, 531 String.valueOf(event.notificationIdentifier), ""); 532 } 533 539 public void 540 push_operational_violation_alarm(ist.coach.itut_q816Components.OperationalViolation event) 541 { 542 System.err.println("---->OperationalViolation received: "); 546 System.err.println("Source Object Name = " + Utils.name2string(event.source)); 547 System.err.println("Source Object Type = " + event.sourceClass); 548 System.err.println("Notification Id = " + event.notificationIdentifier); 549 550 java.util.Date event_date = new java.util.Date (event.eventTime.time); 551 DateFormat df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT); 552 String time_str = df.format(event_date); 553 554 ui_client.print_alarm(time_str, 555 ist.coach.coachEmfClientComponents.gui.GuiMessages.operation_violation_alarm, 556 Utils.name2string(event.source), event.sourceClass, 557 String.valueOf(event.notificationIdentifier), ""); 558 } 559 565 public void 566 push_state_changed_alarm(ist.coach.itut_q816Components.StateChangedEvent event) 567 { 568 System.err.println("---->StateChangedEvent received: "); 572 System.err.println("Source Object Name = " + Utils.name2string(event.source)); 573 System.err.println("Source Object Type = " + event.sourceClass); 574 System.err.println("Notification Id = " + event.notificationIdentifier); 575 String details = new String (); 576 for(int i = 0; i < event.attributeList.length; i++) { 577 details += event.attributeList[i].attributeName + " changed "; 578 if (event.attributeList[i].oldValue != null) { 579 OperationalStateType oldState = OperationalStateTypeHelper.extract( 580 event.attributeList[i].oldValue); 581 details += " from "; 582 switch(oldState.value()) { 583 case OperationalStateType._disabled : 584 details += "Disabled"; 585 break; 586 case OperationalStateType._enabled : 587 details += "Enabled"; 588 break; 589 default: 590 details += "Unknown"; 591 } 592 } 593 if (event.attributeList[i].newValue != null) { 594 OperationalStateType newState = OperationalStateTypeHelper.extract( 595 event.attributeList[i].newValue); 596 details += " to "; 597 switch(newState.value()) { 598 case OperationalStateType._disabled : 599 details += "Disabled"; 600 break; 601 case OperationalStateType._enabled : 602 details += "Enabled"; 603 break; 604 default: 605 details += "Unknown"; 606 } 607 } 608 } 609 610 java.util.Date event_date = new java.util.Date (event.eventTime.time); 611 DateFormat df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT); 612 String time_str = df.format(event_date); 613 614 ui_client.print_alarm(time_str, 615 ist.coach.coachEmfClientComponents.gui.GuiMessages.state_changed_alarm, 616 Utils.name2string(event.source), event.sourceClass, 617 String.valueOf(event.notificationIdentifier), details); 618 } 619 625 public void 626 push_channel_change_alarm(ist.coach.itut_q816Components.ChannelChangeEvent event) 627 { 628 ui_client.print_alarm("", 632 ist.coach.coachEmfClientComponents.gui.GuiMessages.channel_change_alarm, 633 "", "", "", ""); 634 } 635 641 public void 642 push_heartbeat_alarm(ist.coach.itut_q816Components.Heartbeat event) 643 { 644 java.util.Date event_date = new java.util.Date (event.timeStamp.time); 648 DateFormat df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT); 649 String time_str = df.format(event_date); 650 ui_client.print_alarm(time_str, 651 ist.coach.coachEmfClientComponents.gui.GuiMessages.heartbeat_alarm, 652 event.channelID, "AlarmChannel", 653 "", ""); 654 } 655 661 public void 662 push_l_attribute_value_change_alarm(ist.coach.coachEmfServicesComponents.LogAttributeValueChange event) 663 { 664 } 668 674 public void 675 push_l_threshold_alarm(ist.coach.coachEmfServicesComponents.LogThresholdAlarm event) 676 { 677 } 681 687 public java.lang.String 688 name() 689 { 690 return name_; 694 } 695 696 699 public void 700 name(java.lang.String val) 701 { 702 706 name_ = val; 707 if (ui_client != null) 708 ui_client.set_name(name_); 709 System.err.println("Name is set to " + name_); 710 } 711 712 718 public void print(String msg) { 719 ui_client.print(msg); 720 System.out.print(msg); 722 } 723 724 public void println(String msg) { 725 ui_client.println(msg); 726 System.out.println(msg); 727 } 728 729 public String createByManager(String object_class, 730 String [] param_names, 731 Object [] values, 732 String parent_key_val) { 733 734 NameComponent [] parent_object_key = Utils.string2name(parent_key_val); 735 String new_object_key = (values != null && values.length > 0) ? 736 (String ) values[0] : new String (); 737 738 742 try { 743 744 NameComponent [] factoryfinder_name =new NameComponent [2]; 745 factoryfinder_name[0] = new NameComponent ("coach", "ist"); 746 factoryfinder_name[1] = new NameComponent ("", "FactoryFinder"); 747 748 org.omg.CORBA.Object obj = root_context.resolve(factoryfinder_name); 749 750 ist.coach.itut_q816Components.FactoryFinderProvider factory_finder = 751 ist.coach.itut_q816Components.FactoryFinderProviderHelper.narrow(obj); 752 753 ManagedObjectFactory mobject_f = factory_finder.provide_query().find( 754 object_class + "Factory"); 755 756 762 763 766 String nameBinding = object_class + "_" 767 + Utils.name2kind(parent_key_val); 768 System.err.println("Name Binding is " + nameBinding); 769 770 if (mobject_f == null) { 771 System.err.println("Factory Object was null!!"); 772 return new String (); 773 } 774 775 NameComponent [] new_name = null; 776 778 779 if (object_class.equals("ManagedObject")) { 780 new_name = mobject_f.create_base(nameBinding, 781 parent_object_key, new_object_key); 782 } 783 else 784 if (object_class.equals("ManagedElement")) { 785 786 ManagedElementFactory element_factory = 787 ManagedElementFactoryHelper.narrow(mobject_f); 788 789 String userLabel = new String (); 790 if (values.length > 1 && values[1] != null) 791 userLabel = (String ) values[1]; 792 System.err.print("userLabel = " + userLabel + ", "); 793 794 String vendorName = new String (); 795 if (values.length > 2 && values[2] != null) 796 vendorName = (String ) values[2]; 797 System.err.print("vendorName = " + vendorName + ", "); 798 799 String version = new String (); 800 if (values.length > 3 && values[3] != null) 801 version = (String ) values[3]; 802 System.err.print("version = " + version + ", "); 803 804 String locationName = new String (); 805 if (values.length > 4 && values[4] != null) 806 locationName = (String ) values[4]; 807 System.err.println("locationName = " + locationName); 808 809 new_name = element_factory.create(nameBinding, 810 parent_object_key, 811 new_object_key, 812 new String [0], 813 intt.itu.itut_x780.AdministrativeStateType.locked, 814 userLabel, 815 vendorName, 816 version, 817 locationName 818 ); 819 820 } 821 else 822 if (object_class.equals("IpNode")) { 823 824 IpNodeFactory ipnode_factory = IpNodeFactoryHelper.narrow( 825 mobject_f); 826 827 String domainName = new String (); 828 if (values.length > 1 && values[1] != null) 829 domainName = (String ) values[1]; 830 System.err.print("domainName = " + domainName + ", "); 831 832 String hostname = new String (); 833 if (values.length > 2 && values[2] != null) 834 hostname = (String ) values[2]; 835 System.err.print("hostname = " + hostname + ", "); 836 837 byte[] managementIPAddress = new byte[0]; 838 if (values.length > 3 && values[3] != null) 839 managementIPAddress = ((String ) values[3]).getBytes(); 840 System.err.print("managementIPAddress = " + values[3] + ", "); 841 842 int supportedSnmpVersions = 0; 843 if (values.length > 4 && values[4] != null) 844 supportedSnmpVersions = Integer.parseInt((String ) values[4]); 845 System.err.println("supportedSnmpVersions = " + supportedSnmpVersions); 846 847 String userLabel = new String (); 848 if (values.length > 5 && values[5] != null) 849 userLabel = (String ) values[5]; 850 System.err.print("userLabel = " + userLabel + ", "); 851 852 String vendorName = new String (); 853 if (values.length > 6 && values[6] != null) 854 vendorName = (String ) values[6]; 855 System.err.print("vendorName = " + vendorName + ", "); 856 857 String version = new String (); 858 if (values.length > 7 && values[7] != null) 859 version = (String ) values[7]; 860 System.err.print("version = " + version + ", "); 861 862 String locationName = new String (); 863 if (values.length > 8 && values[8] != null) 864 locationName = (String ) values[8]; 865 System.err.println("locationName = " + locationName); 866 867 int snmpPort = 0; 868 if (values.length > 9 && values[9] != null) 869 snmpPort = Integer.parseInt((String ) values[9]); 870 System.err.print("snmpPort = " + snmpPort + ", "); 871 872 String sysName = new String (); 873 if (values.length > 10 && values[10] != null) 874 sysName = (String ) values[10]; 875 System.err.print("sysName = " + values[10] + ", "); 876 877 String sysContact = new String (); 878 if (values.length > 11 && values[11] != null) 879 sysContact = (String ) values[11]; 880 System.err.print("sysContact = " + values[11]); 881 882 System.err.println("Ready to call create on IpNodeFactory!"); 884 new_name = ipnode_factory.create(nameBinding, 885 parent_object_key, 886 new_object_key, 887 new String [0], 888 domainName, 889 hostname, 890 managementIPAddress, 891 supportedSnmpVersions, 892 intt.itu.itut_x780.AdministrativeStateType.locked, 893 userLabel, 894 vendorName, 895 version, 896 locationName, 897 snmpPort, 898 sysName, 899 sysContact 900 ); 901 902 } 903 if (new_name != null && new_name.length > 0) { 904 new_object_key = Utils.name2string(new_name); 905 } 906 else 907 new_object_key = new String (); 908 } 909 catch(CreateError create_e) { 910 treat_create_exceptions(create_e); 911 new_object_key = new String (); 912 } 913 catch(ApplicationError appl_e) { 914 treat_application_exceptions(appl_e); 915 new_object_key = new String (); 916 } 917 catch(Exception e_c) { 918 System.err.println("Exception caught: " + e_c.getMessage()); 919 e_c.printStackTrace(); 920 new_object_key = new String (); 921 } 922 923 return new_object_key; 924 } 925 926 public boolean removeByManager(String name) { 927 928 if (name == null || name.length() == 0) 929 return false; 930 931 try { 932 NameComponent [] terminator_name = new NameComponent [2]; 933 terminator_name[0] = new NameComponent ("coach", "ist"); 934 terminator_name[1] = new NameComponent ("", "TerminatorService"); 935 936 org.omg.CORBA.Object obj = root_context.resolve(terminator_name); 937 938 ist.coach.itut_q816Components.TerminatorServiceProvider terminator = 939 ist.coach.itut_q816Components.TerminatorServiceProviderHelper.narrow(obj); 940 941 if (terminator != null) { 942 terminator.provide_terminator().deleteByName(Utils.string2name(name)); 943 return true; 944 } 945 946 } 947 catch(DeleteError delete_e) { 948 treat_delete_exceptions(delete_e); 949 return false; 950 } 951 catch(Exception e_c) { 952 System.err.println("Exception caught: " + e_c.getMessage()); 953 e_c.printStackTrace(); 954 return false; 955 } 956 return false; 957 958 } 959 960 public ManagedObjectValueType attributesGet(String object_class, 961 String object_key, 962 String []attributes) { 963 964 965 System.err.println("\n--->attributesGet is called for " + object_key + 966 " of type " + object_class); 967 968 ManagedObjectValueType attributes_values = null; 969 NameComponent [] facade_name = new NameComponent [2]; 970 try { 971 if (object_key == null || object_key.length() == 0) 972 return null; 973 974 facade_name[0] = new NameComponent ("coach", "ist"); 975 facade_name[1] = 976 new NameComponent ("", Utils.name2facade(object_key)); 978 979 org.omg.CORBA.Object obj = root_context.resolve(facade_name); 981 982 984 intt.itu.itut_x780.ManagedObject_F mobject_f = 985 intt.itu.itut_x780.ManagedObject_FHelper.narrow(obj); 986 989 if (mobject_f == null) { 990 System.err.println("Facade object can not be found!"); 991 return null; 992 } 993 994 NameComponent [] obj_name = Utils.string2name(object_key); 995 996 attributes_values = (ManagedObjectValueType) mobject_f.attributesGet( 997 Utils.string2name(object_key), 998 new intt.itu.itut_x780.StringSetTypeHolder(attributes)); 999 1000 } 1001 catch(ApplicationError appl_e) { 1002 treat_application_exceptions(appl_e); 1003 } 1004 catch(Exception e_c) { 1005 System.err.println("Exception caught>" 1006 + Utils.name2string(facade_name) + 1007 ": " + e_c.getMessage()); 1008 e_c.printStackTrace(); 1009 } 1010 1011 return attributes_values; 1012 } 1013 1014 public String [] getContained(String superior) { 1015 1016 String [] subordinates = new String [0]; 1018 try { 1019 1020 NameComponent [] c_query = new NameComponent [2]; 1021 c_query[0] = new NameComponent ("coach", "ist"); 1022 c_query[1] = new NameComponent ("", "ContainmentService"); 1023 org.omg.CORBA.Object obj = root_context.resolve(c_query); 1024 1025 ist.coach.itut_q816Components.ContainmentServiceProvider containment = 1026 ist.coach.itut_q816Components.ContainmentServiceProviderHelper.narrow(obj); 1027 1028 if (containment != null) { 1029 NameComponent [][] children = 1030 containment.provide_containment_query().getContained( 1031 Utils.string2name(superior)); 1032 1034 if (children != null && children.length > 0) { 1035 subordinates = new String [children.length]; 1036 for(int i = 0; i < subordinates.length; i++) 1037 subordinates[i] = Utils.name2string(children[i]); 1038 } 1039 } 1040 } 1041 catch(Exception e_c) { 1042 System.err.println("Exception caught: " + e_c.getMessage()); 1043 e_c.printStackTrace(); 1044 } 1045 1046 return subordinates; 1047 } 1048 1049 public boolean setAttributes(String object_key, Vector set_data) { 1050 1051 System.err.println("setAttributes is called on " + object_key + 1052 " of type " + Utils.name2kind(object_key)); 1053 1054 if (object_key == null || object_key.length() == 0) 1055 return false; 1056 1057 String objectkind = Utils.name2kind(object_key); 1058 NameComponent [] facade_name = new NameComponent [2]; 1059 try { 1060 facade_name[0] = new NameComponent ("coach", "ist"); 1061 facade_name[1] = 1062 new NameComponent ("", Utils.name2facade(object_key)); 1063 org.omg.CORBA.Object obj = root_context.resolve(facade_name); 1064 1065 if (objectkind.equals("ManagedElement")) { 1066 1067 ManagedElement_F facade = ManagedElement_FHelper.narrow(obj); 1068 Enumeration set_operations = set_data.elements(); 1069 while(set_operations.hasMoreElements()) { 1070 InvokeSetData set_method = (InvokeSetData) set_operations.nextElement(); 1071 set_method.methodName.invoke(facade, set_method.methodArguments); 1072 } 1073 } 1074 else 1075 if (objectkind.equals("IpNode")) { 1076 1077 IpNode_F facade = IpNode_FHelper.narrow(obj); 1078 Enumeration set_operations = set_data.elements(); 1079 while(set_operations.hasMoreElements()) { 1080 InvokeSetData set_method = (InvokeSetData) set_operations.nextElement(); 1081 set_method.methodName.invoke(facade, set_method.methodArguments); 1082 } 1083 } 1084 else 1085 if (objectkind.equals("LogicalInterface")) { 1086 LogicalInterface_F facade = LogicalInterface_FHelper.narrow(obj); 1087 Enumeration set_operations = set_data.elements(); 1088 while(set_operations.hasMoreElements()) { 1089 InvokeSetData set_method = (InvokeSetData) set_operations.nextElement(); 1090 set_method.methodName.invoke(facade, set_method.methodArguments); 1091 } 1092 } 1093 1094 1095 } 1096 catch(Exception e_c) { 1101 System.err.println("Exception caught>" 1102 + Utils.name2string(facade_name) + 1103 ": " + e_c.getMessage()); 1104 e_c.printStackTrace(); 1105 return false; 1106 } 1107 return true; 1108 } 1109 1110 1111 public void treat_create_exceptions(CreateError create_e) { 1112 System.err.println("Client caught exception during create operation:"); 1113 switch(create_e.info.error.value) { 1114 case intt.itu.itut_x780.CreateErrorConst.duplicateName.value : 1115 System.err.println("Object already exists"); 1116 System.err.println(create_e.info.details); 1117 break; 1118 case intt.itu.itut_x780.CreateErrorConst.invalidNameBinding.value : 1119 System.err.println("InvalidNameBinding has been provided"); 1120 System.err.println(create_e.info.details); 1121 break; 1122 case intt.itu.itut_x780.CreateErrorConst.badName.value : 1123 System.err.println("Bad Name"); 1124 System.err.println(create_e.info.details); 1125 break; 1126 default: 1127 System.err.println(create_e.info.details); 1128 } 1129 ui_client.showCreateError(create_e.info.details); 1130 } 1131 1132 public void treat_delete_exceptions(DeleteError delete_e) { 1133 System.err.println("Client caught exception during remove operation"); 1134 switch(delete_e.info.error.value) { 1135 case intt.itu.itut_x780.DeleteErrorConst.notDeletable.value : 1136 System.err.println("Element can not be deleted by the manager"); 1137 System.err.println(delete_e.info.details); 1138 break; 1139 case intt.itu.itut_x780.DeleteErrorConst.containsObjects.value : 1140 System.err.println("Element contains children and thus can not be deleted"); 1141 System.err.println(delete_e.info.details); 1142 break; 1143 default: 1144 System.err.println(delete_e.info.details); 1145 } 1146 ui_client.showDeleteError(delete_e.info.details); 1147 1148 } 1149 1150 public void treat_application_exceptions(ApplicationError appl_e) { 1151 System.err.println("Application exception caught:"); 1152 switch(appl_e.info.error.value) { 1153 case intt.itu.itut_x780.ApplicationErrorConst.objectNotFound.value : 1154 System.err.println("Object Not Found"); 1155 System.err.println(appl_e.info.details); 1156 break; 1157 case intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value : 1158 System.err.println("Invalid Parameter"); 1159 System.err.println(appl_e.info.details); 1160 break; 1161 default: 1162 System.err.println(appl_e.info.details); 1163 } 1164 ui_client.showAttributesError(appl_e.info.details); 1165 } 1166 1167 1168private class AlarmSubscriptionInfo { 1169 1170 org.omg.Components.Cookie cookie; 1171 AlarmChannelProvider alarm_channel_provider; 1172 1173 AlarmSubscriptionInfo(AlarmChannelProvider alarm_channel_provider, 1174 org.omg.Components.Cookie cookie) { 1175 1176 this.alarm_channel_provider = alarm_channel_provider; 1177 this.cookie = cookie; 1178 } 1179} 1180} 1181 | Popular Tags |