use of org.orcid.jaxb.model.message.OrcidIdentifier in project ORCID-Source by ORCID.
the class DefaultPermissionChecker method performClientChecks.
private void performClientChecks(OAuth2Authentication oAuth2Authentication, ScopePathType requiredScope, OrcidMessage orcidMessage, String orcid) {
OAuth2Request authorizationRequest = oAuth2Authentication.getOAuth2Request();
// as an update
if (orcidMessage != null && orcidMessage.getOrcidProfile() != null && StringUtils.isNotBlank(orcid)) {
OrcidIdentifier orcidOb = orcidMessage.getOrcidProfile().getOrcidIdentifier();
String messageOrcid = orcidOb != null ? orcidOb.getPath() : orcid;
if (StringUtils.isNotBlank(messageOrcid) && !orcid.equals(messageOrcid)) {
throw new IllegalArgumentException("The ORCID in the body and the URI do NOT match. Body ORCID: " + messageOrcid + " URI ORCID: " + orcid + " do NOT match.");
}
profileEntityCacheManager.retrieve(messageOrcid);
if (!profileEntityManager.existsAndNotClaimedAndBelongsTo(messageOrcid, authorizationRequest.getClientId())) {
throw new AccessControlException("You cannot update this profile as it has been claimed, or you are not the owner.");
}
}
}
use of org.orcid.jaxb.model.message.OrcidIdentifier in project ORCID-Source by ORCID.
the class VisibilityFilterImpl method getMessageIdForLog.
private String getMessageIdForLog(OrcidMessage messageToBeFiltered) {
String messageIdForLog = "unknown";
OrcidSearchResults orcidSearchResults = messageToBeFiltered.getOrcidSearchResults();
OrcidProfile orcidProfile = messageToBeFiltered.getOrcidProfile();
if (orcidSearchResults != null) {
messageIdForLog = "orcid-search-results";
} else if (orcidProfile != null) {
OrcidIdentifier orcidIdentifier = orcidProfile.getOrcidIdentifier();
if (orcidIdentifier != null) {
messageIdForLog = orcidIdentifier.getPath();
}
Orcid orcid = orcidProfile.getOrcid();
if (orcid != null) {
messageIdForLog = orcid.getValue();
}
}
return messageIdForLog;
}
use of org.orcid.jaxb.model.message.OrcidIdentifier in project ORCID-Source by ORCID.
the class RegistrationController method getDupicateResearcher.
@RequestMapping(value = "/dupicateResearcher.json", method = RequestMethod.GET)
@ResponseBody
public List<DupicateResearcher> getDupicateResearcher(@RequestParam("givenNames") String givenNames, @RequestParam("familyNames") String familyNames) {
List<DupicateResearcher> drList = new ArrayList<DupicateResearcher>();
List<OrcidProfile> potentialDuplicates = findPotentialDuplicatesByFirstNameLastName(givenNames, familyNames);
for (OrcidProfile op : potentialDuplicates) {
DupicateResearcher dr = new DupicateResearcher();
if (op.getOrcidBio() != null) {
if (op.getOrcidBio().getContactDetails() != null) {
if (op.getOrcidBio().getContactDetails().retrievePrimaryEmail() != null) {
dr.setEmail(op.getOrcidBio().getContactDetails().retrievePrimaryEmail().getValue());
}
}
FamilyName familyName = op.getOrcidBio().getPersonalDetails().getFamilyName();
if (familyName != null) {
dr.setFamilyNames(familyName.getContent());
}
dr.setGivenNames(op.getOrcidBio().getPersonalDetails().getGivenNames().getContent());
dr.setInstitution(null);
}
OrcidIdentifier orcidIdentifier = op.getOrcidIdentifier();
// check for null just in case.
if (orcidIdentifier != null) {
dr.setOrcid(orcidIdentifier.getPath());
}
drList.add(dr);
}
return drList;
}
use of org.orcid.jaxb.model.message.OrcidIdentifier in project ORCID-Source by ORCID.
the class NotificationManagerTest method testAddedDelegatesSentCorrectEmail.
@Test
public void testAddedDelegatesSentCorrectEmail() throws JAXBException, IOException, URISyntaxException {
TargetProxyHelper.injectIntoProxy(notificationManager, "profileEntityCacheManager", mockProfileEntityCacheManager);
TargetProxyHelper.injectIntoProxy(notificationManager, "emailManager", mockEmailManager);
TargetProxyHelper.injectIntoProxy(notificationManager, "profileDao", mockProfileDao);
TargetProxyHelper.injectIntoProxy(notificationManager, "notificationDao", mockNotificationDao);
TargetProxyHelper.injectIntoProxy(notificationManager, "notificationAdapter", mockNotificationAdapter);
final String orcid = "0000-0000-0000-0003";
String delegateOrcid = "1234-5678-1234-5678";
ProfileEntity profile = new ProfileEntity();
RecordNameEntity recordName = new RecordNameEntity();
recordName.setCreditName("My credit name");
recordName.setVisibility(Visibility.PUBLIC);
profile.setRecordNameEntity(recordName);
profile.setSendAdministrativeChangeNotifications(true);
profile.setSendChangeNotifications(true);
profile.setSendMemberUpdateRequests(true);
profile.setSendOrcidNews(true);
EmailEntity emailEntity = new EmailEntity();
emailEntity.setId("test@email.com");
emailEntity.setPrimary(true);
emailEntity.setCurrent(true);
Set<EmailEntity> emails = new HashSet<EmailEntity>();
emails.add(emailEntity);
profile.setEmails(emails);
SourceEntity sourceEntity = new SourceEntity(new ClientDetailsEntity("APP-5555555555555555"));
when(sourceManager.retrieveSourceEntity()).thenReturn(sourceEntity);
when(sourceManager.retrieveSourceOrcid()).thenReturn("APP-5555555555555555");
when(mockNotificationAdapter.toNotificationEntity(Mockito.any(Notification.class))).thenReturn(new NotificationCustomEntity());
Email email = new Email();
email.setEmail("test@email.com");
when(mockProfileEntityCacheManager.retrieve(Mockito.anyString())).thenAnswer(new Answer<ProfileEntity>() {
@Override
public ProfileEntity answer(InvocationOnMock invocation) throws Throwable {
profile.setId(invocation.getArgument(0));
return profile;
}
});
when(mockProfileDao.find(Mockito.anyString())).thenAnswer(new Answer<ProfileEntity>() {
@Override
public ProfileEntity answer(InvocationOnMock invocation) throws Throwable {
profile.setId(invocation.getArgument(0));
return profile;
}
});
when(mockEmailManager.findPrimaryEmail(orcid)).thenReturn(email);
DelegationDetails firstNewDelegate = new DelegationDetails();
DelegateSummary firstNewDelegateSummary = new DelegateSummary();
firstNewDelegateSummary.setCreditName(new CreditName("Jimmy Dove"));
firstNewDelegate.setDelegateSummary(firstNewDelegateSummary);
firstNewDelegateSummary.setOrcidIdentifier(new OrcidIdentifier(delegateOrcid));
for (org.orcid.jaxb.model.common_v2.Locale locale : org.orcid.jaxb.model.common_v2.Locale.values()) {
profile.setLocale(locale);
notificationManager.sendNotificationToAddedDelegate("0000-0000-0000-0003", firstNewDelegate);
}
}
Aggregations