use of javax.xml.bind.JAXBException in project ORCID-Source by ORCID.
the class OrcidClientGroup method unmarshall.
public static OrcidClientGroup unmarshall(InputStream input) {
try {
JAXBContext context = JAXBContext.newInstance(OrcidClientGroup.class.getPackage().getName());
Unmarshaller unmarshaller = context.createUnmarshaller();
return (OrcidClientGroup) unmarshaller.unmarshal(input);
} catch (JAXBException e) {
// XXX Should be more specific exception
throw new RuntimeException("Unable to unmarshall client group" + e);
}
}
use of javax.xml.bind.JAXBException in project ORCID-Source by ORCID.
the class RecordUtil method convertToString.
/**
* @param args
*/
public static String convertToString(Object obj) {
try {
JAXBContext context = JAXBContext.newInstance(obj.getClass());
StringWriter writer = new StringWriter();
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(obj, writer);
return writer.toString();
} catch (JAXBException e) {
return ("Unable to unmarshal because: " + e);
}
}
use of javax.xml.bind.JAXBException in project ORCID-Source by ORCID.
the class OrcidMessage method unmarshall.
public static OrcidMessage unmarshall(Reader reader) {
try {
JAXBContext context = JAXBContext.newInstance(OrcidMessage.class.getPackage().getName());
Unmarshaller unmarshaller = context.createUnmarshaller();
return (OrcidMessage) unmarshaller.unmarshal(reader);
} catch (JAXBException e) {
// XXX Should be more specific exception
throw new RuntimeException("Unable to unmarshall orcid message" + e);
}
}
use of javax.xml.bind.JAXBException in project ORCID-Source by ORCID.
the class S3MessageProcessor method update_1_2_API.
private void update_1_2_API(String orcid) {
if (is12IndexingEnabled) {
try {
OrcidMessage profile = orcid12ApiClient.fetchPublicProfile(orcid);
// Update API 1.2
if (profile != null) {
s3Updater.updateS3(orcid, profile);
recordStatusManager.markAsSent(orcid, AvailableBroker.DUMP_STATUS_1_2_API);
}
} catch (LockedRecordException | DeprecatedRecordException e) {
try {
if (e instanceof LockedRecordException) {
LOG.error("Record " + orcid + " is locked");
exceptionHandler.handle12LockedRecordException(orcid, ((LockedRecordException) e).getOrcidMessage());
} else {
LOG.error("Record " + orcid + " is deprecated");
exceptionHandler.handle12DeprecatedRecordException(orcid, ((DeprecatedRecordException) e).getOrcidDeprecated());
}
recordStatusManager.markAsSent(orcid, AvailableBroker.DUMP_STATUS_1_2_API);
} catch (JsonProcessingException | AmazonClientException | JAXBException e1) {
LOG.error("Unable to handle LockedRecordException for record " + orcid, e1);
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 1.2 API");
LOG.error(e.getMessage(), e);
recordStatusManager.markAsFailed(orcid, AvailableBroker.DUMP_STATUS_1_2_API);
}
}
}
use of javax.xml.bind.JAXBException in project ORCID-Source by ORCID.
the class ValidateV2_1SamplesTest method unmarshall.
private Object unmarshall(Reader reader, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
try {
JAXBContext context = JAXBContext.newInstance(type);
Unmarshaller unmarshaller = context.createUnmarshaller();
if (schemaPath != null) {
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = sf.newSchema(new File(getClass().getResource(schemaPath).toURI()));
unmarshaller.setSchema(schema);
}
return unmarshaller.unmarshal(reader);
} catch (JAXBException e) {
throw new RuntimeException("Unable to unmarshall orcid message" + e);
}
}
Aggregations