예제 #1
0
 @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;
 }
예제 #2
0
 public static void logPatientFeed(
     String patID,
     String eventActionCode,
     byte[] msh10,
     String srcUserID,
     String remoteHost,
     String destUserID,
     boolean success) {
   if (logger != null && logger.isInstalled()) {
     try {
       Calendar timeStamp = logger.timeStamp();
       AuditMessage msg =
           XDSAudit.createPatientFeed(
               patID,
               EventActionCode.Create,
               msh10,
               srcUserID,
               null,
               remoteHost,
               destUserID,
               timeStamp,
               success ? EventOutcomeIndicator.Success : EventOutcomeIndicator.MinorFailure);
       sendAuditMessage(timeStamp, msg);
     } catch (Exception e) {
       log.warn("Audit log of Patient Feed failed!");
       log.debug("AuditLog Exception:", e);
     }
   }
 }
예제 #3
0
 public static void logImport(
     EventTypeCode eventTypeCode,
     String submissionSetUID,
     String patID,
     String srcUserID,
     String altSrcUserID,
     String srcHostName,
     String destUserID,
     String altDestUserID,
     String destHostName,
     RetrieveDocumentSetRequestType docReq,
     boolean success) {
   try {
     Calendar timeStamp = logger.timeStamp();
     AuditMessage msg =
         XDSAudit.createImport(
             eventTypeCode,
             submissionSetUID,
             patID,
             srcUserID,
             altSrcUserID,
             srcHostName,
             destUserID,
             altDestUserID,
             destHostName,
             docReq,
             timeStamp,
             success ? EventOutcomeIndicator.Success : EventOutcomeIndicator.MinorFailure);
     sendAuditMessage(timeStamp, msg);
   } catch (Exception e) {
     log.warn("Audit log of Import (" + eventTypeCode.getDisplayName() + ") failed!");
     log.debug("AuditLog Exception:", e);
   }
 }
예제 #4
0
  public static void logQuery(
      EventTypeCode eventTypeCode,
      AdhocQueryRequest req,
      String srcUserID,
      String altSrcUserID,
      String srcHostName,
      String destUserID,
      String altDestUserID,
      String destHostName,
      boolean success) {

    if (logger != null && logger.isInstalled()) {
      try {
        AdhocQueryType qry = req.getAdhocQuery();
        String patID = XDSUtil.getQueryPatID(qry.getSlot());
        String homeCommunityID =
            InfosetUtil.getSlotValue(qry.getSlot(), XDSConstants.QRY_HOME_COMMUNITY_ID, null);
        if (srcHostName == null) srcHostName = AuditLogger.localHost().getHostName();
        Calendar timeStamp = logger.timeStamp();
        AuditMessage msg =
            XDSAudit.createQuery(
                eventTypeCode,
                qry.getId(),
                patID,
                homeCommunityID,
                InfosetUtil.marshallObject(req, true).getBytes("UTF-8"),
                srcUserID,
                altSrcUserID,
                srcHostName,
                destUserID,
                altDestUserID,
                destHostName,
                timeStamp,
                success ? EventOutcomeIndicator.Success : EventOutcomeIndicator.MinorFailure);
        sendAuditMessage(timeStamp, msg);
      } catch (Exception e) {
        log.warn("Audit log of Stored Query failed!");
        log.debug("AuditLog Exception:", e);
      }
    }
  }
예제 #5
0
  @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;
  }