@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 OrcidDeprecated getOrcidDeprecated(ProfileEntity profileEntity) { OrcidDeprecated orcidDeprecated = null; if (profileEntity.getPrimaryRecord() != null) { orcidDeprecated = new OrcidDeprecated(); orcidDeprecated.setDate(new DeprecatedDate(toXMLGregorianCalendar(profileEntity.getDeprecatedDate()))); PrimaryRecord primaryRecord = new PrimaryRecord(); OrcidIdentifier orcidIdentifier = new OrcidIdentifier(getOrcidIdBase(profileEntity.getPrimaryRecord().getId())); primaryRecord.setOrcidIdentifier(orcidIdentifier); orcidDeprecated.setPrimaryRecord(primaryRecord); } return orcidDeprecated; }
@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; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((orcid == null) ? 0 : orcid.hashCode()); result = prime * result + ((orcidBio == null) ? 0 : orcidBio.hashCode()); result = prime * result + ((orcidHistory == null) ? 0 : orcidHistory.hashCode()); result = prime * result + ((orcidInternal == null) ? 0 : orcidInternal.hashCode()); result = prime * result + ((orcidActivities == null) ? 0 : orcidActivities.hashCode()); result = prime * result + ((password == null) ? 0 : password.hashCode()); result = prime * result + ((securityQuestionAnswer == null) ? 0 : securityQuestionAnswer.hashCode()); result = prime * result + ((type == null) ? 0 : type.hashCode()); result = prime * result + ((groupType == null) ? 0 : groupType.hashCode()); result = prime * result + ((clientType == null) ? 0 : clientType.hashCode()); result = prime * result + ((verificationCode == null) ? 0 : verificationCode.hashCode()); result = prime * result + ((orcidDeprecated == null) ? 0 : orcidDeprecated.hashCode()); return result; }
if (other.getOrcidDeprecated() != null) return false; } else if (!orcidDeprecated.equals(other.getOrcidDeprecated())) return false;
profileIndexDocument.setPrimaryRecord(orcidDeprecated.getPrimaryRecord() != null ? orcidDeprecated.getPrimaryRecord().getOrcidIdentifier().getPath() : null);
} else if (OrcidDeprecatedException.class.isAssignableFrom(t.getClass())) { OrcidDeprecatedException exception = (OrcidDeprecatedException) t; OrcidDeprecated depreciatedError = new OrcidDeprecated(); Map<String, String> params = exception.getParams(); String location = null; PrimaryRecord pr = new PrimaryRecord(); pr.setOrcid(new Orcid(params.get(OrcidDeprecatedException.ORCID))); depreciatedError.setPrimaryRecord(pr); location = getPrimaryRecordLocation(params); String dateString = params.get(OrcidDeprecatedException.DEPRECATED_DATE); dd.setValue(DateUtils.convertToXMLGregorianCalendar(dateString, false)); depreciatedError.setDate(dd);
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; }