@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; OrcidDeprecated other = (OrcidDeprecated) obj; if(date == null){ if(other.getDate() != null) return false; } if(!date.equals(other.getDate())) return false; if(primaryRecord == null){ if(other.getPrimaryRecord() != null) return false; } if(!primaryRecord.equals(other.getPrimaryRecord())) return false; return true; }
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(OrcidDeprecatedException.ORCID, orcidProfile.getOrcidDeprecated().getPrimaryRecord().getOrcidIdentifier().getUri()); if (orcidProfile.getOrcidDeprecated().getDate() != null) { XMLGregorianCalendar deprecatedDate = orcidProfile.getOrcidDeprecated().getDate().getValue(); params.put(OrcidDeprecatedException.DEPRECATED_DATE, deprecatedDate.toString()); } throw new OrcidDeprecatedException(params); } else { orcidMessageUtil.setSourceName(orcidMessage); response = Response.ok(orcidMessage).build(); } return response; }
@Override public OrcidProfile retrieveClaimedOrcidProfile(String orcid, LoadOptions loadOptions) { OrcidProfile orcidProfile = retrieveOrcidProfile(orcid, loadOptions); if (orcidProfile != null) { if (Boolean.TRUE.equals(orcidProfile.getOrcidHistory().getClaimed().isValue()) || orcidProfile.isDeactivated() || isBeingAccessedByCreator(orcidProfile) || haveSystemRole() || isOldEnough(orcidProfile)) { return orcidProfile; } else { if (orcidProfile.getOrcidDeprecated() != null && orcidProfile.getOrcidDeprecated().getPrimaryRecord() != null) return createReservedForClaimOrcidProfile(orcid, orcidProfile.getOrcidDeprecated(), orcidProfile.getOrcidHistory().getLastModifiedDate()); else return createReservedForClaimOrcidProfile(orcid, orcidProfile.getOrcidHistory().getLastModifiedDate()); } } return null; }
profileIndexDocument.setPrimaryRecord(orcidDeprecated.getPrimaryRecord() != null ? orcidDeprecated.getPrimaryRecord().getOrcidIdentifier().getPath() : null);