コード例 #1
0
  private Response getOrcidMessageResponse(OrcidMessage orcidMessage, String requestedOrcid) {
    boolean isProfileDeprecated = false;
    if (orcidMessage == null) {
      Map<String, String> params = new HashMap<String, String>();
      params.put("orcid", requestedOrcid);
      throw new OrcidNotFoundException(params);
    }
    OrcidProfile orcidProfile = orcidMessage.getOrcidProfile();
    if (orcidProfile != null) {
      orcidProfile.setOrcidInternal(null);
      // If profile is deprecated
      if (orcidMessage.getOrcidProfile().getOrcidDeprecated() != null) {
        isProfileDeprecated = true;
      }
    }

    Response response = null;

    if (isProfileDeprecated) {
      Map<String, String> params = new HashMap<String, String>();
      params.put(
          "orcid",
          orcidProfile.getOrcidDeprecated().getPrimaryRecord().getOrcidIdentifier().getUri());
      throw new OrcidDeprecatedException(params);
    } else {
      response = Response.ok(orcidMessage).build();
    }

    return response;
  }
コード例 #2
0
  /**
   * Method to perform the mundane task of checking for null and returning the response with an
   * OrcidMessage entity
   *
   * @param profile
   * @param requestedOrcid
   * @return
   */
  private Response getOrcidMessageResponse(OrcidProfile profile, String requestedOrcid) {

    if (profile == null) {
      Map<String, String> params = new HashMap<String, String>();
      params.put("orcid", requestedOrcid);
      throw new OrcidNotFoundException(params);
    }

    profile.setOrcidInternal(null);
    OrcidMessage orcidMessage = new OrcidMessage(profile);

    return Response.ok(orcidMessage).build();
  }