Search in sources :

Example 1 with SafeThreadData

use of org.nhindirect.xd.soap.SafeThreadData in project nhin-d by DirectProject.

the class XDR method documentRepositoryProvideAndRegisterDocumentSetB.

/* 
     * (non-Javadoc)
     * 
     * @see org.nhind.xdr.DocumentRepositoryAbstract#documentRepositoryProvideAndRegisterDocumentSetB(ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType)
     */
public RegistryResponseType documentRepositoryProvideAndRegisterDocumentSetB(ProvideAndRegisterDocumentSetRequestType body) {
    RegistryResponseType resp = null;
    /**
       * Get thread data
       */
    Long threadID = Thread.currentThread().getId();
    SafeThreadData threadData = SafeThreadData.GetThreadInstance(threadID);
    try {
        resp = provideAndRegisterDocumentSet(body, threadData);
    } catch (Exception x) {
        threadData.setRelatesTo(threadData.getMessageId());
        threadData.setAction("urn:ihe:iti:2007:ProvideAndRegisterDocumentSet-bResponse");
        threadData.setMessageId(UUID.randomUUID().toString());
        threadData.setTo(threadData.getEndpoint());
        threadData.save();
        resp = new RegistryResponseType();
        resp.setStatus("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Failure");
        RegistryErrorList rel = new RegistryErrorList();
        String error = x.getMessage();
        if (error == null) {
            error = x.toString();
        }
        rel.setHighestSeverity(error);
        List<RegistryError> rl = rel.getRegistryError();
        RegistryError re = new RegistryError();
        String[] mess;
        if (error.contains(":"))
            mess = error.split(":");
        else
            mess = error.split(" ");
        String errorCode = mess[0];
        re.setErrorCode(errorCode);
        re.setSeverity("Error");
        re.setCodeContext(error);
        re.setLocation("XDR.java");
        re.setValue(error);
        rl.add(re);
        resp.setRegistryErrorList(rel);
    }
    return resp;
}
Also used : RegistryError(oasis.names.tc.ebxml_regrep.xsd.rs._3.RegistryError) SafeThreadData(org.nhindirect.xd.soap.SafeThreadData) RegistryErrorList(oasis.names.tc.ebxml_regrep.xsd.rs._3.RegistryErrorList) RegistryErrorList(oasis.names.tc.ebxml_regrep.xsd.rs._3.RegistryErrorList) List(java.util.List) RegistryResponseType(oasis.names.tc.ebxml_regrep.xsd.rs._3.RegistryResponseType)

Example 2 with SafeThreadData

use of org.nhindirect.xd.soap.SafeThreadData 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)2 SafeThreadData (org.nhindirect.xd.soap.SafeThreadData)2 List (java.util.List)1 RegistryError (oasis.names.tc.ebxml_regrep.xsd.rs._3.RegistryError)1 RegistryErrorList (oasis.names.tc.ebxml_regrep.xsd.rs._3.RegistryErrorList)1 DocumentRepositoryProxy (org.nhindirect.xd.proxy.DocumentRepositoryProxy)1 DirectSOAPHandlerResolver (org.nhindirect.xd.soap.DirectSOAPHandlerResolver)1