Search in sources :

Example 6 with RegistryResponseType

use of oasis.names.tc.ebxml_regrep.xsd.rs._3.RegistryResponseType in project nhin-d by DirectProject.

the class XDRTest method testDocumentRepositoryProvideAndRegisterDocumentSetB.

/**
     * Test of documentRepositoryProvideAndRegisterDocumentSetB method, of class XDR.
     */
public void testDocumentRepositoryProvideAndRegisterDocumentSetB() throws Exception {
    System.out.println("documentRepositoryProvideAndRegisterDocumentSetB");
    QName qname = new QName("urn:ihe:iti:xds-b:2007", "ProvideAndRegisterDocumentSetRequestType");
    ProvideAndRegisterDocumentSetRequestType body = null;
    try {
        String request = getTestRequest();
        JAXBElement jb = (JAXBElement) XmlUtils.unmarshal(request, ihe.iti.xds_b._2007.ObjectFactory.class);
        body = (ProvideAndRegisterDocumentSetRequestType) jb.getValue();
    } catch (Exception x) {
        x.printStackTrace();
        fail("Failed unmarshalling request");
    }
    DocumentRepositoryAbstract instance = new XDR();
    // Set test objects
    instance.setAuditMessageGenerator(new AuditMessageGenerator(getLogfile()));
    // instance.setMailClient(new SmtpMailClient("gmail-smtp.l.google.com", "lewistower1@gmail.com", "hadron106"));
    instance.setResolver(new RoutingResolverImpl());
    XdConfig config = new XdConfig();
    config.setMailHost("gmail-smtp.l.google.com");
    config.setMailUser("lewistower1@gmail.com");
    config.setMailPass("hadron106");
    instance.setConfig(config);
    RegistryResponseType result = instance.documentRepositoryProvideAndRegisterDocumentSetB(body);
    if (result.getStatus().contains("Failure")) {
        // some organizational firewalls may block this test, so bail out gracefully if that happens
        return;
    }
    String sresult = null;
    try {
        qname = new QName("urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0", "RegistryResponseType");
        sresult = XmlUtils.marshal(qname, result, oasis.names.tc.ebxml_regrep.xsd.rs._3.ObjectFactory.class);
    } catch (Exception x) {
        x.printStackTrace();
        fail("Failed unmarshalling response");
    }
    // System.out.println(sresult);
    assertTrue(sresult.indexOf("ResponseStatusType:Success") >= 0);
}
Also used : QName(javax.xml.namespace.QName) JAXBElement(javax.xml.bind.JAXBElement) RoutingResolverImpl(org.nhindirect.xd.routing.impl.RoutingResolverImpl) XdConfig(org.nhind.xdr.config.XdConfig) AuditMessageGenerator(com.gsihealth.auditclient.AuditMessageGenerator) RegistryResponseType(oasis.names.tc.ebxml_regrep.xsd.rs._3.RegistryResponseType) ProvideAndRegisterDocumentSetRequestType(ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType)

Example 7 with RegistryResponseType

use of oasis.names.tc.ebxml_regrep.xsd.rs._3.RegistryResponseType in project nhin-d by DirectProject.

the class DocumentRepository method forwardRequest.

/**
     * Forward a given ProvideAndRegisterDocumentSetRequestType object to the
     * given XDR endpoint.
     * 
     * @param endpoint
     *            A URL representing an XDR endpoint.
     * @param prds
     *            The ProvideAndRegisterDocumentSetRequestType object.
     * @throws Exception
     */
public String forwardRequest(String endpoint, ProvideAndRegisterDocumentSetRequestType prds, String directTo, String directFrom) throws Exception {
    if (StringUtils.isBlank(endpoint))
        throw new IllegalArgumentException("Endpoint must not be blank");
    if (prds == null)
        throw new IllegalArgumentException("ProvideAndRegisterDocumentSetRequestType must not be null");
    LOGGER.info(" SENDING TO ENDPOINT " + endpoint);
    /**
         * Get thread data by Thread ID
         */
    Long threadID = Thread.currentThread().getId();
    SafeThreadData threadData = SafeThreadData.GetThreadInstance(threadID);
    threadData.setAction("urn:ihe:iti:2007:ProvideAndRegisterDocumentSet-b");
    threadData.setMessageId(UUID.randomUUID().toString());
    threadData.setTo(endpoint);
    threadData.setDirectFrom(directFrom);
    threadData.setDirectTo(directTo);
    threadData.save();
    // Inspect the message
    //
    // QName qname = new QName("urn:ihe:iti:xds-b:2007", "ProvideAndRegisterDocumentSet_bRequest");
    // String body = XMLUtils.marshal(qname, prds, ihe.iti.xds_b._2007.ObjectFactory.class);
    // LOGGER.info(body);
    DocumentRepositoryProxy proxy = new DocumentRepositoryProxy(endpoint, new DirectSOAPHandlerResolver());
    try {
        RegistryResponseType rrt = proxy.provideAndRegisterDocumentSetB(prds);
        String response = rrt.getStatus();
        if (StringUtils.contains(response, "Failure")) {
            throw new Exception("Failure Returned from XDR forward");
        }
        SafeThreadData.clean(threadID);
        LOGGER.info("Handling complete");
        return response;
    } catch (Exception ex) {
        SafeThreadData.clean(threadID);
        throw ex;
    }
}
Also used : SafeThreadData(org.nhindirect.xd.soap.SafeThreadData) DirectSOAPHandlerResolver(org.nhindirect.xd.soap.DirectSOAPHandlerResolver) RegistryResponseType(oasis.names.tc.ebxml_regrep.xsd.rs._3.RegistryResponseType) DocumentRepositoryProxy(org.nhindirect.xd.proxy.DocumentRepositoryProxy)

Aggregations

RegistryResponseType (oasis.names.tc.ebxml_regrep.xsd.rs._3.RegistryResponseType)7 DocumentRepositoryProxy (org.nhindirect.xd.proxy.DocumentRepositoryProxy)3 DirectSOAPHandlerResolver (org.nhindirect.xd.soap.DirectSOAPHandlerResolver)3 Document (ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType.Document)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 DataHandler (javax.activation.DataHandler)2 DataSource (javax.activation.DataSource)2 ByteArrayDataSource (javax.mail.util.ByteArrayDataSource)2 InitialContext (javax.naming.InitialContext)2 MailClient (org.nhind.xdm.MailClient)2 SmtpMailClient (org.nhind.xdm.impl.SmtpMailClient)2 DirectDocuments (org.nhindirect.xd.common.DirectDocuments)2 DirectMessage (org.nhindirect.xd.common.DirectMessage)2 SafeThreadData (org.nhindirect.xd.soap.SafeThreadData)2 AuditMessageGenerator (com.gsihealth.auditclient.AuditMessageGenerator)1 DocumentRepositoryPortType (ihe.iti.xds_b._2007.DocumentRepositoryPortType)1 ProvideAndRegisterDocumentSetRequestType (ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType)1 List (java.util.List)1