public void setOrcidIdentifier(String path) { this.orcidIdentifier = path != null ? new OrcidIdentifier(path) : null; }
public String retrieveOrcidPath() { if (orcidIdentifier == null) { return null; } String path = orcidIdentifier.getPath(); if (path != null) { return path; } if (orcid != null) { return orcid.getValue(); } return null; }
public String retrieveOrcidUriAsString() { if (orcidIdentifier == null) { return null; } String uri = orcidIdentifier.getUri(); if (uri != null) { return uri; } return orcidIdentifier.getValueAsString(); }
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; }
private String getUserOrcidFromOrcidMessage(OrcidMessage message) { OrcidProfile profile = message.getOrcidProfile(); return profile.getOrcidIdentifier().getPath(); }
@Deprecated public DelegateSummary(Orcid orcid) { this.orcid = orcid; this.orcidIdentifier = new OrcidIdentifier(orcid.getValue()); }
@Override public void deleteOrcidProfile(OrcidProfile orcidProfile) { deleteOrcidProfile(orcidProfile.getOrcidIdentifier().getPath()); }
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; }
public void put(OrcidProfile orcidProfile) { put(orcidProfile.getOrcidIdentifier().getPath(), orcidProfile); }
for (GivenPermissionToEntity givenPermissionToEntity : givenPermissionToEntities) { DelegationDetails delegationDetails = new DelegationDetails(); DelegateSummary delegateSummary = new DelegateSummary(new OrcidIdentifier(getOrcidIdBase(givenPermissionToEntity.getReceiver().getId()))); delegateSummary .setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(givenPermissionToEntity.getReceiver().getLastModified()))); for (GivenPermissionByEntity givenPermissionByEntity : givenPermissionByEntities) { DelegationDetails delegationDetails = new DelegationDetails(); DelegateSummary delegateSummary = new DelegateSummary(new OrcidIdentifier(getOrcidIdBase((givenPermissionByEntity.getGiver().getId())))); delegateSummary.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(givenPermissionByEntity.getGiver().getLastModified()))); String creditName = RecordNameUtils.getDisplayName(givenPermissionByEntity.getGiver().getRecordNameEntity());
@Override public OrcidProfile doInTransaction(TransactionStatus status) { return convertToOrcidProfile(profileDao.find(orcidProfile.getOrcidIdentifier().getPath()), LoadOptions.ALL); }
orcidSearchResult.setRelevancyScore(relevancyScore); OrcidProfile orcidProfile = new OrcidProfile(); orcidProfile.setOrcidIdentifier(new OrcidIdentifier(jpaJaxbAdapter.getOrcidIdBase(orcid))); OrcidHistory history = new OrcidHistory(); Date recordLastModified = profileDaoReadOnly.retrieveLastModifiedDate(orcid);
@Override public OrcidProfile updateOrcidPreferences(OrcidProfile updatedOrcidProfile) { OrcidProfile existingProfile = retrieveOrcidProfile(updatedOrcidProfile.getOrcidIdentifier().getPath()); if (existingProfile == null) { return null; } existingProfile.setOrcidPreferences(updatedOrcidProfile.getOrcidPreferences()); OrcidProfile profileToReturn = updateOrcidProfile(existingProfile); notificationManager.sendAmendEmail(updatedOrcidProfile.getOrcidIdentifier().getPath(), AmendedSection.PREFERENCES, null); return profileToReturn; }
orcidSearchResult.setRelevancyScore(relevancyScore); OrcidProfile orcidProfile = new OrcidProfile(); orcidProfile.setOrcidIdentifier(new OrcidIdentifier(jpaJaxbAdapter.getOrcidIdBase(orcid))); OrcidHistory history = new OrcidHistory(); Date recordLastModified = profileDaoReadOnly.retrieveLastModifiedDate(orcid);
@Override @Deprecated //now going via orcid-message-listener public void persistProfileInformationForIndexingIfNecessary(OrcidProfile orcidProfile) { String orcid = orcidProfile.getOrcidIdentifier().getPath(); Date lastModifiedFromSolr = solrDao.retrieveLastModified(orcid); Date lastModifiedFromDb = orcidProfile.getOrcidHistory().getLastModifiedDate().getValue().toGregorianCalendar().getTime(); if (lastModifiedFromDb.equals(lastModifiedFromSolr)) { // Check if re-indexing IndexingStatus indexingStatus = profileDao.retrieveIndexingStatus(orcid); if (!IndexingStatus.REINDEX.equals(indexingStatus)) { // If not re-indexing then skip LOG.info("Index is already up to date for orcid: {}", orcid); return; } } persistProfileInformationForIndexing(orcidProfile); }
protected OrcidProfile createReservedForClaimOrcidProfile(String orcid, OrcidDeprecated deprecatedInfo, LastModifiedDate lastModifiedDate) { OrcidProfile op = new OrcidProfile(); if (jpaJaxbAdapter != null) { op.setOrcidIdentifier(new OrcidIdentifier(jpaJaxbAdapter.getOrcidIdBase(orcid))); } else { op.setOrcidIdentifier(orcid); } if (deprecatedInfo != null) op.setOrcidDeprecated(deprecatedInfo); OrcidHistory oh = new OrcidHistory(); oh.setClaimed(new Claimed(false)); oh.setLastModifiedDate(lastModifiedDate); op.setOrcidHistory(oh); GivenNames gn = new GivenNames(); PersonalDetails pd = new PersonalDetails(); gn.setContent(localeManager.resolveMessage("orcid.reserved_for_claim")); gn.setVisibility(OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility()); pd.setGivenNames(gn); OrcidBio ob = new OrcidBio(); ob.setPersonalDetails(pd); op.setOrcidBio(ob); return op; }
private void performClientChecks(OAuth2Authentication oAuth2Authentication, ScopePathType requiredScope, OrcidMessage orcidMessage, String orcid) { OAuth2Request authorizationRequest = oAuth2Authentication.getOAuth2Request(); // If we have an ORCID in the request, we assume that this is intended // as an update if (orcidMessage != null && orcidMessage.getOrcidProfile() != null && StringUtils.isNotBlank(orcid)) { OrcidIdentifier orcidOb = orcidMessage.getOrcidProfile().getOrcidIdentifier(); String messageOrcid = orcidOb != null ? orcidOb.getPath() : orcid; if (StringUtils.isNotBlank(messageOrcid) && !orcid.equals(messageOrcid)) { throw new IllegalArgumentException("The ORCID in the body and the URI do NOT match. Body ORCID: " + messageOrcid + " URI ORCID: " + orcid + " do NOT match."); } profileEntityCacheManager.retrieve(messageOrcid); if (!profileEntityManager.existsAndNotClaimedAndBelongsTo(messageOrcid, authorizationRequest.getClientId())) { throw new AccessControlException("You cannot update this profile as it has been claimed, or you are not the owner."); } } }
profile.setOrcidIdentifier(new OrcidIdentifier(getOrcidIdBase(profileEntity.getId())));
public static String createCacheKey(OrcidProfile profile) { OrcidHistory orcidHistory = profile.getOrcidHistory(); OrcidIdentifier orcidIdentifier = profile.getOrcidIdentifier(); String xmlFormatLastModifiedDate = (orcidHistory != null && orcidHistory.getLastModifiedDate() != null) ? orcidHistory.getLastModifiedDate().getValue() .toXMLFormat() : "no-last-modified"; String path = orcidIdentifier != null ? orcidIdentifier.getPath() : "no-orcid-identifier"; return StringUtils.join(new String[] {path, xmlFormatLastModifiedDate, profile.getReleaseName() }, "_"); }
/** * Updates the ORCID bio data * * @param updatedOrcidProfile * @return */ @Deprecated @Override public OrcidProfile updateOrcidBio(OrcidProfile updatedOrcidProfile) { addSourceToBioElements(updatedOrcidProfile); OrcidProfile existingProfile = retrieveOrcidProfile(updatedOrcidProfile.getOrcidIdentifier().getPath(), LoadOptions.ALL_WITH_NEW_AFFILIATION_TYPES); if (existingProfile == null) { return null; } // preserve the visibility settings orcidJaxbCopyManager.copyUpdatedBioToExistingWithVisibility(existingProfile.getOrcidBio(), updatedOrcidProfile.getOrcidBio()); OrcidProfile profileToReturn = updateOrcidProfile(existingProfile, UpdateOptions.NO_ACTIVITIES); notificationManager.sendAmendEmail(updatedOrcidProfile.getOrcidIdentifier().getPath(), AmendedSection.BIO, null); return profileToReturn; }