source: ccr/trunk/nhin-vista/projects/NHINC/Current/Product/Production/Gateway/SubscriptionDteEjb/src/java/gov/hhs/fha/nhinc/subscription/dte/CreateAgencyNotifyDocumentHelper.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: 4.4 KB
Line 
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5package gov.hhs.fha.nhinc.subscription.dte;
6
7//import gov.hhs.fha.nhinc.subscription.*;
8import gov.hhs.fha.nhinc.common.nhinccommonadapter.NotifySubscribersOfDocumentRequestType;
9
10
11//import gov.hhs.fha.nhinc.subscription_b_2_overridefordocuments.*;
12//import gov.hhs.fha.nhinc.subscription_b_2_overridefordocuments.NotificationMessageHolderType.Message;
13import gov.hhs.fha.nhinc.common.subscriptionb2overridefordocuments.NotificationMessageHolderType;
14import gov.hhs.fha.nhinc.common.subscriptionb2overridefordocuments.NotificationMessageHolderType.Message;
15import gov.hhs.fha.nhinc.common.subscriptionb2overridefordocuments.NotifyDocumentType;
16import ihe.iti.xds_b._2007.RetrieveDocumentSetRequestType;
17import javax.xml.bind.JAXBElement;
18import javax.xml.ws.wsaddressing.W3CEndpointReference;
19import org.oasis_open.docs.wsn.b_2.Notify;
20//import gov.hhs.fha.nhinc.subscriptiondte.*;
21//import ihe.iti.xds_b._2007.RetrieveDocumentSetRequestType;
22//import javax.xml.bind.JAXBElement;
23//import javax.xml.ws.wsaddressing.W3CEndpointReference;
24//import org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType;
25//import org.oasis_open.docs.wsn.b_2.Notify;
26/**
27 *
28 * @author rayj
29 */
30public class CreateAgencyNotifyDocumentHelper {
31
32 private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(CreateAgencyNotifyDocumentHelper.class);
33
34 public static gov.hhs.fha.nhinc.common.subscriptiondte.CreateAgencyNotifyDocumentResponseType createAgencyNotifyDocument(gov.hhs.fha.nhinc.common.subscriptiondte.CreateAgencyNotifyDocumentRequestType createNotifyRequest) {
35 gov.hhs.fha.nhinc.common.subscriptiondte.CreateAgencyNotifyDocumentResponseType response = new gov.hhs.fha.nhinc.common.subscriptiondte.CreateAgencyNotifyDocumentResponseType();
36
37 NotifySubscribersOfDocumentRequestType agencyNotifyMessage = new NotifySubscribersOfDocumentRequestType();
38 NotifyDocumentType agencyNotify = new NotifyDocumentType();
39 agencyNotifyMessage.setNotify(agencyNotify);
40
41 NotificationMessageHolderType agencyNotificationHolder = new gov.hhs.fha.nhinc.common.subscriptionb2overridefordocuments.NotificationMessageHolderType();
42 agencyNotify.getNotificationMessage().add(agencyNotificationHolder);
43
44 Notify nhinNotify = createNotifyRequest.getNotify();
45 org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType notificationMessageHolder = NotifyHelper.getNotificationMessageHolder(nhinNotify);
46
47 log.info("getting documents");
48 RetrieveDocumentSetRequestType documents = getDocuments(nhinNotify);
49 log.info("(documents==null)=" + (documents == null));
50 if (documents != null) {
51 log.info("(documents.getDocumentRequest().size())=" + (documents.getDocumentRequest().size()));
52 }
53 Message agencyInnerMessage = new Message();
54 agencyNotificationHolder.setMessage(agencyInnerMessage);
55 agencyInnerMessage.setRetrieveDocumentSetRequest(documents);
56
57 W3CEndpointReference nhinSubscriptionReference = SubscriptionReferenceHelper.createNhinSubscriptionReference(createNotifyRequest.getSubscriptionReference());
58 agencyNotificationHolder.setSubscriptionReference(nhinSubscriptionReference);
59
60 response.setNotifySubscribersOfDocumentRequest(agencyNotifyMessage);
61 return response;
62 }
63
64 private static RetrieveDocumentSetRequestType getDocuments(Notify nhinNotify) {
65 RetrieveDocumentSetRequestType documentInfos = null;
66
67 org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType notificationMessageHolder = NotifyHelper.getNotificationMessageHolder(nhinNotify);
68 Object anyItem = notificationMessageHolder.getMessage().getAny();
69 if (anyItem instanceof JAXBElement) {
70 JAXBElement jbElement = (JAXBElement) anyItem;
71 Object jbElementValue = jbElement.getValue();
72 if (jbElementValue instanceof RetrieveDocumentSetRequestType) {
73 documentInfos = (RetrieveDocumentSetRequestType) jbElementValue;
74 }
75 } else if (anyItem instanceof ihe.iti.xds_b._2007.RetrieveDocumentSetRequestType) {
76 documentInfos = (RetrieveDocumentSetRequestType) anyItem;
77 } else {
78 log.info("unhandled anyItem in getDocuments() => " + anyItem);
79 }
80 return documentInfos;
81 }
82}
Note: See TracBrowser for help on using the repository browser.