@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;
  }