KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ist > coach > coachEmsMibComponents > SnmpProtocolMonitorProviderComposition > mgmtSegImpl


1 /*====================================================================
2
3 This file was produced by the OpenCCM CIF_JIMPL generator.
4
5 OpenCCM: The Open CORBA Component Model Platform
6 Copyright (C) 2000-2003 INRIA - USTL - LIFL - GOAL
7 Contact: openccm@objectweb.org
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 USA
23
24 Initial developer(s): Christophe Demarey.
25 Contributor(s): ______________________________________.
26
27 ====================================================================*/

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 JavaDoc;
40 import ist.coach.coachEmfCommon.OperationalViolationImpl;
41
42 import ist.coach.coachEmfCommon.Utils;
43 /**
44  * This is the CIDL-based implementation of the
45  * OMG IDL3 CIDL:coach.ist/coachEmsMibComponents/SnmpProtocolMonitorProviderComposition/SnmpProtocolMonitorProviderHome_impl/SnmpProtocolMonitorProvider_impl/mgmtSeg:1.0 segment type.
46  *
47  * @author OpenCCM CIF_Jimpl Compiler.
48  */

49 public class mgmtSegImpl
50      extends ist.coach.coachEmsMibComponents.SnmpProtocolMonitorProviderComposition.mgmtSeg
51 {
52     // ==================================================================
53
//
54
// Internal states.
55
//
56
// ==================================================================
57

58     // ==================================================================
59
//
60
// Constructors.
61
//
62
// ==================================================================
63

64     public mgmtSegImpl()
65     {
66     }
67
68     // ==================================================================
69
//
70
// Methods.
71
//
72
// ==================================================================
73

74     /**
75      * Implementation of the ::coachEmsMibComponents::SnmpProtocolMonitorMgmt::create operation.
76      */

77     public void
78     create(org.omg.CosNaming.NameComponent JavaDoc[] name,
79                 String JavaDoc objectClass,
80                 String JavaDoc[] packages,
81                 short deletePolicy,
82                 intt.itu.itut_x780.SourceIndicatorType sourceIndicator,
83                 org.omg.CosNaming.NameComponent JavaDoc[] 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                //
92
// DONE : implement
93
//
94

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 JavaDoc(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 JavaDoc(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 JavaDoc(ExceptionMessages.components_connect_error);
134             throw new intt.itu.itut_x780.CreateError(errorCode);
135         }
136
137         String JavaDoc ipAddress = new String JavaDoc();
138         if (mgmtIpAddress != null)
139             ipAddress = new String JavaDoc(mgmtIpAddress);
140
141         try {
142             config.registerIP(name, new String JavaDoc(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     /**
170      * Implementation of the ::coachEmfServices::SnmpAdapter::TrapCallback::notifyTrap operation.
171      */

172     public void
173     notifyTrap(org.omg.CosNaming.NameComponent JavaDoc[] name, String JavaDoc 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         //
180
// DONE : implement
181
//
182

183         String JavaDoc 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 JavaDoc ("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     /**
215      * Implementation of the ::coachEmfServices::SnmpAdapter::TrapCallback::facade_name operation.
216      */

217     public String JavaDoc
218     facade_name()
219     {
220         //
221
// TODO : Implement
222
//
223
return get_main_segment().facade_name();
224     }
225
226 }
227
Popular Tags