source: ccr/trunk/nhin-vista/projects/NHINC/Current/Product/Production/Common/ConnectionManagerEJB/src/java/gov/hhs/fha/nhinc/common/connectionmanager/CMServiceHelper.java@ 507

Last change on this file since 507 was 507, checked in by George Lilly, 15 years ago

NHIN gateway and adaptor for use on linux with VistA EHR and RPMS

File size: 54.0 KB
Line 
1package gov.hhs.fha.nhinc.common.connectionmanager;
2
3import gov.hhs.fha.nhinc.common.connectionmanager.dao.AssigningAuthorityHomeCommunityMappingDAO;
4import java.util.List;
5
6import org.apache.commons.logging.Log;
7import org.apache.commons.logging.LogFactory;
8
9import gov.hhs.fha.nhinc.connectmgr.ConnectionManagerCache;
10
11import gov.hhs.fha.nhinc.common.nhinccommon.HomeCommunitiesType;
12import gov.hhs.fha.nhinc.common.nhinccommon.HomeCommunityType;
13
14import gov.hhs.fha.nhinc.common.connectionmanagerinfo.BusinessEntitiesType;
15import gov.hhs.fha.nhinc.common.connectionmanagerinfo.BusinessEntityType;
16import gov.hhs.fha.nhinc.common.connectionmanagerinfo.ConnectionInfoEndpointType;
17import gov.hhs.fha.nhinc.common.connectionmanagerinfo.ConnectionInfoEndpointsType;
18import gov.hhs.fha.nhinc.common.connectionmanagerinfo.ConnectionInfoType;
19import gov.hhs.fha.nhinc.common.connectionmanagerinfo.ConnectionInfosType;
20import gov.hhs.fha.nhinc.common.connectionmanagerinfo.ForceRefreshInternalConnectCacheRequestType;
21import gov.hhs.fha.nhinc.common.connectionmanagerinfo.ForceRefreshUDDICacheRequestType;
22import gov.hhs.fha.nhinc.common.connectionmanagerinfo.GetAllBusinessEntitiesRequestType;
23import gov.hhs.fha.nhinc.common.connectionmanagerinfo.GetAllBusinessEntitySetByServiceNameRequestType;
24import gov.hhs.fha.nhinc.common.connectionmanagerinfo.GetAllCommunitiesRequestType;
25import gov.hhs.fha.nhinc.common.connectionmanagerinfo.GetAllConnectionInfoEndpointSetByServiceNameRequestType;
26import gov.hhs.fha.nhinc.common.connectionmanagerinfo.GetBusinessEntityByServiceNameRequestType;
27import gov.hhs.fha.nhinc.common.connectionmanagerinfo.GetBusinessEntityRequestType;
28import gov.hhs.fha.nhinc.common.connectionmanagerinfo.GetBusinessEntitySetByServiceNameRequestType;
29import gov.hhs.fha.nhinc.common.connectionmanagerinfo.GetBusinessEntitySetRequestType;
30import gov.hhs.fha.nhinc.common.connectionmanagerinfo.GetConnectionInfoEndpointByServiceNameRequestType;
31import gov.hhs.fha.nhinc.common.connectionmanagerinfo.GetConnectionInfoEndpointSetByServiceNameRequestType;
32import gov.hhs.fha.nhinc.common.connectionmanagerinfo.GetConnectionInfoEndpointSetRequestType;
33import gov.hhs.fha.nhinc.common.connectionmanagerinfo.HomeCommunitiesWithServiceNameType;
34import gov.hhs.fha.nhinc.common.connectionmanagerinfo.HomeCommunityWithServiceNameType;
35import gov.hhs.fha.nhinc.common.connectionmanagerinfo.SuccessOrFailType;
36import gov.hhs.fha.nhinc.common.connectionmanagerinfo.GetAllConnectionInfoSetByServiceNameRequestType;
37
38import gov.hhs.fha.nhinc.common.connectionmanagerinfo.GetAssigningAuthoritiesByHomeCommunityRequestType;
39import gov.hhs.fha.nhinc.common.connectionmanagerinfo.GetAssigningAuthoritiesByHomeCommunityResponseType;
40import gov.hhs.fha.nhinc.common.connectionmanagerinfo.GetHomeCommunityByAssigningAuthorityRequestType;
41import gov.hhs.fha.nhinc.common.connectionmanagerinfo.GetHomeCommunityByAssigningAuthorityResponseType;
42import gov.hhs.fha.nhinc.common.connectionmanagerinfo.StoreAssigningAuthorityToHomeCommunityMappingRequestType;
43import gov.hhs.fha.nhinc.common.connectionmanagerinfo.GetConnectionInfoEndpontFromNhinTargetType;
44import gov.hhs.fha.nhinc.common.nhinccommon.AcknowledgementType;
45import gov.hhs.fha.nhinc.common.nhinccommon.AssigningAuthoritiesType;
46import gov.hhs.fha.nhinc.common.nhinccommon.AssigningAuthorityType;
47import gov.hhs.fha.nhinc.common.nhinccommon.EPRType;
48import gov.hhs.fha.nhinc.connectmgr.CMEprUtil;
49import gov.hhs.fha.nhinc.connectmgr.data.CMBusinessEntities;
50import gov.hhs.fha.nhinc.connectmgr.data.CMBusinessEntity;
51import gov.hhs.fha.nhinc.connectmgr.data.CMEprInfo;
52import gov.hhs.fha.nhinc.connectmgr.data.CMHomeCommunity;
53import gov.hhs.fha.nhinc.nhinclib.NullChecker;
54import java.util.ArrayList;
55
56/**
57 * This class is a helper class to the ConnectionManagerService. It does
58 * most of the java level work so that it can be unit tested outside of
59 * the web service container.
60 *
61 * @author Les Westberg
62 */
63public class CMServiceHelper {
64
65 private static Log log = LogFactory.getLog(CMServiceHelper.class);
66
67 /**
68 * This method returns a list of all communities that are known.
69 *
70 * @param part1 The only purpose for this parameter is so that the
71 * web service has a unique document that identifies this
72 * operation. The values themselves are not used.
73 * @return List of all communities.
74 */
75 public static HomeCommunitiesType getAllCommunities(GetAllCommunitiesRequestType part1) {
76 HomeCommunitiesType oCommunities = new HomeCommunitiesType();
77
78 List<CMHomeCommunity> oaCMHomeCommunity = null;
79
80 try {
81 oaCMHomeCommunity = ConnectionManagerCache.getAllCommunities();
82 } catch (Throwable t) {
83 String sErrorMessage = "Failed to retrieve home communities. Error: " + t.getMessage();
84 log.error(sErrorMessage, t);
85 }
86
87 oCommunities = CMTransform.listCMHomeCommunityToHomeCommunitiesType(oaCMHomeCommunity);
88 return oCommunities;
89 }
90
91 /**
92 * This method returns a list of all communities along with their demongraphic
93 * information that are known.
94 *
95 * @param part1 The only purpose for this parameter is so that the
96 * web service has a unique document that identifies this
97 * operation. The values themselves are not used.
98 * @return List of all communities.
99 */
100 public static BusinessEntitiesType getAllBusinessEntities(GetAllBusinessEntitiesRequestType part1) {
101 BusinessEntitiesType oBusinessEntities = new BusinessEntitiesType();
102
103 CMBusinessEntities oCMBusinessEntities = null;
104
105 try {
106 oCMBusinessEntities = ConnectionManagerCache.getAllBusinessEntities();
107 } catch (Throwable t) {
108 String sErrorMessage = "Failed to retrieve home business entities. Error: " + t.getMessage();
109 log.error(sErrorMessage, t);
110 }
111
112 oBusinessEntities = CMTransform.cmBusinessEntitiesToBusinessEntitiesType(oCMBusinessEntities);
113 return oBusinessEntities;
114 }
115
116 /**
117 * This method retrieves the information about a single business entity.
118 *
119 * @param part1 The home community ID for the business entity.
120 * @return The information about the business entity.
121 */
122 public static BusinessEntityType getBusinessEntity(GetBusinessEntityRequestType part1) {
123 BusinessEntityType oBusinessEntity = null;
124 String sHomeCommunityId = "";
125 if ((part1 != null) &&
126 (part1.getHomeCommunity() != null) &&
127 (part1.getHomeCommunity().getHomeCommunityId() != null) &&
128 (part1.getHomeCommunity().getHomeCommunityId().length() > 0) &&
129 (part1.getAssigningAuthority() != null) &&
130 (part1.getAssigningAuthority().getAssigningAuthorityId() != null) &&
131 (part1.getAssigningAuthority().getAssigningAuthorityId().length() > 0)) {
132 AssigningAuthorityHomeCommunityMappingDAO mappingDao = new AssigningAuthorityHomeCommunityMappingDAO();
133 sHomeCommunityId = CMTransform.formatHomeCommunityId(part1.getHomeCommunity().getHomeCommunityId());
134 mappingDao.storeMapping(sHomeCommunityId, part1.getAssigningAuthority().getAssigningAuthorityId());
135 } else if ((part1 != null) &&
136 (part1.getHomeCommunity() != null) &&
137 (part1.getHomeCommunity().getHomeCommunityId() != null) &&
138 (part1.getHomeCommunity().getHomeCommunityId().length() > 0)) {
139 sHomeCommunityId = CMTransform.formatHomeCommunityId(part1.getHomeCommunity().getHomeCommunityId());
140 } else if ((part1 != null) &&
141 (part1.getAssigningAuthority() != null) &&
142 (part1.getAssigningAuthority().getAssigningAuthorityId().length() > 0)) {
143 String assigningAuthId = part1.getAssigningAuthority().getAssigningAuthorityId();
144 AssigningAuthorityHomeCommunityMappingDAO mappingDao = new AssigningAuthorityHomeCommunityMappingDAO();
145 sHomeCommunityId = mappingDao.getHomeCommunityId(assigningAuthId);
146 }
147
148 // If we have a home community ID, do the retrieve ....
149 //------------------------------------------------------
150 if ((sHomeCommunityId != null) &&
151 (sHomeCommunityId.length() > 0)) {
152 CMBusinessEntity oCMBusinessEntity = null;
153
154 try {
155 oCMBusinessEntity = ConnectionManagerCache.getBusinessEntity(sHomeCommunityId);
156 } catch (Throwable t) {
157 String sErrorMessage = "Failed to retrieve business entity. Error: " + t.getMessage();
158 log.error(sErrorMessage, t);
159 }
160
161 oBusinessEntity = CMTransform.cmBusinessEntityToBusinessEntityType(oCMBusinessEntity);
162 }
163
164 return oBusinessEntity;
165 }
166
167 /**
168 * This retrieves the business entity set from the cache.
169 *
170 * @param saHomeCommunityId The list of home community ids.
171 * @return The Business entities that are retrieved.
172 */
173 private static CMBusinessEntities retrieveBusinessEntitySetFromCache(List<String> saHomeCommunityId) {
174 CMBusinessEntities oCMBusinessEntities = null;
175
176 if ((saHomeCommunityId != null) &&
177 (saHomeCommunityId.size() > 0)) {
178 try {
179 oCMBusinessEntities = ConnectionManagerCache.getBusinessEntitySet(saHomeCommunityId);
180 } catch (Throwable t) {
181 String sErrorMessage = "Failed to retrieve business entities. Error: " + t.getMessage();
182 log.error(sErrorMessage, t);
183 }
184 }
185
186 return oCMBusinessEntities;
187 }
188
189 /**
190 * This method returns the connection information for the set of home communities that were passed in.
191 *
192 * @param part1 The set of home communities for which the connection information is needed.
193 * @return The connection info for the home communities.
194 */
195 public static ConnectionInfosType getConnectionInfoSet(HomeCommunitiesType part1) {
196 ConnectionInfosType oConnectionInfos = null;
197
198 if ((part1 != null) &&
199 (part1.getHomeCommunity() != null) &&
200 (part1.getHomeCommunity().size() > 0)) {
201
202 List<String> saHomeCommunityId = CMTransform.listHomeCommunityToListHomeCommunityId(part1.getHomeCommunity());
203 CMBusinessEntities oCMBusinessEntities = retrieveBusinessEntitySetFromCache(saHomeCommunityId);
204 oConnectionInfos = CMTransform.cmBusinessEntitiesToConnectionInfosType(oCMBusinessEntities);
205
206 } // if ((part1 != null) &&
207
208 return oConnectionInfos;
209 }
210
211 /**
212 * This method returns the connection endpoint information for the set of home communities
213 * that were passed in.
214 *
215 * @param part1 The set of home communities for which the connection information is needed.
216 * @return The connection endpoint info for the home communities.
217 */
218 public static ConnectionInfoEndpointsType getConnectionInfoEndpointSet(GetConnectionInfoEndpointSetRequestType part1) {
219 ConnectionInfoEndpointsType oConnectionInfoEndpoints = null;
220 List<String> saHomeCommunityId = null;
221
222 if ((part1 != null) &&
223 (part1.getHomeCommunities() != null) &&
224 (part1.getHomeCommunities().getHomeCommunity() != null) &&
225 (part1.getHomeCommunities().getHomeCommunity().size() > 0)) {
226 saHomeCommunityId = CMTransform.listHomeCommunityToListHomeCommunityId(part1.getHomeCommunities().getHomeCommunity());
227 } else if ((part1 != null) &&
228 (part1.getAssigningAuthorities() != null) &&
229 (part1.getAssigningAuthorities().getAssigningAuthority() != null) &&
230 (part1.getAssigningAuthorities().getAssigningAuthority().size() > 0)) {
231 AssigningAuthorityHomeCommunityMappingDAO mappingDao = new AssigningAuthorityHomeCommunityMappingDAO();
232 int size = part1.getAssigningAuthorities().getAssigningAuthority().size();
233 List<AssigningAuthorityType> assignIdList = part1.getAssigningAuthorities().getAssigningAuthority();
234 String tempHomeCommId = "";
235 saHomeCommunityId = new ArrayList();
236 for (int i = 0; i < size; i++) {
237 tempHomeCommId = mappingDao.getHomeCommunityId(assignIdList.get(i).getAssigningAuthorityId());
238 saHomeCommunityId.add(tempHomeCommId);
239 }
240 }
241 CMBusinessEntities oCMBusinessEntities = retrieveBusinessEntitySetFromCache(saHomeCommunityId);
242 oConnectionInfoEndpoints = CMTransform.cmBusinessEntitiesToConnectionInfoEndpointsType(oCMBusinessEntities);
243 return oConnectionInfoEndpoints;
244 }
245
246 /**
247 * This method returns the business information along with their connection information
248 * for the set of home communities that were passed in.
249 *
250 * @param part1 The set of home communities for which the connection information is needed.
251 * @return The connection and business info for the home communities.
252 */
253 public static BusinessEntitiesType getBusinessEntitySet(GetBusinessEntitySetRequestType part1) {
254 BusinessEntitiesType oBusinessEntities = null;
255 CMBusinessEntities oCMBusinessEntities = null;
256 List<String> saHomeCommunityId = null;
257
258 if ((part1 != null) &&
259 (part1.getHomeCommunities() != null) &&
260 (part1.getHomeCommunities().getHomeCommunity() != null) &&
261 (part1.getHomeCommunities().getHomeCommunity().size() > 0) &&
262 (part1.getAssigningAuthorities() != null) &&
263 (part1.getAssigningAuthorities().getAssigningAuthority() != null) &&
264 (part1.getAssigningAuthorities().getAssigningAuthority().size() > 0)) {
265 String sHomeCommId = "";
266 String sAssigningAuthId = "";
267 int hSize = part1.getHomeCommunities().getHomeCommunity().size();
268 AssigningAuthorityHomeCommunityMappingDAO mappingDao = new AssigningAuthorityHomeCommunityMappingDAO();
269 List<HomeCommunityType> homeCommunityTypeList = part1.getHomeCommunities().getHomeCommunity();
270 for (int i = 0; i < hSize; i++) {
271 sHomeCommId = CMTransform.formatHomeCommunityId(homeCommunityTypeList.get(i).getHomeCommunityId());
272 sAssigningAuthId = part1.getAssigningAuthorities().getAssigningAuthority().get(i).getAssigningAuthorityId();
273 mappingDao.storeMapping(sHomeCommId, sAssigningAuthId);
274 }
275 saHomeCommunityId = CMTransform.listHomeCommunityToListHomeCommunityId(part1.getHomeCommunities().getHomeCommunity());
276 oCMBusinessEntities = retrieveBusinessEntitySetFromCache(saHomeCommunityId);
277 oBusinessEntities = CMTransform.cmBusinessEntitiesToBusinessEntitiesType(oCMBusinessEntities);
278 } else if ((part1 != null) &&
279 (part1.getHomeCommunities() != null) &&
280 (part1.getHomeCommunities().getHomeCommunity() != null) &&
281 (part1.getHomeCommunities().getHomeCommunity().size() > 0)) {
282 saHomeCommunityId = CMTransform.listHomeCommunityToListHomeCommunityId(part1.getHomeCommunities().getHomeCommunity());
283 oCMBusinessEntities = retrieveBusinessEntitySetFromCache(saHomeCommunityId);
284 oBusinessEntities = CMTransform.cmBusinessEntitiesToBusinessEntitiesType(oCMBusinessEntities);
285 } else if ((part1 != null) &&
286 (part1.getAssigningAuthorities() != null) &&
287 (part1.getAssigningAuthorities().getAssigningAuthority() != null) &&
288 (part1.getAssigningAuthorities().getAssigningAuthority().size() > 0)) {
289 int size = part1.getAssigningAuthorities().getAssigningAuthority().size();
290 saHomeCommunityId = new ArrayList();
291 String assigningAuthId = "";
292 AssigningAuthorityHomeCommunityMappingDAO mappingDao = new AssigningAuthorityHomeCommunityMappingDAO();
293 for (int i = 0; i < size; i++) {
294 assigningAuthId = part1.getAssigningAuthorities().getAssigningAuthority().get(i).getAssigningAuthorityId();
295 saHomeCommunityId.add(mappingDao.getHomeCommunityId(assigningAuthId));
296 }
297 oCMBusinessEntities = retrieveBusinessEntitySetFromCache(saHomeCommunityId);
298 oBusinessEntities = CMTransform.cmBusinessEntitiesToBusinessEntitiesType(oCMBusinessEntities);
299 }
300 return oBusinessEntities;
301 }
302
303 /**
304 * This retrieves the business entity set from the cache by service name.
305 *
306 * @param saHomeCommunityId The list of home community ids.
307 * @param sServiceName The name of the service.
308 * @return The Business entities that are retrieved.
309 */
310 private static CMBusinessEntities retrieveBusinessEntitySetByServiceNameFromCache(List<String> saHomeCommunityId,
311 String sServiceName) {
312 CMBusinessEntities oCMBusinessEntities = null;
313
314 if ((saHomeCommunityId != null) &&
315 (saHomeCommunityId.size() > 0)) {
316 try {
317 oCMBusinessEntities = ConnectionManagerCache.getBusinessEntitySetByServiceName(saHomeCommunityId, sServiceName);
318 } catch (Throwable t) {
319 String sErrorMessage = "Failed to retrieve business entities. Error: " + t.getMessage();
320 log.error(sErrorMessage, t);
321 }
322 }
323 return oCMBusinessEntities;
324 }
325
326 /**
327 * This method retrieves the ConnectionInformation for a specific service at a
328 * specific set of home communities
329 *
330 * @param part1 This contains the home communities identification and the name of the service that the
331 * connection info is desired.
332 * @return The connection information for the service at the specified home community.
333 */
334 public static ConnectionInfosType getConnectionInfoSetByServiceName(HomeCommunitiesWithServiceNameType part1) {
335 ConnectionInfosType oConnectionInfos = null;
336 List<String> saHomeCommunityId = null;
337 String sServiceName = "";
338
339 if ((part1 != null) &&
340 (part1.getHomeCommunities() != null) &&
341 (part1.getHomeCommunities().getHomeCommunity() != null) &&
342 (part1.getHomeCommunities().getHomeCommunity().size() > 0) &&
343 (part1.getServiceName() != null) &&
344 (part1.getServiceName().length() > 0)) {
345 sServiceName = part1.getServiceName();
346 saHomeCommunityId = CMTransform.listHomeCommunityToListHomeCommunityId(part1.getHomeCommunities().getHomeCommunity());
347 } else if ((part1 != null) &&
348 (part1.getAssigningAuthorities() != null) &&
349 (part1.getAssigningAuthorities().getAssigningAuthority() != null) &&
350 (part1.getAssigningAuthorities().getAssigningAuthority().size() > 0) &&
351 (part1.getServiceName() != null) &&
352 (part1.getServiceName().length() > 0)) {
353 sServiceName = part1.getServiceName();
354 int size = part1.getAssigningAuthorities().getAssigningAuthority().size();
355 AssigningAuthorityHomeCommunityMappingDAO mappingDao = new AssigningAuthorityHomeCommunityMappingDAO();
356 saHomeCommunityId = new ArrayList();
357 String assigningAuthId = "";
358 List<AssigningAuthorityType> assignList = part1.getAssigningAuthorities().getAssigningAuthority();
359 for (int i = 0; i < size; i++) {
360 assigningAuthId = assignList.get(i).getAssigningAuthorityId();
361 saHomeCommunityId.add(mappingDao.getHomeCommunityId(assigningAuthId));
362 }
363 }
364 CMBusinessEntities oCMBusinessEntities = retrieveBusinessEntitySetByServiceNameFromCache(saHomeCommunityId, sServiceName);
365 oConnectionInfos = CMTransform.cmBusinessEntitiesToConnectionInfosType(oCMBusinessEntities);
366 return oConnectionInfos;
367 }
368
369 /**
370 * This method retrieves the Endpoint Connection Information for a specific service at a
371 * specific set of home communities
372 *
373 * @param part1 This contains the home communities identification and the name of the service that the
374 * connection info is desired.
375 * @return The endpoint connection information for the service at the specified home community.
376 */
377 public static ConnectionInfoEndpointsType getConnectionInfoEndpointSetByServiceName(GetConnectionInfoEndpointSetByServiceNameRequestType part1) {
378 ConnectionInfoEndpointsType oConnectionInfoEndpoints = null;
379 List<String> saHomeCommunityId = null;
380 String sServiceName = "";
381 if ((part1 != null) &&
382 (part1.getHomeCommunitiesWithServiceName() != null) &&
383 (part1.getHomeCommunitiesWithServiceName().getHomeCommunities() != null) &&
384 (part1.getHomeCommunitiesWithServiceName().getHomeCommunities().getHomeCommunity() != null) &&
385 (part1.getHomeCommunitiesWithServiceName().getHomeCommunities().getHomeCommunity().size() > 0) &&
386 (part1.getHomeCommunitiesWithServiceName().getServiceName() != null) &&
387 (part1.getHomeCommunitiesWithServiceName().getServiceName().length() > 0)) {
388 sServiceName = part1.getHomeCommunitiesWithServiceName().getServiceName();
389 List<HomeCommunityType> oaHomeCommunity = part1.getHomeCommunitiesWithServiceName().getHomeCommunities().getHomeCommunity();
390 saHomeCommunityId = CMTransform.listHomeCommunityToListHomeCommunityId(oaHomeCommunity);
391 } else if ((part1 != null) &&
392 (part1.getHomeCommunitiesWithServiceName() != null) &&
393 (part1.getHomeCommunitiesWithServiceName().getAssigningAuthorities() != null) &&
394 (part1.getHomeCommunitiesWithServiceName().getAssigningAuthorities().getAssigningAuthority() != null) &&
395 (part1.getHomeCommunitiesWithServiceName().getAssigningAuthorities().getAssigningAuthority().size() > 0) &&
396 (part1.getHomeCommunitiesWithServiceName().getServiceName() != null) &&
397 (part1.getHomeCommunitiesWithServiceName().getServiceName().length() > 0)) {
398 sServiceName = part1.getHomeCommunitiesWithServiceName().getServiceName();
399 List<AssigningAuthorityType> assignList = part1.getHomeCommunitiesWithServiceName().getAssigningAuthorities().getAssigningAuthority();
400 String tempHomeCommId = "";
401 AssigningAuthorityHomeCommunityMappingDAO mappingDao = new AssigningAuthorityHomeCommunityMappingDAO();
402 int size = part1.getHomeCommunitiesWithServiceName().getAssigningAuthorities().getAssigningAuthority().size();
403 saHomeCommunityId = new ArrayList();
404 for (int i = 0; i < size; i++) {
405 tempHomeCommId = mappingDao.getHomeCommunityId(assignList.get(i).getAssigningAuthorityId());
406 saHomeCommunityId.add(tempHomeCommId);
407 }
408 }
409 CMBusinessEntities oCMBusinessEntities = retrieveBusinessEntitySetByServiceNameFromCache(saHomeCommunityId, sServiceName);
410 oConnectionInfoEndpoints = CMTransform.cmBusinessEntitiesToConnectionInfoEndpointsType(oCMBusinessEntities);
411 return oConnectionInfoEndpoints;
412 }
413
414 /**
415 * This method retrieves the business entity and Connection Information for a specific service at a
416 * specific set of home communities
417 *
418 * @param part1 This contains the home communities identification and the name of the service that the
419 * connection info is desired.
420 * @return The endpoint connection information for the service at the specified home community.
421 */
422 public static BusinessEntitiesType getBusinessEntitySetByServiceName(GetBusinessEntitySetByServiceNameRequestType part1) {
423 BusinessEntitiesType oBusinessEntities = null;
424 List<String> saHomeCommunityId = null;
425 String sServiceName = "";
426
427 if ((part1 != null) &&
428 (part1.getHomeCommunitiesWithServiceName() != null) &&
429 (part1.getHomeCommunitiesWithServiceName().getHomeCommunities() != null) &&
430 (part1.getHomeCommunitiesWithServiceName().getHomeCommunities().getHomeCommunity() != null) &&
431 (part1.getHomeCommunitiesWithServiceName().getHomeCommunities().getHomeCommunity().size() > 0) &&
432 (part1.getHomeCommunitiesWithServiceName().getAssigningAuthorities() != null) &&
433 (part1.getHomeCommunitiesWithServiceName().getAssigningAuthorities().getAssigningAuthority() != null) &&
434 (part1.getHomeCommunitiesWithServiceName().getAssigningAuthorities().getAssigningAuthority().size() > 0)) {
435 int size = part1.getHomeCommunitiesWithServiceName().getHomeCommunities().getHomeCommunity().size();
436 String sHCommId = "";
437 String sAssAuthId = "";
438 AssigningAuthorityHomeCommunityMappingDAO mappingDao = new AssigningAuthorityHomeCommunityMappingDAO();
439 List<HomeCommunityType> homeCommList = part1.getHomeCommunitiesWithServiceName().getHomeCommunities().getHomeCommunity();
440 List<AssigningAuthorityType> assignAuthList = part1.getHomeCommunitiesWithServiceName().getAssigningAuthorities().getAssigningAuthority();
441 for (int i = 0; i < size; i++) {
442 sHCommId = CMTransform.formatHomeCommunityId(homeCommList.get(i).getHomeCommunityId());
443 sAssAuthId = assignAuthList.get(i).getAssigningAuthorityId();
444 if (sHCommId != null && sHCommId.length() > 0 && sAssAuthId != null && sAssAuthId.length() > 0) {
445 mappingDao.storeMapping(sHCommId, sAssAuthId);
446 }
447 }
448 }
449
450 if ((part1 != null) &&
451 (part1.getHomeCommunitiesWithServiceName() != null) &&
452 (part1.getHomeCommunitiesWithServiceName().getHomeCommunities() != null) &&
453 (part1.getHomeCommunitiesWithServiceName().getHomeCommunities().getHomeCommunity() != null) &&
454 (part1.getHomeCommunitiesWithServiceName().getHomeCommunities().getHomeCommunity().size() > 0) &&
455 (part1.getHomeCommunitiesWithServiceName().getServiceName() != null) &&
456 (part1.getHomeCommunitiesWithServiceName().getServiceName().length() > 0)) {
457 sServiceName = part1.getHomeCommunitiesWithServiceName().getServiceName();
458 List<HomeCommunityType> oaHomeCommunity = part1.getHomeCommunitiesWithServiceName().getHomeCommunities().getHomeCommunity();
459 saHomeCommunityId = CMTransform.listHomeCommunityToListHomeCommunityId(oaHomeCommunity);
460 } else if ((part1 != null) &&
461 (part1.getHomeCommunitiesWithServiceName() != null) &&
462 (part1.getHomeCommunitiesWithServiceName().getAssigningAuthorities() != null) &&
463 (part1.getHomeCommunitiesWithServiceName().getAssigningAuthorities().getAssigningAuthority() != null) &&
464 (part1.getHomeCommunitiesWithServiceName().getAssigningAuthorities().getAssigningAuthority().size() > 0) &&
465 (part1.getHomeCommunitiesWithServiceName().getServiceName() != null) &&
466 (part1.getHomeCommunitiesWithServiceName().getServiceName().length() > 0)) {
467 sServiceName = part1.getHomeCommunitiesWithServiceName().getServiceName();
468 AssigningAuthorityHomeCommunityMappingDAO mappingDao = new AssigningAuthorityHomeCommunityMappingDAO();
469 int size = part1.getHomeCommunitiesWithServiceName().getAssigningAuthorities().getAssigningAuthority().size();
470 List<AssigningAuthorityType> assignList = part1.getHomeCommunitiesWithServiceName().getAssigningAuthorities().getAssigningAuthority();
471 String sAssigningAuthorityId = "";
472 String tempHomeCommunityId = "";
473 saHomeCommunityId = new ArrayList();
474 for (int i = 0; i < size; i++) {
475 sAssigningAuthorityId = assignList.get(i).getAssigningAuthorityId();
476 tempHomeCommunityId = mappingDao.getHomeCommunityId(sAssigningAuthorityId);
477 saHomeCommunityId.add(tempHomeCommunityId);
478 }
479 }
480 CMBusinessEntities oCMBusinessEntities = retrieveBusinessEntitySetByServiceNameFromCache(saHomeCommunityId, sServiceName);
481 oBusinessEntities = CMTransform.cmBusinessEntitiesToBusinessEntitiesType(oCMBusinessEntities);
482 return oBusinessEntities;
483 }
484
485 /**
486 * This retrieves the business entity from the cache by service name.
487 *
488 * @param sHomeCommunityId The home community id.
489 * @param sServiceName The name of the service.
490 * @return The Business entities that are retrieved.
491 */
492 private static CMBusinessEntity retrieveBusinessEntityByServiceNameFromCache(String sHomeCommunityId,
493 String sServiceName) {
494 CMBusinessEntity oCMBusinessEntity = null;
495
496 if ((sHomeCommunityId != null) &&
497 (sHomeCommunityId.length() > 0) &&
498 (sServiceName != null) &&
499 (sServiceName.length() > 0)) {
500 try {
501 oCMBusinessEntity = ConnectionManagerCache.getBusinessEntityByServiceName(sHomeCommunityId, sServiceName);
502 } catch (Throwable t) {
503 String sErrorMessage = "Failed to retrieve business entity. Error: " + t.getMessage();
504 log.error(sErrorMessage, t);
505 }
506 }
507
508 return oCMBusinessEntity;
509 }
510
511 /**
512 * This method retrieves the ConnectionInformation for a specific service at a specific home community.
513 *
514 * @param part1 This contains the home community identification and the name of the service that the
515 * connection info is desired.
516 * @return The connection information for the service at the specified home community.
517 */
518 public static ConnectionInfoType getConnectionInfoByServiceName(HomeCommunityWithServiceNameType part1) {
519 ConnectionInfoType oConnectionInfo = null;
520 String sServiceName = "";
521 String sHomeCommunityId = "";
522
523 if ((part1 != null) &&
524 (part1.getHomeCommunity() != null) &&
525 (part1.getHomeCommunity().getHomeCommunityId() != null) &&
526 (part1.getHomeCommunity().getHomeCommunityId().length() > 0) &&
527 (part1.getServiceName() != null) &&
528 (part1.getServiceName().length() > 0)) {
529 sServiceName = part1.getServiceName();
530 sHomeCommunityId = CMTransform.formatHomeCommunityId(part1.getHomeCommunity().getHomeCommunityId());
531 } else if ((part1 != null) &&
532 (part1.getAssigningAuthority() != null) &&
533 (part1.getAssigningAuthority().getAssigningAuthorityId() != null) &&
534 (part1.getAssigningAuthority().getAssigningAuthorityId().length() > 0) &&
535 (part1.getServiceName() != null) &&
536 (part1.getServiceName().length() > 0)) {
537 sServiceName = part1.getServiceName();
538 String assigningAuthId = part1.getAssigningAuthority().getAssigningAuthorityId();
539 AssigningAuthorityHomeCommunityMappingDAO mappingDao = new AssigningAuthorityHomeCommunityMappingDAO();
540 sHomeCommunityId = mappingDao.getHomeCommunityId(assigningAuthId);
541 }
542
543 if ((sServiceName != null) &&
544 (sServiceName.length() > 0) &&
545 (sHomeCommunityId != null) &&
546 (sHomeCommunityId.length() > 0)) {
547 CMBusinessEntity oCMBusinessEntity = retrieveBusinessEntityByServiceNameFromCache(sHomeCommunityId, sServiceName);
548 if (oCMBusinessEntity != null) {
549 // We already have a routine to transform a CMBusinessEntities - so use it...
550 //---------------------------------------------------------------------------
551 CMBusinessEntities oCMBusinessEntities = new CMBusinessEntities();
552 oCMBusinessEntities.getBusinessEntity().add(oCMBusinessEntity);
553 ConnectionInfosType oConnectionInfos = CMTransform.cmBusinessEntitiesToConnectionInfosType(oCMBusinessEntities);
554 if ((oConnectionInfos != null) &&
555 (oConnectionInfos.getConnectionInfo() != null) &&
556 (oConnectionInfos.getConnectionInfo().size() > 0)) {
557 // We only gave it one so we should only get one back...
558 //-------------------------------------------------------
559 oConnectionInfo = oConnectionInfos.getConnectionInfo().get(0);
560 }
561 }
562 }
563 return oConnectionInfo;
564 }
565
566 /**
567 * This method retrieves the endpoint Connection Information for a specific service at a
568 * specific home community.
569 *
570 * @param part1 This contains the home community identification and the name of the service that the
571 * connection info is desired.
572 * @return The endpoint connection information for the service at the specified home community.
573 */
574 public static ConnectionInfoEndpointType getConnectionInfoEndpointByServiceName(GetConnectionInfoEndpointByServiceNameRequestType part1) {
575 ConnectionInfoEndpointType oConnectionInfoEndpoint = null;
576 String sServiceName = "";
577 String sHomeCommunityId = "";
578
579 if ((part1 != null) &&
580 (part1.getHomeCommunityWithServiceName() != null) &&
581 (part1.getHomeCommunityWithServiceName().getHomeCommunity() != null) &&
582 (part1.getHomeCommunityWithServiceName().getHomeCommunity().getHomeCommunityId() != null) &&
583 (part1.getHomeCommunityWithServiceName().getHomeCommunity().getHomeCommunityId().length() > 0) &&
584 (part1.getHomeCommunityWithServiceName().getServiceName() != null) &&
585 (part1.getHomeCommunityWithServiceName().getServiceName().length() > 0)) {
586 sServiceName = part1.getHomeCommunityWithServiceName().getServiceName();
587 sHomeCommunityId = CMTransform.formatHomeCommunityId(part1.getHomeCommunityWithServiceName().getHomeCommunity().getHomeCommunityId());
588
589 } else if ((part1 != null) &&
590 (part1.getHomeCommunityWithServiceName() != null) &&
591 (part1.getHomeCommunityWithServiceName().getAssigningAuthority() != null) &&
592 (part1.getHomeCommunityWithServiceName().getAssigningAuthority().getAssigningAuthorityId() != null) &&
593 (part1.getHomeCommunityWithServiceName().getAssigningAuthority().getAssigningAuthorityId().length() > 0) &&
594 (part1.getHomeCommunityWithServiceName().getServiceName() != null) &&
595 (part1.getHomeCommunityWithServiceName().getServiceName().length() > 0)) {
596 String assigningAuthId = part1.getHomeCommunityWithServiceName().getAssigningAuthority().getAssigningAuthorityId();
597 AssigningAuthorityHomeCommunityMappingDAO mappingDao = new AssigningAuthorityHomeCommunityMappingDAO();
598 sHomeCommunityId = mappingDao.getHomeCommunityId(assigningAuthId);
599 sServiceName = part1.getHomeCommunityWithServiceName().getServiceName();
600 }
601
602 if (sServiceName != null && sServiceName.length() > 0 && sHomeCommunityId != null && sHomeCommunityId.length() > 0) {
603 CMBusinessEntity oCMBusinessEntity = retrieveBusinessEntityByServiceNameFromCache(sHomeCommunityId, sServiceName);
604 if (oCMBusinessEntity != null) {
605 // We already have a routine to transform a CMBusinessEntities - so use it...
606 //---------------------------------------------------------------------------
607 CMBusinessEntities oCMBusinessEntities = new CMBusinessEntities();
608 oCMBusinessEntities.getBusinessEntity().add(oCMBusinessEntity);
609 ConnectionInfoEndpointsType oConnectionInfoEndpoints = CMTransform.cmBusinessEntitiesToConnectionInfoEndpointsType(oCMBusinessEntities);
610 if ((oConnectionInfoEndpoints != null) &&
611 (oConnectionInfoEndpoints.getConnectionInfoEndpoint() != null) &&
612 (oConnectionInfoEndpoints.getConnectionInfoEndpoint().size() > 0)) {
613 // We only gave it one so we should only get one back...
614 //-------------------------------------------------------
615 oConnectionInfoEndpoint = oConnectionInfoEndpoints.getConnectionInfoEndpoint().get(0);
616 }
617 }
618 }
619 return oConnectionInfoEndpoint;
620 }
621
622 /**
623 * This method retrieves the business entity and Connection Information for a specific service
624 * at a specific home community.
625 *
626 * @param part1 This contains the home community identification and the name of the service that the
627 * connection info is desired.
628 * @return The connection information for the service at the specified home community.
629 */
630 public static BusinessEntityType getBusinessEntityByServiceName(GetBusinessEntityByServiceNameRequestType part1) {
631 BusinessEntityType oBusinessEntity = null;
632 String sServiceName = "";
633 String sHomeCommunityId = "";
634 String sAssigningAuthorityId = "";
635 if ((part1 != null) &&
636 (part1.getHomeCommunityWithServiceName() != null) &&
637 (part1.getHomeCommunityWithServiceName().getHomeCommunity() != null) &&
638 (part1.getHomeCommunityWithServiceName().getHomeCommunity().getHomeCommunityId() != null) &&
639 (part1.getHomeCommunityWithServiceName().getHomeCommunity().getHomeCommunityId().length() > 0) &&
640 (part1.getHomeCommunityWithServiceName().getServiceName() != null) &&
641 (part1.getHomeCommunityWithServiceName().getServiceName().length() > 0)) {
642 sServiceName = part1.getHomeCommunityWithServiceName().getServiceName();
643 sHomeCommunityId = CMTransform.formatHomeCommunityId(part1.getHomeCommunityWithServiceName().getHomeCommunity().getHomeCommunityId());
644 } else if ((part1 != null) &&
645 (part1.getHomeCommunityWithServiceName() != null) &&
646 (part1.getHomeCommunityWithServiceName().getAssigningAuthority() != null) &&
647 (part1.getHomeCommunityWithServiceName().getAssigningAuthority().getAssigningAuthorityId() != null) &&
648 (part1.getHomeCommunityWithServiceName().getAssigningAuthority().getAssigningAuthorityId().length() > 0) &&
649 (part1.getHomeCommunityWithServiceName().getServiceName() != null) &&
650 (part1.getHomeCommunityWithServiceName().getServiceName().length() > 0)) {
651 sServiceName = part1.getHomeCommunityWithServiceName().getServiceName();
652 sAssigningAuthorityId = part1.getHomeCommunityWithServiceName().getAssigningAuthority().getAssigningAuthorityId();
653 AssigningAuthorityHomeCommunityMappingDAO mappingDao = new AssigningAuthorityHomeCommunityMappingDAO();
654 sHomeCommunityId = mappingDao.getHomeCommunityId(sAssigningAuthorityId);
655 }
656
657 if (sHomeCommunityId != null && sHomeCommunityId.length() > 0 && sServiceName != null && sServiceName.length() > 0) {
658 CMBusinessEntity oCMBusinessEntity = retrieveBusinessEntityByServiceNameFromCache(sHomeCommunityId, sServiceName);
659 if (oCMBusinessEntity != null) {
660 // We already have a routine to transform a CMBusinessEntities - so use it...
661 //---------------------------------------------------------------------------
662 CMBusinessEntities oCMBusinessEntities = new CMBusinessEntities();
663 oCMBusinessEntities.getBusinessEntity().add(oCMBusinessEntity);
664 BusinessEntitiesType oBusinessEntities = CMTransform.cmBusinessEntitiesToBusinessEntitiesType(oCMBusinessEntities);
665 if ((oBusinessEntities != null) &&
666 (oBusinessEntities.getBusinessEntity() != null) &&
667 (oBusinessEntities.getBusinessEntity().size() > 0)) {
668 // We only gave it one so we should only get one back...
669 //-------------------------------------------------------
670 oBusinessEntity = oBusinessEntities.getBusinessEntity().get(0);
671 }
672 }
673 }
674 return oBusinessEntity;
675 }
676
677 /**
678 * This retrieves the business entity set from the cache by service name.
679 *
680 * @param sServiceName The name of the service.
681 * @return The Business entities that are retrieved.
682 */
683 private static CMBusinessEntities retrieveAllBusinessEntitySetByServiceNameFromCache(String sServiceName) {
684 CMBusinessEntities oCMBusinessEntities = null;
685
686 if ((sServiceName != null) &&
687 (sServiceName.length() > 0)) {
688 try {
689 oCMBusinessEntities = ConnectionManagerCache.getAllBusinessEntitySetByServiceName(sServiceName);
690 } catch (Throwable t) {
691 String sErrorMessage = "Failed to retrieve business entities. Error: " + t.getMessage();
692 log.error(sErrorMessage, t);
693 }
694 }
695
696 return oCMBusinessEntities;
697 }
698
699 /**
700 * This method returns the connection information for all known home communities that support the specified
701 * service.
702 *
703 * @param part1 The name of the service that is desired.
704 * @return The connection information for each known home community that supports the specified service.
705 */
706 public static ConnectionInfosType getAllConnectionInfoSetByServiceName(GetAllConnectionInfoSetByServiceNameRequestType part1) {
707 ConnectionInfosType oConnectionInfos = null;
708
709 if ((part1 != null) &&
710 (part1.getServiceName() != null) &&
711 (part1.getServiceName().length() > 0)) {
712 String sServiceName = part1.getServiceName();
713
714 CMBusinessEntities oCMBusinessEntities = retrieveAllBusinessEntitySetByServiceNameFromCache(sServiceName);
715 oConnectionInfos = CMTransform.cmBusinessEntitiesToConnectionInfosType(oCMBusinessEntities);
716
717 } // if ((part1 != null) &&
718
719 return oConnectionInfos;
720 }
721
722 /**
723 * This method returns the endpoint connection information for all known home communities that
724 * support the specified service.
725 *
726 * @param part1 The name of the service that is desired.
727 * @return The endpoint connection information for each known home community that
728 * supports the specified service.
729 */
730 public static ConnectionInfoEndpointsType getAllConnectionInfoEndpointSetByServiceName(GetAllConnectionInfoEndpointSetByServiceNameRequestType part1) {
731 ConnectionInfoEndpointsType oConnectionInfoEndpoints = null;
732
733 if ((part1 != null) &&
734 (part1.getServiceName() != null) &&
735 (part1.getServiceName().length() > 0)) {
736 String sServiceName = part1.getServiceName();
737
738 CMBusinessEntities oCMBusinessEntities = retrieveAllBusinessEntitySetByServiceNameFromCache(sServiceName);
739 oConnectionInfoEndpoints = CMTransform.cmBusinessEntitiesToConnectionInfoEndpointsType(oCMBusinessEntities);
740
741 } // if ((part1 != null) &&
742
743 return oConnectionInfoEndpoints;
744 }
745
746 /**
747 * This method returns the business entity and service connection information for all known
748 * home communities that support the specified service.
749 *
750 * @param part1 The name of the service that is desired.
751 * @return The business entity and service connection information for each known
752 * home community that supports the specified service.
753 */
754 public static BusinessEntitiesType getAllBusinessEntitySetByServiceName(GetAllBusinessEntitySetByServiceNameRequestType part1) {
755 BusinessEntitiesType oBusinessEntities = null;
756
757 if ((part1 != null) &&
758 (part1.getServiceName() != null) &&
759 (part1.getServiceName().length() > 0)) {
760 String sServiceName = part1.getServiceName();
761
762 CMBusinessEntities oCMBusinessEntities = retrieveAllBusinessEntitySetByServiceNameFromCache(sServiceName);
763 oBusinessEntities = CMTransform.cmBusinessEntitiesToBusinessEntitiesType(oCMBusinessEntities);
764
765 } // if ((part1 != null) &&
766
767 return oBusinessEntities;
768 }
769
770 /**
771 * This method does nothing. The issue here is that refreshing the
772 * cache now is dependent on the timestamp of the uddiConnectionInfo.xml
773 * file changing. So anytime that timestamp changes, it will automatically
774 * flush. so this method is no longer needed.
775 *
776 * @param part1 The only purpose for this parameter is so that the
777 * web service has a unique document that identifies this
778 * operation. The values themselves are not used.
779 * @return Whether this succeeded or failed.
780 */
781 public static SuccessOrFailType forceRefreshUDDICache(ForceRefreshUDDICacheRequestType part1) {
782 SuccessOrFailType oSuccessOrFailType = new SuccessOrFailType();
783 oSuccessOrFailType.setSuccess(false);
784 return oSuccessOrFailType;
785 }
786
787 /**
788 * This method causes the Internal Connection service information to be refreshed.
789 *
790 * @param part1 The only purpose for this parameter is so that the
791 * web service has a unique document that identifies this
792 * operation. The values themselves are not used.
793 * @return Whether this succeeded or failed.
794 */
795 public static SuccessOrFailType forceRefreshInternalConnectCache(ForceRefreshInternalConnectCacheRequestType part1) {
796 SuccessOrFailType oSuccessOrFailType = new SuccessOrFailType();
797
798 try {
799 ConnectionManagerCache.forceRefreshInternalConnectCache();
800 oSuccessOrFailType.setSuccess(true);
801 } catch (Throwable t) {
802 String sErrorMessage = "Failed to call ConnectionManagerCache.forceRefreshInternalConnectionCache()";
803 log.error(sErrorMessage, t);
804 oSuccessOrFailType.setSuccess(false);
805
806 }
807 return oSuccessOrFailType;
808 }
809
810 public static AcknowledgementType storeAssigningAuthorityToHomeCommunityMapping(StoreAssigningAuthorityToHomeCommunityMappingRequestType storeAssigningAuthorityToHomeCommunityMappingRequest) {
811 log.debug("--Begin CMServiceHelper.storeAssigningAuthorityToHomeCommunityMapping() --");
812 String success = "";
813 AcknowledgementType ack = new AcknowledgementType();
814 if (storeAssigningAuthorityToHomeCommunityMappingRequest == null) {
815 ack.setMessage("Input mapping data not found");
816 log.error("--Input mapping data not found --");
817 return ack;
818 }
819
820 if (storeAssigningAuthorityToHomeCommunityMappingRequest.getAssigningAuthority() == null) {
821 ack.setMessage("Set proper assigning authority");
822 log.error("--Set proper assigning authority --");
823 return ack;
824 }
825
826 if (storeAssigningAuthorityToHomeCommunityMappingRequest.getAssigningAuthority().getAssigningAuthorityId() == null) {
827 ack.setMessage("Set proper assigning authority Id value");
828 log.error("--Set proper assigning authority Id value --");
829 return ack;
830 }
831
832 String assigningAuthId = storeAssigningAuthorityToHomeCommunityMappingRequest.getAssigningAuthority().getAssigningAuthorityId();
833
834 if (storeAssigningAuthorityToHomeCommunityMappingRequest.getHomeCommunity() == null) {
835 ack.setMessage("Unable to store mapping, Set home community properly");
836 log.error("--Unable to store mapping, Set home community properly --");
837 return ack;
838 }
839
840 if (storeAssigningAuthorityToHomeCommunityMappingRequest.getHomeCommunity().getHomeCommunityId() == null) {
841 ack.setMessage("Unable to store mapping, Set proper Home Community Id");
842 log.error("--Unable to store mapping, Set proper Home Community Id --");
843 return ack;
844 }
845 String homeCommId = CMTransform.formatHomeCommunityId(storeAssigningAuthorityToHomeCommunityMappingRequest.getHomeCommunity().getHomeCommunityId());
846 AssigningAuthorityHomeCommunityMappingDAO mappingDao = new AssigningAuthorityHomeCommunityMappingDAO();
847 boolean result = mappingDao.storeMapping(homeCommId, assigningAuthId);
848 if (result) {
849 success = "Successfully stored mapping";
850 log.debug("Successfully stored mapping");
851 } else {
852 success = "Map not stored similar map already exists in the repository";
853 log.warn("Map not stored similar map already exists in the repository");
854 }
855 ack.setMessage(success);
856 log.debug("--End CMServiceHelper.storeAssigningAuthorityToHomeCommunityMapping() --");
857 return ack;
858 }
859
860 public static GetAssigningAuthoritiesByHomeCommunityResponseType getAssigningAuthoritiesByHomeCommunity(GetAssigningAuthoritiesByHomeCommunityRequestType requestType) {
861 log.debug("-- Begin CMServiceHelper.getAssigningAuthoritiesByHomeCommunity() --");
862 GetAssigningAuthoritiesByHomeCommunityResponseType responseType = null;
863 if (requestType == null) {
864 return null;
865 }
866 HomeCommunityType hcType = requestType.getHomeCommunity();
867 if (hcType == null) {
868 return null;
869 }
870 String hcId = CMTransform.formatHomeCommunityId(hcType.getHomeCommunityId());
871 if (hcId != null && !hcId.equals("")) {
872 AssigningAuthorityHomeCommunityMappingDAO mappingDao = new AssigningAuthorityHomeCommunityMappingDAO();
873 responseType = new GetAssigningAuthoritiesByHomeCommunityResponseType();
874 AssigningAuthoritiesType aaType = new AssigningAuthoritiesType();
875 List<String> aaList = mappingDao.getAssigningAuthoritiesByHomeCommunity(hcId);
876 if(aaList!=null && aaList.size()>0)
877 {
878 AssigningAuthorityType aayType = null;
879 for(String sAA : aaList)
880 {
881 log.debug("Assiging Authorities for ");
882 aayType = new AssigningAuthorityType();
883 aayType.setAssigningAuthorityId(sAA);
884 aaType.getAssigningAuthority().add(aayType);
885 }
886 }
887 responseType.setAssigningAuthoritiesId(aaType);
888 }
889 log.debug("-- Begin CMServiceHelper.getAssigningAuthoritiesByHomeCommunity() --");
890 return responseType;
891 }
892
893 /**
894 *
895 * @param requestType
896 * @return GetHomeCommunityByAssigningAuthorityResponseType
897 */
898 public static GetHomeCommunityByAssigningAuthorityResponseType getHomeCommunityByAssigningAuthority(GetHomeCommunityByAssigningAuthorityRequestType requestType) {
899 if (requestType == null) {
900 return null;
901 }
902 if (requestType.getAssigningAuthorities() == null) {
903 return null;
904 }
905 if (requestType.getAssigningAuthorities().getAssigningAuthorityId() == null) {
906 return null;
907 }
908 String assigningAuthId = requestType.getAssigningAuthorities().getAssigningAuthorityId();
909 AssigningAuthorityHomeCommunityMappingDAO mappingDao = new AssigningAuthorityHomeCommunityMappingDAO();
910 GetHomeCommunityByAssigningAuthorityResponseType resType = new GetHomeCommunityByAssigningAuthorityResponseType();
911 HomeCommunityType hc = new HomeCommunityType();
912 hc.setHomeCommunityId(mappingDao.getHomeCommunityId(assigningAuthId));
913 resType.setHomeCommunity(hc);
914 return resType;
915 }
916
917 /**
918 *
919 * @param requestType
920 * @return GetHomeCommunityByAssigningAuthorityResponseType
921 */
922 public static EPRType getConnectionInfoEndpontFromNhinTarget(GetConnectionInfoEndpontFromNhinTargetType message) {
923 ConnectionInfoEndpointType oConnectionInfoEndpoint = null;
924 EPRType endPtRef = null;
925
926 if (message != null &&
927 message.getNhinTargetSystem() != null) {
928 if (message.getNhinTargetSystem().getEpr() != null) {
929 // Just echo back the Endpoint Reference that was sent into this method
930 endPtRef = message.getNhinTargetSystem().getEpr();
931 } else if (NullChecker.isNotNullish(message.getNhinTargetSystem().getUrl()) &&
932 NullChecker.isNotNullish(message.getServiceName())) {
933 // Get the Endpoint Reference based on URL and Service Name
934 endPtRef = CMTransform.createEPR(message.getServiceName(), message.getNhinTargetSystem().getUrl());
935 } else if (message.getNhinTargetSystem().getHomeCommunity() != null &&
936 NullChecker.isNotNullish(message.getNhinTargetSystem().getHomeCommunity().getHomeCommunityId()) &&
937 NullChecker.isNotNullish(message.getServiceName())) {
938 // Get the Endpoint Reference based on Home Community Id and Service Name
939 CMBusinessEntity oCMBusinessEntity = retrieveBusinessEntityByServiceNameFromCache(message.getNhinTargetSystem().getHomeCommunity().getHomeCommunityId(), message.getServiceName());
940
941 if (oCMBusinessEntity != null) {
942 CMBusinessEntities oCMBusinessEntities = new CMBusinessEntities();
943 oCMBusinessEntities.getBusinessEntity().add(oCMBusinessEntity);
944 ConnectionInfoEndpointsType oConnectionInfoEndpoints = CMTransform.cmBusinessEntitiesToConnectionInfoEndpointsType(oCMBusinessEntities);
945
946 if ((oConnectionInfoEndpoints != null) &&
947 NullChecker.isNotNullish(oConnectionInfoEndpoints.getConnectionInfoEndpoint())) {
948 oConnectionInfoEndpoint = oConnectionInfoEndpoints.getConnectionInfoEndpoint().get(0);
949
950 if (oConnectionInfoEndpoint.getServiceConnectionInfoEndpoints() != null &&
951 NullChecker.isNotNullish(oConnectionInfoEndpoint.getServiceConnectionInfoEndpoints().getServiceConnectionInfoEndpoint()) &&
952 oConnectionInfoEndpoint.getServiceConnectionInfoEndpoints().getServiceConnectionInfoEndpoint().get(0).getEPR() != null) {
953 endPtRef = oConnectionInfoEndpoint.getServiceConnectionInfoEndpoints().getServiceConnectionInfoEndpoint().get(0).getEPR();
954 }
955 }
956 }
957 }
958 }
959
960 return endPtRef;
961 }
962}
Note: See TracBrowser for help on using the repository browser.