Search in sources :

Example 11 with Deprecated

use of org.orcid.jaxb.model.record_v2.Deprecated in project ORCID-Source by ORCID.

the class S3MessageProcessor method update_2_0_API.

private void update_2_0_API(BaseMessage message) {
    String orcid = message.getOrcid();
    if (is20IndexingEnabled) {
        // Update API 2.0
        try {
            Record record = orcid20ApiClient.fetchPublicRecord(message);
            if (record != null) {
                s3Updater.updateS3(orcid, record);
                recordStatusManager.markAsSent(orcid, AvailableBroker.DUMP_STATUS_2_0_API);
            }
        } catch (LockedRecordException | DeprecatedRecordException e) {
            try {
                OrcidError error = null;
                if (e instanceof LockedRecordException) {
                    LOG.error("Record " + orcid + " is locked");
                    error = ((LockedRecordException) e).getOrcidError();
                } else {
                    LOG.error("Record " + orcid + " is deprecated");
                    error = ((DeprecatedRecordException) e).getOrcidError();
                }
                exceptionHandler.handle20Exception(orcid, error);
                recordStatusManager.markAsSent(orcid, AvailableBroker.DUMP_STATUS_2_0_API);
            } catch (Exception e1) {
                LOG.error("Unable to handle LockedRecordException for record " + orcid, e1);
                recordStatusManager.markAsFailed(orcid, AvailableBroker.DUMP_STATUS_2_0_API);
            }
        } catch (AmazonClientException e) {
            LOG.error("Unable to fetch record " + orcid + " for 2.0 API: " + e.getMessage(), e);
            recordStatusManager.markAsFailed(orcid, AvailableBroker.DUMP_STATUS_1_2_API);
        } catch (Exception e) {
            // something else went wrong fetching record from ORCID and
            // threw a
            // runtime exception
            LOG.error("Unable to fetch record " + orcid + " for 2.0 API: " + e.getMessage(), e);
            recordStatusManager.markAsFailed(orcid, AvailableBroker.DUMP_STATUS_2_0_API);
        }
    }
}
Also used : LockedRecordException(org.orcid.listener.exception.LockedRecordException) OrcidError(org.orcid.jaxb.model.error_v2.OrcidError) DeprecatedRecordException(org.orcid.listener.exception.DeprecatedRecordException) AmazonClientException(com.amazonaws.AmazonClientException) Record(org.orcid.jaxb.model.record_v2.Record) LockedRecordException(org.orcid.listener.exception.LockedRecordException) DeprecatedRecordException(org.orcid.listener.exception.DeprecatedRecordException) IOException(java.io.IOException) AmazonClientException(com.amazonaws.AmazonClientException)

Example 12 with Deprecated

use of org.orcid.jaxb.model.record_v2.Deprecated in project ORCID-Source by ORCID.

the class S3MessageProcessor method update_2_0_API.

private void update_2_0_API(String orcid) {
    if (is20IndexingEnabled) {
        // Update API 2.0
        try {
            Record record = orcid20ApiClient.fetchPublicProfile(orcid);
            if (record != null) {
                s3Updater.updateS3(orcid, record);
                recordStatusManager.markAsSent(orcid, AvailableBroker.DUMP_STATUS_2_0_API);
            }
        } catch (LockedRecordException | DeprecatedRecordException e) {
            try {
                OrcidError error = null;
                if (e instanceof LockedRecordException) {
                    LOG.error("Record " + orcid + " is locked");
                    error = ((LockedRecordException) e).getOrcidError();
                } else {
                    LOG.error("Record " + orcid + " is deprecated");
                    error = ((DeprecatedRecordException) e).getOrcidError();
                }
                exceptionHandler.handle20Exception(orcid, error);
                recordStatusManager.markAsSent(orcid, AvailableBroker.DUMP_STATUS_2_0_API);
            } catch (JsonProcessingException | AmazonClientException | JAXBException e1) {
                LOG.error("Unable to handle LockedRecordException for record " + orcid, e1);
                recordStatusManager.markAsFailed(orcid, AvailableBroker.DUMP_STATUS_2_0_API);
            }
        } catch (Exception e) {
            // something else went wrong fetching record from ORCID and
            // threw a
            // runtime exception
            LOG.error("Unable to fetch record " + orcid + " for 2.0 API");
            LOG.error(e.getMessage(), e);
            recordStatusManager.markAsFailed(orcid, AvailableBroker.DUMP_STATUS_2_0_API);
        }
    }
}
Also used : LockedRecordException(org.orcid.listener.exception.LockedRecordException) OrcidError(org.orcid.jaxb.model.error_v2.OrcidError) DeprecatedRecordException(org.orcid.listener.exception.DeprecatedRecordException) Record(org.orcid.jaxb.model.record_v2.Record) LockedRecordException(org.orcid.listener.exception.LockedRecordException) DeprecatedRecordException(org.orcid.listener.exception.DeprecatedRecordException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) JAXBException(javax.xml.bind.JAXBException) AmazonClientException(com.amazonaws.AmazonClientException)

Example 13 with Deprecated

use of org.orcid.jaxb.model.record_v2.Deprecated in project ORCID-Source by ORCID.

the class ValidateV2RC4SamplesTest 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;
        }
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Error reading notification from classpath", e);
    }
}
Also used : Email(org.orcid.jaxb.model.record_rc4.Email) InputStreamReader(java.io.InputStreamReader) Keyword(org.orcid.jaxb.model.record_rc4.Keyword) Address(org.orcid.jaxb.model.record_rc4.Address) OtherNames(org.orcid.jaxb.model.record_rc4.OtherNames) CreditName(org.orcid.jaxb.model.record_rc4.CreditName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier) History(org.orcid.jaxb.model.record_rc4.History) ActivitiesSummary(org.orcid.jaxb.model.record.summary_rc4.ActivitiesSummary) Deprecated(org.orcid.jaxb.model.record_rc4.Deprecated) Biography(org.orcid.jaxb.model.record_rc4.Biography) ResearcherUrl(org.orcid.jaxb.model.record_rc4.ResearcherUrl)

Example 14 with Deprecated

use of org.orcid.jaxb.model.record_v2.Deprecated in project ORCID-Source by ORCID.

the class ValidateV2RC3SamplesTest method testMarshallDeprecated.

@Test
public void testMarshallDeprecated() throws JAXBException, SAXException, URISyntaxException {
    Deprecated object = (Deprecated) unmarshallFromPath("/record_2.0_rc3/samples/deprecated-2.0_rc3.xml", Deprecated.class);
    marshall(object, "/record_2.0_rc3/deprecated-2.0_rc3.xsd");
}
Also used : Deprecated(org.orcid.jaxb.model.record_rc3.Deprecated) Test(org.junit.Test)

Example 15 with Deprecated

use of org.orcid.jaxb.model.record_v2.Deprecated in project ORCID-Source by ORCID.

the class ValidateV2RC3SamplesTest 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;
        }
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Error reading notification from classpath", e);
    }
}
Also used : Email(org.orcid.jaxb.model.record_rc3.Email) InputStreamReader(java.io.InputStreamReader) Keyword(org.orcid.jaxb.model.record_rc3.Keyword) Address(org.orcid.jaxb.model.record_rc3.Address) OtherNames(org.orcid.jaxb.model.record_rc3.OtherNames) CreditName(org.orcid.jaxb.model.record_rc3.CreditName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc3.PersonExternalIdentifier) History(org.orcid.jaxb.model.record_rc3.History) ActivitiesSummary(org.orcid.jaxb.model.record.summary_rc3.ActivitiesSummary) Deprecated(org.orcid.jaxb.model.record_rc3.Deprecated) Biography(org.orcid.jaxb.model.record_rc3.Biography) ResearcherUrl(org.orcid.jaxb.model.record_rc3.ResearcherUrl)

Aggregations

IOException (java.io.IOException)7 DeprecatedRecordException (org.orcid.listener.exception.DeprecatedRecordException)6 InputStreamReader (java.io.InputStreamReader)5 Reader (java.io.Reader)5 Test (org.junit.Test)5 LockedRecordException (org.orcid.listener.exception.LockedRecordException)5 Biography (org.orcid.jaxb.model.record_v2.Biography)4 ArrayList (java.util.ArrayList)3 JAXBException (javax.xml.bind.JAXBException)3 OrcidError (org.orcid.jaxb.model.error_v2.OrcidError)3 Deprecated (org.orcid.jaxb.model.record_rc2.Deprecated)3 Address (org.orcid.jaxb.model.record_v2.Address)3 CreditName (org.orcid.jaxb.model.record_v2.CreditName)3 Funding (org.orcid.jaxb.model.record_v2.Funding)3 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)3 AmazonClientException (com.amazonaws.AmazonClientException)2 List (java.util.List)2 Document (org.bson.Document)2 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)2 FundingGroup (org.orcid.jaxb.model.record.summary_v2.FundingGroup)2