Search in sources :

Example 61 with OrcidMessage

use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.

the class OrcidSearchManagerImpl method findPublicProfileById.

@Override
public OrcidMessage findPublicProfileById(String orcid) {
    OrcidMessage om = null;
    try {
        if (cachingSource.equals(DB)) {
            OrcidProfile orcidProfile = orcidProfileCacheManager.retrievePublic(orcid);
            orcidProfile.setOrcidInternal(null);
            om = new OrcidMessage(orcidProfile);
        } else {
            try (Reader reader = solrDao.findByOrcidAsReader(orcid)) {
                if (reader != null) {
                    BufferedReader br = new BufferedReader(reader);
                    om = OrcidMessage.unmarshall(br);
                }
            }
        }
    } catch (NonTransientDataAccessResourceException e) {
        throw new OrcidSearchException("Error searching by id: " + orcid, e);
    } catch (IOException e) {
        throw new OrcidSearchException("Error closing stream for id: " + orcid, e);
    }
    if (om == null)
        throw new OrcidSearchException("Result is null");
    return om;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) NonTransientDataAccessResourceException(org.springframework.dao.NonTransientDataAccessResourceException) OrcidSearchException(org.orcid.core.exception.OrcidSearchException) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) BufferedReader(java.io.BufferedReader) Reader(java.io.Reader) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException)

Example 62 with OrcidMessage

use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.

the class NotificationManagerTest method testSendWelcomeEmail.

@Test
public void testSendWelcomeEmail() throws JAXBException, IOException, URISyntaxException {
    OrcidMessage orcidMessage = (OrcidMessage) unmarshaller.unmarshal(getClass().getResourceAsStream(ORCID_INTERNAL_FULL_XML));
    OrcidProfile orcidProfile = orcidMessage.getOrcidProfile();
    notificationManager.sendWelcomeEmail(orcidProfile.getOrcidIdentifier().getPath(), orcidProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail().getValue());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 63 with OrcidMessage

use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.

the class ValidationManagerTest method testEmptyMessage.

@Test(expected = OrcidValidationException.class)
public void testEmptyMessage() {
    OrcidMessage message = new OrcidMessage();
    incomingValidationManager.validateMessage(message);
}
Also used : OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) BaseTest(org.orcid.core.BaseTest) Test(org.junit.Test)

Example 64 with OrcidMessage

use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.

the class BaseControllerTest method getOrcidProfile.

protected static OrcidProfile getOrcidProfile() {
    try {
        JAXBContext context = JAXBContext.newInstance(OrcidMessage.class);
        Unmarshaller unmarshaller = context.createUnmarshaller();
        OrcidMessage orcidMessage = (OrcidMessage) unmarshaller.unmarshal(BaseControllerTest.class.getResourceAsStream("/orcid-internal-full-message-latest.xml"));
        return orcidMessage.getOrcidProfile();
    } catch (JAXBException e) {
        throw new RuntimeException(e);
    }
}
Also used : OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) JAXBException(javax.xml.bind.JAXBException) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller)

Example 65 with OrcidMessage

use of org.orcid.jaxb.model.message.OrcidMessage in project ORCID-Source by ORCID.

the class T2OrcidApiServiceVersionedDelegatorImpl method addWorks.

@Override
public Response addWorks(UriInfo uriInfo, String orcid, OrcidMessage orcidMessage) {
    Response response = null;
    validateIncomingMessage(orcidMessage, orcid);
    OrcidMessage upgradedMessage = upgradeMessage(orcidMessage);
    response = t2OrcidApiServiceDelegator.addWorks(uriInfo, orcid, upgradedMessage);
    return response;
}
Also used : Response(javax.ws.rs.core.Response) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage)

Aggregations

OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)173 Test (org.junit.Test)108 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)64 DBUnitTest (org.orcid.test.DBUnitTest)49 ClientResponse (com.sun.jersey.api.client.ClientResponse)36 Response (javax.ws.rs.core.Response)26 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)22 Transactional (org.springframework.transaction.annotation.Transactional)22 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)20 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)19 Email (org.orcid.jaxb.model.message.Email)18 BaseTest (org.orcid.core.BaseTest)17 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)16 Affiliation (org.orcid.jaxb.model.message.Affiliation)13 OrcidSearchResult (org.orcid.jaxb.model.message.OrcidSearchResult)12 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)12 JAXBContext (javax.xml.bind.JAXBContext)11 Unmarshaller (javax.xml.bind.Unmarshaller)11 Organization (org.orcid.jaxb.model.message.Organization)11 OrganizationAddress (org.orcid.jaxb.model.message.OrganizationAddress)11