use of org.orcid.jaxb.model.record_v2.Record in project ORCID-Source by ORCID.
the class ValidateV2SamplesTest method unmarshallFromPath.
private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
Object obj = unmarshall(reader, type, schemaPath);
Object result = null;
if (ResearcherUrls.class.equals(type)) {
result = (ResearcherUrls) obj;
} else if (ResearcherUrl.class.equals(type)) {
result = (ResearcherUrl) obj;
} else if (PersonalDetails.class.equals(type)) {
result = (PersonalDetails) obj;
} else if (PersonExternalIdentifier.class.equals(type)) {
result = (PersonExternalIdentifier) obj;
} else if (PersonExternalIdentifiers.class.equals(type)) {
result = (PersonExternalIdentifiers) obj;
} else if (Biography.class.equals(type)) {
result = (Biography) obj;
} else if (Name.class.equals(type)) {
result = (Name) obj;
} else if (CreditName.class.equals(type)) {
result = (CreditName) obj;
} else if (OtherName.class.equals(type)) {
result = (OtherName) obj;
} else if (OtherNames.class.equals(type)) {
result = (OtherNames) obj;
} else if (Keywords.class.equals(type)) {
result = (Keywords) obj;
} else if (Keyword.class.equals(type)) {
result = (Keyword) obj;
} else if (Addresses.class.equals(type)) {
result = (Addresses) obj;
} else if (Address.class.equals(type)) {
result = (Address) obj;
} else if (Emails.class.equals(type)) {
result = (Emails) obj;
} else if (Email.class.equals(type)) {
result = (Email) obj;
} else if (Person.class.equals(type)) {
result = (Person) obj;
} else if (Deprecated.class.equals(type)) {
result = (Deprecated) obj;
} else if (Preferences.class.equals(type)) {
result = (Preferences) obj;
} else if (History.class.equals(type)) {
result = (History) obj;
} else if (Record.class.equals(type)) {
result = (Record) obj;
} else if (ActivitiesSummary.class.equals(type)) {
result = (ActivitiesSummary) obj;
} else if (Works.class.equals(type)) {
result = (Works) obj;
}
return result;
} catch (IOException e) {
throw new RuntimeException("Error reading notification from classpath", e);
}
}
use of org.orcid.jaxb.model.record_v2.Record in project ORCID-Source by ORCID.
the class ValidateV2_1IdentifiersTest method testPeerReview.
/** Test both types of identifier here
*
* @throws SAXException
* @throws IOException
* @throws JAXBException
* @throws ParserConfigurationException
*/
@Test
public void testPeerReview() throws SAXException, IOException, JAXBException, ParserConfigurationException {
PeerReview peerReview = unmarshallFromPath("/record_2.1/samples/read_samples/peer-review-2.1.xml", PeerReview.class);
ExternalID id = peerReview.getExternalIdentifiers().getExternalIdentifier().get(0);
assertEquals("source-work-id", id.getType());
assertEquals("work:external-identifier-id", id.getValue());
assertEquals(new Url("http://orcid.org"), id.getUrl());
assertEquals(Relationship.SELF, id.getRelationship());
ExternalID subjectid = peerReview.getSubjectExternalIdentifier();
assertEquals("doi", subjectid.getType());
assertEquals("peer-review:subject-external-identifier-id", subjectid.getValue());
assertEquals(new Url("http://orcid.org"), subjectid.getUrl());
assertEquals(Relationship.SELF, subjectid.getRelationship());
Validator validator = getValidator("peer-review");
validator.validate(marshall(PeerReview.class, peerReview));
validator.validate(marshallToDOM(PeerReview.class, peerReview));
//do the full record too
peerReview = unmarshallFromPath("/record_2.1/samples/read_samples/peer-review-full-2.1.xml", PeerReview.class);
id = peerReview.getExternalIdentifiers().getExternalIdentifier().get(0);
assertEquals("source-work-id", id.getType());
assertEquals("work:external-identifier-id", id.getValue());
assertEquals(new Url("http://orcid.org"), id.getUrl());
assertEquals(Relationship.SELF, id.getRelationship());
subjectid = peerReview.getSubjectExternalIdentifier();
assertEquals("doi", subjectid.getType());
assertEquals("peer-review:subject-external-identifier-id", subjectid.getValue());
assertEquals(new Url("http://orcid.org"), subjectid.getUrl());
assertEquals(Relationship.SELF, subjectid.getRelationship());
}
use of org.orcid.jaxb.model.record_v2.Record in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorImpl method viewRecord.
@Override
public Response viewRecord(String orcid) {
Record record = recordManagerReadOnly.getPublicRecord(orcid);
publicAPISecurityManagerV2.filter(record);
if (record.getPerson() != null) {
sourceUtilsReadOnly.setSourceName(record.getPerson());
}
if (record.getActivitiesSummary() != null) {
ActivityUtils.cleanEmptyFields(record.getActivitiesSummary());
sourceUtilsReadOnly.setSourceName(record.getActivitiesSummary());
}
ElementUtils.setPathToRecord(record, orcid);
Api2_0_LastModifiedDatesHelper.calculateLastModified(record);
return Response.ok(record).build();
}
use of org.orcid.jaxb.model.record_v2.Record in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_ReadRecordTest method testViewRecordWrongScope.
@Test
public void testViewRecordWrongScope() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
Response response = serviceDelegator.viewRecord(ORCID);
// Verify everything inside is public
Record record = (Record) response.getEntity();
assertNotNull(record);
assertEquals("/0000-0000-0000-0003", record.getPath());
assertEquals("/0000-0000-0000-0003/activities", record.getActivitiesSummary().getPath());
Utils.assertIsPublicOrSource(record.getActivitiesSummary(), SecurityContextTestUtils.DEFAULT_CLIENT_ID);
assertEquals("/0000-0000-0000-0003/person", record.getPerson().getPath());
Utils.assertIsPublicOrSource(record.getPerson(), SecurityContextTestUtils.DEFAULT_CLIENT_ID);
}
use of org.orcid.jaxb.model.record_v2.Record in project ORCID-Source by ORCID.
the class EmailManagerTest method moveEmailToOtherAccountTest.
@Test
public void moveEmailToOtherAccountTest() {
String email = "public@email.com";
String from = "4444-4444-4444-4441";
String to = "4444-4444-4444-4499";
ProfileEntity destinationBefore = profileDao.find(to);
Date beforeLastModified = destinationBefore.getLastModified();
Map<String, String> map = emailManager.findOricdIdsByCommaSeparatedEmails(email);
assertNotNull(map);
assertEquals(from, map.get(email));
emailManager.moveEmailToOtherAccount(email, from, to);
ProfileEntity destinationAfter = profileDao.find(to);
Date afterLastModified = destinationAfter.getLastModified();
assertFalse(beforeLastModified.equals(afterLastModified));
assertTrue(afterLastModified.getTime() > beforeLastModified.getTime());
//Assert the email was moved
map = emailManager.findOricdIdsByCommaSeparatedEmails(email);
assertNotNull(map);
assertEquals(to, map.get(email));
//Assert the email is not anymore in the from record
Emails emails = emailManager.getEmails(from, System.currentTimeMillis());
for (Email e : emails.getEmails()) {
assertFalse(email.equals(e.getEmail()));
}
//Assert the email belongs to the to record
emails = emailManager.getEmails(to, System.currentTimeMillis());
boolean found = false;
for (Email e : emails.getEmails()) {
if (email.equals(e.getEmail())) {
found = true;
}
}
assertTrue(found);
}
Aggregations