use of org.orcid.jaxb.model.message.Visibility in project ORCID-Source by ORCID.
the class OrcidJaxbCopyManagerImpl method copyUpdatedExternalIdentifiersToExistingPreservingVisibility.
@Override
public void copyUpdatedExternalIdentifiersToExistingPreservingVisibility(OrcidBio existing, OrcidBio updated) {
if (updated.getExternalIdentifiers() == null) {
return;
}
ExternalIdentifiers existingExternalIdentifiers = existing.getExternalIdentifiers();
ExternalIdentifiers updatedExternalIdentifiers = updated.getExternalIdentifiers();
Visibility existingExternalIdentifiersVisibility = existingExternalIdentifiers != null ? existingExternalIdentifiers.getVisibility() : null;
Visibility updatedExternalIdentifiersVisibility = updatedExternalIdentifiers.getVisibility();
if (updatedExternalIdentifiersVisibility == null && existingExternalIdentifiersVisibility == null) {
updatedExternalIdentifiers.setVisibility(OrcidVisibilityDefaults.EXTERNAL_IDENTIFIER_DEFAULT.getVisibility());
} else if (updatedExternalIdentifiersVisibility == null && existingExternalIdentifiersVisibility != null) {
updatedExternalIdentifiers.setVisibility(existingExternalIdentifiersVisibility);
}
existing.setExternalIdentifiers(updatedExternalIdentifiers);
}
use of org.orcid.jaxb.model.message.Visibility in project ORCID-Source by ORCID.
the class OrcidJaxbCopyManagerImpl method copyUpdatedShortDescriptionToExistingPreservingVisibility.
@Override
public void copyUpdatedShortDescriptionToExistingPreservingVisibility(OrcidBio existing, OrcidBio updated) {
if (updated.getBiography() == null) {
return;
}
Biography existingShortDescription = existing.getBiography();
Biography updatedShortDescription = updated.getBiography();
Visibility existingShortDescriptionVisibility = existingShortDescription != null ? existingShortDescription.getVisibility() : OrcidVisibilityDefaults.SHORT_DESCRIPTION_DEFAULT.getVisibility();
Visibility updatedShortDescriptionVisibility = updatedShortDescription != null ? updatedShortDescription.getVisibility() : existingShortDescriptionVisibility;
if (updatedShortDescriptionVisibility == null && existingShortDescriptionVisibility == null) {
updatedShortDescription.setVisibility(OrcidVisibilityDefaults.SHORT_DESCRIPTION_DEFAULT.getVisibility());
} else if (updatedShortDescriptionVisibility == null && existingShortDescriptionVisibility != null) {
updatedShortDescription.setVisibility(existingShortDescriptionVisibility);
}
if (existingShortDescription != null) {
if (existingShortDescription.getVisibility() != null && !existingShortDescription.getVisibility().equals(Visibility.PRIVATE)) {
existing.setBiography(updatedShortDescription);
}
} else {
existing.setBiography(updatedShortDescription);
}
}
use of org.orcid.jaxb.model.message.Visibility in project ORCID-Source by ORCID.
the class OrcidJaxbCopyManagerImpl method copyUpdatedResearcherUrlPreservingVisbility.
@Override
public void copyUpdatedResearcherUrlPreservingVisbility(OrcidBio existing, OrcidBio updated) {
if (updated.getResearcherUrls() == null) {
return;
}
ResearcherUrls existingResearcherUrls = existing.getResearcherUrls();
ResearcherUrls updatedResearcherUrls = updated.getResearcherUrls();
Visibility existingVisibility = (existingResearcherUrls != null && existingResearcherUrls.getVisibility() != null) ? existingResearcherUrls.getVisibility() : OrcidVisibilityDefaults.RESEARCHER_URLS_DEFAULT.getVisibility();
Visibility updatedVisibility = (updatedResearcherUrls != null && updatedResearcherUrls.getVisibility() != null) ? updatedResearcherUrls.getVisibility() : existingVisibility;
// now visibility has been preserved, overwrite the content
updatedResearcherUrls.setVisibility(updatedVisibility);
existing.setResearcherUrls(updatedResearcherUrls);
}
use of org.orcid.jaxb.model.message.Visibility in project ORCID-Source by ORCID.
the class DefaultOAuthClientVisibilityTest method testCheckClientPermissionsAllowOnlyPublicAndLimitedVisibility.
@Test
@Transactional
@Rollback
public void testCheckClientPermissionsAllowOnlyPublicAndLimitedVisibility() throws Exception {
Set<String> resourceIds = new HashSet<String>(Arrays.asList("orcid"));
HashSet<GrantedAuthority> grantedAuthorities = new HashSet<GrantedAuthority>(Arrays.asList(new SimpleGrantedAuthority("ROLE_CLIENT")));
AuthorizationRequest request = new AuthorizationRequest("4444-4444-4444-4446", Arrays.asList("/orcid-bio/external-identifiers/create"));
request.setAuthorities(grantedAuthorities);
request.setResourceIds(resourceIds);
ProfileEntity entity = new ProfileEntity("4444-4444-4444-4446");
OrcidOauth2UserAuthentication oauth2UserAuthentication = new OrcidOauth2UserAuthentication(entity, true);
// we care only that an OAuth client request results in the correct
// visibilities
OrcidOAuth2Authentication oAuth2Authentication = new OrcidOAuth2Authentication(request, oauth2UserAuthentication, "made-up-token");
OrcidOauth2TokenDetail tokenDetail = new OrcidOauth2TokenDetail();
tokenDetail.setScope("/orcid-bio/external-identifiers/create");
tokenDetail.setDateCreated(new Date());
when(orcidOauth2TokenDetailService.findNonDisabledByTokenValue(any(String.class))).thenReturn(tokenDetail);
ScopePathType scopePathType = ScopePathType.ORCID_BIO_EXTERNAL_IDENTIFIERS_CREATE;
Set<Visibility> visibilitiesForClient = permissionChecker.obtainVisibilitiesForAuthentication(oAuth2Authentication, scopePathType, getOrcidMessage());
assertTrue(visibilitiesForClient.size() == 3);
assertTrue(visibilitiesForClient.contains(Visibility.LIMITED));
assertTrue(visibilitiesForClient.contains(Visibility.REGISTERED_ONLY));
assertTrue(visibilitiesForClient.contains(Visibility.PUBLIC));
}
use of org.orcid.jaxb.model.message.Visibility in project ORCID-Source by ORCID.
the class OrcidJaxbCopyManagerImpl method copyCreditNamePreservingVisibility.
private void copyCreditNamePreservingVisibility(PersonalDetails existingPersonalDetails, PersonalDetails updatedPersonalDetails) {
CreditName existingCreditName = existingPersonalDetails.getCreditName();
CreditName updatedCreditName = updatedPersonalDetails.getCreditName();
// if no update, nothing to do
if (updatedCreditName == null) {
return;
}
// otherwise take into account the visibility of updated and existing
Visibility existingVisibility = (existingCreditName != null && existingCreditName.getVisibility() != null) ? existingCreditName.getVisibility() : OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility();
// If it is private, ignore the request
if (!existingVisibility.equals(Visibility.PRIVATE)) {
Visibility updatedVisibility = (updatedCreditName != null && updatedCreditName.getVisibility() != null) ? updatedCreditName.getVisibility() : existingVisibility;
updatedCreditName.setVisibility(updatedVisibility);
// now visibility has been preserved, overwrite the content
existingPersonalDetails.setCreditName(updatedCreditName);
}
}
Aggregations