1 28 29 package ist.coach.coachEmsMibComponents.SnmpProtocolMonitorProviderComposition; 30 31 import ist.coach.coachEmfCommon.CreateErrorInfoTypeImpl; 32 import ist.coach.coachEmfCommon.ObjectCreationImpl; 33 import ist.coach.coachEmfCommon.ExceptionMessages; 34 import ist.coach.coachEmfCommon.ApplicationErrorInfoTypeImpl; 35 import intt.itu.itut_x780.ApplicationError; 36 import intt.itu.itut_x780.UIDType; 37 import intt.itu.itut_x780.AttributeValueType; 38 39 import org.omg.CosNaming.NameComponent ; 40 import ist.coach.coachEmfCommon.OperationalViolationImpl; 41 42 import ist.coach.coachEmfCommon.Utils; 43 49 public class mgmtSegImpl 50 extends ist.coach.coachEmsMibComponents.SnmpProtocolMonitorProviderComposition.mgmtSeg 51 { 52 58 64 public mgmtSegImpl() 65 { 66 } 67 68 74 77 public void 78 create(org.omg.CosNaming.NameComponent [] name, 79 String objectClass, 80 String [] packages, 81 short deletePolicy, 82 intt.itu.itut_x780.SourceIndicatorType sourceIndicator, 83 org.omg.CosNaming.NameComponent [] superior, 84 byte[] mgmtIpAddress, 85 int supportedSnmpVersions, 86 int snmpPort) 87 throws intt.itu.itut_x780.ApplicationError, 88 89 intt.itu.itut_x780.CreateError 90 { 91 95 if (SnmpProtocolMonitorProviderImpl.elements.containsKey(Utils.name2string(name))) { 96 97 CreateErrorInfoTypeImpl errorCode = 98 new CreateErrorInfoTypeImpl(); 99 100 errorCode.error = new UIDType( 101 intt.itu.itut_x780.CreateErrorConst.moduleName.value, 102 intt.itu.itut_x780.CreateErrorConst.duplicateName.value); 103 104 errorCode.details = new String (Utils.name2string(name) + 105 " object already exists."); 106 throw new intt.itu.itut_x780.CreateError(errorCode); 107 } 108 109 SnmpProtocolMonitorDataStructure snmpProtocolData = 110 new SnmpProtocolMonitorDataStructure( 111 name, 112 objectClass, 113 packages, 114 sourceIndicator, 115 deletePolicy, 116 new String (mgmtIpAddress), 117 snmpPort, 118 supportedSnmpVersions); 119 120 synchronized(SnmpProtocolMonitorProviderImpl.elements) { 121 SnmpProtocolMonitorProviderImpl.elements.put(Utils.name2string(name), snmpProtocolData); 122 } 123 124 ist.coach.coachEmfServices.SnmpAdapter.SnmpTrapDaemon config = null; 125 if ((config = get_context().get_connection_config()) == null) { 126 CreateErrorInfoTypeImpl errorCode = 127 new CreateErrorInfoTypeImpl(); 128 129 errorCode.error = new UIDType( 130 intt.itu.itut_x780.CreateErrorConst.moduleName.value, 131 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 132 133 errorCode.details = new String (ExceptionMessages.components_connect_error); 134 throw new intt.itu.itut_x780.CreateError(errorCode); 135 } 136 137 String ipAddress = new String (); 138 if (mgmtIpAddress != null) 139 ipAddress = new String (mgmtIpAddress); 140 141 try { 142 config.registerIP(name, new String (ipAddress)); 143 } 144 catch( ist.coach.coachEmfServices.SnmpAdapter.SnmpApplicationError snmp_ex) { 145 System.err.println("Could not register SnmpProtocolMonitor " + 146 Utils.name2string(name) + " to the SNMP Trap Service"); 147 System.err.println("Reason= " + snmp_ex.reason); 148 ApplicationErrorInfoTypeImpl error_code = new ApplicationErrorInfoTypeImpl(); 149 error_code.error = new UIDType( 150 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 151 intt.itu.itut_x780.ApplicationErrorConst.downstreamError.value); 152 153 error_code.details = snmp_ex.reason; 154 155 throw new ApplicationError(error_code); 156 } 157 158 org.omg.TimeBase.UtcT eventTime = new org.omg.TimeBase.UtcT (System.currentTimeMillis(), 159 0, (short) 0, (short) 0); 160 get_context().push_objectCreation(new ObjectCreationImpl(eventTime, 161 name, 162 objectClass, 163 SnmpProtocolMonitorProviderImpl.getUniqueNotificationIdentifier(), 164 165 sourceIndicator, 166 new AttributeValueType[0])); 167 } 168 169 172 public void 173 notifyTrap(org.omg.CosNaming.NameComponent [] name, String community, int trapID, int trapType, ist.coach.coachEmfServices.SnmpAdapter.DataType[] trapData) 174 throws intt.itu.itut_x780.ApplicationError, 175 176 ist.coach.coachEmfServices.SnmpAdapter.SnmpApplicationError 177 { 178 179 183 String key = Utils.name2string(name); 184 185 if (SnmpProtocolMonitorProviderImpl.elements.containsKey(key) == false) { 186 187 ApplicationErrorInfoTypeImpl error_code = 188 new ApplicationErrorInfoTypeImpl(); 189 190 error_code.error = new UIDType( 191 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 192 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 193 194 error_code.details = new String ("SnmpProtocolMonitor object with name" + 195 key + " does not exist."); 196 197 throw new ApplicationError(error_code); 198 } 199 SnmpProtocolMonitorDataStructure data = 200 (SnmpProtocolMonitorDataStructure) SnmpProtocolMonitorProviderImpl.elements.get(key); 201 202 org.omg.TimeBase.UtcT eventTime = new org.omg.TimeBase.UtcT(System.currentTimeMillis(), 203 0,(short) 0,(short) 0); 204 OperationalViolationImpl operationViolationEvent = new OperationalViolationImpl( 205 eventTime, 206 data.name, 207 data.objectclass, 208 SnmpProtocolMonitorProviderImpl.getUniqueNotificationIdentifier()); 209 210 get_context().push_operationalViolation(operationViolationEvent); 211 212 } 213 214 217 public String 218 facade_name() 219 { 220 return get_main_segment().facade_name(); 224 } 225 226 } 227 | Popular Tags |