1 21 package ist.coach.coachEmsMibComponents; 22 23 import intt.itu.itut_x780.UIDType; 24 import intt.itu.itut_x780.CreateError; 25 import intt.itu.itut_x780.ApplicationError; 26 import intt.itu.itut_x780.ManagedObjectValueType; 27 import intt.itu.itut_x780.AttributeValueChangeType; 28 import intt.itu.itut_x780.AttributeValueType; 29 import intt.itu.itut_x780.SourceIndicatorType; 30 import intt.itu.itut_x780.OperationalStateTypeHelper; 31 32 import intt.itu.itut_m3120.NOuserLabelPackageException; 33 import intt.itu.itut_m3120.NOvendorNamePackageException; 34 import intt.itu.itut_m3120.NOversionPackageException; 35 import intt.itu.itut_m3120.NOlocationNamePackageException; 36 37 import ist.coach.coachEmfCommon.Utils; 38 import ist.coach.coachEmfCommon.StateChangedEventImpl; 39 import ist.coach.coachEmfCommon.ObjectCreationImpl; 40 import ist.coach.coachEmfCommon.ObjectDeletionImpl; 41 import ist.coach.coachEmfCommon.ExceptionMessages; 42 import ist.coach.coachEmfCommon.CreateErrorInfoTypeImpl; 43 import ist.coach.coachEmfCommon.ApplicationErrorInfoTypeImpl; 44 import ist.coach.coachEmfCommon.ManagedObjectValueTypeImpl; 45 import ist.coach.coachEmfCommon.DataTypeImpl; 46 47 import ist.coach.coachEmfServices.SnmpAdapter.DataType; 48 import ist.coach.coachEmfServices.SnmpAdapter.SnmpApplicationError; 49 50 import ist.coach.coachEmsMib.IpNodeValueType; 51 import ist.coach.coachEmsMib.NOsysInformationSetPackageException; 52 53 import ist.coach.coachEmsCommon.IpNodeValueTypeImpl; 54 import org.omg.CosNaming.NameComponent ; 55 import org.omg.CORBA.TCKind ; 56 57 import org.opennms.protocols.snmp.SnmpSMI; 58 59 import java.util.Hashtable ; 60 64 public class IpNodeProviderMonolithicImpl 65 extends org.omg.CORBA.LocalObject 66 implements CCM_IpNodeProvider, 67 ist.coach.coachEmsMibComponents.CCM_IpNodeMgmt, 68 ist.coach.coachEmfServices.SnmpAdapter.CCM_TrapCallback, 69 org.omg.Components.SessionComponent 70 { 71 79 org.omg.CORBA.ORB orb = null; 80 private CCM_IpNodeProvider_Context the_context_; 81 private String _facade_name; 82 private int notifId = 1000; 83 84 private static final String IF_NUMBER_OID = ".1.3.6.1.2.1.2.1.0"; 85 private static final String SYS_DESCR_OID = ".1.3.6.1.2.1.1.1.0"; 86 private static final String SYS_OBJECTID_OID = ".1.3.6.1.2.1.1.2.0"; 87 private static final String SYS_UPTIME_OID = ".1.3.6.1.2.1.1.3.0"; 88 private static final String SYS_CONTACT_OID = ".1.3.6.1.2.1.1.4.0"; 89 private static final String SYS_NAME_OID = ".1.3.6.1.2.1.1.5.0"; 90 private static final String SYS_LOCATION_OID = ".1.3.6.1.2.1.1.6.0"; 91 private static final String SYS_SERVICES_OID = ".1.3.6.1.2.1.1.7.0"; 92 private static final String TIME_OID = ".1.3.6.1.2.1.1.3.0"; 93 94 private static final int COLDSTART_TRAP = 1; 95 private static final int NETSNMP_SHUTDOWN_TRAP = 4; 96 97 private static final String SYS_INFO_SET_PACKAGE = "sysInfoSetPackage"; 98 private static final String LOCATION_NAME_PACKAGE = "locationNamePackage"; 99 private static final String USER_LABEL_PACKAGE = "userLabelPackage"; 100 private static final String VENDOR_NAME_PACKAGE = "vendorNamePackage"; 101 private static final String VERSION_PACKAGE = "versionPackage"; 102 103 private static final String READ_COMMUNITY = "public"; 104 private static final String WRITE_COMMUNITY = "private"; 105 106 private Hashtable elements; 107 108 ist.coach.coachEmfServices.SnmpAdapter.SnmpConnector connector = null; 109 ist.coach.coachEmfServices.SnmpAdapter.SnmpTrapDaemon config = null; 110 118 public 119 IpNodeProviderMonolithicImpl() 120 { 121 the_context_ = null; 122 this.elements = new Hashtable (); 123 } 124 130 131 142 public CCM_IpNodeProvider_Context 143 getContext() 144 { 145 return the_context_; 146 } 147 161 public void 162 configuration_complete() 163 throws org.omg.Components.InvalidConfiguration 164 { 165 169 if ((connector = the_context_.get_connection_connector()) == null) 170 throw new org.omg.Components.InvalidConfiguration(); 171 172 if ((config = the_context_.get_connection_config()) == null) 173 throw new org.omg.Components.InvalidConfiguration(); 174 175 orb = org.objectweb.ccm.CORBA.TheORB.getORB(); 176 System.err.println("IpNodeProvider configuration completed..."); 177 } 178 194 public void 195 set_session_context(org.omg.Components.SessionContext context) 196 throws org.omg.Components.CCMException 197 { 198 the_context_ = (CCM_IpNodeProvider_Context)context; 199 } 200 210 public void 211 ccm_activate() 212 throws org.omg.Components.CCMException 213 { 214 } 218 228 public void 229 ccm_passivate() 230 throws org.omg.Components.CCMException 231 { 232 } 236 246 public void 247 ccm_remove() 248 throws org.omg.Components.CCMException 249 { 250 } 254 265 public ist.coach.coachEmsMibComponents.CCM_IpNodeMgmt 266 get_mgmt() 267 { 268 return this; 269 } 270 276 287 public java.lang.String 288 facade_name() 289 { 290 return _facade_name; 294 } 295 296 299 public void 300 facade_name(java.lang.String val) 301 { 302 if (val != null) 306 _facade_name = new String (val); 307 308 309 } 310 311 314 public NameComponent [] nameGet() { 315 return Utils.string2name(_facade_name); 316 } 317 318 324 public java.lang.String 325 domainNameGet(org.omg.CosNaming.NameComponent [] name) 326 throws intt.itu.itut_x780.ApplicationError 327 { 328 String key = Utils.name2string(name); 332 333 if (this.elements.containsKey(key) == false) { 334 ApplicationErrorInfoTypeImpl error_code = 335 new ApplicationErrorInfoTypeImpl(); 336 337 error_code.error = new UIDType( 338 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 339 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 340 341 error_code.details = new String ("object with name" + 342 key + " does not exist."); 343 344 throw new ApplicationError(error_code); 345 } 346 347 IpNodeDataStructure data = (IpNodeDataStructure) this.elements.get(key); 348 349 return data.domainName; 350 } 351 357 public java.lang.String 358 hostnameGet(org.omg.CosNaming.NameComponent [] name) 359 throws intt.itu.itut_x780.ApplicationError 360 { 361 365 366 String key = Utils.name2string(name); 367 368 if (this.elements.containsKey(key) == false) { 369 ApplicationErrorInfoTypeImpl error_code = 370 new ApplicationErrorInfoTypeImpl(); 371 372 error_code.error = new UIDType( 373 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 374 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 375 376 error_code.details = new String ("object with name" + 377 key + " does not exist."); 378 379 throw new ApplicationError(error_code); 380 } 381 382 IpNodeDataStructure data = (IpNodeDataStructure) this.elements.get(key); 383 384 return data.hostname; 385 } 386 392 public byte[] 393 managementIPAddressGet(org.omg.CosNaming.NameComponent [] name) 394 throws intt.itu.itut_x780.ApplicationError 395 { 396 String key = Utils.name2string(name); 400 401 if (this.elements.containsKey(key) == false) { 402 ApplicationErrorInfoTypeImpl error_code = 403 new ApplicationErrorInfoTypeImpl(); 404 405 error_code.error = new UIDType( 406 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 407 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 408 409 error_code.details = new String ("object with name" + 410 key + " does not exist."); 411 412 throw new ApplicationError(error_code); 413 } 414 415 IpNodeDataStructure data = (IpNodeDataStructure) this.elements.get(key); 416 417 return data.managementIPAddress; 418 419 } 420 426 public int 427 supportedSnmpVersionsGet(org.omg.CosNaming.NameComponent [] name) 428 throws intt.itu.itut_x780.ApplicationError 429 { 430 434 435 String key = Utils.name2string(name); 436 437 if (this.elements.containsKey(key) == false) { 438 ApplicationErrorInfoTypeImpl error_code = 439 new ApplicationErrorInfoTypeImpl(); 440 441 error_code.error = new UIDType( 442 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 443 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 444 445 error_code.details = new String ("object with name" + 446 key + " does not exist."); 447 448 throw new ApplicationError(error_code); 449 } 450 451 IpNodeDataStructure data = (IpNodeDataStructure) this.elements.get(key); 452 453 return data.supportedSnmpVersions; 454 } 455 461 public int 462 snmpPortGet(org.omg.CosNaming.NameComponent [] name) 463 throws intt.itu.itut_x780.ApplicationError 464 { 465 String key = Utils.name2string(name); 469 470 if (this.elements.containsKey(key) == false) { 471 ApplicationErrorInfoTypeImpl error_code = 472 new ApplicationErrorInfoTypeImpl(); 473 474 error_code.error = new UIDType( 475 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 476 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 477 478 error_code.details = new String ("object with name" + 479 key + " does not exist."); 480 481 throw new ApplicationError(error_code); 482 } 483 484 IpNodeDataStructure data = (IpNodeDataStructure) this.elements.get(key); 485 486 return data.snmpPort; 487 488 } 489 495 public int 496 ifNumberGet(org.omg.CosNaming.NameComponent [] name) 497 throws intt.itu.itut_x780.ApplicationError 498 { 499 DataType ifNumberData = null; 503 504 String key = Utils.name2string(name); 505 506 if (this.elements.containsKey(key) == false) { 507 508 ApplicationErrorInfoTypeImpl error_code = 509 new ApplicationErrorInfoTypeImpl(); 510 511 error_code.error = new UIDType( 512 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 513 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 514 515 error_code.details = new String ("object with name" + 516 key + " does not exist."); 517 518 throw new ApplicationError(error_code); 519 } 520 521 522 try { 523 524 ifNumberData = this.connector.get( 525 IF_NUMBER_OID, 526 new String (this.managementIPAddressGet(name)), 527 this.snmpPortGet(name), 528 READ_COMMUNITY); 529 } 530 catch (SnmpApplicationError e) { 531 532 ApplicationErrorInfoTypeImpl error_code = 533 new ApplicationErrorInfoTypeImpl(); 534 535 error_code.error = new UIDType( 536 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 537 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 538 539 if (e.reason.equals(ExceptionMessages.agent_response_error)) 540 error_code.details = ExceptionMessages.agent_response_error; 541 else 542 error_code.details = new String ("Could not retrieve ifNumber " + 543 "for IpNode Object with name " + key + ":" + 544 " Object with Snmp Object Identifier " + IF_NUMBER_OID + 545 " does not exist."); 546 547 throw new ApplicationError(error_code); 548 549 } 550 551 org.omg.CORBA.Any value = ifNumberData.value; 552 553 if(value.type().kind().value() != TCKind._tk_long) { 554 555 ApplicationErrorInfoTypeImpl error_code = 556 new ApplicationErrorInfoTypeImpl(); 557 558 error_code.error = new UIDType( 559 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 560 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 561 562 error_code.details = new String ("Could not retrieve ifNumber " + 563 "for IpNode Object with name " + key + ":" + 564 " Object with Snmp Object Identifier " + IF_NUMBER_OID + 565 " is not of type long, as expected."); 566 567 throw new ApplicationError(error_code); 568 569 } 570 571 int ifNumber = value.extract_long(); 572 573 return ifNumber; 574 575 } 576 582 public java.lang.String 583 sysDescrGet(org.omg.CosNaming.NameComponent [] name) 584 throws intt.itu.itut_x780.ApplicationError 585 { 586 590 DataType sysDescrData = null; 591 592 String key = Utils.name2string(name); 593 594 if (this.elements.containsKey(key) == false) { 595 596 ApplicationErrorInfoTypeImpl error_code = 597 new ApplicationErrorInfoTypeImpl(); 598 599 error_code.error = new UIDType( 600 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 601 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 602 603 error_code.details = new String ("object with name" + 604 key + " does not exist."); 605 606 throw new ApplicationError(error_code); 607 } 608 609 610 try { 611 612 sysDescrData = this.connector.get( 613 SYS_DESCR_OID, 614 new String (this.managementIPAddressGet(name)), 615 this.snmpPortGet(name), 616 READ_COMMUNITY); 617 } 618 catch (SnmpApplicationError e) { 619 620 ApplicationErrorInfoTypeImpl error_code = 621 new ApplicationErrorInfoTypeImpl(); 622 623 error_code.error = new UIDType( 624 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 625 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 626 627 if (e.reason.equals(ExceptionMessages.agent_response_error)) 628 error_code.details = ExceptionMessages.agent_response_error; 629 else 630 error_code.details = new String ("Could not retrieve sysDescr " + 631 "for IpNode Object with name " + key + ":" + 632 " Object with Snmp Object Identifier " + SYS_DESCR_OID + 633 " does not exist."); 634 635 throw new ApplicationError(error_code); 636 637 } 638 639 org.omg.CORBA.Any value = sysDescrData.value; 640 641 if(value.type().kind().value() != org.omg.CORBA.OctetSeqHelper.type().kind().value()) { 643 ApplicationErrorInfoTypeImpl error_code = 644 new ApplicationErrorInfoTypeImpl(); 645 646 error_code.error = new UIDType( 647 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 648 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 649 650 error_code.details = new String ("Could not retrieve sysDescr " + 651 "for IpNode Object with name " + key + ":" + 652 " Object with Snmp Object Identifier " + SYS_DESCR_OID + 653 " is not of type string, as expected."); 654 655 throw new ApplicationError(error_code); 656 657 } 658 String sysDescr = new String (org.omg.CORBA.OctetSeqHelper.extract(value)); 659 661 return sysDescr; 662 } 663 669 public java.lang.String 670 sysObjectIDGet(org.omg.CosNaming.NameComponent [] name) 671 throws intt.itu.itut_x780.ApplicationError 672 { 673 677 DataType sysObjectIDData = null; 678 679 String key = Utils.name2string(name); 680 681 if (this.elements.containsKey(key) == false) { 682 683 ApplicationErrorInfoTypeImpl error_code = 684 new ApplicationErrorInfoTypeImpl(); 685 686 error_code.error = new UIDType( 687 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 688 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 689 690 error_code.details = new String ("object with name" + 691 key + " does not exist."); 692 693 throw new ApplicationError(error_code); 694 } 695 696 697 try { 698 699 sysObjectIDData = this.connector.get( 700 SYS_OBJECTID_OID, 701 new String (this.managementIPAddressGet(name)), 702 this.snmpPortGet(name), 703 READ_COMMUNITY); 704 } 705 catch (SnmpApplicationError e) { 706 707 ApplicationErrorInfoTypeImpl error_code = 708 new ApplicationErrorInfoTypeImpl(); 709 710 error_code.error = new UIDType( 711 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 712 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 713 714 if (e.reason.equals(ExceptionMessages.agent_response_error)) 715 error_code.details = ExceptionMessages.agent_response_error; 716 else 717 error_code.details = new String ("Could not retrieve sysObjectID " + 718 "for IpNode Object with name " + key + ":" + 719 " Object with Snmp Object Identifier " + SYS_OBJECTID_OID + 720 " does not exist."); 721 722 throw new ApplicationError(error_code); 723 724 } 725 726 org.omg.CORBA.Any value = sysObjectIDData.value; 727 728 if(value.type().kind().value() != TCKind._tk_string) { 729 730 ApplicationErrorInfoTypeImpl error_code = 731 new ApplicationErrorInfoTypeImpl(); 732 733 error_code.error = new UIDType( 734 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 735 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 736 737 error_code.details = new String ("Could not retrieve sysObjectID " + 738 "for IpNode Object with name " + key + ":" + 739 " Object with Snmp Object Identifier " + SYS_OBJECTID_OID + 740 " is not of type string, as expected."); 741 742 throw new ApplicationError(error_code); 743 744 } 745 746 String sysObjectID = value.extract_string(); 747 748 return sysObjectID; 749 } 750 756 public long 757 sysUpTimeGet(org.omg.CosNaming.NameComponent [] name) 758 throws intt.itu.itut_x780.ApplicationError 759 { 760 DataType sysUpTimeData = null; 764 765 String key = Utils.name2string(name); 766 767 if (this.elements.containsKey(key) == false) { 768 769 ApplicationErrorInfoTypeImpl error_code = 770 new ApplicationErrorInfoTypeImpl(); 771 772 error_code.error = new UIDType( 773 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 774 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 775 776 error_code.details = new String ("object with name" + 777 key + " does not exist."); 778 779 throw new ApplicationError(error_code); 780 } 781 782 783 try { 784 785 sysUpTimeData = this.connector.get( 786 SYS_UPTIME_OID, 787 new String (this.managementIPAddressGet(name)), 788 this.snmpPortGet(name), 789 READ_COMMUNITY); 790 } 791 catch (SnmpApplicationError e) { 792 793 ApplicationErrorInfoTypeImpl error_code = 794 new ApplicationErrorInfoTypeImpl(); 795 796 error_code.error = new UIDType( 797 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 798 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 799 800 if (e.reason.equals(ExceptionMessages.agent_response_error)) 801 error_code.details = ExceptionMessages.agent_response_error; 802 else 803 error_code.details = new String ("Could not retrieve sysUpTime " + 804 "for IpNode Object with name " + key + ":" + 805 " Object with Snmp Object Identifier " + SYS_UPTIME_OID + 806 " does not exist."); 807 808 throw new ApplicationError(error_code); 809 810 } 811 812 org.omg.CORBA.Any value = sysUpTimeData.value; 813 814 if(value.type().kind().value() != TCKind._tk_longlong) { 815 816 ApplicationErrorInfoTypeImpl error_code = 817 new ApplicationErrorInfoTypeImpl(); 818 819 error_code.error = new UIDType( 820 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 821 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 822 823 error_code.details = new String ("Could not retrieve sysUpTime " + 824 "for IpNode Object with name " + key + ":" + 825 " Object with Snmp Object Identifier " + SYS_UPTIME_OID + 826 " is not of type long, as expected."); 827 828 throw new ApplicationError(error_code); 829 830 } 831 832 long sysUpTime = value.extract_longlong(); 833 834 return sysUpTime; 835 836 } 837 843 public java.lang.String 844 sysContactGet(org.omg.CosNaming.NameComponent [] name) 845 throws intt.itu.itut_x780.ApplicationError 846 { 847 851 852 DataType sysDescrData = null; 853 854 String key = Utils.name2string(name); 855 856 if (this.elements.containsKey(key) == false) { 857 858 ApplicationErrorInfoTypeImpl error_code = 859 new ApplicationErrorInfoTypeImpl(); 860 861 error_code.error = new UIDType( 862 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 863 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 864 865 error_code.details = new String ("object with name" + 866 key + " does not exist."); 867 868 throw new ApplicationError(error_code); 869 } 870 871 872 try { 873 874 sysDescrData = this.connector.get( 875 SYS_CONTACT_OID, 876 new String (this.managementIPAddressGet(name)), 877 this.snmpPortGet(name), 878 READ_COMMUNITY); 879 } 880 catch (SnmpApplicationError e) { 881 882 ApplicationErrorInfoTypeImpl error_code = 883 new ApplicationErrorInfoTypeImpl(); 884 885 error_code.error = new UIDType( 886 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 887 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 888 889 if (e.reason.equals(ExceptionMessages.agent_response_error)) 890 error_code.details = ExceptionMessages.agent_response_error; 891 else 892 error_code.details = new String ("Could not retrieve sysContact " + 893 "for IpNode Object with name " + key + ":" + 894 " Object with Snmp Object Identifier " + SYS_CONTACT_OID + 895 " does not exist."); 896 897 throw new ApplicationError(error_code); 898 899 } 900 901 org.omg.CORBA.Any value = sysDescrData.value; 902 903 if (value.type().kind().value() != org.omg.CORBA.OctetSeqHelper.type().kind().value()) { 905 ApplicationErrorInfoTypeImpl error_code = 906 new ApplicationErrorInfoTypeImpl(); 907 908 error_code.error = new UIDType( 909 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 910 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 911 912 error_code.details = new String ("Could not retrieve sysContact " + 913 "for IpNode Object with name " + key + ":" + 914 " Object with Snmp Object Identifier " + SYS_CONTACT_OID + 915 " is not of type string, as expected."); 916 917 throw new ApplicationError(error_code); 918 919 } 920 String sysContact = new String (org.omg.CORBA.OctetSeqHelper.extract(value)); 921 923 return sysContact; 924 } 925 931 public void 932 sysContactSet(org.omg.CosNaming.NameComponent [] name, java.lang.String sysContact) 933 throws intt.itu.itut_x780.ApplicationError, ist.coach.coachEmsMib.NOsysInformationSetPackageException 934 { 935 939 String key = Utils.name2string(name); 940 941 if (this.elements.containsKey(key) == false) { 942 943 ApplicationErrorInfoTypeImpl error_code = 944 new ApplicationErrorInfoTypeImpl(); 945 946 error_code.error = new UIDType( 947 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 948 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 949 950 error_code.details = new String ("object with name" + 951 key + " does not exist."); 952 953 throw new ApplicationError(error_code); 954 } 955 956 if (!Utils.packageIsSupported(SYS_INFO_SET_PACKAGE, 957 packagesGet(name))) { 958 System.out.println("Package " + SYS_INFO_SET_PACKAGE + 959 "is not supported by IpNode Object" + key); 960 961 throw new NOsysInformationSetPackageException(); 962 } 963 964 org.omg.CORBA.Any value = orb.create_any(); 965 org.omg.CORBA.OctetSeqHelper.insert(value, sysContact.getBytes()); 967 DataTypeImpl sysContactData = new DataTypeImpl( 968 SYS_CONTACT_OID, 969 value, 970 SnmpSMI.SMI_STRING); 971 972 try { 973 974 this.connector.set( 975 sysContactData, 976 new String (this.managementIPAddressGet(name)), 977 this.snmpPortGet(name), 978 WRITE_COMMUNITY); 979 } 980 catch (SnmpApplicationError e) { 981 982 ApplicationErrorInfoTypeImpl error_code = 983 new ApplicationErrorInfoTypeImpl(); 984 985 error_code.error = new UIDType( 986 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 987 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 988 989 if (e.reason.equals(ExceptionMessages.agent_response_error)) 990 error_code.details = ExceptionMessages.agent_response_error; 991 else 992 error_code.details = new String ("Could not set sysContact " + 993 "for IpNode Object with name " + key + "."); 994 995 throw new ApplicationError(error_code); 996 997 } 998 999 } 1000 1006 public java.lang.String 1007 sysNameGet(org.omg.CosNaming.NameComponent [] name) 1008 throws intt.itu.itut_x780.ApplicationError 1009 { 1010 1014 DataType sysNameData = null; 1015 1016 String key = Utils.name2string(name); 1017 1018 if (this.elements.containsKey(key) == false) { 1019 1020 ApplicationErrorInfoTypeImpl error_code = 1021 new ApplicationErrorInfoTypeImpl(); 1022 1023 error_code.error = new UIDType( 1024 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1025 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1026 1027 error_code.details = new String ("object with name" + 1028 key + " does not exist."); 1029 1030 throw new ApplicationError(error_code); 1031 } 1032 1033 1034 try { 1035 1036 sysNameData = this.connector.get( 1037 SYS_NAME_OID, 1038 new String (this.managementIPAddressGet(name)), 1039 this.snmpPortGet(name), 1040 READ_COMMUNITY); 1041 } 1042 catch (SnmpApplicationError e) { 1043 1044 ApplicationErrorInfoTypeImpl error_code = 1045 new ApplicationErrorInfoTypeImpl(); 1046 1047 error_code.error = new UIDType( 1048 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1049 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1050 1051 if (e.reason.equals(ExceptionMessages.agent_response_error)) 1052 error_code.details = ExceptionMessages.agent_response_error; 1053 else 1054 error_code.details = new String ("Could not retrieve sysName " + 1055 "for IpNode Object with name " + key + ":" + 1056 " Object with Snmp Object Identifier " + SYS_NAME_OID + 1057 " does not exist."); 1058 1059 throw new ApplicationError(error_code); 1060 1061 } 1062 1063 org.omg.CORBA.Any value = sysNameData.value; 1064 1065 if(value.type().kind().value() != org.omg.CORBA.OctetSeqHelper.type().kind().value()) { 1067 ApplicationErrorInfoTypeImpl error_code = 1068 new ApplicationErrorInfoTypeImpl(); 1069 1070 error_code.error = new UIDType( 1071 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1072 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1073 1074 error_code.details = new String ("Could not retrieve sysName " + 1075 "for IpNode Object with name " + key + ":" + 1076 " Object with Snmp Object Identifier " + SYS_NAME_OID + 1077 " is not of type string, as expected."); 1078 1079 throw new ApplicationError(error_code); 1080 1081 } 1082 1083 String sysName = new String (org.omg.CORBA.OctetSeqHelper.extract(value)); 1085 return sysName; 1086 } 1087 1093 public void 1094 sysNameSet(org.omg.CosNaming.NameComponent [] name, java.lang.String sysName) 1095 throws intt.itu.itut_x780.ApplicationError, ist.coach.coachEmsMib.NOsysInformationSetPackageException 1096 { 1097 1101 String key = Utils.name2string(name); 1102 1103 if (this.elements.containsKey(key) == false) { 1104 1105 ApplicationErrorInfoTypeImpl error_code = 1106 new ApplicationErrorInfoTypeImpl(); 1107 1108 error_code.error = new UIDType( 1109 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1110 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1111 1112 error_code.details = new String ("object with name" + 1113 key + " does not exist."); 1114 1115 throw new ApplicationError(error_code); 1116 } 1117 1118 if (!Utils.packageIsSupported(SYS_INFO_SET_PACKAGE, 1119 packagesGet(name))) { 1120 System.out.println("Package " + SYS_INFO_SET_PACKAGE + 1121 "is not supported by IpNode Object" + key); 1122 1123 throw new NOsysInformationSetPackageException(); 1124 } 1125 1126 org.omg.CORBA.Any value = orb.create_any(); 1127 1129 org.omg.CORBA.OctetSeqHelper.insert(value, sysName.getBytes()); 1130 1131 DataTypeImpl sysNameData = new DataTypeImpl( 1132 SYS_NAME_OID, 1133 value, 1134 SnmpSMI.SMI_STRING); 1135 1136 try { 1137 1138 this.connector.set( 1139 sysNameData, 1140 new String (this.managementIPAddressGet(name)), 1141 this.snmpPortGet(name), 1142 WRITE_COMMUNITY); 1143 } 1144 catch (SnmpApplicationError e) { 1145 1146 ApplicationErrorInfoTypeImpl error_code = 1147 new ApplicationErrorInfoTypeImpl(); 1148 1149 error_code.error = new UIDType( 1150 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1151 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1152 1153 if (e.reason.equals(ExceptionMessages.agent_response_error)) 1154 error_code.details = ExceptionMessages.agent_response_error; 1155 else 1156 error_code.details = new String ("Could not set sysName " + 1157 "for IpNode Object with name " + key + "."); 1158 1159 throw new ApplicationError(error_code); 1160 1161 } 1162 } 1163 1169 public short 1170 sysServicesGet(org.omg.CosNaming.NameComponent [] name) 1171 throws intt.itu.itut_x780.ApplicationError 1172 { 1173 1177 DataType sysServicesData = null; 1178 1179 String key = Utils.name2string(name); 1180 1181 if (this.elements.containsKey(key) == false) { 1182 1183 ApplicationErrorInfoTypeImpl error_code = 1184 new ApplicationErrorInfoTypeImpl(); 1185 1186 error_code.error = new UIDType( 1187 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1188 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1189 1190 error_code.details = new String ("object with name" + 1191 key + " does not exist."); 1192 1193 throw new ApplicationError(error_code); 1194 } 1195 1196 1197 try { 1198 1199 sysServicesData = this.connector.get( 1200 SYS_SERVICES_OID, 1201 new String (this.managementIPAddressGet(name)), 1202 this.snmpPortGet(name), 1203 READ_COMMUNITY); 1204 } 1205 catch (SnmpApplicationError e) { 1206 1207 ApplicationErrorInfoTypeImpl error_code = 1208 new ApplicationErrorInfoTypeImpl(); 1209 1210 error_code.error = new UIDType( 1211 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1212 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1213 1214 if (e.reason.equals(ExceptionMessages.agent_response_error)) 1215 error_code.details = ExceptionMessages.agent_response_error; 1216 else 1217 error_code.details = new String ("Could not retrieve sysServices " + 1218 "for IpNode Object with name " + key + ":" + 1219 " Object with Snmp Object Identifier " + SYS_SERVICES_OID + 1220 " does not exist."); 1221 1222 throw new ApplicationError(error_code); 1223 1224 } 1225 1226 org.omg.CORBA.Any value = sysServicesData.value; 1227 1228 if(value.type().kind().value() != TCKind._tk_long) { 1229 1230 ApplicationErrorInfoTypeImpl error_code = 1231 new ApplicationErrorInfoTypeImpl(); 1232 1233 error_code.error = new UIDType( 1234 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1235 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1236 1237 error_code.details = new String ("Could not retrieve sysServices " + 1238 "for IpNode Object with name " + key + ":" + 1239 " Object with Snmp Object Identifier " + SYS_SERVICES_OID + 1240 " is not of type int, as expected."); 1241 1242 throw new ApplicationError(error_code); 1243 1244 } 1245 1246 short sysServices = (short)value.extract_long(); 1247 1248 return sysServices; 1249 1250 } 1251 1257 public intt.itu.itut_x780.AdministrativeStateType 1258 administrativeStateGet(org.omg.CosNaming.NameComponent [] name) 1259 throws intt.itu.itut_x780.ApplicationError 1260 { 1261 1265 String key = Utils.name2string(name); 1266 1267 if (this.elements.containsKey(key) == false) { 1268 1269 ApplicationErrorInfoTypeImpl error_code = 1270 new ApplicationErrorInfoTypeImpl(); 1271 1272 error_code.error = new UIDType( 1273 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1274 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1275 1276 error_code.details = new String ("object with name" + 1277 key + " does not exist."); 1278 1279 throw new ApplicationError(error_code); 1280 } 1281 1282 IpNodeDataStructure ipNodeData = (IpNodeDataStructure)this.elements.get( 1283 Utils.name2string(name)); 1284 1285 return ipNodeData.administrativeState; 1286 1287 } 1288 1294 public void 1295 administrativeStateSet(org.omg.CosNaming.NameComponent [] name, intt.itu.itut_x780.AdministrativeStateType administrativeState) 1296 throws intt.itu.itut_x780.ApplicationError 1297 { 1298 1302 1304 String key = Utils.name2string(name); 1305 1306 if (this.elements.containsKey(key) == false) { 1307 1308 ApplicationErrorInfoTypeImpl error_code = 1309 new ApplicationErrorInfoTypeImpl(); 1310 1311 error_code.error = new UIDType( 1312 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1313 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1314 1315 error_code.details = new String ("object with name" + 1316 key + " does not exist."); 1317 1318 throw new ApplicationError(error_code); 1319 } 1320 1321 IpNodeDataStructure ipNodeData = (IpNodeDataStructure)this.elements.get(key); 1322 1323 ipNodeData.administrativeState = administrativeState; 1324 } 1325 1331 public intt.itu.itut_x780.OperationalStateType 1332 operationalStateGet(org.omg.CosNaming.NameComponent [] name) 1333 throws intt.itu.itut_x780.ApplicationError 1334 { 1335 1340 String key = Utils.name2string(name); 1341 1342 if (this.elements.containsKey(key) == false) { 1343 1344 ApplicationErrorInfoTypeImpl error_code = 1345 new ApplicationErrorInfoTypeImpl(); 1346 1347 error_code.error = new UIDType( 1348 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1349 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1350 1351 error_code.details = new String ("object with name" + 1352 key + " does not exist."); 1353 1354 throw new ApplicationError(error_code); 1355 } 1356 1357 IpNodeDataStructure ipNodeData = (IpNodeDataStructure)this.elements.get( 1358 Utils.name2string(name)); 1359 1360 return ipNodeData.operationalState; 1361 1362 } 1363 1369 public intt.itu.itut_x780.UsageStateType 1370 usageStateGet(org.omg.CosNaming.NameComponent [] name) 1371 throws intt.itu.itut_x780.ApplicationError 1372 { 1373 1377 1379 String key = Utils.name2string(name); 1380 1381 if (this.elements.containsKey(key) == false) { 1382 1383 ApplicationErrorInfoTypeImpl error_code = 1384 new ApplicationErrorInfoTypeImpl(); 1385 1386 error_code.error = new UIDType( 1387 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1388 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1389 1390 error_code.details = new String ("object with name" + 1391 key + " does not exist."); 1392 1393 throw new ApplicationError(error_code); 1394 } 1395 return intt.itu.itut_x780.UsageStateType.active; 1396 } 1397 1403 public java.lang.String 1404 userLabelGet(org.omg.CosNaming.NameComponent [] name) 1405 throws intt.itu.itut_x780.ApplicationError, intt.itu.itut_m3120.NOuserLabelPackageException 1406 { 1407 1411 String key = Utils.name2string(name); 1412 1413 if (this.elements.containsKey(key) == false) { 1414 1415 ApplicationErrorInfoTypeImpl error_code = 1416 new ApplicationErrorInfoTypeImpl(); 1417 1418 error_code.error = new UIDType( 1419 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1420 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1421 1422 error_code.details = new String ("object with name" + 1423 key + " does not exist."); 1424 1425 throw new ApplicationError(error_code); 1426 } 1427 1428 if (!Utils.packageIsSupported(USER_LABEL_PACKAGE, 1429 packagesGet(name))) { 1430 throw new NOuserLabelPackageException(); 1431 } 1432 1433 IpNodeDataStructure ipNodeData = (IpNodeDataStructure)this.elements.get(key); 1434 1435 return ipNodeData.userLabel; 1436 } 1437 1443 public void 1444 userLabelSet(org.omg.CosNaming.NameComponent [] name, java.lang.String userLabel) 1445 throws intt.itu.itut_x780.ApplicationError, intt.itu.itut_m3120.NOuserLabelPackageException 1446 { 1447 1451 String key = Utils.name2string(name); 1452 1453 if (this.elements.containsKey(key) == false) { 1454 1455 ApplicationErrorInfoTypeImpl error_code = 1456 new ApplicationErrorInfoTypeImpl(); 1457 1458 error_code.error = new UIDType( 1459 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1460 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1461 1462 error_code.details = new String ("object with name" + 1463 key + " does not exist."); 1464 1465 throw new ApplicationError(error_code); 1466 } 1467 1468 if (!Utils.packageIsSupported(USER_LABEL_PACKAGE, 1469 packagesGet(name))) { 1470 throw new NOuserLabelPackageException(); 1471 } 1472 1473 IpNodeDataStructure ipNodeData = (IpNodeDataStructure)this.elements.get(key); 1474 1475 ipNodeData.userLabel = userLabel; 1476 } 1477 1483 public java.lang.String 1484 vendorNameGet(org.omg.CosNaming.NameComponent [] name) 1485 throws intt.itu.itut_x780.ApplicationError, intt.itu.itut_m3120.NOvendorNamePackageException 1486 { 1487 1491 String key = Utils.name2string(name); 1492 1493 if (this.elements.containsKey(key) == false) { 1494 1495 ApplicationErrorInfoTypeImpl error_code = 1496 new ApplicationErrorInfoTypeImpl(); 1497 1498 error_code.error = new UIDType( 1499 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1500 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1501 1502 error_code.details = new String ("object with name" + 1503 key + " does not exist."); 1504 1505 throw new ApplicationError(error_code); 1506 } 1507 1508 if (!Utils.packageIsSupported(VENDOR_NAME_PACKAGE, 1509 packagesGet(name))) { 1510 throw new NOvendorNamePackageException(); 1511 } 1512 1513 IpNodeDataStructure ipNodeData = (IpNodeDataStructure)this.elements.get(key); 1514 1515 return ipNodeData.vendorName; 1516 } 1517 1523 public void 1524 vendorNameSet(org.omg.CosNaming.NameComponent [] name, java.lang.String vendorName) 1525 throws intt.itu.itut_x780.ApplicationError, intt.itu.itut_m3120.NOvendorNamePackageException 1526 { 1527 1531 String key = Utils.name2string(name); 1532 1533 if (this.elements.containsKey(key) == false) { 1534 1535 ApplicationErrorInfoTypeImpl error_code = 1536 new ApplicationErrorInfoTypeImpl(); 1537 1538 error_code.error = new UIDType( 1539 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1540 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1541 1542 error_code.details = new String ("object with name" + 1543 key + " does not exist."); 1544 1545 throw new ApplicationError(error_code); 1546 } 1547 1548 if (!Utils.packageIsSupported(VENDOR_NAME_PACKAGE, 1549 packagesGet(name))) { 1550 throw new NOvendorNamePackageException(); 1551 } 1552 1553 IpNodeDataStructure ipNodeData = (IpNodeDataStructure)this.elements.get(key); 1554 1555 ipNodeData.vendorName = vendorName; 1556 } 1557 1563 public java.lang.String 1564 versionGet(org.omg.CosNaming.NameComponent [] name) 1565 throws intt.itu.itut_x780.ApplicationError, intt.itu.itut_m3120.NOversionPackageException 1566 { 1567 1571 String key = Utils.name2string(name); 1572 1573 if (this.elements.containsKey(key) == false) { 1574 1575 ApplicationErrorInfoTypeImpl error_code = 1576 new ApplicationErrorInfoTypeImpl(); 1577 1578 error_code.error = new UIDType( 1579 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1580 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1581 1582 error_code.details = new String ("object with name" + 1583 key + " does not exist."); 1584 1585 throw new ApplicationError(error_code); 1586 } 1587 1588 if (!Utils.packageIsSupported(VERSION_PACKAGE, 1589 packagesGet(name))) { 1590 throw new NOversionPackageException(); 1591 } 1592 1593 IpNodeDataStructure ipNodeData = (IpNodeDataStructure)this.elements.get(key); 1594 1595 return ipNodeData.version; 1596 } 1597 1603 public void 1604 versionSet(org.omg.CosNaming.NameComponent [] name, java.lang.String version) 1605 throws intt.itu.itut_x780.ApplicationError, intt.itu.itut_m3120.NOversionPackageException 1606 { 1607 1611 String key = Utils.name2string(name); 1612 1613 if (this.elements.containsKey(key) == false) { 1614 1615 ApplicationErrorInfoTypeImpl error_code = 1616 new ApplicationErrorInfoTypeImpl(); 1617 1618 error_code.error = new UIDType( 1619 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1620 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1621 1622 error_code.details = new String ("object with name" + 1623 key + " does not exist."); 1624 1625 throw new ApplicationError(error_code); 1626 } 1627 1628 if (!Utils.packageIsSupported(VERSION_PACKAGE, 1629 packagesGet(name))) { 1630 throw new NOversionPackageException(); 1631 } 1632 1633 IpNodeDataStructure ipNodeData = (IpNodeDataStructure)this.elements.get(key); 1634 1635 ipNodeData.version = version; 1636 } 1637 1643 public java.lang.String 1644 locationNameGet(org.omg.CosNaming.NameComponent [] name) 1645 throws intt.itu.itut_x780.ApplicationError, intt.itu.itut_m3120.NOlocationNamePackageException 1646 { 1647 1651 DataType sysLocationData = null; 1652 1653 String key = Utils.name2string(name); 1654 1655 if (this.elements.containsKey(key) == false) { 1656 1657 ApplicationErrorInfoTypeImpl error_code = 1658 new ApplicationErrorInfoTypeImpl(); 1659 1660 error_code.error = new UIDType( 1661 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1662 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1663 1664 error_code.details = new String ("object with name" + 1665 key + " does not exist."); 1666 1667 throw new ApplicationError(error_code); 1668 } 1669 1670 if (!Utils.packageIsSupported(LOCATION_NAME_PACKAGE, 1671 packagesGet(name))) { 1672 System.out.println("Package " + LOCATION_NAME_PACKAGE + 1673 "is not supported by IpNode Object" + key); 1674 1675 throw new NOlocationNamePackageException(); 1676 } 1677 1678 1679 try { 1680 1681 sysLocationData = this.connector.get( 1682 SYS_LOCATION_OID, 1683 new String (this.managementIPAddressGet(name)), 1684 this.snmpPortGet(name), 1685 READ_COMMUNITY); 1686 } 1687 catch (SnmpApplicationError e) { 1688 1689 ApplicationErrorInfoTypeImpl error_code = 1690 new ApplicationErrorInfoTypeImpl(); 1691 1692 error_code.error = new UIDType( 1693 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1694 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1695 1696 if (e.reason.equals(ExceptionMessages.agent_response_error)) 1697 error_code.details = ExceptionMessages.agent_response_error; 1698 else 1699 error_code.details = new String ("Could not retrieve sysLocation " + 1700 "for IpNode Object with name " + key + ":" + 1701 " Object with Snmp Object Identifier " + SYS_LOCATION_OID + 1702 " does not exist."); 1703 1704 throw new ApplicationError(error_code); 1705 1706 } 1707 1708 org.omg.CORBA.Any value = sysLocationData.value; 1709 if (value.type().kind().value() != org.omg.CORBA.OctetSeqHelper.type().kind().value()) { 1712 ApplicationErrorInfoTypeImpl error_code = 1713 new ApplicationErrorInfoTypeImpl(); 1714 1715 error_code.error = new UIDType( 1716 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1717 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1718 1719 error_code.details = new String ("Could not retrieve sysLocation " + 1720 "for IpNode Object with name " + key + ":" + 1721 " Object with Snmp Object Identifier " + SYS_LOCATION_OID + 1722 " is not of expected type."); 1723 1724 throw new ApplicationError(error_code); 1725 1726 } 1727 String sysLocation = new String (org.omg.CORBA.OctetSeqHelper.extract(value)); 1730 return sysLocation; 1731 } 1732 1738 public void 1739 locationNameSet(org.omg.CosNaming.NameComponent [] name, java.lang.String locationName) 1740 throws intt.itu.itut_x780.ApplicationError, intt.itu.itut_m3120.NOlocationNamePackageException 1741 { 1742 1746 String key = Utils.name2string(name); 1747 1748 if (this.elements.containsKey(key) == false) { 1749 1750 ApplicationErrorInfoTypeImpl error_code = 1751 new ApplicationErrorInfoTypeImpl(); 1752 1753 error_code.error = new UIDType( 1754 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1755 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1756 1757 error_code.details = new String ("object with name" + 1758 key + " does not exist."); 1759 1760 throw new ApplicationError(error_code); 1761 } 1762 1763 if (!Utils.packageIsSupported(LOCATION_NAME_PACKAGE, 1764 packagesGet(name))) { 1765 System.out.println("Package " + LOCATION_NAME_PACKAGE + 1766 "is not supported by IpNode Object" + key); 1767 1768 throw new NOlocationNamePackageException(); 1769 } 1770 1771 org.omg.CORBA.Any value = orb.create_any(); 1772 1775 org.omg.CORBA.OctetSeqHelper.insert(value, locationName.getBytes()); 1776 1777 DataTypeImpl sysLocationData = new DataTypeImpl( 1778 SYS_LOCATION_OID, 1779 value, 1780 SnmpSMI.SMI_STRING); 1781 1782 try { 1783 1784 this.connector.set( 1785 sysLocationData, 1786 new String (this.managementIPAddressGet(name)), 1787 this.snmpPortGet(name), 1788 WRITE_COMMUNITY); 1789 } 1790 catch (SnmpApplicationError e) { 1791 1792 ApplicationErrorInfoTypeImpl error_code = 1793 new ApplicationErrorInfoTypeImpl(); 1794 1795 error_code.error = new UIDType( 1796 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1797 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1798 1799 if (e.reason.equals(ExceptionMessages.agent_response_error)) 1800 error_code.details = ExceptionMessages.agent_response_error; 1801 else 1802 error_code.details = new String ("Could not set sysLocation " + 1803 "for IpNode Object with name " + key + "."); 1804 1805 throw new ApplicationError(error_code); 1806 1807 } 1808 } 1809 1810 1816 1817 public java.lang.String 1818 objectClassGet(org.omg.CosNaming.NameComponent [] name) 1819 throws intt.itu.itut_x780.ApplicationError 1820 { 1821 1825 String key = Utils.name2string(name); 1826 1827 if (this.elements.containsKey(key) == false) { 1828 1829 ApplicationErrorInfoTypeImpl error_code = 1830 new ApplicationErrorInfoTypeImpl(); 1831 1832 error_code.error = new UIDType( 1833 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1834 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1835 1836 error_code.details = new String ("object with name" + 1837 key + " does not exist."); 1838 1839 throw new ApplicationError(error_code); 1840 } 1841 1842 IpNodeDataStructure ipNodeData = 1843 (IpNodeDataStructure)this.elements.get(key); 1844 1845 return ipNodeData.objectclass; 1846 } 1847 1853 public intt.itu.itut_x780.ManagedObjectValueType 1854 attributesGet(org.omg.CosNaming.NameComponent [] name, intt.itu.itut_x780.StringSetTypeHolder attributeNames) 1855 throws intt.itu.itut_x780.ApplicationError 1856 { 1857 1861 String key = Utils.name2string(name); 1862 1863 if (this.elements.containsKey(key) == false) { 1864 1865 ApplicationErrorInfoTypeImpl error_code = 1866 new ApplicationErrorInfoTypeImpl(); 1867 1868 error_code.error = new UIDType( 1869 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1870 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1871 1872 error_code.details = new String ("object with name" + 1873 key + " does not exist."); 1874 1875 throw new ApplicationError(error_code); 1876 } 1877 1878 IpNodeDataStructure ipNodeData = 1879 (IpNodeDataStructure)this.elements.get(key); 1880 1881 String userLabel = new String (); 1882 String vendorName = new String (); 1883 String version = new String (); 1884 String locationName = new String (); 1885 1886 try { 1887 userLabel = userLabelGet(name); 1888 } 1889 catch (NOuserLabelPackageException noUserLabel) { 1890 1891 } 1892 1893 try { 1894 vendorName = vendorNameGet(name); 1895 } 1896 catch (NOvendorNamePackageException noVendorName) { 1897 1898 } 1899 1900 try { 1901 version = versionGet(name); 1902 } 1903 catch (NOversionPackageException noVersion) { 1904 1905 } 1906 1907 try { 1908 locationName = locationNameGet(name); 1909 } 1910 catch (NOlocationNamePackageException noLocation) { 1911 1912 } 1913 1914 IpNodeValueTypeImpl ipNodeValueType = new IpNodeValueTypeImpl( 1915 1916 ipNodeData.administrativeState, 1917 this.operationalStateGet(name), 1918 this.usageStateGet(name), 1919 userLabel, 1920 vendorName, 1921 version, 1922 locationName, 1923 ipNodeData.domainName, 1924 ipNodeData.hostname, 1925 ipNodeData.managementIPAddress, 1926 ipNodeData.supportedSnmpVersions, 1927 ipNodeData.snmpPort, 1928 this.ifNumberGet(name), 1929 this.sysDescrGet(name), 1930 this.sysObjectIDGet(name), 1931 this.sysUpTimeGet(name), 1932 this.sysContactGet(name), 1933 this.sysNameGet(name), 1934 this.sysServicesGet(name), 1935 ipNodeData.name, 1936 ipNodeData.objectclass, 1937 ipNodeData.packageNameList, 1938 ipNodeData.sourceIndicator, 1939 ipNodeData.deletePolicy 1940 ); 1941 1942 return ipNodeValueType; 1943 } 1944 1950 public java.lang.String [] 1951 packagesGet(org.omg.CosNaming.NameComponent [] name) 1952 throws intt.itu.itut_x780.ApplicationError 1953 { 1954 1958 String key = Utils.name2string(name); 1959 1960 if (this.elements.containsKey(key) == false) { 1961 1962 ApplicationErrorInfoTypeImpl error_code = 1963 new ApplicationErrorInfoTypeImpl(); 1964 1965 error_code.error = new UIDType( 1966 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 1967 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 1968 1969 error_code.details = new String ("object with name" + 1970 key + " does not exist."); 1971 1972 throw new ApplicationError(error_code); 1973 } 1974 1975 IpNodeDataStructure ipNodeData = 1976 (IpNodeDataStructure)this.elements.get(key); 1977 1978 return ipNodeData.packageNameList; 1979 } 1980 1986 public intt.itu.itut_x780.SourceIndicatorType 1987 creationSourceGet(org.omg.CosNaming.NameComponent [] name) 1988 throws intt.itu.itut_x780.ApplicationError 1989 { 1990 1994 String key = Utils.name2string(name); 1995 1996 if (this.elements.containsKey(key) == false) { 1997 1998 ApplicationErrorInfoTypeImpl error_code = 1999 new ApplicationErrorInfoTypeImpl(); 2000 2001 error_code.error = new UIDType( 2002 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 2003 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 2004 2005 error_code.details = new String ("object with name" + 2006 key + " does not exist."); 2007 2008 throw new ApplicationError(error_code); 2009 } 2010 2011 IpNodeDataStructure ipNodeData = 2012 (IpNodeDataStructure)this.elements.get(key); 2013 2014 return ipNodeData.sourceIndicator; 2015 } 2016 2022 public short 2023 deletePolicyGet(org.omg.CosNaming.NameComponent [] name) 2024 throws intt.itu.itut_x780.ApplicationError 2025 { 2026 2030 String key = Utils.name2string(name); 2031 2032 if (this.elements.containsKey(key) == false) { 2033 2034 ApplicationErrorInfoTypeImpl error_code = 2035 new ApplicationErrorInfoTypeImpl(); 2036 2037 error_code.error = new UIDType( 2038 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 2039 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 2040 2041 error_code.details = new String ("object with name" + 2042 key + " does not exist."); 2043 2044 throw new ApplicationError(error_code); 2045 } 2046 2047 IpNodeDataStructure ipNodeData = 2048 (IpNodeDataStructure)this.elements.get(key); 2049 2050 return ipNodeData.deletePolicy; 2051 } 2052 2058 public void 2059 destroy(org.omg.CosNaming.NameComponent [] name) 2060 throws intt.itu.itut_x780.ApplicationError, intt.itu.itut_x780.DeleteError 2061 { 2062 2066 String key = Utils.name2string(name); 2067 2068 if (this.elements.containsKey(key) == false) { 2069 2070 ApplicationErrorInfoTypeImpl error_code = 2071 new ApplicationErrorInfoTypeImpl(); 2072 2073 error_code.error = new UIDType( 2074 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 2075 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 2076 2077 error_code.details = new String ("object with name" + 2078 key + " does not exist."); 2079 2080 throw new ApplicationError(error_code); 2081 } 2082 2083 IpNodeDataStructure ipNodeData = (IpNodeDataStructure) this.elements.remove(key); 2084 try { 2085 config.unregister(name); 2086 } 2087 catch(ist.coach.coachEmfServices.SnmpAdapter.SnmpApplicationError snmp_e) { 2088 System.err.println("There was a problem unregistering " + Utils.name2string(name) + 2089 " from the SNMP Trap Deamon"); 2090 } 2091 2092 org.omg.TimeBase.UtcT eventTime = new org.omg.TimeBase.UtcT(System.currentTimeMillis(), 2093 0,(short) 0,(short) 0); 2094 the_context_.push_objectDeletion(new ObjectDeletionImpl(eventTime, name, 2095 ipNodeData.objectclass, 2096 getUniqueNotificationIdentifier(), 2097 ipNodeData.sourceIndicator, 2099 new AttributeValueType[0])); 2100 } 2101 2112 public void 2113 create( org.omg.CosNaming.NameComponent [] name, 2114 String objectClass, 2115 java.lang.String [] packages, 2116 short deletePolicy, 2117 intt.itu.itut_x780.SourceIndicatorType sourceIndicator, 2118 java.lang.String domainName, 2119 java.lang.String hostname, 2120 byte[] managementIPAddress, 2121 int supportedSnmpVersions, 2122 intt.itu.itut_x780.AdministrativeStateType administrativeState, 2123 java.lang.String userLabel, 2124 java.lang.String vendorName, 2125 java.lang.String version, 2126 java.lang.String locationName, 2127 int snmpPort, 2128 java.lang.String sysName, 2129 java.lang.String sysContact) 2130 throws intt.itu.itut_x780.ApplicationError, intt.itu.itut_x780.CreateError 2131 { 2132 2136 boolean sysInfoSetPackageIsSupported = false; 2137 2138 2139 if (this.elements.containsKey(Utils.name2string(name))) { 2140 2141 CreateErrorInfoTypeImpl errorCode = 2142 new CreateErrorInfoTypeImpl(); 2143 2144 errorCode.error = new UIDType( 2145 intt.itu.itut_x780.CreateErrorConst.moduleName.value, 2146 intt.itu.itut_x780.CreateErrorConst.duplicateName.value); 2147 2148 errorCode.details = new String (Utils.name2string(name) + 2149 " object already exists."); 2150 throw new intt.itu.itut_x780.CreateError(errorCode); 2151 2152 } 2153 2154 IpNodeDataStructure ipNodeData = new IpNodeDataStructure( 2155 domainName, 2156 hostname, 2157 managementIPAddress, 2158 name, 2159 packages, 2160 supportedSnmpVersions, 2161 administrativeState, 2162 userLabel, 2163 vendorName, 2164 version, 2165 locationName, 2166 snmpPort, 2167 sysName, 2168 sysContact, 2169 objectClass, 2170 deletePolicy, 2171 sourceIndicator, 2172 intt.itu.itut_x780.OperationalStateType.enabled); 2173 2174 this.elements.put(Utils.name2string(name), ipNodeData); 2175 2176 2178 String ipAddress = new String (); 2179 if (managementIPAddress != null) 2180 ipAddress = new String (managementIPAddress); 2181 2182 try { 2183 config.registerIP(name, ipAddress); 2184 } 2185 catch( ist.coach.coachEmfServices.SnmpAdapter.SnmpApplicationError snmp_ex) { 2186 System.err.println("Could not register IpNode " + 2187 Utils.name2string(name) + " to the SNMP Trap Service"); 2188 System.err.println("Reason= " + snmp_ex.reason); 2189 ApplicationErrorInfoTypeImpl error_code = new ApplicationErrorInfoTypeImpl(); 2190 error_code.error = new UIDType( 2191 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 2192 intt.itu.itut_x780.ApplicationErrorConst.downstreamError.value); 2193 2194 error_code.details = snmp_ex.reason; 2195 2196 throw new ApplicationError(error_code); 2197 } 2198 2199 org.omg.TimeBase.UtcT eventTime = new org.omg.TimeBase.UtcT(System.currentTimeMillis(), 2200 0,(short) 0,(short) 0); 2201 2202 the_context_.push_objectCreation(new ObjectCreationImpl(eventTime, name, 2204 objectClass, 2205 getUniqueNotificationIdentifier(), 2206 sourceIndicator, 2208 new AttributeValueType[0])); 2209 2210 System.err.println("IpNodeProvider finished create operations..."); 2211 } 2212 2223 public void 2224 notifyTrap(org.omg.CosNaming.NameComponent [] name, 2225 java.lang.String community, 2226 int trapID, int trapType, 2227 ist.coach.coachEmfServices.SnmpAdapter.DataType[] trapData) 2228 throws intt.itu.itut_x780.ApplicationError, ist.coach.coachEmfServices.SnmpAdapter.SnmpApplicationError 2229 { 2230 2234 2237 String key = Utils.name2string(name); 2238 2239 if (this.elements.containsKey(key) == false) { 2240 2241 ApplicationErrorInfoTypeImpl error_code = 2242 new ApplicationErrorInfoTypeImpl(); 2243 2244 error_code.error = new UIDType( 2245 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 2246 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 2247 2248 error_code.details = new String ("object with name" + 2249 key + " does not exist."); 2250 2251 throw new ApplicationError(error_code); 2252 } 2253 2254 IpNodeDataStructure data = (IpNodeDataStructure) this.elements.get(key); 2255 2256 intt.itu.itut_x780.OperationalStateType oldValue = data.operationalState; 2257 2258 intt.itu.itut_x780.OperationalStateType newValue = null; 2259 2260 2261 if (trapType == COLDSTART_TRAP) { 2262 2263 newValue = intt.itu.itut_x780.OperationalStateType.enabled; 2264 2265 } 2266 else 2267 if (trapType == NETSNMP_SHUTDOWN_TRAP) { 2268 2269 newValue = intt.itu.itut_x780.OperationalStateType.disabled; 2270 2271 } 2272 else { 2273 2274 System.err.println("IpNode_F does not know how to handle trap of type " + 2275 trapType); 2276 2277 ApplicationErrorInfoTypeImpl error_code = 2278 new ApplicationErrorInfoTypeImpl(); 2279 2280 error_code.error = new UIDType( 2281 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 2282 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 2283 2284 error_code.details = new String ("IpNode_F does not know how to handle" + 2285 " trap of type " + trapType + "."); 2286 2287 throw new ApplicationError(error_code); 2288 2289 } 2290 2291 if (newValue == oldValue) { 2292 2293 2295 ApplicationErrorInfoTypeImpl error_code = 2296 new ApplicationErrorInfoTypeImpl(); 2297 2298 error_code.error = new UIDType( 2299 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 2300 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 2301 2302 error_code.details = new String (" Cannot emmit StateChange Event when no" + 2303 " state change has occured for IpNode with name " + 2304 Utils.name2string(name)); 2305 2306 throw new ApplicationError(error_code); 2307 } 2308 2309 data.operationalState = newValue; 2310 2311 long trapTime = 0; 2312 boolean trapTimeFound = false; 2313 2314 for (int i = 0; i < trapData.length; i++) { 2315 2316 if (trapData[i].identifier.equals(TIME_OID)) { 2317 2318 org.omg.CORBA.Any value = trapData[i].value; 2319 2320 if(value.type().kind().value() != TCKind._tk_longlong) { 2321 2322 ApplicationErrorInfoTypeImpl error_code = 2323 new ApplicationErrorInfoTypeImpl(); 2324 2325 error_code.error = new UIDType( 2326 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 2327 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 2328 2329 error_code.details = new String ("Could not retrieve event time " + 2330 " for trap. Object with Snmp Object Identifier " + TIME_OID + 2331 " is not of type long, as expected."); 2332 2333 throw new ApplicationError(error_code); 2334 2335 } 2336 2337 trapTime = value.extract_longlong(); 2338 trapTimeFound = true; 2339 break; 2340 } 2341 2342 } 2343 2344 if (trapTimeFound == false) { 2345 ApplicationErrorInfoTypeImpl error_code = 2346 new ApplicationErrorInfoTypeImpl(); 2347 2348 error_code.error = new UIDType( 2349 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 2350 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 2351 2352 error_code.details = new String ("Could not retrieve event time " + 2353 " for trap."); 2354 2355 throw new ApplicationError(error_code); 2356 } 2357 2358 org.omg.TimeBase.UtcT eventTime = new org.omg.TimeBase.UtcT(System.currentTimeMillis(), 2360 0,(short) 0,(short) 0); 2361 2362 int notificationId = getUniqueNotificationIdentifier(); 2364 2365 String sourceClass = data.objectclass; 2366 2367 SourceIndicatorType sourceIndicator = SourceIndicatorType.unknown; 2368 2369 org.omg.CORBA.Any oldValue_any = orb.create_any(); 2370 OperationalStateTypeHelper.insert(oldValue_any, oldValue); 2371 2372 org.omg.CORBA.Any newValue_any = orb.create_any(); 2373 OperationalStateTypeHelper.insert(newValue_any, newValue); 2374 2375 AttributeValueChangeType [] changedValues = new AttributeValueChangeType[1]; 2376 changedValues[0] = new AttributeValueChangeType( 2377 "operationalState", 2378 oldValue_any, 2379 newValue_any); 2380 2381 StateChangedEventImpl stateChangedEvent = new StateChangedEventImpl( 2382 eventTime, 2383 name, 2384 sourceClass, 2385 notificationId, 2386 sourceIndicator, 2387 changedValues); 2389 2390 2397 the_context_.push_stateChange(stateChangedEvent); 2398 2399 } 2400 2401 private int getUniqueNotificationIdentifier() { 2402 2403 notifId++; 2404 2405 return (notifId); 2406 } 2407 2408 2409 class IpNodeDataStructure { 2410 2411 public String domainName; 2412 public String hostname; 2413 public byte[] managementIPAddress; 2414 public NameComponent [] name; 2415 public String [] packageNameList; 2416 public int supportedSnmpVersions; 2417 public intt.itu.itut_x780.AdministrativeStateType administrativeState; 2418 public String userLabel; 2419 public String vendorName; 2420 public String version; 2421 public String locationName; 2422 public int snmpPort; 2423 public String sysName; 2424 public String sysContact; 2425 public String objectclass; 2426 public short deletePolicy; 2427 public intt.itu.itut_x780.SourceIndicatorType sourceIndicator; 2428 public intt.itu.itut_x780.OperationalStateType operationalState; 2429 2430 private int notificationIdentifier; 2431 2432 public IpNodeDataStructure ( 2433 String domainName, 2434 String hostname, 2435 byte[] managementIPAddress, 2436 NameComponent [] name, 2437 String [] packageNameList, 2438 int supportedSnmpVersions, 2439 intt.itu.itut_x780.AdministrativeStateType administrativeState, 2440 String userLabel, 2441 String vendorName, 2442 String version, 2443 String locationName, 2444 int snmpPort, 2445 String sysName, 2446 String sysContact, 2447 String objectclass, 2448 short deletePolicy, 2449 intt.itu.itut_x780.SourceIndicatorType sourceIndicator, 2450 intt.itu.itut_x780.OperationalStateType operationalState) { 2451 2452 this.domainName = domainName; 2453 this.hostname = hostname; 2454 this.managementIPAddress = managementIPAddress; 2455 this.name = name; 2456 this.packageNameList = packageNameList; 2457 this.supportedSnmpVersions = supportedSnmpVersions; 2458 this.administrativeState = administrativeState; 2459 this.userLabel = userLabel; 2460 this.vendorName = vendorName; 2461 this.version = version; 2462 this.locationName = locationName; 2463 this.snmpPort = snmpPort; 2464 this.sysName = sysName; 2465 this.sysContact = sysContact; 2466 this.objectclass = objectclass; 2467 this.deletePolicy = deletePolicy; 2468 this.sourceIndicator = sourceIndicator; 2469 this.operationalState = operationalState; 2470 2471 this.notificationIdentifier = 0; 2472 } 2473 2474 public int getUniqueNotificationIdentifier() { 2475 2476 this.notificationIdentifier++; 2477 2478 return (this.notificationIdentifier); 2479 } 2480 2481 } 2482} 2483 | Popular Tags |