/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package gov.hhs.fha.nhinc.subscription.dte; //import gov.hhs.fha.nhinc.subscription.*; import gov.hhs.fha.nhinc.common.nhinccommonadapter.NotifySubscribersOfDocumentRequestType; //import gov.hhs.fha.nhinc.subscription_b_2_overridefordocuments.*; //import gov.hhs.fha.nhinc.subscription_b_2_overridefordocuments.NotificationMessageHolderType.Message; import gov.hhs.fha.nhinc.common.subscriptionb2overridefordocuments.NotificationMessageHolderType; import gov.hhs.fha.nhinc.common.subscriptionb2overridefordocuments.NotificationMessageHolderType.Message; import gov.hhs.fha.nhinc.common.subscriptionb2overridefordocuments.NotifyDocumentType; import ihe.iti.xds_b._2007.RetrieveDocumentSetRequestType; import javax.xml.bind.JAXBElement; import javax.xml.ws.wsaddressing.W3CEndpointReference; import org.oasis_open.docs.wsn.b_2.Notify; //import gov.hhs.fha.nhinc.subscriptiondte.*; //import ihe.iti.xds_b._2007.RetrieveDocumentSetRequestType; //import javax.xml.bind.JAXBElement; //import javax.xml.ws.wsaddressing.W3CEndpointReference; //import org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType; //import org.oasis_open.docs.wsn.b_2.Notify; /** * * @author rayj */ public class CreateAgencyNotifyDocumentHelper { private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(CreateAgencyNotifyDocumentHelper.class); public static gov.hhs.fha.nhinc.common.subscriptiondte.CreateAgencyNotifyDocumentResponseType createAgencyNotifyDocument(gov.hhs.fha.nhinc.common.subscriptiondte.CreateAgencyNotifyDocumentRequestType createNotifyRequest) { gov.hhs.fha.nhinc.common.subscriptiondte.CreateAgencyNotifyDocumentResponseType response = new gov.hhs.fha.nhinc.common.subscriptiondte.CreateAgencyNotifyDocumentResponseType(); NotifySubscribersOfDocumentRequestType agencyNotifyMessage = new NotifySubscribersOfDocumentRequestType(); NotifyDocumentType agencyNotify = new NotifyDocumentType(); agencyNotifyMessage.setNotify(agencyNotify); NotificationMessageHolderType agencyNotificationHolder = new gov.hhs.fha.nhinc.common.subscriptionb2overridefordocuments.NotificationMessageHolderType(); agencyNotify.getNotificationMessage().add(agencyNotificationHolder); Notify nhinNotify = createNotifyRequest.getNotify(); org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType notificationMessageHolder = NotifyHelper.getNotificationMessageHolder(nhinNotify); log.info("getting documents"); RetrieveDocumentSetRequestType documents = getDocuments(nhinNotify); log.info("(documents==null)=" + (documents == null)); if (documents != null) { log.info("(documents.getDocumentRequest().size())=" + (documents.getDocumentRequest().size())); } Message agencyInnerMessage = new Message(); agencyNotificationHolder.setMessage(agencyInnerMessage); agencyInnerMessage.setRetrieveDocumentSetRequest(documents); W3CEndpointReference nhinSubscriptionReference = SubscriptionReferenceHelper.createNhinSubscriptionReference(createNotifyRequest.getSubscriptionReference()); agencyNotificationHolder.setSubscriptionReference(nhinSubscriptionReference); response.setNotifySubscribersOfDocumentRequest(agencyNotifyMessage); return response; } private static RetrieveDocumentSetRequestType getDocuments(Notify nhinNotify) { RetrieveDocumentSetRequestType documentInfos = null; org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType notificationMessageHolder = NotifyHelper.getNotificationMessageHolder(nhinNotify); Object anyItem = notificationMessageHolder.getMessage().getAny(); if (anyItem instanceof JAXBElement) { JAXBElement jbElement = (JAXBElement) anyItem; Object jbElementValue = jbElement.getValue(); if (jbElementValue instanceof RetrieveDocumentSetRequestType) { documentInfos = (RetrieveDocumentSetRequestType) jbElementValue; } } else if (anyItem instanceof ihe.iti.xds_b._2007.RetrieveDocumentSetRequestType) { documentInfos = (RetrieveDocumentSetRequestType) anyItem; } else { log.info("unhandled anyItem in getDocuments() => " + anyItem); } return documentInfos; } }