use of org.orcid.jaxb.model.message.Email in project ORCID-Source by ORCID.
the class RDFWriterTest method fakeBio.
private OrcidMessage fakeBio() throws DatatypeConfigurationException {
OrcidMessage orcidMessage = new OrcidMessage();
OrcidProfile orcidProfile1 = new OrcidProfile();
OrcidIdentifier orcidIdentifier = new OrcidIdentifier();
orcidProfile1.setOrcidIdentifier(orcidIdentifier);
orcidIdentifier.setUri("http://orcid.example.com/000-1337");
orcidIdentifier.setPath("000-1337");
OrcidBio bio = new OrcidBio();
orcidProfile1.setOrcidBio(bio);
OrcidHistory history = new OrcidHistory();
XMLGregorianCalendar value = dataTypeFactory.newXMLGregorianCalendar(1980, 12, 31, 23, 29, 29, 999, 0);
history.setCreationMethod(CreationMethod.WEBSITE);
history.setLastModifiedDate(new LastModifiedDate(value));
orcidProfile1.setOrcidHistory(history);
PersonalDetails personal = new PersonalDetails();
bio.setPersonalDetails(personal);
personal.setFamilyName(new FamilyName("Doe"));
personal.setCreditName(new CreditName("John F Doe"));
personal.setGivenNames(new GivenNames("John"));
personal.setOtherNames(new OtherNames());
personal.getOtherNames().addOtherName("Johnny", Visibility.PUBLIC);
personal.getOtherNames().addOtherName("Mr Doe", Visibility.PUBLIC);
ResearcherUrls urls = new ResearcherUrls();
bio.setResearcherUrls(urls);
ResearcherUrl anonymous = new ResearcherUrl(new Url("http://example.com/anon"), Visibility.PUBLIC);
urls.getResearcherUrl().add(anonymous);
// "home page" - with strange casing
ResearcherUrl homePage = new ResearcherUrl(new Url("http://example.com/myPage"), new UrlName("homePage"), Visibility.PUBLIC);
urls.getResearcherUrl().add(homePage);
ResearcherUrl foaf = new ResearcherUrl(new Url("http://example.com/foaf#me"), new UrlName("FOAF"), Visibility.PUBLIC);
urls.getResearcherUrl().add(foaf);
ResearcherUrl webId = new ResearcherUrl(new Url("http://example.com/webId"), new UrlName("webID"), Visibility.PUBLIC);
urls.getResearcherUrl().add(webId);
ResearcherUrl other = new ResearcherUrl(new Url("http://example.com/other"), new UrlName("other"), Visibility.PUBLIC);
urls.getResearcherUrl().add(other);
bio.setContactDetails(new ContactDetails());
bio.getContactDetails().setEmail(Arrays.asList(new Email("john@example.org"), new Email("doe@example.com")));
bio.getContactDetails().setAddress(new Address());
bio.getContactDetails().getAddress().setCountry(new Country(Iso3166Country.GB));
orcidMessage.setOrcidProfile(orcidProfile1);
return orcidMessage;
}
use of org.orcid.jaxb.model.message.Email in project ORCID-Source by ORCID.
the class OrcidBatchLoad method assignPersistenceFields.
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();
}
use of org.orcid.jaxb.model.message.Email in project ORCID-Source by ORCID.
the class T2OrcidApiServiceVersionedDelegatorTest method testAttemptCreateWithTotallyIncorrectVersion.
@Test(expected = OrcidValidationException.class)
public void testAttemptCreateWithTotallyIncorrectVersion() {
setUpSecurityContextForClientOnly();
OrcidMessage orcidMessage = createStubOrcidMessage();
orcidMessage.setMessageVersion("abc");
Email email = new Email("madeupemail4@semantico.com");
orcidMessage.getOrcidProfile().getOrcidBio().getContactDetails().getEmail().add(email);
t2OrcidApiServiceDelegatorV2_1.createProfile(mockedUriInfo, orcidMessage);
}
use of org.orcid.jaxb.model.message.Email in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testReadPrivateEmailsOnBio.
@Test
public void testReadPrivateEmailsOnBio() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4497", ScopePathType.ORCID_BIO_READ_LIMITED, ScopePathType.EMAIL_READ_PRIVATE);
/*Example A List on 4444-4444-4444-4497:
Item 1 Private (client is source)
Item 2 Private (other source)
Item 3 Limited
Item 4 Public
*/
OrcidProfile p = ((OrcidMessage) t2OrcidApiServiceDelegator.findBioDetails("4444-4444-4444-4497").getEntity()).getOrcidProfile();
List<Email> emails = p.getOrcidBio().getContactDetails().getEmail();
assertEquals(3, emails.size());
boolean privateFound = false;
boolean publicFound = false;
boolean limitedFound = false;
for (Email email : emails) {
if ("public_4444-4444-4444-4497@test.orcid.org".equals(email.getValue()) && Visibility.PUBLIC.equals(email.getVisibility())) {
publicFound = true;
} else if ("limited_4444-4444-4444-4497@test.orcid.org".equals(email.getValue()) && Visibility.LIMITED.equals(email.getVisibility())) {
limitedFound = true;
} else if ("private_4444-4444-4444-4497@test.orcid.org".equals(email.getValue()) && Visibility.PRIVATE.equals(email.getVisibility())) {
privateFound = true;
}
}
assertTrue(publicFound);
assertTrue(limitedFound);
assertTrue(privateFound);
}
use of org.orcid.jaxb.model.message.Email in project ORCID-Source by ORCID.
the class T2OrcidApiServiceVersionedDelegatorTest method testCreateAndReadOwnCreation.
@Test
public void testCreateAndReadOwnCreation() {
setUpSecurityContextForClientOnly();
OrcidMessage orcidMessage = createStubOrcidMessage();
Email email = new Email("madeupemail@semantico.com");
email.setPrimary(true);
orcidMessage.getOrcidProfile().getOrcidBio().getContactDetails().getEmail().add(email);
Response createResponse = t2OrcidApiServiceDelegatorLatest.createProfile(mockedUriInfo, orcidMessage);
assertNotNull(createResponse);
assertEquals(HttpStatus.SC_CREATED, createResponse.getStatus());
String location = ((URI) createResponse.getMetadata().getFirst("Location")).getPath();
assertNotNull(location);
String orcid = location.substring(1, 20);
Response readResponse = t2OrcidApiServiceDelegatorLatest.findFullDetails(orcid);
assertNotNull(readResponse);
assertEquals(HttpStatus.SC_OK, readResponse.getStatus());
OrcidMessage retrievedMessage = (OrcidMessage) readResponse.getEntity();
assertEquals(orcid, retrievedMessage.getOrcidProfile().getOrcidIdentifier().getPath());
assertEquals("Test credit name", retrievedMessage.getOrcidProfile().getOrcidBio().getPersonalDetails().getCreditName().getContent());
}
Aggregations