private void upgradeProfile(OrcidProfile orcidProfile) { if (orcidProfile != null) { if (orcidProfile.getOrcidBio() != null) if (orcidProfile.getOrcidBio().getExternalIdentifiers() != null) for (ExternalIdentifier externalIdentifier: orcidProfile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier()) { externalIdentifier.setExternalIdSource(externalIdentifier.getExternalIdOrcid()); externalIdentifier.setExternalIdOrcid(null); } if(orcidProfile.getOrcidInternal() != null) orcidProfile.getOrcidInternal().setSalesforceId(new SalesforceId()); } }
public boolean sendVerifiedRequiredAnnouncement2017(OrcidProfile orcidProfile) { String orcid = orcidProfile.getOrcidIdentifier().getPath(); String email = orcidProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail().getValue(); String emailFriendlyName = notificationManager.deriveEmailFriendlyName(profileDaoReadOnly.find(orcid)); String verificationUrl = notificationManager.createVerificationUrl(email, orcidUrlManager.getBaseUrl()); String emailFrequencyUrl = notificationManager.createUpdateEmailFrequencyUrl(orcidProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail().getValue()); Map<String, Boolean> features = new HashMap<String, Boolean>(); for(Features f : Features.values()) { features.put(f.name(), f.isActive()); } Locale locale = localeManager.getLocaleFromOrcidProfile(orcidProfile); Map<String, Object> templateParams = new HashMap<String, Object>(); templateParams.put("emailName", emailFriendlyName); templateParams.put("verificationUrl", verificationUrl); templateParams.put("emailFrequencyUrl", emailFrequencyUrl); templateParams.put("orcid", orcid); templateParams.put("baseUri", orcidUrlManager.getBaseUrl()); templateParams.put("messages", this.messages); templateParams.put("messageArgs", new Object[0]); templateParams.put("locale", locale); templateParams.put("features", features); String subject = messages.getMessage("email.service_announcement.subject.imporant_information", null, locale); String text = templateManager.processTemplate("verified_required_announcement_2017.ftl", templateParams); String html = templateManager.processTemplate("verified_required_announcement_2017_html.ftl", templateParams); return mailGunManager.sendEmail("support@notify.orcid.org", email, subject, text, html); }
private void checkMessage(OrcidMessage orcidMessage) { OrcidProfile orcidProfile = orcidMessage != null ? orcidMessage.getOrcidProfile() : null; if (orcidProfile == null) { if (requireOrcidProfile) { throw new OrcidValidationException("There must be an orcid-profile element"); } } else { checkBio(orcidProfile.getOrcidBio()); checkActivities(orcidProfile.getOrcidActivities()); } }
if (orcidProfile.getOrcidBio() != null) { if (orcidProfile.getOrcidBio().getBiography() != null) { if (isClaimed) { orcidProfile.getOrcidBio().getBiography().setVisibility(defaultActivityVis); } else { Visibility visibility = orcidProfile.getOrcidBio().getBiography().getVisibility(); orcidProfile.getOrcidBio().getBiography().setVisibility(visibility != null ? visibility : Visibility.PRIVATE); if (orcidProfile.getOrcidBio().getExternalIdentifiers() != null) { Visibility listVisibility = orcidProfile.getOrcidBio().getExternalIdentifiers().getVisibility(); for (ExternalIdentifier x : orcidProfile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier()) { if (isClaimed) { x.setVisibility(defaultActivityVis); if (orcidProfile.getOrcidBio().getKeywords() != null) { Visibility listVisibility = orcidProfile.getOrcidBio().getKeywords().getVisibility(); for (Keyword x : orcidProfile.getOrcidBio().getKeywords().getKeyword()) { if (isClaimed) { x.setVisibility(defaultActivityVis); if (orcidProfile.getOrcidBio().getResearcherUrls() != null) { Visibility listVisibility = orcidProfile.getOrcidBio().getResearcherUrls().getVisibility(); for (ResearcherUrl x : orcidProfile.getOrcidBio().getResearcherUrls().getResearcherUrl()) { if (isClaimed) { x.setVisibility(defaultActivityVis); if (orcidProfile.getOrcidBio().getPersonalDetails() != null && orcidProfile.getOrcidBio().getPersonalDetails().getOtherNames() != null) { Visibility listVisibility = orcidProfile.getOrcidBio().getPersonalDetails().getOtherNames().getVisibility(); for (OtherName x : orcidProfile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName()) {
public boolean sendServiceAnnouncement_1_For_2015(OrcidProfile orcidProfile) { String orcid = orcidProfile.getOrcidIdentifier().getPath(); String email = orcidProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail().getValue(); String emailFriendlyName = notificationManager.deriveEmailFriendlyName(profileDaoReadOnly.find(orcid)); Map<String, Object> templateParams = new HashMap<String, Object>(); templateParams.put("emailName", emailFriendlyName); String verificationUrl = notificationManager.createVerificationUrl(email, orcidUrlManager.getBaseUrl()); boolean needsVerification = !orcidProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail().isVerified() && orcidProfile.getType().equals(org.orcid.jaxb.model.message.OrcidType.USER) && !orcidProfile.isDeactivated(); if (needsVerification) { templateParams.put("verificationUrl", verificationUrl); String emailFrequencyUrl = notificationManager.createUpdateEmailFrequencyUrl(orcidProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail().getValue()); templateParams.put("emailFrequencyUrl", emailFrequencyUrl); templateParams.put("orcid", orcid);
/** * 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; }
/** * Add new external identifiers to an existing profile * * @param updatedOrcidProfile * @return */ @Override public OrcidProfile addExternalIdentifiers(OrcidProfile updatedOrcidProfile) { OrcidProfile existingProfile = retrieveOrcidProfile(updatedOrcidProfile.getOrcidIdentifier().getPath(), LoadOptions.ALL_WITH_NEW_AFFILIATION_TYPES); if (existingProfile != null && existingProfile.getOrcidBio() != null) { OrcidBio orcidBio = existingProfile.getOrcidBio(); ExternalIdentifiers externalIdentifiers = orcidBio.getExternalIdentifiers(); if (externalIdentifiers == null) { orcidBio.setExternalIdentifiers(new ExternalIdentifiers()); } ExternalIdentifiers externalIdentifier = updatedOrcidProfile.getOrcidBio().getExternalIdentifiers(); List<ExternalIdentifier> updatedExternalIdentifiers = externalIdentifier.getExternalIdentifier(); List<ExternalIdentifier> existingExternalIdentifiers = orcidBio.getExternalIdentifiers().getExternalIdentifier(); // Copy all the existing external identifiers to the updated profile for (ExternalIdentifier ei : existingExternalIdentifiers) { updatedExternalIdentifiers.add(ei); } orcidJaxbCopyManager.copyUpdatedExternalIdentifiersToExistingPreservingVisibility(orcidBio, updatedOrcidProfile.getOrcidBio()); OrcidProfile profileToReturn = updateOrcidProfile(existingProfile); notificationManager.sendAmendEmail(updatedOrcidProfile.getOrcidIdentifier().getPath(), AmendedSection.EXTERNAL_IDENTIFIERS, null); return profileToReturn; } else { return null; } }
private void assignPersistenceFields(OrcidProfile profile) { // set the transient fields that the encrypters need profile.setPassword("password"); // profile.setOrcidIdentifier(); profile.setSecurityQuestionAnswer("securityQuestionAnswer"); profile.setVerificationCode("1111"); // randomise any fields that are uniquely constrained so that we can // re-use the test data profile.getOrcidBio().getContactDetails().addOrReplacePrimaryEmail(new Email(RandomStringUtils.randomAlphabetic(150))); Keywords keywords = new Keywords(); keywords.getKeyword().add(new Keyword(RandomStringUtils.randomAlphabetic(255), Visibility.PUBLIC)); profile.getOrcidBio().setKeywords(keywords); profile.retrieveOrcidWorks().getOrcidWork(); }
/** * Add source to the profile emails * * @param orcidProfile * The profile * @param amenderOrcid * The orcid of the user or client that add the email to the * profile user */ private void addSourceToEmails(OrcidProfile orcidProfile) { if (orcidProfile != null && orcidProfile.getOrcidBio() != null && orcidProfile.getOrcidBio().getContactDetails() != null && orcidProfile.getOrcidBio().getContactDetails().getEmail() != null) { SourceEntity entity = sourceManager.retrieveSourceEntity(); for (Email email : orcidProfile.getOrcidBio().getContactDetails().getEmail()) { if (entity.getSourceClient() != null && !PojoUtil.isEmpty(entity.getSourceClient().getId())) { email.setSourceClientId(entity.getSourceClient().getId()); } else if(entity.getSourceProfile() != null && !PojoUtil.isEmpty(entity.getSourceProfile().getId())) { email.setSource(entity.getSourceProfile().getId()); } } } }
private void upgradeProfile(OrcidProfile orcidProfile) { if (orcidProfile != null) { if (orcidProfile.getOrcidBio() != null) { if (orcidProfile.getOrcidBio().getExternalIdentifiers() != null) for (ExternalIdentifier externalIdentifier : orcidProfile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier()) { ExternalIdSource eis = externalIdentifier.getExternalIdSource(); if (eis != null) { externalIdentifier.setSource(new Source(eis.getPath())); externalIdentifier.setExternalIdSource(null); } } } if (orcidProfile.getOrcidActivities() != null) { if (orcidProfile.getOrcidActivities().getOrcidWorks() != null) { for (OrcidWork act : orcidProfile.getOrcidActivities().getOrcidWorks().getOrcidWork()) upgradeActivity(act); } } } }
@Override public OrcidProfile createOrcidProfileAndNotify(OrcidProfile orcidProfile) { OrcidProfile createdOrcidProfile = createOrcidProfile(orcidProfile, true, false); notificationManager.sendApiRecordCreationEmail(orcidProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail().getValue(), orcidProfile.getOrcidIdentifier().getPath()); return createdOrcidProfile; }
@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); } } }
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.SERVICE_ANNOUNCEMENT_SKIPPED_1_FOR_2015);
private void downgradeProfile(OrcidProfile orcidProfile) { if (orcidProfile != null) { if (orcidProfile.getOrcidBio() != null) if (orcidProfile.getOrcidBio().getExternalIdentifiers() != null) for (ExternalIdentifier externalIdentifier : orcidProfile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier()) { Source source = externalIdentifier.getSource(); if (source != null) {
/** * See {@link OrcidApiServiceDelegator}{@link #searchByQuery(Map)} */ @Override @VisibilityControl public Response searchByQuery(Map<String, List<String>> queryMap) { validateSearchParams(queryMap); OrcidMessage orcidMessage = orcidSearchManager.findOrcidsByQuery(queryMap); List<OrcidSearchResult> searchResults = orcidMessage.getOrcidSearchResults() != null ? orcidMessage.getOrcidSearchResults().getOrcidSearchResult() : null; List<OrcidSearchResult> filteredResults = new ArrayList<OrcidSearchResult>(); OrcidSearchResults orcidSearchResults = new OrcidSearchResults(); if (searchResults != null) { orcidSearchResults.setNumFound(orcidMessage.getOrcidSearchResults().getNumFound()); if (searchResults.size() > 0) { for (OrcidSearchResult searchResult : searchResults) { OrcidSearchResult filteredSearchResult = new OrcidSearchResult(); OrcidProfile filteredProfile = new OrcidProfile(); filteredSearchResult.setRelevancyScore(searchResult.getRelevancyScore()); filteredProfile.setOrcid(searchResult.getOrcidProfile().getOrcid()); filteredProfile.setOrcidId(searchResult.getOrcidProfile().getOrcidId()); filteredProfile.setOrcidIdentifier(searchResult.getOrcidProfile().getOrcidIdentifier()); filteredProfile.setOrcidBio(searchResult.getOrcidProfile().getOrcidBio()); filteredSearchResult.setOrcidProfile(filteredProfile); filteredResults.add(filteredSearchResult); } } } orcidSearchResults.getOrcidSearchResult().addAll(filteredResults); return getOrcidSearchResultsResponse(orcidSearchResults, queryMap.toString()); }
private void downgradeProfile(OrcidProfile orcidProfile) { if (orcidProfile != null) { if (orcidProfile.getOrcidBio() != null) if (orcidProfile.getOrcidBio().getExternalIdentifiers() != null) for (ExternalIdentifier externalIdentifier : orcidProfile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier()) { externalIdentifier.setExternalIdOrcid(externalIdentifier.getExternalIdSource()); externalIdentifier.setExternalIdSource(null); } if (orcidProfile.getOrcidActivities() != null) { if (orcidProfile.getOrcidActivities().getAffiliations() != null) for (Activity act : orcidProfile.getOrcidActivities().getAffiliations().getAffiliation()) downGradeActivity(act); if (orcidProfile.getOrcidActivities().getFundings() != null) for (Activity act : orcidProfile.getOrcidActivities().getFundings().getFundings()) downGradeActivity(act); if (orcidProfile.getOrcidActivities().getOrcidWorks() != null) for (Activity act : orcidProfile.getOrcidActivities().getOrcidWorks().getOrcidWork()) downGradeActivity(act); } if(orcidProfile.getOrcidInternal() != null) { orcidProfile.getOrcidInternal().setSalesforceId(null); } } }
existingMap = EmailEntity.mapByLowerCaseEmail(existingEmails); OrcidBio orcidBio = orcidProfile.getOrcidBio(); if (orcidBio != null) { ContactDetails contactDetails = orcidBio.getContactDetails();
private void downgradeProfile(OrcidProfile orcidProfile) { if (orcidProfile != null) { orcidProfile.setAffiliations(null); OrcidBio orcidBio = orcidProfile.getOrcidBio(); if (orcidBio != null) { ContactDetails contactDetails = orcidBio.getContactDetails(); if (contactDetails != null) { for (Email email : contactDetails.getEmail()) { email.setSourceClientId(null); } } ExternalIdentifiers extIds = orcidBio.getExternalIdentifiers(); if (extIds != null) { for (ExternalIdentifier extId : extIds.getExternalIdentifier()) { extId.setSource(null); } } } if (orcidProfile.getOrcidActivities() != null) { if (orcidProfile.getOrcidActivities().getOrcidWorks() != null) { for (OrcidWork act : orcidProfile.getOrcidActivities().getOrcidWorks().getOrcidWork()) downGradeActivity(act); } } } }
@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; }
if (orcidProfile != null && orcidProfile.getOrcidBio() != null) { OrcidBio bio = orcidProfile.getOrcidBio();