private void doRegisterDocumentAndCheckError( SubmitObjectsRequest req, String errorCode, String prefix) { RegistryResponseType rsp = null; try { rsp = session.documentRegistryRegisterDocumentSetB(req); } catch (Exception x) { fail(prefix + ": Register document failed unexpected! Error:" + x); } if (!XDSConstants.XDS_B_STATUS_FAILURE.equals(rsp.getStatus())) { fail(prefix + ": Register document should fail with error code:" + errorCode); } String error = rsp.getRegistryErrorList().getRegistryError().get(0).getErrorCode(); assertEquals(prefix + ": Error code:", errorCode, error); }
@Override public RegistryResponseType documentRepositoryProvideAndRegisterDocumentSetB( ProvideAndRegisterDocumentSetRequestType req) { log.info("################ documentRepositoryProvideAndRegisterDocumentSetB called!"); RegistryResponseType rsp; XDSDocument[] storedDocs = null; URL registryURL = null; String[] submUIDAndpatid = getSubmissionUIDandPatID(req.getSubmitObjectsRequest()); try { if (submUIDAndpatid[1] == null) throw new XDSException( XDSException.XDS_ERR_REPOSITORY_METADATA_ERROR, "Missing patientID!", null); String srcID = getSourceID(req); registryURL = getRegistryWsdlUrl(srcID); String groupID = getFsGroupID(submUIDAndpatid[1]); logRequest(req); List<ExtrinsicObjectType> extrObjs = checkRequest(req); storedDocs = storeDocuments(req, extrObjs, groupID); SubmitObjectsRequest submitRequest = req.getSubmitObjectsRequest(); rsp = dispatchSubmitObjectsRequest(submitRequest, registryURL); } catch (Exception x) { rsp = factory.createRegistryResponseType(); if (x instanceof XDSException) { XDSUtil.addError(rsp, (XDSException) x); } else { XDSUtil.addError( rsp, new XDSException( XDSException.XDS_ERR_REPOSITORY_ERROR, "Unexpected error in XDS service !: " + x.getMessage(), x)); } } boolean success = XDSConstants.XDS_B_STATUS_SUCCESS.equals(rsp.getStatus()); AuditRequestInfo info = new AuditRequestInfo(LogHandler.getInboundSOAPHeader(), wsContext); if (storedDocs != null) { XDSAudit.logRepositoryPnRExport( submUIDAndpatid[0], submUIDAndpatid[1], info, registryURL, success); } commit(storedDocs, success); if (!success) ejbContext.setRollbackOnly(); XDSAudit.logRepositoryImport( submUIDAndpatid[0], submUIDAndpatid[1], info, XDSConstants.XDS_B_STATUS_SUCCESS.equals(rsp.getStatus())); log.info("################ documentRepositoryProvideAndRegisterDocumentSetB finished!"); return rsp; }
@Override public RetrieveDocumentSetResponseType documentRepositoryRetrieveDocumentSet( RetrieveDocumentSetRequestType req) { log.info("################ documentRepositoryRetrieveDocumentSet called!"); RetrieveDocumentSetResponseType rsp = iheFactory.createRetrieveDocumentSetResponseType(); try { String repositoryUID = getRepositoryUniqueId(); String docUid, reqRepoUid; XDSDocument doc; RetrieveDocumentSetResponseType.DocumentResponse docRsp; List<String> retrievedUIDs = new ArrayList<String>(); int requestCount = req.getDocumentRequest().size(); RegistryErrorList regErrors = factory.createRegistryErrorList(); List<RegistryError> mainErrors = regErrors.getRegistryError(); for (DocumentRequest docReq : req.getDocumentRequest()) { reqRepoUid = docReq.getRepositoryUniqueId(); docUid = docReq.getDocumentUniqueId(); if (reqRepoUid == null || docUid == null || reqRepoUid.trim().length() == 0 || docUid.trim().length() == 0) { mainErrors.add( XDSUtil.getRegistryError( XDSException.XDS_ERR_SEVERITY_ERROR, XDSException.XDS_ERR_REPOSITORY_ERROR, "Missing required request parameter! (Repository- or Document Unique ID)", null)); continue; } if (reqRepoUid.equals(repositoryUID)) { doc = retrieveDocument(docUid); if (doc != null) { try { docRsp = getDocumentResponse(doc, getRepositoryUniqueId()); rsp.getDocumentResponse().add(docRsp); retrievedUIDs.add(docUid); } catch (IOException e) { String msg = "Error in building DocumentResponse for document:" + doc; log.error(msg); mainErrors.add( XDSUtil.getRegistryError( XDSException.XDS_ERR_SEVERITY_ERROR, XDSException.XDS_ERR_REPOSITORY_ERROR, msg, docUid)); } } else { String msg = "Document not found! document UID:" + docUid; log.warn(msg); mainErrors.add( XDSUtil.getRegistryError( XDSException.XDS_ERR_SEVERITY_ERROR, XDSException.XDS_ERR_DOCUMENT_UNIQUE_ID_ERROR, msg, docUid)); } } else { String msg = "DocumentRepositoryUID=" + reqRepoUid + " is unknown! This repository unique ID:" + repositoryUID; log.warn(msg); mainErrors.add( XDSUtil.getRegistryError( XDSException.XDS_ERR_SEVERITY_ERROR, XDSException.XDS_ERR_UNKNOWN_REPOSITORY_ID, msg, docUid)); } } RegistryResponseType regRsp = factory.createRegistryResponseType(); int nrOfDocs = rsp.getDocumentResponse().size(); if (nrOfDocs == 0) { if (mainErrors.size() == 0) throw new XDSException( XDSException.XDS_ERR_DOCUMENT_UNIQUE_ID_ERROR, "None of the requested documents were found. This repository unique ID " + repositoryUID, null); regRsp.setStatus(XDSConstants.XDS_B_STATUS_FAILURE); } else if (nrOfDocs < requestCount) { regRsp.setStatus(XDSConstants.XDS_B_STATUS_PARTIAL_SUCCESS); } else { regRsp.setStatus(XDSConstants.XDS_B_STATUS_SUCCESS); } if (mainErrors.size() > 0) { regRsp.setRegistryErrorList(regErrors); } rsp.setRegistryResponse(regRsp); } catch (Exception x) { if (x instanceof XDSException) { XDSUtil.addError(rsp, (XDSException) x); } else { XDSUtil.addError( rsp, new XDSException( XDSException.XDS_ERR_REPOSITORY_ERROR, "Unexpected error in XDS service !: " + x.getMessage(), x)); } } AuditRequestInfo info = new AuditRequestInfo(LogHandler.getInboundSOAPHeader(), wsContext); XDSAudit.logRepositoryRetrieveExport(req, rsp, info); log.info("################ documentRepositoryRetrieveDocumentSet finished!"); return rsp; }