private void downgradeProfile(OrcidProfile orcidProfile) { if (orcidProfile != null) { if(orcidProfile.getOrcidHistory() !=null && orcidProfile.getOrcidHistory().getCreationMethod() != null) { CreationMethod c = orcidProfile.getOrcidHistory().getCreationMethod(); if (c.equals(CreationMethod.MEMBER_REFERRED) || c.equals(CreationMethod.DIRECT)) orcidProfile.getOrcidHistory().setCreationMethod(CreationMethod.WEBSITE); } orcidProfile.setFundings(null); } }
public Date extractLastModifiedDate() { OrcidHistory orcidHistory = this.getOrcidHistory(); if (orcidHistory == null) return null; LastModifiedDate lastModifiedDate = orcidHistory.getLastModifiedDate(); if (lastModifiedDate == null) return null; return lastModifiedDate.getValue().toGregorianCalendar().getTime(); }
@Deprecated protected boolean isOldEnough(OrcidProfile orcidProfile) { return DateUtils.olderThan(orcidProfile.getOrcidHistory().getSubmissionDate().getValue().toGregorianCalendar().getTime(), claimWaitPeriodDays); }
private String getSponsorOrcid(OrcidMessage orcidMessage) { if (orcidMessage != null && orcidMessage.getOrcidProfile() != null && orcidMessage.getOrcidProfile().getOrcidHistory() != null && orcidMessage.getOrcidProfile().getOrcidHistory().getSource() != null) { return orcidMessage.getOrcidProfile().getOrcidHistory().getSource().retrieveSourcePath(); } else { return null; } }
protected boolean isBeingAccessedByCreator(OrcidProfile orcidProfile) { String amenderOrcid = sourceManager.retrieveSourceOrcid(); Source source = orcidProfile.getOrcidHistory().getSource(); if (NullUtils.noneNull(amenderOrcid, source)) { return amenderOrcid.equals(source.retrieveSourcePath()); } return false; }
@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); }
@Override protected void doInTransactionWithoutResult(TransactionStatus status) { OrcidProfile orcidProfile = orcidProfileManager.retrieveOrcidProfile(orcid); Date originalLastModified = orcidProfile.getOrcidHistory().getLastModifiedDate().getValue().toGregorianCalendar().getTime(); IndexingStatus originalIndexingStatus = profileDao.find(orcid).getIndexingStatus(); // Save it straight back - it will be saved back in the // new DB table automatically orcidProfileManager.updateOrcidProfile(orcidProfile); if (!updateLastModified) { profileDao.updateLastModifiedDateAndIndexingStatusWithoutResult(orcid, originalLastModified, originalIndexingStatus); } } });
private void setAffiliationPrivacy(OrcidProfile updatedOrcidProfile, Visibility defaultAffiliationVisibility) { OrcidHistory orcidHistory = updatedOrcidProfile.getOrcidHistory(); boolean isClaimed = orcidHistory != null ? orcidHistory.getClaimed().isValue() : false; OrcidActivities incomingActivities = updatedOrcidProfile.getOrcidActivities(); if (incomingActivities != null) { Affiliations incomingWorks = incomingActivities.getAffiliations(); if (incomingWorks != null) { setAffiliationPrivacy(incomingWorks, defaultAffiliationVisibility, isClaimed); } } }
@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; }
private void setFundingPrivacy(OrcidProfile updatedOrcidProfile, Visibility defaultFundingVisibility) { OrcidHistory orcidHistory = updatedOrcidProfile.getOrcidHistory(); boolean isClaimed = orcidHistory != null ? orcidHistory.getClaimed().isValue() : false; OrcidActivities incomingActivities = updatedOrcidProfile.getOrcidActivities(); if (incomingActivities != null) { FundingList incomingFundingList = incomingActivities.getFundings(); if (incomingFundingList != null) { setFundingPrivacy(incomingFundingList, defaultFundingVisibility, isClaimed); } } }
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() }, "_"); }
private void setWorkPrivacy(OrcidProfile updatedOrcidProfile, Visibility defaultWorkVisibility) { OrcidHistory orcidHistory = updatedOrcidProfile.getOrcidHistory(); boolean isClaimed = orcidHistory != null ? orcidHistory.getClaimed().isValue() : false; OrcidActivities incomingActivities = updatedOrcidProfile.getOrcidActivities(); if (incomingActivities != null) { OrcidWorks incomingWorks = incomingActivities.getOrcidWorks(); if (incomingWorks != null) { setWorkPrivacy(incomingWorks, defaultWorkVisibility, isClaimed); } } }
String clientId = authorizationRequest.getClientId(); String sponsorOrcid = getSponsorOrcid(orcidMessage); if (StringUtils.isNotBlank(sponsorOrcid) && clientId.equals(sponsorOrcid) && !orcidMessage.getOrcidProfile().getOrcidHistory().isClaimed()) { visibilities.add(Visibility.LIMITED); visibilities.add(Visibility.PRIVATE);
private void downgradeProfile(OrcidProfile orcidProfile) { if (orcidProfile != null) { if (orcidProfile.getOrcidHistory() != null) { if (orcidProfile.getOrcidHistory().getVerifiedEmail() != null) { orcidProfile.getOrcidHistory().setVerifiedEmail(null); if (orcidProfile.getOrcidHistory().getVerifiedPrimaryEmail() != null) { orcidProfile.getOrcidHistory().setVerifiedPrimaryEmail(null);
return new ProfileEventResult(orcidId, ProfileEventType.SERVICE_ANNOUNCEMENT_SKIPPED_1_FOR_2015); if (orcidProfile.getOrcidHistory() != null) { if (orcidProfile.getOrcidHistory().getClaimed() != null && orcidProfile.getOrcidHistory().getClaimed().isValue() == false) return new ProfileEventResult(orcidId, ProfileEventType.SERVICE_ANNOUNCEMENT_SKIPPED_1_FOR_2015);
FundingList updatedFundingList = updatedOrcidProfile.retrieveFundings(); Visibility workVisibilityDefault = existingProfile.getOrcidInternal().getPreferences().getActivitiesVisibilityDefault().getValue(); Boolean claimed = existingProfile.getOrcidHistory().isClaimed(); setFundingPrivacy(updatedFundingList, workVisibilityDefault, claimed == null ? false : claimed); updatedFundingList = dedupeFundings(updatedFundingList);
Affiliations updatedAffiliations = updatedOrcidProfile.retrieveAffiliations(); Visibility workVisibilityDefault = existingProfile.getOrcidInternal().getPreferences().getActivitiesVisibilityDefault().getValue(); Boolean claimed = existingProfile.getOrcidHistory().isClaimed(); setAffiliationPrivacy(updatedAffiliations, workVisibilityDefault, claimed == null ? false : claimed); updatedAffiliations = dedupeAffiliations(updatedAffiliations);
addSourceToEmails(orcidProfile, existingProfileEntity, amenderOrcid); Boolean claimed = orcidProfile.getOrcidHistory() != null ? orcidProfile.getOrcidHistory().isClaimed() : existingProfileEntity.getClaimed();
@Override public ProfileEntity toProfileEntity(OrcidProfile profile, ProfileEntity existingProfileEntity, UpdateOptions updateOptions) { Assert.notNull(profile, "Cannot convert a null OrcidProfile"); ProfileEntity profileEntity = existingProfileEntity == null ? new ProfileEntity() : existingProfileEntity; // if orcid-id exist us it String orcidString = profile.getOrcidIdentifier().getPath(); if (profile.retrieveOrcidUriAsString() != null && !profile.retrieveOrcidUriAsString().isEmpty()) { orcidString = OrcidStringUtils.getOrcidNumber(profile.retrieveOrcidUriAsString()); } profileEntity.setId(orcidString); profileEntity.setOrcidType(profile.getType().name()); profileEntity.setGroupType(profile.getGroupType() != null ? profile.getGroupType().name() : null); setBioDetails(profileEntity, profile.getOrcidBio()); setHistoryDetails(profileEntity, profile.getOrcidHistory()); setActivityDetails(profileEntity, profile.getOrcidActivities(), updateOptions); setInternalDetails(profileEntity, profile.getOrcidInternal()); setPreferencesDetails(profileEntity, profile.getOrcidPreferences()); profileEntity.setUserLastIp(profile.getUserLastIp()); profileEntity.setReviewed(profile.isReviewed()); if(profileEntity.getUsedRecaptchaOnRegistration() == null) { profileEntity.setUsedRecaptchaOnRegistration(false); } return profileEntity; }
@Override public ProfileEventResult call() throws Exception { String orcidId = getOrcidProfile().getOrcidIdentifier().getPath(); if (orcidProfile.getOrcidBio() == null || orcidProfile.getOrcidBio().getContactDetails() == null || orcidProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail() == null || orcidProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail().getValue() == null) { return new ProfileEventResult(orcidId, ProfileEventType.VERIFIED_REQUIRED_SKIPPED_2017); } if (orcidProfile.isLocked() || orcidProfile.isDeactivated() || orcidProfile.getOrcidDeprecated() != null || !orcidProfile.getOrcidHistory().getClaimed().isValue()) { return new ProfileEventResult(orcidId, ProfileEventType.VERIFIED_REQUIRED_SKIPPED_2017); } Email primaryEmail = orcidProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail(); if (primaryEmail.isVerified()) { return new ProfileEventResult(orcidId, ProfileEventType.VERIFIED_REQUIRED_HAS_VALIDATED_2017); } else { try { boolean sent = sendVerifiedRequiredAnnouncement2017(orcidProfile); if (sent) { return new ProfileEventResult(orcidId, ProfileEventType.VERIFIED_REQUIRED_SENT_2017); } else { return new ProfileEventResult(orcidId, ProfileEventType.VERIFIED_REQUIRED_FAIL_2017); } } catch (Exception e) { LOG.error("ProfileEventType exception trying to send email to: " + orcidProfile.retrieveOrcidUriAsString(), e); return new ProfileEventResult(orcidId, ProfileEventType.VERIFIED_REQUIRED_FAIL_2017); } } }