Search in sources :

Example 66 with JAXBException

use of javax.xml.bind.JAXBException in project ORCID-Source by ORCID.

the class ValidateV2_1IdentifiersTest method marshall.

/** Marshals to a JAXBSource backed by SAX
     * 
     * @param type
     * @param obj
     * @return
     */
private Source marshall(Class<?> type, Object obj) {
    try {
        JAXBContext context = JAXBContext.newInstance(type);
        JAXBSource source = new JAXBSource(context, obj);
        return source;
    } catch (JAXBException e) {
        throw new RuntimeException("Unable to unmarshall orcid message" + e);
    }
}
Also used : JAXBException(javax.xml.bind.JAXBException) JAXBContext(javax.xml.bind.JAXBContext) JAXBSource(javax.xml.bind.util.JAXBSource)

Example 67 with JAXBException

use of javax.xml.bind.JAXBException in project ORCID-Source by ORCID.

the class ValidateV2SamplesTest 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);
    }
}
Also used : SchemaFactory(javax.xml.validation.SchemaFactory) Schema(javax.xml.validation.Schema) JAXBException(javax.xml.bind.JAXBException) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) File(java.io.File)

Example 68 with JAXBException

use of javax.xml.bind.JAXBException in project ORCID-Source by ORCID.

the class NotificationsTest method unmarshall.

public NotificationPermission unmarshall(Reader reader) {
    try {
        JAXBContext context = JAXBContext.newInstance(NotificationPermission.class.getPackage().getName());
        Unmarshaller unmarshaller = context.createUnmarshaller();
        return (NotificationPermission) unmarshaller.unmarshal(reader);
    } catch (JAXBException e) {
        throw new RuntimeException("Unable to unmarshall orcid message" + e);
    }
}
Also used : JAXBException(javax.xml.bind.JAXBException) JAXBContext(javax.xml.bind.JAXBContext) NotificationPermission(org.orcid.jaxb.model.notification.permission_v2.NotificationPermission) Unmarshaller(javax.xml.bind.Unmarshaller)

Example 69 with JAXBException

use of javax.xml.bind.JAXBException in project ORCID-Source by ORCID.

the class ValidateV2IdentifiersTest method unmarshall.

private Object unmarshall(Reader reader, Class<?> type) {
    try {
        JAXBContext context = JAXBContext.newInstance(type);
        Unmarshaller unmarshaller = context.createUnmarshaller();
        return unmarshaller.unmarshal(reader);
    } catch (JAXBException e) {
        throw new RuntimeException("Unable to unmarshall orcid message" + e);
    }
}
Also used : JAXBException(javax.xml.bind.JAXBException) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller)

Example 70 with JAXBException

use of javax.xml.bind.JAXBException in project ORCID-Source by ORCID.

the class NotificationsTest method unmarshall.

public NotificationPermission unmarshall(Reader reader) {
    try {
        JAXBContext context = JAXBContext.newInstance(NotificationPermission.class.getPackage().getName());
        Unmarshaller unmarshaller = context.createUnmarshaller();
        return (NotificationPermission) unmarshaller.unmarshal(reader);
    } catch (JAXBException e) {
        throw new RuntimeException("Unable to unmarshall orcid message" + e);
    }
}
Also used : JAXBException(javax.xml.bind.JAXBException) JAXBContext(javax.xml.bind.JAXBContext) NotificationPermission(org.orcid.jaxb.model.notification.permission_rc2.NotificationPermission) Unmarshaller(javax.xml.bind.Unmarshaller)

Aggregations

JAXBException (javax.xml.bind.JAXBException)402 JAXBContext (javax.xml.bind.JAXBContext)126 IOException (java.io.IOException)93 Unmarshaller (javax.xml.bind.Unmarshaller)91 Marshaller (javax.xml.bind.Marshaller)69 ArrayList (java.util.ArrayList)38 StringWriter (java.io.StringWriter)35 List (java.util.List)35 Map (java.util.Map)33 SAXException (org.xml.sax.SAXException)32 File (java.io.File)29 InputStream (java.io.InputStream)29 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)28 HashSet (java.util.HashSet)28 JAXBElement (javax.xml.bind.JAXBElement)24 XMLStreamException (javax.xml.stream.XMLStreamException)23 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)22 StringReader (java.io.StringReader)21 HashMap (java.util.HashMap)21 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)20