use of org.orcid.jaxb.model.message.Visibility in project ORCID-Source by ORCID.
the class OrcidProfileManagerImpl method addAffiliations.
/**
* Adds a new {@link List<org.orcid.jaxb.model.message.Affiliation<}
* to the {@link} OrcidProfile} and returns the updated values
*
* @param updatedOrcidProfile
* @return
*/
@Override
@Transactional
public void addAffiliations(OrcidProfile updatedOrcidProfile) {
String orcid = updatedOrcidProfile.getOrcidIdentifier().getPath();
OrcidProfile existingProfile = retrieveOrcidProfile(orcid);
if (existingProfile == null) {
throw new IllegalArgumentException("No record found for " + orcid);
}
Affiliations existingAffiliations = existingProfile.retrieveAffiliations();
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);
String amenderOrcid = sourceManager.retrieveSourceOrcid();
addSourceToAffiliations(updatedAffiliations, amenderOrcid);
List<Affiliation> updatedAffiliationsList = updatedAffiliations.getAffiliation();
checkAndUpdateDisambiguatedOrganization(updatedAffiliationsList);
checkForAlreadyExistingAffiliations(existingAffiliations, updatedAffiliationsList);
persistAddedAffiliations(orcid, updatedAffiliationsList);
profileDao.flush();
boolean notificationsEnabled = existingProfile.getOrcidInternal().getPreferences().getNotificationsEnabled();
if (notificationsEnabled) {
notificationManager.sendAmendEmail(existingProfile, AmendedSection.AFFILIATION);
}
}
use of org.orcid.jaxb.model.message.Visibility in project ORCID-Source by ORCID.
the class OrcidProfileManagerImpl method addFundings.
/**
* Adds a new {@link List<org.orcid.jaxb.model.message.FundingList<}
* to the {@link} OrcidProfile} and returns the updated values
*
* @param updatedOrcidProfile
* @return
*/
@Override
@Transactional
public void addFundings(OrcidProfile updatedOrcidProfile) {
String orcid = updatedOrcidProfile.getOrcidIdentifier().getPath();
OrcidProfile existingProfile = retrieveOrcidProfile(orcid);
if (existingProfile == null) {
throw new IllegalArgumentException("No record found for " + orcid);
}
String amenderOrcid = sourceManager.retrieveSourceOrcid();
FundingList existingFundingList = existingProfile.retrieveFundings();
// updates the amount format to the right format according to the
// current locale
setFundingAmountsWithTheCorrectFormat(updatedOrcidProfile);
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);
addSourceToFundings(updatedFundingList, amenderOrcid);
List<Funding> updatedList = updatedFundingList.getFundings();
checkForAlreadyExistingFundings(existingFundingList, updatedList);
persistAddedFundings(orcid, updatedList);
profileDao.flush();
boolean notificationsEnabled = existingProfile.getOrcidInternal().getPreferences().getNotificationsEnabled();
if (notificationsEnabled) {
notificationManager.sendAmendEmail(existingProfile, AmendedSection.FUNDING);
}
}
use of org.orcid.jaxb.model.message.Visibility in project ORCID-Source by ORCID.
the class OrcidProfileManagerImpl method addDefaultVisibilityToBioItems.
private void addDefaultVisibilityToBioItems(OrcidProfile orcidProfile, Visibility defaultActivityVis, Boolean isClaimed) {
if (defaultActivityVis == null) {
defaultActivityVis = Visibility.PRIVATE;
}
if (isClaimed == null) {
isClaimed = false;
}
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);
} else {
x.setVisibility(listVisibility != null ? listVisibility : Visibility.PRIVATE);
}
}
}
if (orcidProfile.getOrcidBio().getKeywords() != null) {
Visibility listVisibility = orcidProfile.getOrcidBio().getKeywords().getVisibility();
for (Keyword x : orcidProfile.getOrcidBio().getKeywords().getKeyword()) {
if (isClaimed) {
x.setVisibility(defaultActivityVis);
} else {
x.setVisibility(listVisibility != null ? listVisibility : Visibility.PRIVATE);
}
}
}
if (orcidProfile.getOrcidBio().getResearcherUrls() != null) {
Visibility listVisibility = orcidProfile.getOrcidBio().getResearcherUrls().getVisibility();
for (ResearcherUrl x : orcidProfile.getOrcidBio().getResearcherUrls().getResearcherUrl()) {
if (isClaimed) {
x.setVisibility(defaultActivityVis);
} else {
x.setVisibility(listVisibility != null ? listVisibility : Visibility.PRIVATE);
}
}
}
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()) {
if (isClaimed) {
x.setVisibility(defaultActivityVis);
} else {
x.setVisibility(listVisibility != null ? listVisibility : Visibility.PRIVATE);
}
}
}
if (orcidProfile.getOrcidBio().getContactDetails() != null && orcidProfile.getOrcidBio().getContactDetails().getAddress() != null && orcidProfile.getOrcidBio().getContactDetails().getAddress().getCountry() != null) {
Country country = orcidProfile.getOrcidBio().getContactDetails().getAddress().getCountry();
if (isClaimed) {
country.setVisibility(defaultActivityVis);
} else {
country.setVisibility(country.getVisibility() != null ? country.getVisibility() : Visibility.PRIVATE);
}
}
}
}
use of org.orcid.jaxb.model.message.Visibility in project ORCID-Source by ORCID.
the class DefaultPermissionChecker method getVisibilitiesForOauth2Authentication.
private Set<Visibility> getVisibilitiesForOauth2Authentication(OAuth2Authentication oAuth2Authentication, OrcidMessage orcidMessage, ScopePathType requiredScope) {
Set<Visibility> visibilities = new HashSet<Visibility>();
visibilities.add(Visibility.PUBLIC);
String orcid = orcidMessage.getOrcidProfile().getOrcidIdentifier().getPath();
// effectively means that the user can only see the public data
try {
checkScopes(oAuth2Authentication, requiredScope);
} catch (AccessControlException e) {
return visibilities;
}
// we can allow for access of protected data
if (!oAuth2Authentication.isClientOnly() && oAuth2Authentication.getPrincipal() != null && ProfileEntity.class.isAssignableFrom(oAuth2Authentication.getPrincipal().getClass())) {
ProfileEntity principal = (ProfileEntity) oAuth2Authentication.getPrincipal();
visibilities.add(Visibility.REGISTERED_ONLY);
if (principal != null && principal.getId().equals(orcid)) {
Set<String> requestedScopes = oAuth2Authentication.getOAuth2Request().getScope();
for (String scope : requestedScopes) {
if (ScopePathType.hasStringScope(scope, requiredScope)) {
visibilities.add(Visibility.LIMITED);
break;
}
}
}
// This is a client credential authenticated client. If the profile
// was created using this client and it
// hasn't been claimed, it's theirs to read
} else if (oAuth2Authentication.isClientOnly()) {
OAuth2Request authorizationRequest = oAuth2Authentication.getOAuth2Request();
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);
}
}
return visibilities;
}
use of org.orcid.jaxb.model.message.Visibility in project ORCID-Source by ORCID.
the class OrcidJaxbCopyManagerImpl method copyUpdatedKeywordsToExistingPreservingVisibility.
@Override
public void copyUpdatedKeywordsToExistingPreservingVisibility(OrcidBio existing, OrcidBio updated) {
if (updated.getKeywords() == null) {
return;
}
Visibility existingKeywordsVisibility = existing.getKeywords() != null && existing.getKeywords().getVisibility() != null ? existing.getKeywords().getVisibility() : OrcidVisibilityDefaults.KEYWORD_DEFAULT.getVisibility();
Visibility updatedKeywordsVisibility = updated.getKeywords().getVisibility() != null ? updated.getKeywords().getVisibility() : existingKeywordsVisibility;
Keywords updatedKeywords = updated.getKeywords();
updatedKeywords.setVisibility(updatedKeywordsVisibility);
existing.setKeywords(updatedKeywords);
}
Aggregations