private static void addDocuments( List<ParticipantObjectIdentification> pois, RetrieveDocumentSetRequestType req, List<String> docUIDs, boolean success) { List<DocumentRequest> docRequests = req.getDocumentRequest(); List<ParticipantObjectDetail> details; for (DocumentRequest docReq : docRequests) { if (isAddDocument(docReq.getDocumentUniqueId(), docUIDs, success)) { ParticipantObjectIdentification poi = AuditMessages.createParticipantObjectIdentification( docReq.getDocumentUniqueId(), ParticipantObjectIDTypeCode.ReportNumber, null, (byte[]) null, AuditMessages.ParticipantObjectTypeCode.SystemObject, AuditMessages.ParticipantObjectTypeCodeRole.Report, null, null, null); details = poi.getParticipantObjectDetail(); details.add( AuditMessages.createParticipantObjectDetail( "Repository Unique Id", docReq.getRepositoryUniqueId().getBytes())); if (docReq.getHomeCommunityId() != null) details.add( AuditMessages.createParticipantObjectDetail( "ihe:homeCommunityID", docReq.getHomeCommunityId().getBytes())); pois.add(poi); } } }
public static void logExport( EventTypeCode eventTypeCode, RetrieveDocumentSetRequestType req, RetrieveDocumentSetResponseType rsp, AuditRequestInfo info) { if (logger == null || !logger.isInstalled()) return; List<DocumentRequest> docReq = req.getDocumentRequest(); List<String> retrievedUIDs = new ArrayList<String>(); for (DocumentResponse doc : rsp.getDocumentResponse()) retrievedUIDs.add(doc.getDocumentUniqueId()); if (retrievedUIDs.size() > 0) { logExport( eventTypeCode, null, null, info.getRequestURI(), AuditLogger.processID(), info.getLocalHost(), info.getReplyTo(), null, info.getRemoteHost(), req, retrievedUIDs, true); } if (retrievedUIDs.size() < docReq.size()) { List<String> failedUIDs = new ArrayList<String>(); for (DocumentRequest doc : req.getDocumentRequest()) if (!retrievedUIDs.contains(doc.getDocumentUniqueId())) failedUIDs.add(doc.getDocumentUniqueId()); logExport( eventTypeCode, null, null, info.getRequestURI(), AuditLogger.processID(), info.getLocalHost(), info.getReplyTo(), null, info.getRemoteHost(), req, failedUIDs, false); } }
@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; }