Search in sources :

Example 1 with XdConfig

use of org.nhind.xdr.config.XdConfig in project nhin-d by DirectProject.

the class DocumentRepositoryAbstract method getResolver.

private RoutingResolver getResolver() {
    if (resolver == null) {
        String configService = null;
        try {
            configService = getServletContext().getInitParameter(PARAM_CONFIG_SERVICE);
        } catch (Exception x) {
        // eat it
        }
        if (StringUtils.isNotBlank(configService)) {
            try {
                resolver = new RoutingResolverImpl(configService);
                config = new XdConfig(configService);
            } catch (Exception e) {
                LOGGER.warning("Unable to create resolver from URL, falling back to default");
                resolver = new RoutingResolverImpl();
            }
        } else {
            resolver = new RoutingResolverImpl();
        }
    }
    return resolver;
}
Also used : RoutingResolverImpl(org.nhindirect.xd.routing.impl.RoutingResolverImpl) XdConfig(org.nhind.xdr.config.XdConfig)

Example 2 with XdConfig

use of org.nhind.xdr.config.XdConfig in project nhin-d by DirectProject.

the class DocumentRepositoryAbstract method getConfig.

private XdConfig getConfig() {
    XdConfig lconfig = null;
    String configService = null;
    try {
        configService = getServletContext().getInitParameter(PARAM_CONFIG_SERVICE);
    } catch (Exception e) {
        // TODO: define a custom exception
        throw new RuntimeException("Unable to find XD configuration URL", e);
    }
    if (StringUtils.isNotBlank(configService)) {
        try {
            lconfig = new XdConfig(configService);
        } catch (Exception e) {
            // TODO: define a custom exception
            throw new RuntimeException("Unable to create config from URL", e);
        }
    } else {
        // TODO: define a custom exception
        throw new RuntimeException("Configuration URL is blank");
    }
    return lconfig;
}
Also used : XdConfig(org.nhind.xdr.config.XdConfig)

Example 3 with XdConfig

use of org.nhind.xdr.config.XdConfig 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 4 with XdConfig

use of org.nhind.xdr.config.XdConfig in project nhin-d by DirectProject.

the class XDRTest method testDocumentRepositoryRetrieveDocumentSet.

/**
     * Test the documentRepositoryRetrieveDocumentSet method.
     */
public void testDocumentRepositoryRetrieveDocumentSet() throws Exception {
    try {
        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"));
        XdConfig config = new XdConfig();
        config.setMailHost("gmail-smtp.l.google.com");
        config.setMailUser("lewistower1@gmail.com");
        config.setMailPass("hadron106");
        instance.setConfig(config);
        @SuppressWarnings("unused") RetrieveDocumentSetResponseType response = null;
        RetrieveDocumentSetRequestType body = new RetrieveDocumentSetRequestType();
        response = instance.documentRepositoryRetrieveDocumentSet(body);
        fail("Exception not thrown");
    } catch (UnsupportedOperationException e) {
        assertTrue(true);
    }
}
Also used : RetrieveDocumentSetResponseType(ihe.iti.xds_b._2007.RetrieveDocumentSetResponseType) XdConfig(org.nhind.xdr.config.XdConfig) AuditMessageGenerator(com.gsihealth.auditclient.AuditMessageGenerator) RetrieveDocumentSetRequestType(ihe.iti.xds_b._2007.RetrieveDocumentSetRequestType)

Aggregations

XdConfig (org.nhind.xdr.config.XdConfig)4 AuditMessageGenerator (com.gsihealth.auditclient.AuditMessageGenerator)2 RoutingResolverImpl (org.nhindirect.xd.routing.impl.RoutingResolverImpl)2 ProvideAndRegisterDocumentSetRequestType (ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType)1 RetrieveDocumentSetRequestType (ihe.iti.xds_b._2007.RetrieveDocumentSetRequestType)1 RetrieveDocumentSetResponseType (ihe.iti.xds_b._2007.RetrieveDocumentSetResponseType)1 JAXBElement (javax.xml.bind.JAXBElement)1 QName (javax.xml.namespace.QName)1 RegistryResponseType (oasis.names.tc.ebxml_regrep.xsd.rs._3.RegistryResponseType)1