1 | package gov.hhs.fha.nhinc.common.connectionmanager;
|
---|
2 |
|
---|
3 | import org.apache.commons.logging.Log;
|
---|
4 | import org.apache.commons.logging.LogFactory;
|
---|
5 |
|
---|
6 | import gov.hhs.fha.nhinc.connectmgr.data.CMAddress;
|
---|
7 | import gov.hhs.fha.nhinc.connectmgr.data.CMAddresses;
|
---|
8 | import gov.hhs.fha.nhinc.connectmgr.data.CMBindingDescriptions;
|
---|
9 | import gov.hhs.fha.nhinc.connectmgr.data.CMBindingNames;
|
---|
10 | import gov.hhs.fha.nhinc.connectmgr.data.CMBindingTemplate;
|
---|
11 | import gov.hhs.fha.nhinc.connectmgr.data.CMBindingTemplates;
|
---|
12 | import gov.hhs.fha.nhinc.connectmgr.data.CMBusinessDescriptions;
|
---|
13 | import gov.hhs.fha.nhinc.connectmgr.data.CMBusinessEntities;
|
---|
14 | import gov.hhs.fha.nhinc.connectmgr.data.CMBusinessEntity;
|
---|
15 | import gov.hhs.fha.nhinc.connectmgr.data.CMBusinessNames;
|
---|
16 | import gov.hhs.fha.nhinc.connectmgr.data.CMBusinessService;
|
---|
17 | import gov.hhs.fha.nhinc.connectmgr.data.CMBusinessServices;
|
---|
18 | import gov.hhs.fha.nhinc.connectmgr.data.CMContact;
|
---|
19 | import gov.hhs.fha.nhinc.connectmgr.data.CMContactDescriptions;
|
---|
20 | import gov.hhs.fha.nhinc.connectmgr.data.CMContacts;
|
---|
21 | import gov.hhs.fha.nhinc.connectmgr.data.CMDiscoveryURLs;
|
---|
22 | import gov.hhs.fha.nhinc.connectmgr.data.CMEmails;
|
---|
23 | import gov.hhs.fha.nhinc.connectmgr.data.CMEprInfo;
|
---|
24 | import gov.hhs.fha.nhinc.connectmgr.data.CMPersonNames;
|
---|
25 | import gov.hhs.fha.nhinc.connectmgr.data.CMPhones;
|
---|
26 | import gov.hhs.fha.nhinc.connectmgr.data.CMStates;
|
---|
27 |
|
---|
28 | import java.util.List;
|
---|
29 |
|
---|
30 | import gov.hhs.fha.nhinc.connectmgr.data.CMHomeCommunity;
|
---|
31 | import gov.hhs.fha.nhinc.connectmgr.CMEprUtil;
|
---|
32 |
|
---|
33 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.AddressType;
|
---|
34 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.AddressesType;
|
---|
35 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.BindingDescriptionsType;
|
---|
36 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.BindingNamesType;
|
---|
37 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.BindingTemplateType;
|
---|
38 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.BindingTemplatesType;
|
---|
39 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.BusinessDescriptionsType;
|
---|
40 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.BusinessEntitiesType;
|
---|
41 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.BusinessEntityType;
|
---|
42 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.BusinessNamesType;
|
---|
43 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.BusinessServiceType;
|
---|
44 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.BusinessServicesType;
|
---|
45 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.ConnectionInfoEndpointType;
|
---|
46 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.ConnectionInfoEndpointsType;
|
---|
47 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.ConnectionInfoType;
|
---|
48 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.ConnectionInfosType;
|
---|
49 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.ContactDescriptionsType;
|
---|
50 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.ContactType;
|
---|
51 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.ContactsType;
|
---|
52 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.DiscoveryURLsType;
|
---|
53 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.EmailsType;
|
---|
54 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.PersonNamesType;
|
---|
55 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.PhonesType;
|
---|
56 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.ServiceConnectionInfoEndpointType;
|
---|
57 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.ServiceConnectionInfoEndpointsType;
|
---|
58 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.ServiceConnectionInfoType;
|
---|
59 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.ServiceConnectionInfosType;
|
---|
60 | import gov.hhs.fha.nhinc.common.connectionmanagerinfo.StatesType;
|
---|
61 |
|
---|
62 | import gov.hhs.fha.nhinc.common.nhinccommon.HomeCommunitiesType;
|
---|
63 | import gov.hhs.fha.nhinc.common.nhinccommon.HomeCommunityType;
|
---|
64 | import gov.hhs.fha.nhinc.common.nhinccommon.EPRType;
|
---|
65 | import gov.hhs.fha.nhinc.common.nhinccommon.CreateEPRRequestType;
|
---|
66 |
|
---|
67 | import gov.hhs.fha.nhinc.nhinclib.NullChecker;
|
---|
68 | import java.net.URL;
|
---|
69 | import java.util.ArrayList;
|
---|
70 |
|
---|
71 | import javax.xml.namespace.QName;
|
---|
72 |
|
---|
73 | import org.xmlsoap.schemas.ws._2004._08.addressing.EndpointReferenceType;
|
---|
74 | import org.xmlsoap.schemas.ws._2004._08.addressing.AttributedURI;
|
---|
75 | import org.xmlsoap.schemas.ws._2004._08.addressing.ServiceNameType;
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * This class is used to transform from the internal POJO representations of
|
---|
79 | * connection manager information to the Web Service representations.
|
---|
80 | *
|
---|
81 | * @author Les Westberg
|
---|
82 | */
|
---|
83 | public class CMTransform
|
---|
84 | {
|
---|
85 | private static Log log = LogFactory.getLog(CMTransform.class);
|
---|
86 | private static final String EPR_PROPERTY_FILE_NAME = "connectionEPR";
|
---|
87 | private static final String EPR_NAMESPACE_URI = "NamespaceURI";
|
---|
88 | private static final String EPR_PORT_NAME = "PortName";
|
---|
89 | private static final String EPR_SERVICE_NAME = "ServiceName";
|
---|
90 | private static final String EPR_NAMESPACE_PREFIX = "NamespacePrefix";
|
---|
91 |
|
---|
92 | /**
|
---|
93 | * Transform a POJO representation of a CMHomeCommunity to the web service represenation.
|
---|
94 | *
|
---|
95 | * @param oCMHomeCommunity The POJO representation.
|
---|
96 | * @return The web service representation.
|
---|
97 | */
|
---|
98 | public static HomeCommunityType cmHomeCommunityToHomeCommunity(CMHomeCommunity oCMHomeCommunity)
|
---|
99 | {
|
---|
100 | HomeCommunityType oHomeCommunity = new HomeCommunityType();
|
---|
101 |
|
---|
102 | if (oCMHomeCommunity == null)
|
---|
103 | {
|
---|
104 | return null;
|
---|
105 | }
|
---|
106 |
|
---|
107 | oHomeCommunity.setDescription(oCMHomeCommunity.getDescription());
|
---|
108 | oHomeCommunity.setName(oCMHomeCommunity.getName());
|
---|
109 | oHomeCommunity.setHomeCommunityId(oCMHomeCommunity.getHomeCommunityId());
|
---|
110 |
|
---|
111 | return oHomeCommunity;
|
---|
112 |
|
---|
113 | }
|
---|
114 |
|
---|
115 | /**
|
---|
116 | * Transform a POJO representation of a CMBusinessEntity to the web service represenation of a home commnity.
|
---|
117 | *
|
---|
118 | * @param oCMBusinessEntity The POJO representation.
|
---|
119 | * @return The web service representation.
|
---|
120 | */
|
---|
121 | public static HomeCommunityType cmBusinessEntityToHomeCommunity(CMBusinessEntity oCMBusinessEntity)
|
---|
122 | {
|
---|
123 | HomeCommunityType oHomeCommunity = new HomeCommunityType();
|
---|
124 |
|
---|
125 | if (oCMBusinessEntity == null)
|
---|
126 | {
|
---|
127 | return null;
|
---|
128 | }
|
---|
129 |
|
---|
130 | // Description
|
---|
131 | //------------
|
---|
132 | if ((oCMBusinessEntity.getDescriptions() != null) &&
|
---|
133 | (oCMBusinessEntity.getDescriptions().getBusinessDescription() != null) &&
|
---|
134 | (oCMBusinessEntity.getDescriptions().getBusinessDescription().size() > 0) &&
|
---|
135 | (oCMBusinessEntity.getDescriptions().getBusinessDescription().get(0) != null) &&
|
---|
136 | (oCMBusinessEntity.getDescriptions().getBusinessDescription().get(0).length() > 0))
|
---|
137 | {
|
---|
138 | oHomeCommunity.setDescription(oCMBusinessEntity.getDescriptions().getBusinessDescription().get(0));
|
---|
139 | }
|
---|
140 |
|
---|
141 | // Name
|
---|
142 | //------
|
---|
143 | if ((oCMBusinessEntity.getNames() != null) &&
|
---|
144 | (oCMBusinessEntity.getNames().getBusinessName() != null) &&
|
---|
145 | (oCMBusinessEntity.getNames().getBusinessName().size() > 0) &&
|
---|
146 | (oCMBusinessEntity.getNames().getBusinessName().get(0) != null) &&
|
---|
147 | (oCMBusinessEntity.getNames().getBusinessName().get(0).length() > 0))
|
---|
148 | {
|
---|
149 | oHomeCommunity.setName(oCMBusinessEntity.getNames().getBusinessName().get(0));
|
---|
150 | }
|
---|
151 |
|
---|
152 |
|
---|
153 | // Home Community Id
|
---|
154 | //-------------------
|
---|
155 | oHomeCommunity.setHomeCommunityId(oCMBusinessEntity.getHomeCommunityId());
|
---|
156 |
|
---|
157 | return oHomeCommunity;
|
---|
158 |
|
---|
159 | }
|
---|
160 |
|
---|
161 | /**
|
---|
162 | * Transform the information in a list of CMHomeCommunity objects to the web service representation
|
---|
163 | * of these data types.
|
---|
164 | *
|
---|
165 | * @param oaCMHomeCommunity The POJO home community information.
|
---|
166 | * @return The Web service representation of the information.
|
---|
167 | */
|
---|
168 | public static HomeCommunitiesType listCMHomeCommunityToHomeCommunitiesType(List<CMHomeCommunity> oaCMHomeCommunity)
|
---|
169 | {
|
---|
170 | HomeCommunitiesType oCommunities = new HomeCommunitiesType();
|
---|
171 |
|
---|
172 | if ((oaCMHomeCommunity != null) && (oaCMHomeCommunity.size() > 0))
|
---|
173 | {
|
---|
174 | for (CMHomeCommunity oCMHomeCommunity : oaCMHomeCommunity)
|
---|
175 | {
|
---|
176 | HomeCommunityType oHomeCommunity = cmHomeCommunityToHomeCommunity(oCMHomeCommunity);
|
---|
177 |
|
---|
178 | if (oHomeCommunity != null)
|
---|
179 | {
|
---|
180 | oCommunities.getHomeCommunity().add(oHomeCommunity);
|
---|
181 | }
|
---|
182 | } // for (CMHomeCommunity oCommunity : oaHomeCommunity)
|
---|
183 | }
|
---|
184 |
|
---|
185 | if (oCommunities.getHomeCommunity().size() > 0)
|
---|
186 | {
|
---|
187 | return oCommunities;
|
---|
188 | }
|
---|
189 | else
|
---|
190 | {
|
---|
191 | return null;
|
---|
192 | }
|
---|
193 |
|
---|
194 | }
|
---|
195 |
|
---|
196 | /**
|
---|
197 | * Transform the information in a CMPhones object to the web service representation
|
---|
198 | * of this data type.
|
---|
199 | *
|
---|
200 | * @param oCMPhones The POJO information.
|
---|
201 | * @return The Web service representation of the information.
|
---|
202 | */
|
---|
203 | public static PhonesType cmPhonesToPhonesType(CMPhones oCMPhones)
|
---|
204 | {
|
---|
205 | PhonesType oPhones = new PhonesType();
|
---|
206 |
|
---|
207 | if ((oCMPhones == null) ||
|
---|
208 | (oCMPhones.getPhone() == null) ||
|
---|
209 | (oCMPhones.getPhone().size() <= 0))
|
---|
210 | {
|
---|
211 | return null;
|
---|
212 | }
|
---|
213 |
|
---|
214 | oPhones.getPhone().addAll(oCMPhones.getPhone());
|
---|
215 |
|
---|
216 | return oPhones;
|
---|
217 | }
|
---|
218 |
|
---|
219 | /**
|
---|
220 | * Transform the information in a CMPersonNames object to the web service representation
|
---|
221 | * of this data type.
|
---|
222 | *
|
---|
223 | * @param oCMPersonNames The POJO information.
|
---|
224 | * @return The Web service representation of the information.
|
---|
225 | */
|
---|
226 | public static PersonNamesType cmPersonNamesToPersonNamesType(CMPersonNames oCMPersonNames)
|
---|
227 | {
|
---|
228 | PersonNamesType oPersonNames = new PersonNamesType();
|
---|
229 |
|
---|
230 | if ((oCMPersonNames == null) ||
|
---|
231 | (oCMPersonNames.getPersonName() == null) ||
|
---|
232 | (oCMPersonNames.getPersonName().size() <= 0))
|
---|
233 | {
|
---|
234 | return null;
|
---|
235 | }
|
---|
236 |
|
---|
237 | oPersonNames.getPersonName().addAll(oCMPersonNames.getPersonName());
|
---|
238 |
|
---|
239 | return oPersonNames;
|
---|
240 |
|
---|
241 | }
|
---|
242 |
|
---|
243 | /**
|
---|
244 | * Transform the information in a CMEmails object to the web service representation
|
---|
245 | * of this data type.
|
---|
246 | *
|
---|
247 | * @param oCMEmails The POJO information.
|
---|
248 | * @return The Web service representation of the information.
|
---|
249 | */
|
---|
250 | public static EmailsType cmEmailsToEmailstype(CMEmails oCMEmails)
|
---|
251 | {
|
---|
252 | EmailsType oEmails = new EmailsType();
|
---|
253 |
|
---|
254 | if ((oCMEmails == null) ||
|
---|
255 | (oCMEmails.getEmail() == null) ||
|
---|
256 | (oCMEmails.getEmail().size() <= 0))
|
---|
257 | {
|
---|
258 | return null;
|
---|
259 | }
|
---|
260 |
|
---|
261 | oEmails.getEmail().addAll(oCMEmails.getEmail());
|
---|
262 |
|
---|
263 | return oEmails;
|
---|
264 | }
|
---|
265 |
|
---|
266 | /**
|
---|
267 | * Transform the information in a CMContactDescriptions object to the web service representation
|
---|
268 | * of this data type.
|
---|
269 | *
|
---|
270 | * @param oCMContactDescriptions The POJO information.
|
---|
271 | * @return The Web service representation of the information.
|
---|
272 | */
|
---|
273 | public static ContactDescriptionsType cmContactDescriptionsToContactDescriptionsType(CMContactDescriptions oCMContactDescriptions)
|
---|
274 | {
|
---|
275 | ContactDescriptionsType oContactDescriptions = new ContactDescriptionsType();
|
---|
276 |
|
---|
277 | if ((oCMContactDescriptions == null) ||
|
---|
278 | (oCMContactDescriptions.getDescription() == null) ||
|
---|
279 | (oCMContactDescriptions.getDescription().size() <= 0))
|
---|
280 | {
|
---|
281 | return null;
|
---|
282 | }
|
---|
283 |
|
---|
284 | oContactDescriptions.getDescription().addAll(oCMContactDescriptions.getDescription());
|
---|
285 |
|
---|
286 | return oContactDescriptions;
|
---|
287 | }
|
---|
288 |
|
---|
289 | /**
|
---|
290 | * Transform the information in a CMAddresses object to the web service representation
|
---|
291 | * of this data type.
|
---|
292 | *
|
---|
293 | * @param oCMAddresses The POJO information.
|
---|
294 | * @return The Web service representation of the information.
|
---|
295 | */
|
---|
296 | public static AddressesType cmAddressesToAddressesType(CMAddresses oCMAddresses)
|
---|
297 | {
|
---|
298 | AddressesType oAddresses = new AddressesType();
|
---|
299 |
|
---|
300 | if ((oCMAddresses == null) ||
|
---|
301 | (oCMAddresses.getAddress() == null) ||
|
---|
302 | (oCMAddresses.getAddress().size() <= 0))
|
---|
303 | {
|
---|
304 | return null;
|
---|
305 | }
|
---|
306 |
|
---|
307 | for (CMAddress oCMAddress : oCMAddresses.getAddress())
|
---|
308 | {
|
---|
309 | AddressType oAddress = new AddressType();
|
---|
310 |
|
---|
311 | if ((oCMAddress.getAddressLine() != null) &&
|
---|
312 | (oCMAddress.getAddressLine().size() > 0))
|
---|
313 | {
|
---|
314 | oAddress.getAddressLine().addAll(oCMAddress.getAddressLine());
|
---|
315 | }
|
---|
316 |
|
---|
317 | oAddresses.getAddress().add(oAddress);
|
---|
318 | }
|
---|
319 |
|
---|
320 | return oAddresses;
|
---|
321 | }
|
---|
322 |
|
---|
323 | /**
|
---|
324 | * Transform the information in a CMBindingNames object to the web service representation
|
---|
325 | * of this data type.
|
---|
326 | *
|
---|
327 | * @param oCMBindingNames The POJO information.
|
---|
328 | * @return The Web service representation of the information.
|
---|
329 | */
|
---|
330 | public static List<BindingNamesType> cmBindingNamesToListBindingNamesType(CMBindingNames oCMBindingNames)
|
---|
331 | {
|
---|
332 | List<BindingNamesType> oaBindingNames = new ArrayList<BindingNamesType>();
|
---|
333 |
|
---|
334 | if ((oCMBindingNames == null) ||
|
---|
335 | (oCMBindingNames.getName() == null) ||
|
---|
336 | (oCMBindingNames.getName().size() <= 0))
|
---|
337 | {
|
---|
338 | return null;
|
---|
339 | }
|
---|
340 |
|
---|
341 | for (String sCMBindingName : oCMBindingNames.getName())
|
---|
342 | {
|
---|
343 | BindingNamesType oBindingNames = new BindingNamesType();
|
---|
344 | oBindingNames.getName().add(sCMBindingName);
|
---|
345 | oaBindingNames.add(oBindingNames);
|
---|
346 | }
|
---|
347 |
|
---|
348 | if (oaBindingNames.size() > 0)
|
---|
349 | {
|
---|
350 | return oaBindingNames;
|
---|
351 | }
|
---|
352 | else
|
---|
353 | {
|
---|
354 | return null;
|
---|
355 | }
|
---|
356 | }
|
---|
357 |
|
---|
358 | /**
|
---|
359 | * Transform the information in a CMBindingDescriptions object to the web service representation
|
---|
360 | * of this data type.
|
---|
361 | *
|
---|
362 | * @param oCMBindingDescriptions The POJO information.
|
---|
363 | * @return The Web service representation of the information.
|
---|
364 | */
|
---|
365 | public static List<BindingDescriptionsType> cmBindingDescriptionsToListBindingDescriptionsType(CMBindingDescriptions oCMBindingDescriptions)
|
---|
366 | {
|
---|
367 | List<BindingDescriptionsType> oaBindingDescriptions = new ArrayList<BindingDescriptionsType>();
|
---|
368 |
|
---|
369 | if ((oCMBindingDescriptions == null) ||
|
---|
370 | (oCMBindingDescriptions.getDescription() == null) ||
|
---|
371 | (oCMBindingDescriptions.getDescription().size() <= 0))
|
---|
372 | {
|
---|
373 | return null;
|
---|
374 | }
|
---|
375 |
|
---|
376 | for (String sCMBindingDescription : oCMBindingDescriptions.getDescription())
|
---|
377 | {
|
---|
378 | BindingDescriptionsType oBindingDescriptions = new BindingDescriptionsType();
|
---|
379 | oBindingDescriptions.getDescription().add(sCMBindingDescription);
|
---|
380 | oaBindingDescriptions.add(oBindingDescriptions);
|
---|
381 | }
|
---|
382 |
|
---|
383 | if (oaBindingDescriptions.size() > 0)
|
---|
384 | {
|
---|
385 | return oaBindingDescriptions;
|
---|
386 | }
|
---|
387 | else
|
---|
388 | {
|
---|
389 | return null;
|
---|
390 | }
|
---|
391 | }
|
---|
392 |
|
---|
393 | /**
|
---|
394 | * Transform the information in a CMBindingTemplates object to the web service representation
|
---|
395 | * of this data type.
|
---|
396 | *
|
---|
397 | * @param oCMBindingTemplates The POJO information.
|
---|
398 | * @return The Web service representation of the information.
|
---|
399 | */
|
---|
400 | public static BindingTemplatesType cmBindingTemplatesToBindingTemplatesType(CMBindingTemplates oCMBindingTemplates)
|
---|
401 | {
|
---|
402 | BindingTemplatesType oBindingTemplates = new BindingTemplatesType();
|
---|
403 |
|
---|
404 | if ((oCMBindingTemplates == null) ||
|
---|
405 | (oCMBindingTemplates.getBindingTemplate() == null) ||
|
---|
406 | (oCMBindingTemplates.getBindingTemplate().size() <= 0))
|
---|
407 | {
|
---|
408 | return null;
|
---|
409 | }
|
---|
410 |
|
---|
411 | for (CMBindingTemplate oCMBindingTemplate : oCMBindingTemplates.getBindingTemplate())
|
---|
412 | {
|
---|
413 | BindingTemplateType oBindingTemplate = new BindingTemplateType();
|
---|
414 |
|
---|
415 | oBindingTemplate.setBindingKey(oCMBindingTemplate.getBindingKey());
|
---|
416 | oBindingTemplate.setEndpointURL(oCMBindingTemplate.getEndpointURL());
|
---|
417 | oBindingTemplate.setWsdlURL(oCMBindingTemplate.getWsdlURL());
|
---|
418 |
|
---|
419 | oBindingTemplates.getBindingTemplate().add(oBindingTemplate);
|
---|
420 | }
|
---|
421 |
|
---|
422 | if (oBindingTemplates.getBindingTemplate().size() > 0)
|
---|
423 | {
|
---|
424 | return oBindingTemplates;
|
---|
425 | }
|
---|
426 | else
|
---|
427 | {
|
---|
428 | return null;
|
---|
429 | }
|
---|
430 | }
|
---|
431 |
|
---|
432 | /**
|
---|
433 | * Transform the information in a States object to the web service representation
|
---|
434 | * of this data type.
|
---|
435 | *
|
---|
436 | * @param oCMStates The POJO information.
|
---|
437 | * @return The Web service representation of the information.
|
---|
438 | */
|
---|
439 | public static StatesType cmStatesToStatesType(CMStates oCMStates)
|
---|
440 | {
|
---|
441 | StatesType oStates = new StatesType();
|
---|
442 |
|
---|
443 | if ((oCMStates == null) ||
|
---|
444 | (oCMStates.getState() == null) ||
|
---|
445 | (oCMStates.getState().size() <= 0))
|
---|
446 | {
|
---|
447 | return null;
|
---|
448 | }
|
---|
449 |
|
---|
450 | oStates.getState().addAll(oCMStates.getState());
|
---|
451 |
|
---|
452 | return oStates;
|
---|
453 | }
|
---|
454 |
|
---|
455 | /**
|
---|
456 | * Transform the information in a CMBusinessNames object to the web service representation
|
---|
457 | * of this data type.
|
---|
458 | *
|
---|
459 | * @param oCMBusinessNames The POJO information.
|
---|
460 | * @return The Web service representation of the information.
|
---|
461 | */
|
---|
462 | public static BusinessNamesType cmBusinessNamesToBusinessNamesType(CMBusinessNames oCMBusinessNames)
|
---|
463 | {
|
---|
464 | BusinessNamesType oBusinessNames = new BusinessNamesType();
|
---|
465 |
|
---|
466 | if ((oCMBusinessNames == null) ||
|
---|
467 | (oCMBusinessNames.getBusinessName() == null) ||
|
---|
468 | (oCMBusinessNames.getBusinessName().size() <= 0))
|
---|
469 | {
|
---|
470 | return null;
|
---|
471 | }
|
---|
472 |
|
---|
473 | oBusinessNames.getBusinessName().addAll(oCMBusinessNames.getBusinessName());
|
---|
474 |
|
---|
475 | return oBusinessNames;
|
---|
476 |
|
---|
477 | }
|
---|
478 |
|
---|
479 | /**
|
---|
480 | * Transform the information in a CMDiscoveryURLs object to the web service representation
|
---|
481 | * of this data type.
|
---|
482 | *
|
---|
483 | * @param oCMDiscoveryURLs The POJO information.
|
---|
484 | * @return The Web service representation of the information.
|
---|
485 | */
|
---|
486 | public static DiscoveryURLsType cmDiscoveryURLsToDiscoveryURLsType(CMDiscoveryURLs oCMDiscoveryURLs)
|
---|
487 | {
|
---|
488 | DiscoveryURLsType oDiscoveryURLs = new DiscoveryURLsType();
|
---|
489 |
|
---|
490 | if ((oCMDiscoveryURLs == null) ||
|
---|
491 | (oCMDiscoveryURLs.getDiscoveryURL() == null) ||
|
---|
492 | (oCMDiscoveryURLs.getDiscoveryURL().size() <= 0))
|
---|
493 | {
|
---|
494 | return null;
|
---|
495 | }
|
---|
496 |
|
---|
497 | oDiscoveryURLs.getDiscoveryURL().addAll(oCMDiscoveryURLs.getDiscoveryURL());
|
---|
498 |
|
---|
499 | return oDiscoveryURLs;
|
---|
500 |
|
---|
501 | }
|
---|
502 |
|
---|
503 | /**
|
---|
504 | * Transform the information in a CMBusinessDescriptions object to the web service representation
|
---|
505 | * of this data type.
|
---|
506 | *
|
---|
507 | * @param oCMBusinessDescriptions The POJO information.
|
---|
508 | * @return The Web service representation of the information.
|
---|
509 | */
|
---|
510 | public static BusinessDescriptionsType cmBusinessDescriptionsToBusinessDescriptionsType(CMBusinessDescriptions oCMBusinessDescriptions)
|
---|
511 | {
|
---|
512 | BusinessDescriptionsType oBusinessDescriptions = new BusinessDescriptionsType();
|
---|
513 |
|
---|
514 | if ((oCMBusinessDescriptions == null) ||
|
---|
515 | (oCMBusinessDescriptions.getBusinessDescription() == null) ||
|
---|
516 | (oCMBusinessDescriptions.getBusinessDescription().size() <= 0))
|
---|
517 | {
|
---|
518 | return null;
|
---|
519 | }
|
---|
520 |
|
---|
521 | oBusinessDescriptions.getBusinessDescription().addAll(oCMBusinessDescriptions.getBusinessDescription());
|
---|
522 |
|
---|
523 | return oBusinessDescriptions;
|
---|
524 | }
|
---|
525 |
|
---|
526 | /**
|
---|
527 | * Transform the information in a CMContacts object to the web service representation
|
---|
528 | * of this data type.
|
---|
529 | *
|
---|
530 | * @param oCMContacts The POJO information.
|
---|
531 | * @return The Web service representation of the information.
|
---|
532 | */
|
---|
533 | public static ContactsType cmContactsToContactsType(CMContacts oCMContacts)
|
---|
534 | {
|
---|
535 | ContactsType oContacts = new ContactsType();
|
---|
536 |
|
---|
537 | if ((oCMContacts == null) ||
|
---|
538 | (oCMContacts.getContact() == null) ||
|
---|
539 | (oCMContacts.getContact().size() <= 0))
|
---|
540 | {
|
---|
541 | return null;
|
---|
542 | }
|
---|
543 |
|
---|
544 | for (CMContact oCMContact : oCMContacts.getContact())
|
---|
545 | {
|
---|
546 | ContactType oContact = new ContactType();
|
---|
547 | oContact.setAddresses(cmAddressesToAddressesType(oCMContact.getAddresses()));
|
---|
548 | oContact.setDescriptions(cmContactDescriptionsToContactDescriptionsType(oCMContact.getDescriptions()));
|
---|
549 | oContact.setEmails(cmEmailsToEmailstype(oCMContact.getEmails()));
|
---|
550 | oContact.setPersonNames(cmPersonNamesToPersonNamesType(oCMContact.getPersonNames()));
|
---|
551 | oContact.setPhones(cmPhonesToPhonesType(oCMContact.getPhones()));
|
---|
552 | oContacts.getContact().add(oContact);
|
---|
553 | }
|
---|
554 |
|
---|
555 | if (oContacts.getContact().size() > 0)
|
---|
556 | {
|
---|
557 | return oContacts;
|
---|
558 | }
|
---|
559 | else
|
---|
560 | {
|
---|
561 | return null;
|
---|
562 | }
|
---|
563 | }
|
---|
564 |
|
---|
565 | /**
|
---|
566 | * Transform the information in a CMBusinessServices object to the web service representation
|
---|
567 | * of this data type.
|
---|
568 | *
|
---|
569 | * @param oCMBusinessServices The POJO information.
|
---|
570 | * @return The Web service representation of the information.
|
---|
571 | */
|
---|
572 | public static BusinessServicesType cmBusinessServicesToBusinessServicesType(CMBusinessServices oCMBusinessServices)
|
---|
573 | {
|
---|
574 | BusinessServicesType oBusinessServices = new BusinessServicesType();
|
---|
575 |
|
---|
576 | if ((oCMBusinessServices == null ||
|
---|
577 | (oCMBusinessServices.getBusinessService() == null) ||
|
---|
578 | (oCMBusinessServices.getBusinessService().size() <= 0)))
|
---|
579 | {
|
---|
580 | return null;
|
---|
581 | }
|
---|
582 |
|
---|
583 | for (CMBusinessService oCMBusinessService : oCMBusinessServices.getBusinessService())
|
---|
584 | {
|
---|
585 | BusinessServiceType oBusinessService = new BusinessServiceType();
|
---|
586 | oBusinessService.setBindingTemplates(cmBindingTemplatesToBindingTemplatesType(oCMBusinessService.getBindingTemplates()));
|
---|
587 | oBusinessService.setInternalWebService(oCMBusinessService.isInternalWebService());
|
---|
588 | oBusinessService.setServiceKey(oCMBusinessService.getServiceKey());
|
---|
589 | oBusinessService.setServiceVersion(oCMBusinessService.getServiceVersion());
|
---|
590 | oBusinessService.setUniformServiceName(oCMBusinessService.getUniformServiceName());
|
---|
591 |
|
---|
592 | List<BindingDescriptionsType> oaBindingDescriptions = cmBindingDescriptionsToListBindingDescriptionsType(oCMBusinessService.getDescriptions());
|
---|
593 | if ((oaBindingDescriptions != null) &&
|
---|
594 | (oaBindingDescriptions.size() > 0))
|
---|
595 | {
|
---|
596 | oBusinessService.getDescriptions().addAll(oaBindingDescriptions);
|
---|
597 | }
|
---|
598 |
|
---|
599 | List<BindingNamesType> oaBindingNames = cmBindingNamesToListBindingNamesType(oCMBusinessService.getNames());
|
---|
600 | if ((oaBindingNames != null) &&
|
---|
601 | (oaBindingNames.size() > 0))
|
---|
602 | {
|
---|
603 | oBusinessService.getNames().addAll(oaBindingNames);
|
---|
604 | }
|
---|
605 |
|
---|
606 | oBusinessServices.getBusinessService().add(oBusinessService);
|
---|
607 | }
|
---|
608 |
|
---|
609 |
|
---|
610 | if (oBusinessServices.getBusinessService().size() > 0)
|
---|
611 | {
|
---|
612 | return oBusinessServices;
|
---|
613 | }
|
---|
614 | else
|
---|
615 | {
|
---|
616 | return null;
|
---|
617 | }
|
---|
618 | }
|
---|
619 |
|
---|
620 | /**
|
---|
621 | * Transform the information in a CMBusinessEntity objects to the web service representation
|
---|
622 | * of these data types.
|
---|
623 | *
|
---|
624 | * @param oCMBusinessEntity The POJO information.
|
---|
625 | * @return The Web service representation of the information.
|
---|
626 | */
|
---|
627 | public static BusinessEntityType cmBusinessEntityToBusinessEntityType(CMBusinessEntity oCMBusinessEntity)
|
---|
628 | {
|
---|
629 | BusinessEntityType oBusinessEntity = new BusinessEntityType();
|
---|
630 |
|
---|
631 | if (oCMBusinessEntity == null)
|
---|
632 | {
|
---|
633 | return null;
|
---|
634 | }
|
---|
635 |
|
---|
636 | oBusinessEntity.setBusinessKey(oCMBusinessEntity.getBusinessKey());
|
---|
637 | oBusinessEntity.setBusinessServices(cmBusinessServicesToBusinessServicesType(oCMBusinessEntity.getBusinessServices()));
|
---|
638 | oBusinessEntity.setContacts(cmContactsToContactsType(oCMBusinessEntity.getContacts()));
|
---|
639 | oBusinessEntity.setDescriptions(cmBusinessDescriptionsToBusinessDescriptionsType(oCMBusinessEntity.getDescriptions()));
|
---|
640 | oBusinessEntity.setDiscoveryURLs(cmDiscoveryURLsToDiscoveryURLsType(oCMBusinessEntity.getDiscoveryURLs()));
|
---|
641 | oBusinessEntity.setFederalHIE(oCMBusinessEntity.isFederalHIE());
|
---|
642 | oBusinessEntity.setHomeCommunityId(oCMBusinessEntity.getHomeCommunityId());
|
---|
643 | oBusinessEntity.setNames(cmBusinessNamesToBusinessNamesType(oCMBusinessEntity.getNames()));
|
---|
644 | oBusinessEntity.setPublicKey(oCMBusinessEntity.getPublicKey());
|
---|
645 | oBusinessEntity.setPublicKeyURI(oCMBusinessEntity.getPublicKeyURI());
|
---|
646 | oBusinessEntity.setStates(cmStatesToStatesType(oCMBusinessEntity.getStates()));
|
---|
647 |
|
---|
648 | return oBusinessEntity;
|
---|
649 | }
|
---|
650 |
|
---|
651 | /**
|
---|
652 | * Transform the information in a CMBusinessEntities objects to the web service representation
|
---|
653 | * of these data types.
|
---|
654 | *
|
---|
655 | * @param oCMBusinessEntities The POJO information.
|
---|
656 | * @return The Web service representation of the information.
|
---|
657 | */
|
---|
658 | public static BusinessEntitiesType cmBusinessEntitiesToBusinessEntitiesType(CMBusinessEntities oCMBusinessEntities)
|
---|
659 | {
|
---|
660 | BusinessEntitiesType oBusinessEntities = new BusinessEntitiesType();
|
---|
661 |
|
---|
662 | if ((oCMBusinessEntities != null) &&
|
---|
663 | (oCMBusinessEntities.getBusinessEntity() != null) &&
|
---|
664 | (oCMBusinessEntities.getBusinessEntity().size() > 0))
|
---|
665 | {
|
---|
666 | for (CMBusinessEntity oCMBusinessEntity : oCMBusinessEntities.getBusinessEntity())
|
---|
667 | {
|
---|
668 | BusinessEntityType oBusinessEntity = cmBusinessEntityToBusinessEntityType(oCMBusinessEntity);
|
---|
669 | if (oBusinessEntity != null)
|
---|
670 | {
|
---|
671 | oBusinessEntities.getBusinessEntity().add(oBusinessEntity);
|
---|
672 | }
|
---|
673 | } // for (CMHomeCommunity oCommunity : oaHomeCommunity)
|
---|
674 | }
|
---|
675 |
|
---|
676 | if (oBusinessEntities.getBusinessEntity().size() > 0)
|
---|
677 | {
|
---|
678 | return oBusinessEntities;
|
---|
679 | }
|
---|
680 | else
|
---|
681 | {
|
---|
682 | return null;
|
---|
683 | }
|
---|
684 | }
|
---|
685 |
|
---|
686 | /**
|
---|
687 | * This transforms the information in a CMBusinessServices object to a ServiceConnectionInfosType object.
|
---|
688 | *
|
---|
689 | * @param oCMBusinessServices The information to be transformed.
|
---|
690 | * @return The transformed information.
|
---|
691 | */
|
---|
692 | public static ServiceConnectionInfosType cmBusinessServicesToServiceConnectionInfos(CMBusinessServices oCMBusinessServices)
|
---|
693 | {
|
---|
694 | ServiceConnectionInfosType oServiceConnectionInfos = new ServiceConnectionInfosType();
|
---|
695 |
|
---|
696 | if ((oCMBusinessServices == null) ||
|
---|
697 | (oCMBusinessServices.getBusinessService() == null) ||
|
---|
698 | (oCMBusinessServices.getBusinessService().size() <= 0))
|
---|
699 | {
|
---|
700 | return null;
|
---|
701 | }
|
---|
702 |
|
---|
703 | for (CMBusinessService oCMBusinessService : oCMBusinessServices.getBusinessService())
|
---|
704 | {
|
---|
705 | ServiceConnectionInfoType oServiceConnectionInfo = new ServiceConnectionInfoType();
|
---|
706 | boolean bHaveData = false;
|
---|
707 |
|
---|
708 | // Uniform Service Name
|
---|
709 | //---------------------
|
---|
710 | if ((oCMBusinessService.getUniformServiceName() != null) &&
|
---|
711 | (oCMBusinessService.getUniformServiceName().length() > 0))
|
---|
712 | {
|
---|
713 | oServiceConnectionInfo.setServiceName(oCMBusinessService.getUniformServiceName());
|
---|
714 | bHaveData = true;
|
---|
715 | }
|
---|
716 |
|
---|
717 | // URL
|
---|
718 | // Note that the UDDI server is set up to have multiple URLs per UniformServiceName. However
|
---|
719 | // there should only be one. We will use the first one we see...
|
---|
720 | //--------------------------------------------------------------------------------------------
|
---|
721 | if ((oCMBusinessService != null) &&
|
---|
722 | (oCMBusinessService.getBindingTemplates() != null) &&
|
---|
723 | (oCMBusinessService.getBindingTemplates().getBindingTemplate() != null) &&
|
---|
724 | (oCMBusinessService.getBindingTemplates().getBindingTemplate().size() > 0) &&
|
---|
725 | (oCMBusinessService.getBindingTemplates().getBindingTemplate().get(0) != null) &&
|
---|
726 | (oCMBusinessService.getBindingTemplates().getBindingTemplate().get(0).getEndpointURL() != null) &&
|
---|
727 | (oCMBusinessService.getBindingTemplates().getBindingTemplate().get(0).getEndpointURL().length() > 0))
|
---|
728 | {
|
---|
729 | String sURL = oCMBusinessService.getBindingTemplates().getBindingTemplate().get(0).getEndpointURL();
|
---|
730 | oServiceConnectionInfo.setUrl(sURL);
|
---|
731 | bHaveData = true;
|
---|
732 |
|
---|
733 | try
|
---|
734 | {
|
---|
735 | URL oURL = new URL(sURL);
|
---|
736 |
|
---|
737 | String sValue = oURL.getFile();
|
---|
738 | if ((sValue != null) && (sValue.length() > 0))
|
---|
739 | {
|
---|
740 | oServiceConnectionInfo.setFile(sValue);
|
---|
741 | }
|
---|
742 | else
|
---|
743 | {
|
---|
744 | oServiceConnectionInfo.setFile("");
|
---|
745 | }
|
---|
746 |
|
---|
747 | sValue = oURL.getHost();
|
---|
748 | if ((sValue != null) && (sValue.length() > 0))
|
---|
749 | {
|
---|
750 | oServiceConnectionInfo.setHost(sValue);
|
---|
751 | }
|
---|
752 | else
|
---|
753 | {
|
---|
754 | oServiceConnectionInfo.setHost("");
|
---|
755 | }
|
---|
756 |
|
---|
757 | sValue = oURL.getPath();
|
---|
758 | if ((sValue != null) && (sValue.length() > 0))
|
---|
759 | {
|
---|
760 | oServiceConnectionInfo.setPath(sValue);
|
---|
761 | }
|
---|
762 | else
|
---|
763 | {
|
---|
764 | oServiceConnectionInfo.setPath("");
|
---|
765 | }
|
---|
766 |
|
---|
767 | sValue = oURL.getPort() + "";
|
---|
768 | if ((sValue != null) && (sValue.length() > 0))
|
---|
769 | {
|
---|
770 | oServiceConnectionInfo.setPort(sValue);
|
---|
771 | }
|
---|
772 | else
|
---|
773 | {
|
---|
774 | oServiceConnectionInfo.setPort("");
|
---|
775 | }
|
---|
776 |
|
---|
777 | sValue = oURL.getProtocol();
|
---|
778 | if ((sValue != null) && (sValue.length() > 0))
|
---|
779 | {
|
---|
780 | oServiceConnectionInfo.setProtocol(sValue);
|
---|
781 | }
|
---|
782 | else
|
---|
783 | {
|
---|
784 | oServiceConnectionInfo.setProtocol("");
|
---|
785 | }
|
---|
786 | }
|
---|
787 | catch (Throwable t)
|
---|
788 | {
|
---|
789 | String sErrorMessage = "Failed to decompose URL into its parts. URL='" +
|
---|
790 | sURL + "'. Error: " + t.getMessage();
|
---|
791 | log.error(sErrorMessage, t);
|
---|
792 | }
|
---|
793 |
|
---|
794 | } // if ((oCMBusinessService != null) &&
|
---|
795 |
|
---|
796 | if (bHaveData)
|
---|
797 | {
|
---|
798 | oServiceConnectionInfos.getServiceConnectionInfo().add(oServiceConnectionInfo);
|
---|
799 | }
|
---|
800 |
|
---|
801 | } // for (CMBusinessService oCMBusinessService : oCMBusinessServices.getBusinessService())
|
---|
802 |
|
---|
803 | return oServiceConnectionInfos;
|
---|
804 | }
|
---|
805 |
|
---|
806 | /**
|
---|
807 | * This transforms the information in a CMBusinessServices object to a ServiceConnectionInfoEndpointsType object.
|
---|
808 | *
|
---|
809 | * @param oCMBusinessServices The information to be transformed.
|
---|
810 | * @return The transformed information.
|
---|
811 | */
|
---|
812 | public static ServiceConnectionInfoEndpointsType cmBusinessServicesToServiceConnectionInfoEndpointsType(CMBusinessServices oCMBusinessServices)
|
---|
813 | {
|
---|
814 | ServiceConnectionInfoEndpointsType oServiceConnectionInfoEndpoints = new ServiceConnectionInfoEndpointsType();
|
---|
815 |
|
---|
816 | if ((oCMBusinessServices == null) ||
|
---|
817 | (oCMBusinessServices.getBusinessService() == null) ||
|
---|
818 | (oCMBusinessServices.getBusinessService().size() <= 0))
|
---|
819 | {
|
---|
820 | return null;
|
---|
821 | }
|
---|
822 |
|
---|
823 | for (CMBusinessService oCMBusinessService : oCMBusinessServices.getBusinessService())
|
---|
824 | {
|
---|
825 | ServiceConnectionInfoEndpointType oServiceConnectionInfoEndpoint = new ServiceConnectionInfoEndpointType();
|
---|
826 | boolean bHaveData = false;
|
---|
827 | String sServiceName = "";
|
---|
828 |
|
---|
829 | // Uniform Service Name
|
---|
830 | //---------------------
|
---|
831 | if ((oCMBusinessService.getUniformServiceName() != null) &&
|
---|
832 | (oCMBusinessService.getUniformServiceName().length() > 0))
|
---|
833 | {
|
---|
834 | oServiceConnectionInfoEndpoint.setServiceName(oCMBusinessService.getUniformServiceName());
|
---|
835 | sServiceName = oCMBusinessService.getUniformServiceName();
|
---|
836 | bHaveData = true;
|
---|
837 | }
|
---|
838 |
|
---|
839 | // URL - Put into an EPR
|
---|
840 | // Note that the UDDI server is set up to have multiple URLs per UniformServiceName. However
|
---|
841 | // there should only be one. We will use the first one we see...
|
---|
842 |
|
---|
843 | //--------------------------------------------------------------------------------------------
|
---|
844 | if ((oCMBusinessService != null) &&
|
---|
845 | (oCMBusinessService.getBindingTemplates() != null) &&
|
---|
846 | (oCMBusinessService.getBindingTemplates().getBindingTemplate() != null) &&
|
---|
847 | (oCMBusinessService.getBindingTemplates().getBindingTemplate().size() > 0) &&
|
---|
848 | (oCMBusinessService.getBindingTemplates().getBindingTemplate().get(0) != null) &&
|
---|
849 | (oCMBusinessService.getBindingTemplates().getBindingTemplate().get(0).getEndpointURL() != null) &&
|
---|
850 | (oCMBusinessService.getBindingTemplates().getBindingTemplate().get(0).getEndpointURL().length() > 0))
|
---|
851 | {
|
---|
852 | String sURL = oCMBusinessService.getBindingTemplates().getBindingTemplate().get(0).getEndpointURL();
|
---|
853 | EPRType oEpr = createEPR(sServiceName, sURL);
|
---|
854 | if (oEpr != null)
|
---|
855 | {
|
---|
856 | oServiceConnectionInfoEndpoint.setEPR(oEpr);
|
---|
857 | bHaveData = true;
|
---|
858 | }
|
---|
859 |
|
---|
860 | } // if ((oCMBusinessService != null) &&
|
---|
861 |
|
---|
862 | if (bHaveData)
|
---|
863 | {
|
---|
864 | oServiceConnectionInfoEndpoints.getServiceConnectionInfoEndpoint().add(oServiceConnectionInfoEndpoint);
|
---|
865 | }
|
---|
866 |
|
---|
867 | } // for (CMBusinessService oCMBusinessService : oCMBusinessServices.getBusinessService())
|
---|
868 |
|
---|
869 | return oServiceConnectionInfoEndpoints;
|
---|
870 | }
|
---|
871 |
|
---|
872 | /**
|
---|
873 | * This method creates an endpoint for the given service name and URL.
|
---|
874 | *
|
---|
875 | * @param sServiceName The service name for the service.
|
---|
876 | * @param sUrl The URL that is being used for the service.
|
---|
877 | * @return The Endpoint reference to be returned.
|
---|
878 | */
|
---|
879 | public static EPRType createEPR(String sServiceName, String sUrl)
|
---|
880 | {
|
---|
881 | if ((sServiceName == null) || (sServiceName.length() <= 0))
|
---|
882 | {
|
---|
883 | return null;
|
---|
884 | }
|
---|
885 |
|
---|
886 | EPRType oEpr = new EPRType();
|
---|
887 |
|
---|
888 | EndpointReferenceType oRefType = new EndpointReferenceType();
|
---|
889 |
|
---|
890 | oEpr.setEndpointReference(oRefType);
|
---|
891 |
|
---|
892 | CreateEPRRequestType oEprReq = new CreateEPRRequestType();
|
---|
893 | log.info("Generating EPR for service: " + sServiceName);
|
---|
894 |
|
---|
895 | CMEprInfo oCMEprInfo = null;
|
---|
896 |
|
---|
897 | try
|
---|
898 | {
|
---|
899 | oCMEprInfo = CMEprUtil.createEPR(sServiceName);
|
---|
900 | }
|
---|
901 | catch (Exception e)
|
---|
902 | {
|
---|
903 | String sErrorMessage = "Failed to retrieve EPR info for service name: " + sServiceName +
|
---|
904 | ". Error: " + e.getMessage();
|
---|
905 | log.warn(sErrorMessage, e);
|
---|
906 |
|
---|
907 | // Set to default values.
|
---|
908 | //-----------------------
|
---|
909 | oCMEprInfo = new CMEprInfo();
|
---|
910 | oCMEprInfo.setNamespacePrefix("");
|
---|
911 | oCMEprInfo.setNamespaceURI("");
|
---|
912 | oCMEprInfo.setPortName("");
|
---|
913 | oCMEprInfo.setServiceName("");
|
---|
914 | oCMEprInfo.setUniformServiceName("");
|
---|
915 | }
|
---|
916 |
|
---|
917 | oEprReq.setNamespacePrefix(oCMEprInfo.getNamespacePrefix());
|
---|
918 | oEprReq.setNamespaceURI(oCMEprInfo.getNamespaceURI());
|
---|
919 | oEprReq.setPortName(oCMEprInfo.getPortName());
|
---|
920 | oEprReq.setServiceName(oCMEprInfo.getServiceName());
|
---|
921 |
|
---|
922 | AttributedURI oAddress = new AttributedURI();
|
---|
923 | oAddress.setValue(sUrl);
|
---|
924 | oRefType.setAddress(oAddress);
|
---|
925 |
|
---|
926 | log.debug("address.getValue() -- " + oAddress.getValue());
|
---|
927 |
|
---|
928 | ServiceNameType oEprServiceName = new ServiceNameType();
|
---|
929 | oEprServiceName.setPortName(oEprReq.getPortName());
|
---|
930 | log.debug("createEPRIn.getPortName() -- " + oEprReq.getPortName());
|
---|
931 |
|
---|
932 | QName serviceNameValue = new QName(oEprReq.getNamespaceURI(), oEprReq.getServiceName(), oEprReq.getNamespacePrefix());
|
---|
933 | log.debug("serviceNameValue -- " + oEprReq.getServiceName());
|
---|
934 | log.debug("NamespacePrefix -- " + oEprReq.getNamespacePrefix());
|
---|
935 | oEprServiceName.setValue(serviceNameValue);
|
---|
936 | oRefType.setServiceName(oEprServiceName);
|
---|
937 |
|
---|
938 | log.info("createEndpoint() -- End");
|
---|
939 |
|
---|
940 | return oEpr;
|
---|
941 | }
|
---|
942 |
|
---|
943 |
|
---|
944 | /**
|
---|
945 | * This transforms the information in a CMBusinessEntities structure to a ConnectionInfosType structure.
|
---|
946 | *
|
---|
947 | * @param oCMBusinessEntities The information to be transformed.
|
---|
948 | * @return The transformed information.
|
---|
949 | */
|
---|
950 | public static ConnectionInfosType cmBusinessEntitiesToConnectionInfosType(CMBusinessEntities oCMBusinessEntities)
|
---|
951 | {
|
---|
952 | ConnectionInfosType oConnectionInfos = new ConnectionInfosType();
|
---|
953 |
|
---|
954 | if ((oCMBusinessEntities == null) ||
|
---|
955 | (oCMBusinessEntities.getBusinessEntity() == null) ||
|
---|
956 | (oCMBusinessEntities.getBusinessEntity().size() <= 0))
|
---|
957 | {
|
---|
958 | return null;
|
---|
959 | }
|
---|
960 |
|
---|
961 | for (CMBusinessEntity oCMBusinessEntity : oCMBusinessEntities.getBusinessEntity())
|
---|
962 | {
|
---|
963 | ConnectionInfoType oConnectionInfo = new ConnectionInfoType();
|
---|
964 | boolean bHaveData = false;
|
---|
965 |
|
---|
966 | // Home community information
|
---|
967 | //---------------------------
|
---|
968 | HomeCommunityType oHomeCommunity = cmBusinessEntityToHomeCommunity(oCMBusinessEntity);
|
---|
969 | if (oHomeCommunity != null)
|
---|
970 | {
|
---|
971 | oConnectionInfo.setHomeCommunity(oHomeCommunity);
|
---|
972 | bHaveData = true;
|
---|
973 | }
|
---|
974 |
|
---|
975 | ServiceConnectionInfosType oServiceConnectionInfos = null;
|
---|
976 | oServiceConnectionInfos = cmBusinessServicesToServiceConnectionInfos(oCMBusinessEntity.getBusinessServices());
|
---|
977 | if (oServiceConnectionInfos != null)
|
---|
978 | {
|
---|
979 | oConnectionInfo.setServiceConnectionInfos(oServiceConnectionInfos);
|
---|
980 | bHaveData = true;
|
---|
981 | }
|
---|
982 |
|
---|
983 | if (bHaveData)
|
---|
984 | {
|
---|
985 | oConnectionInfos.getConnectionInfo().add(oConnectionInfo);
|
---|
986 | }
|
---|
987 | }
|
---|
988 |
|
---|
989 | if (oConnectionInfos.getConnectionInfo().size() > 0)
|
---|
990 | {
|
---|
991 | return oConnectionInfos;
|
---|
992 | }
|
---|
993 | else
|
---|
994 | {
|
---|
995 | return null;
|
---|
996 | }
|
---|
997 | }
|
---|
998 |
|
---|
999 | /**
|
---|
1000 | * This transforms a CMBusinessEntities object into a ConectionInfoEndpointsType object.
|
---|
1001 | *
|
---|
1002 | * @param oCMBusinessEntities The object to be transformed.
|
---|
1003 | * @return The transformed object.
|
---|
1004 | */
|
---|
1005 | public static ConnectionInfoEndpointsType cmBusinessEntitiesToConnectionInfoEndpointsType(CMBusinessEntities oCMBusinessEntities)
|
---|
1006 | {
|
---|
1007 | ConnectionInfoEndpointsType oConnectionInfoEndpoints = new ConnectionInfoEndpointsType();
|
---|
1008 |
|
---|
1009 | if ((oCMBusinessEntities == null) ||
|
---|
1010 | (oCMBusinessEntities.getBusinessEntity() == null) ||
|
---|
1011 | (oCMBusinessEntities.getBusinessEntity().size() <= 0))
|
---|
1012 | {
|
---|
1013 | return null;
|
---|
1014 | }
|
---|
1015 |
|
---|
1016 | for (CMBusinessEntity oCMBusinessEntity : oCMBusinessEntities.getBusinessEntity())
|
---|
1017 | {
|
---|
1018 | ConnectionInfoEndpointType oConnectionInfoEndpoint = new ConnectionInfoEndpointType();
|
---|
1019 | boolean bHaveData = false;
|
---|
1020 |
|
---|
1021 | // Home community information
|
---|
1022 | //---------------------------
|
---|
1023 | HomeCommunityType oHomeCommunity = cmBusinessEntityToHomeCommunity(oCMBusinessEntity);
|
---|
1024 | if (oHomeCommunity != null)
|
---|
1025 | {
|
---|
1026 | oConnectionInfoEndpoint.setHomeCommunity(oHomeCommunity);
|
---|
1027 | bHaveData = true;
|
---|
1028 | }
|
---|
1029 |
|
---|
1030 | ServiceConnectionInfoEndpointsType oServiceConnectionInfoEndpoints = null;
|
---|
1031 | oServiceConnectionInfoEndpoints = cmBusinessServicesToServiceConnectionInfoEndpointsType(oCMBusinessEntity.getBusinessServices());
|
---|
1032 | if (oServiceConnectionInfoEndpoints != null)
|
---|
1033 | {
|
---|
1034 | oConnectionInfoEndpoint.setServiceConnectionInfoEndpoints(oServiceConnectionInfoEndpoints);
|
---|
1035 | bHaveData = true;
|
---|
1036 | }
|
---|
1037 |
|
---|
1038 | if (bHaveData)
|
---|
1039 | {
|
---|
1040 | oConnectionInfoEndpoints.getConnectionInfoEndpoint().add(oConnectionInfoEndpoint);
|
---|
1041 | }
|
---|
1042 | }
|
---|
1043 |
|
---|
1044 | if (oConnectionInfoEndpoints.getConnectionInfoEndpoint().size() > 0)
|
---|
1045 | {
|
---|
1046 | return oConnectionInfoEndpoints;
|
---|
1047 | }
|
---|
1048 | else
|
---|
1049 | {
|
---|
1050 | return null;
|
---|
1051 | }
|
---|
1052 |
|
---|
1053 | }
|
---|
1054 | /**
|
---|
1055 | * This transforms a list of HomeCommunities into a list of HomeCommunityIds.
|
---|
1056 | *
|
---|
1057 | * @param oaHomeCommunity The list of home communities.
|
---|
1058 | * @return The list of home community ids.
|
---|
1059 | */
|
---|
1060 | public static List<String> listHomeCommunityToListHomeCommunityId(List<HomeCommunityType> oaHomeCommunity)
|
---|
1061 | {
|
---|
1062 | ArrayList<String> saHomeCommunityId = new ArrayList<String>();
|
---|
1063 | String tempHomeCommunityId = "";
|
---|
1064 | if ((oaHomeCommunity != null) &&
|
---|
1065 | (oaHomeCommunity.size() > 0))
|
---|
1066 | {
|
---|
1067 | saHomeCommunityId = new ArrayList<String>();
|
---|
1068 |
|
---|
1069 | for (HomeCommunityType oHomeCommunity : oaHomeCommunity)
|
---|
1070 | {
|
---|
1071 | if ((oHomeCommunity.getHomeCommunityId() != null) &&
|
---|
1072 | (oHomeCommunity.getHomeCommunityId().length() > 0))
|
---|
1073 | {
|
---|
1074 | tempHomeCommunityId = formatHomeCommunityId(oHomeCommunity.getHomeCommunityId());
|
---|
1075 | saHomeCommunityId.add(tempHomeCommunityId);
|
---|
1076 | }
|
---|
1077 | }
|
---|
1078 | }
|
---|
1079 |
|
---|
1080 | if (saHomeCommunityId.size() > 0)
|
---|
1081 | {
|
---|
1082 | return saHomeCommunityId;
|
---|
1083 | }
|
---|
1084 | else
|
---|
1085 | {
|
---|
1086 | return null;
|
---|
1087 | }
|
---|
1088 | }
|
---|
1089 |
|
---|
1090 | /**
|
---|
1091 | * This method take home community id as input verifies if the home community id consists of urn:id: at the begining and strip it off
|
---|
1092 | * @param homeCommunityId
|
---|
1093 | * @return String
|
---|
1094 | */
|
---|
1095 | public static String formatHomeCommunityId(String homeCommunityId)
|
---|
1096 | {
|
---|
1097 | String homeCommId = "";
|
---|
1098 | if(homeCommunityId.contains("urn:id:"))
|
---|
1099 | {
|
---|
1100 | homeCommId = homeCommunityId.substring("urn:id:".length(), homeCommunityId.length());
|
---|
1101 | } else
|
---|
1102 | {
|
---|
1103 | homeCommId = homeCommunityId;
|
---|
1104 | }
|
---|
1105 | return homeCommId;
|
---|
1106 | }
|
---|
1107 |
|
---|
1108 | }
|
---|