Ejemplo n.º 1
0
  /**
   * Method description
   *
   * @param registryResponse
   * @param context
   * @return
   */
  private boolean checkForSuccess(
      GetDocumentsSQResponseMessage registryResponse, SDRActivityContext context) {

    boolean result = false;

    SubmitDocumentResponse sdrResponse = context.getSubmitDocumentResponse();
    Document document = context.getDocument();

    List<String> objectRefs = null;

    try {

      objectRefs = parseObjectRefs(registryResponse, context);

    } catch (XdsException e) {

      // Downstream XDS returned an error
      String msg = String.format("Document id can not be validated as unique: %s", e.getMessage());

      sdrResponse.addResponse(document, ResponseTypeStatus.Failure, msg);
    }

    if (objectRefs != null) {

      if (objectRefs.isEmpty()) {

        result = true;

      } else {

        String errmsg = "Document already exists in the registry. It will not be processed.";

        logger.error(errmsg);
        sdrResponse.addResponse(document, ResponseTypeStatus.Failure, errmsg);
      }
    }

    return result;
  }
Ejemplo n.º 2
0
  /**
   * Method description
   *
   * @param context
   * @return
   */
  @Override
  public boolean execute(SDRActivityContext context) {

    boolean result = false;

    Document doc = context.getDocument();

    if (doc.isGeneratedDocumentId()) {

      // if we generated the id, nothing to check
      result = true;

    } else if (StringUtils.equals(doc.getDocumentIdAsOID(), doc.getReplaceIdAsOID())) {

      // error condition
      String errmsg =
          String.format(
              "Document Id (OID) %s equals Replace Id (OID) %s. These IDs can not be the same.",
              doc.getDocumentIdAsOID(), doc.getReplaceIdAsOID());

      SubmitDocumentResponse sdrResponse = context.getSubmitDocumentResponse();

      logger.error(errmsg);
      sdrResponse.addResponse(doc, ResponseTypeStatus.Failure, errmsg);

    } else {

      GetDocumentsSQResponseMessage getDocsResp =
          callGetDocumentsSQ(context, doc.getDocumentIdAsOID());

      if (getDocsResp != null) {

        result = checkForSuccess(getDocsResp, context);
      }
    }

    return result;
  }