use of org.orcid.jaxb.model.message.PersonalDetails in project ORCID-Source by ORCID.
the class OrcidIndexManagerImplTest method getOrcidProfileMandatoryOnly.
/**
* According to the validation rules on the web front end, these fields are
* mandatory. Ultimately they may or may not make it into SOLR due to
* visibility restrictions
*
* @return OrcidProfile with only mandatory fields populated.
*/
private OrcidProfile getOrcidProfileMandatoryOnly() {
OrcidProfile orcidProfile = new OrcidProfile();
orcidProfile.setOrcidIdentifier("5678");
OrcidBio orcidBio = new OrcidBio();
orcidProfile.setOrcidBio(orcidBio);
ContactDetails contactDetails = new ContactDetails();
contactDetails.addOrReplacePrimaryEmail(new Email("stan@test.com"));
orcidBio.setContactDetails(contactDetails);
PersonalDetails personalDetails = new PersonalDetails();
FamilyName familyName = new FamilyName("Logan");
familyName.setVisibility(Visibility.PUBLIC);
personalDetails.setFamilyName(familyName);
GivenNames givenNames = new GivenNames("Donald Edward");
givenNames.setVisibility(Visibility.PUBLIC);
personalDetails.setGivenNames(givenNames);
orcidBio.setPersonalDetails(personalDetails);
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
Affiliations affiliations = new Affiliations();
orcidActivities.setAffiliations(affiliations);
return orcidProfile;
}
use of org.orcid.jaxb.model.message.PersonalDetails in project ORCID-Source by ORCID.
the class OrcidIndexManagerImplTest method getStandardOrcid.
private OrcidProfile getStandardOrcid() {
OrcidProfile orcidProfile = new OrcidProfile();
orcidProfile.setOrcidIdentifier("1234");
OrcidBio orcidBio = new OrcidBio();
ContactDetails contactDetails = new ContactDetails();
Email email = new Email("email");
email.setVisibility(Visibility.PUBLIC);
contactDetails.addOrReplacePrimaryEmail(email);
orcidBio.setContactDetails(contactDetails);
Keywords bioKeywords = new Keywords();
bioKeywords.getKeyword().add(new Keyword("Pavement Studies", Visibility.PUBLIC));
bioKeywords.getKeyword().add(new Keyword("Advanced Tea Making", Visibility.PUBLIC));
bioKeywords.setVisibility(Visibility.PUBLIC);
orcidBio.setKeywords(bioKeywords);
PersonalDetails personalDetails = new PersonalDetails();
CreditName creditName = new CreditName("credit name");
creditName.setVisibility(Visibility.PUBLIC);
personalDetails.setCreditName(creditName);
FamilyName familyName = new FamilyName("familyName");
familyName.setVisibility(Visibility.PUBLIC);
personalDetails.setFamilyName(familyName);
OtherNames otherNames = new OtherNames();
otherNames.setVisibility(Visibility.PUBLIC);
otherNames.getOtherName().add(new OtherName("Other 1", Visibility.PUBLIC));
otherNames.getOtherName().add(new OtherName("Other 2", Visibility.PUBLIC));
personalDetails.setOtherNames(otherNames);
GivenNames givenNames = new GivenNames("givenNames");
givenNames.setVisibility(Visibility.PUBLIC);
personalDetails.setGivenNames(givenNames);
orcidBio.setPersonalDetails(personalDetails);
ExternalIdentifiers externalIdentifiers = new ExternalIdentifiers();
externalIdentifiers.setVisibility(Visibility.PUBLIC);
orcidBio.setExternalIdentifiers(externalIdentifiers);
ExternalIdentifier externalIdentifier1 = createExternalIdentifier("45678", "defghi");
externalIdentifiers.getExternalIdentifier().add(externalIdentifier1);
ExternalIdentifier externalIdentifier2 = createExternalIdentifier("54321", "abc123");
externalIdentifiers.getExternalIdentifier().add(externalIdentifier2);
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
Affiliations affiliations = new Affiliations();
orcidActivities.setAffiliations(affiliations);
FundingList fundings = new FundingList();
orcidActivities.setFundings(fundings);
OrcidWorks orcidWorks = new OrcidWorks();
OrcidWork orcidWork1 = new OrcidWork();
orcidWork1.setVisibility(Visibility.PUBLIC);
OrcidWork orcidWork2 = new OrcidWork();
orcidWork2.setVisibility(Visibility.PUBLIC);
OrcidWork orcidWork3 = new OrcidWork();
orcidWork3.setVisibility(Visibility.LIMITED);
WorkTitle workTitle1 = new WorkTitle();
Title title1 = new Title("Work title 1");
workTitle1.setTitle(title1);
workTitle1.setSubtitle(null);
orcidWork1.setWorkTitle(workTitle1);
WorkExternalIdentifier wei = new WorkExternalIdentifier();
wei.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work1-pmid"));
wei.setWorkExternalIdentifierType(WorkExternalIdentifierType.PMID);
orcidWork1.setWorkExternalIdentifiers(new WorkExternalIdentifiers(Arrays.asList(wei)));
WorkTitle workTitle2 = new WorkTitle();
Title title2 = new Title("Work title 2");
workTitle2.setSubtitle(null);
workTitle2.setTitle(title2);
orcidWork2.setWorkTitle(workTitle2);
WorkTitle workTitle3 = new WorkTitle();
Title title3 = new Title("Work Title 3");
workTitle3.setSubtitle(null);
workTitle3.setTitle(title3);
orcidWork3.setWorkTitle(workTitle3);
orcidWorks.setOrcidWork(new ArrayList<OrcidWork>(Arrays.asList(new OrcidWork[] { orcidWork1, orcidWork2, orcidWork3 })));
orcidProfile.setOrcidWorks(orcidWorks);
orcidProfile.setOrcidBio(orcidBio);
return orcidProfile;
}
use of org.orcid.jaxb.model.message.PersonalDetails in project ORCID-Source by ORCID.
the class OrcidApiAuthorizationSecurityAspect method visibilityResponseFilter.
@AfterReturning(pointcut = "@annotation(accessControl)", returning = "response")
public void visibilityResponseFilter(Response response, AccessControl accessControl) {
if (accessControl.requestComesFromInternalApi()) {
return;
}
Object entity = response.getEntity();
if (entity != null && OrcidMessage.class.isAssignableFrom(entity.getClass())) {
OrcidMessage orcidMessage = (OrcidMessage) entity;
//If it is search results, don't filter them, just return them
if (orcidMessage.getOrcidSearchResults() != null) {
return;
}
// get the client id
Object authentication = getAuthentication();
Set<Visibility> visibilities = new HashSet<Visibility>();
if (allowAnonymousAccess((Authentication) authentication, accessControl)) {
visibilities.add(Visibility.PUBLIC);
} else {
visibilities = permissionChecker.obtainVisibilitiesForAuthentication(getAuthentication(), accessControl.requiredScope(), orcidMessage);
}
//If the message contains a bio, and the given name is filtered, restore it as an empty space
boolean setEmptyGivenNameIfFiltered = false;
if (orcidMessage.getOrcidProfile() != null) {
if (orcidMessage.getOrcidProfile() != null && orcidMessage.getOrcidProfile().getOrcidBio() != null) {
setEmptyGivenNameIfFiltered = true;
}
}
ScopePathType requiredScope = accessControl.requiredScope();
// If the required scope is */read-limited or */update
if (isUpdateOrReadScope(requiredScope)) {
// if it should be able to
if (OrcidOAuth2Authentication.class.isAssignableFrom(authentication.getClass())) {
OrcidOAuth2Authentication orcidAuth = (OrcidOAuth2Authentication) getAuthentication();
OAuth2Request authorization = orcidAuth.getOAuth2Request();
String clientId = authorization.getClientId();
// #1: Get the user orcid
String userOrcid = getUserOrcidFromOrcidMessage(orcidMessage);
// #2: Evaluate the scope to know which field to filter
boolean allowWorks = false;
boolean allowFunding = false;
boolean allowAffiliations = false;
// Get the update equivalent scope, if it is reading, but,
// doesnt have the read permissions, check if it have the
// update permissions
ScopePathType equivalentUpdateScope = getEquivalentUpdateScope(requiredScope);
if (requiredScope.equals(ScopePathType.READ_LIMITED)) {
if (hasScopeEnabled(clientId, userOrcid, ScopePathType.ORCID_WORKS_READ_LIMITED.getContent(), ScopePathType.ORCID_WORKS_UPDATE.getContent()))
allowWorks = true;
if (hasScopeEnabled(clientId, userOrcid, ScopePathType.FUNDING_READ_LIMITED.getContent(), ScopePathType.FUNDING_UPDATE.getContent()))
allowFunding = true;
if (hasScopeEnabled(clientId, userOrcid, ScopePathType.AFFILIATIONS_READ_LIMITED.getContent(), ScopePathType.AFFILIATIONS_UPDATE.getContent()))
allowAffiliations = true;
} else if (requiredScope.equals(ScopePathType.ORCID_WORKS_UPDATE) || requiredScope.equals(ScopePathType.ORCID_WORKS_READ_LIMITED)) {
// works
if (hasScopeEnabled(clientId, userOrcid, requiredScope.getContent(), equivalentUpdateScope == null ? null : equivalentUpdateScope.getContent()))
// If so, allow him to see private works
allowWorks = true;
} else if (requiredScope.equals(ScopePathType.FUNDING_UPDATE) || requiredScope.equals(ScopePathType.FUNDING_READ_LIMITED)) {
// funding
if (hasScopeEnabled(clientId, userOrcid, requiredScope.getContent(), equivalentUpdateScope == null ? null : equivalentUpdateScope.getContent()))
// If so, allow him to see private funding
allowFunding = true;
} else if (requiredScope.equals(ScopePathType.AFFILIATIONS_UPDATE) || requiredScope.equals(ScopePathType.AFFILIATIONS_READ_LIMITED)) {
// affiliations
if (hasScopeEnabled(clientId, userOrcid, requiredScope.getContent(), equivalentUpdateScope == null ? null : equivalentUpdateScope.getContent()))
// If so, allow him to see private affiliations
allowAffiliations = true;
}
visibilityFilter.filter(orcidMessage, clientId, allowWorks, allowFunding, allowAffiliations, visibilities.toArray(new Visibility[visibilities.size()]));
} else {
visibilityFilter.filter(orcidMessage, null, false, false, false, visibilities.toArray(new Visibility[visibilities.size()]));
}
} else {
visibilityFilter.filter(orcidMessage, null, false, false, false, visibilities.toArray(new Visibility[visibilities.size()]));
}
//If the given name was set at the beginning and now is filtered, it means we should restore it as an empty field
if (setEmptyGivenNameIfFiltered) {
if (orcidMessage.getOrcidProfile() != null) {
if (orcidMessage.getOrcidProfile().getOrcidBio() == null) {
orcidMessage.getOrcidProfile().setOrcidBio(new OrcidBio());
}
if (orcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails() == null) {
orcidMessage.getOrcidProfile().getOrcidBio().setPersonalDetails(new PersonalDetails());
}
}
}
//Filter given or family names visibility
if (orcidMessage.getOrcidProfile() != null) {
if (orcidMessage.getOrcidProfile().getOrcidBio() != null) {
if (orcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails() != null) {
if (orcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails().getGivenNames() != null) {
orcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails().getGivenNames().setVisibility(null);
} else {
//Null given names could break client integrations, so, lets return an empty string
GivenNames empty = new GivenNames();
empty.setContent(StringUtils.EMPTY);
orcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails().setGivenNames(empty);
}
if (orcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails().getFamilyName() != null) {
orcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails().getFamilyName().setVisibility(null);
}
}
}
}
//replace section visibilities now we may have filtered items
if (orcidMessage.getOrcidProfile() != null) {
if (orcidMessage.getOrcidProfile().getOrcidBio() != null) {
if (orcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails() != null) {
OtherNames n = orcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails().getOtherNames();
if (n != null) {
n.setVisibility(getMostFromCollection(n.getOtherName()));
}
}
ExternalIdentifiers ids = orcidMessage.getOrcidProfile().getOrcidBio().getExternalIdentifiers();
if (ids != null) {
ids.setVisibility(getMostFromCollection(ids.getExternalIdentifier()));
}
Keywords kws = orcidMessage.getOrcidProfile().getOrcidBio().getKeywords();
if (kws != null) {
kws.setVisibility(getMostFromCollection(kws.getKeyword()));
}
ResearcherUrls urls = orcidMessage.getOrcidProfile().getOrcidBio().getResearcherUrls();
if (urls != null) {
urls.setVisibility(getMostFromCollection(urls.getResearcherUrl()));
}
}
}
}
}
use of org.orcid.jaxb.model.message.PersonalDetails in project ORCID-Source by ORCID.
the class EmailMessageSenderTest method testCreateDigest.
@Test
public void testCreateDigest() throws IOException {
OrcidProfile orcidProfile = new OrcidProfile();
OrcidBio orcidBio = new OrcidBio();
orcidProfile.setOrcidBio(orcidBio);
PersonalDetails personalDetails = new PersonalDetails();
orcidBio.setPersonalDetails(personalDetails);
personalDetails.setGivenNames(new GivenNames("John"));
personalDetails.setFamilyName(new FamilyName("Watson"));
OrcidInternal orcidInternal = new OrcidInternal();
Preferences preferences = new Preferences();
orcidProfile.setOrcidInternal(orcidInternal);
orcidInternal.setPreferences(preferences);
preferences.setSendEmailFrequencyDays("7.0");
List<Notification> notifications = new ArrayList<>();
NotificationPermission notification1 = new NotificationPermission();
notification1.setPutCode(1L);
Items activities1 = new Items();
notification1.setItems(activities1);
activities1.getItems().add(createActivity(ItemType.WORK, "Work 1", "123446/67654"));
activities1.getItems().add(createActivity(ItemType.WORK, "Work 2", "http://dx.doi.org/123446/67655"));
notification1.setCreatedDate(DateUtils.convertToXMLGregorianCalendar("2014-07-10T13:39:31"));
notification1.setAuthorizationUrl(new AuthorizationUrl("https://thirdparty.com/add-to-orcid/12345"));
Source source1 = new Source();
source1.setSourceName(new SourceName("Super Institution 1"));
source1.setSourceClientId(new SourceClientId("APP-5555-5555-5555-5555"));
notification1.setSource(source1);
notifications.add(notification1);
NotificationPermission notification2 = new NotificationPermission();
notification2.setPutCode(2L);
Items activities2 = new Items();
notification2.setItems(activities2);
activities2.getItems().add(createActivity(ItemType.EMPLOYMENT, "Employment 1 ", "12345/abc"));
notification2.setCreatedDate(DateUtils.convertToXMLGregorianCalendar("2014-08-17T10:22:15"));
notification2.setAuthorizationUrl(new AuthorizationUrl("https://thirdparty.com/add-to-orcid/abc"));
Source source2 = new Source();
source2.setSourceName(new SourceName("Super Institution 1"));
source2.setSourceClientId(new SourceClientId("APP-5555-5555-5555-5555"));
notification2.setSource(source2);
notifications.add(notification2);
NotificationPermission notification3 = new NotificationPermission();
notification3.setPutCode(3L);
Items activities3 = new Items();
notification3.setItems(activities3);
activities3.getItems().add(createActivity(ItemType.WORK, "Work 3", "12345/def"));
activities3.getItems().add(createActivity(ItemType.WORK, "Work 4", "12345/ghi"));
notification3.setCreatedDate(DateUtils.convertToXMLGregorianCalendar("2014-07-10T08:53:56"));
notification3.setAuthorizationUrl(new AuthorizationUrl("https://thirdparty.com/add-to-orcid/def"));
Source source3 = new Source();
source3.setSourceName(new SourceName("Lovely Publisher 1"));
notification3.setSource(source3);
source3.setSourceClientId(new SourceClientId("APP-ABCD-ABCD-ABCD-ABCD"));
notifications.add(notification3);
NotificationCustom notification4 = new NotificationCustom();
notification4.setPutCode(4L);
notification4.setSubject("We have release a new messaging feature");
notification4.setCreatedDate(DateUtils.convertToXMLGregorianCalendar("2014-07-10T08:53:56"));
notifications.add(notification4);
NotificationCustom notification5 = new NotificationCustom();
notification5.setPutCode(5L);
notification5.setSubject("The ORCID registry is now available in Orc");
notification5.setCreatedDate(DateUtils.convertToXMLGregorianCalendar("2014-07-11T06:42:18"));
notifications.add(notification5);
NotificationAmended notification6 = new NotificationAmended();
notification6.setPutCode(6L);
notification6.setSubject("Amended by member");
notification6.setAmendedSection(AmendedSection.FUNDING);
notification6.setCreatedDate(DateUtils.convertToXMLGregorianCalendar("2014-07-12T18:44:36"));
notification6.setSource(source3);
notifications.add(notification6);
EmailMessage emailMessage = emailMessageSender.createDigest(orcidProfile, notifications, Locale.ENGLISH);
assertNotNull(emailMessage);
String expectedBodyText = IOUtils.toString(getClass().getResourceAsStream("example_digest_email_body.txt"));
String expectedBodyHtml = IOUtils.toString(getClass().getResourceAsStream("example_digest_email_body.html"));
assertTrue(expectedBodyText.contains("Lovely Publisher 1 has updated recent funding on your ORCID record."));
assertTrue(expectedBodyHtml.contains("Lovely Publisher 1 has updated recent funding on your ORCID record."));
assertTrue(expectedBodyText.contains("Super Institution 1: Request to add items"));
assertTrue(expectedBodyHtml.contains("Super Institution 1: Request to add items"));
assertTrue(expectedBodyText.contains("/action"));
assertTrue(expectedBodyHtml.contains("/action"));
assertEquals("[ORCID] John Watson you have 6 new notifications", emailMessage.getSubject());
}
use of org.orcid.jaxb.model.message.PersonalDetails in project ORCID-Source by ORCID.
the class OrcidSearchManagerImplTest method getOrcidProfileAllIndexFieldsPopulated.
private OrcidProfile getOrcidProfileAllIndexFieldsPopulated() {
OrcidProfile orcidProfile = new OrcidProfile();
orcidProfile.setOrcidIdentifier("5678");
OrcidBio orcidBio = new OrcidBio();
PersonalDetails personalDetails = new PersonalDetails();
personalDetails.setFamilyName(new FamilyName("Logan"));
personalDetails.setGivenNames(new GivenNames("Donald Edward"));
personalDetails.setCreditName(new CreditName("Stanley Higgins"));
OtherNames otherNames = new OtherNames();
otherNames.getOtherName().add(new OtherName("Edward Bass", null));
otherNames.getOtherName().add(new OtherName("Gareth Dove", null));
personalDetails.setOtherNames(otherNames);
orcidBio.setPersonalDetails(personalDetails);
orcidProfile.setOrcidBio(orcidBio);
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
Affiliations affiliations = new Affiliations();
orcidActivities.setAffiliations(affiliations);
OrcidWorks orcidWorks = new OrcidWorks();
orcidProfile.setOrcidWorks(orcidWorks);
OrcidWork orcidWork1 = new OrcidWork();
OrcidWork orcidWork2 = new OrcidWork();
assignWorkIdentifers(orcidWork1, orcidWork2);
orcidWorks.getOrcidWork().add(orcidWork1);
orcidWorks.getOrcidWork().add(orcidWork2);
orcidProfile.setOrcidWorks(orcidWorks);
FundingList orcidFundings = new FundingList();
orcidProfile.setFundings(orcidFundings);
Funding funding1 = new Funding();
funding1.setVisibility(Visibility.PUBLIC);
FundingTitle title = new FundingTitle();
title.setTitle(new Title("grant1"));
funding1.setTitle(title);
funding1.setDescription("Grant 1 - a short description");
funding1.setPutCode("grant 1 - put-code");
Funding funding2 = new Funding();
funding2.setVisibility(Visibility.PUBLIC);
FundingTitle title2 = new FundingTitle();
title2.setTitle(new Title("grant2"));
funding2.setTitle(title2);
funding2.setDescription("Grant 2 - a short description");
funding2.setPutCode("grant 2 - put-code");
orcidFundings.getFundings().add(funding1);
orcidFundings.getFundings().add(funding2);
return orcidProfile;
}
Aggregations