Beispiel #1
0
 public static void addOrOverwriteSlot(
     RegistryObjectType ro, Map<String, SlotType1> slots, String slotName, String... val)
     throws JAXBException {
   if (slots.containsKey(slotName)) {
     SlotType1 oldSlot = (SlotType1) slots.get(slotName);
     ro.getSlot().remove(oldSlot);
   }
   SlotType1 slot = objFac.createSlotType1();
   slot.setName(slotName);
   ValueListType valueList = objFac.createValueListType();
   for (int i = 0; i < val.length; i++) {
     valueList.getValue().add(val[i]);
   }
   slot.setValueList(valueList);
   ro.getSlot().add(slot);
 }
 @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;
  }
Beispiel #4
0
 public static AdhocQueryResponse emptyAdhocQueryResponse() {
   AdhocQueryResponse rsp = objFac.createAdhocQueryResponse();
   rsp.setRegistryObjectList(objFac.createRegistryObjectListType());
   return rsp;
 }
Beispiel #5
0
 protected AdhocQueryResponse initAdhocQueryResponse() {
   AdhocQueryResponse rsp = factory.createAdhocQueryResponse();
   rsp.setStatus(XDSConstants.XDS_B_STATUS_SUCCESS);
   return rsp;
 }