Search in sources :

Example 76 with XMLStreamException

use of javax.xml.stream.XMLStreamException in project wildfly by wildfly.

the class FederationSubsystemReader_1_0 method parseHandlerConfig.

@Override
protected void parseHandlerConfig(final XMLExtendedStreamReader reader, final ModelNode entityProviderNode, final List<ModelNode> addOperations) throws XMLStreamException {
    String name = reader.getAttributeValue("", COMMON_CLASS_NAME.getName());
    if (name == null) {
        name = reader.getAttributeValue("", COMMON_CODE.getName());
        if (name != null) {
            name = HandlerTypeEnum.forType(name);
        }
    }
    ModelNode handlerNode = parseConfig(reader, COMMON_HANDLER, name, entityProviderNode, HandlerResourceDefinition.INSTANCE.getAttributes(), addOperations);
    parseElement(new ElementParser() {

        @Override
        public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException {
            switch(element) {
                case COMMON_HANDLER_PARAMETER:
                    parseConfig(reader, COMMON_HANDLER_PARAMETER, COMMON_NAME.getName(), parentNode, HandlerParameterResourceDefinition.INSTANCE.getAttributes(), addOperations);
                    break;
                default:
                    throw unexpectedElement(reader);
            }
        }
    }, COMMON_HANDLER, handlerNode, reader, addOperations);
}
Also used : ModelElement(org.wildfly.extension.picketlink.common.model.ModelElement) XMLStreamException(javax.xml.stream.XMLStreamException) ModelNode(org.jboss.dmr.ModelNode) XMLExtendedStreamReader(org.jboss.staxmapper.XMLExtendedStreamReader)

Example 77 with XMLStreamException

use of javax.xml.stream.XMLStreamException in project wildfly by wildfly.

the class AbstractIDMSubsystemReader method parseFileStoreConfig.

private void parseFileStoreConfig(final XMLExtendedStreamReader reader, final ModelNode identityManagementNode, final List<ModelNode> addOperations) throws XMLStreamException {
    ModelNode fileStoreNode = parseConfig(reader, FILE_STORE, null, identityManagementNode, FileStoreResourceDefinition.INSTANCE.getAttributes(), addOperations);
    parseElement(new ElementParser() {

        @Override
        public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException {
            switch(element) {
                case IDENTITY_STORE_CREDENTIAL_HANDLER:
                    parseCredentialHandlerConfig(reader, parentNode, addOperations);
                    break;
                case SUPPORTED_TYPES:
                    parseSupportedTypesConfig(reader, parentNode, addOperations);
                    break;
            }
        }
    }, FILE_STORE, fileStoreNode, reader, addOperations);
}
Also used : ModelElement(org.wildfly.extension.picketlink.common.model.ModelElement) XMLStreamException(javax.xml.stream.XMLStreamException) ModelNode(org.jboss.dmr.ModelNode) XMLExtendedStreamReader(org.jboss.staxmapper.XMLExtendedStreamReader)

Example 78 with XMLStreamException

use of javax.xml.stream.XMLStreamException in project wildfly by wildfly.

the class AbstractIDMSubsystemReader method parseIdentityConfigurationConfig.

private void parseIdentityConfigurationConfig(final XMLExtendedStreamReader reader, final ModelNode parentNode, final List<ModelNode> addOperations) throws XMLStreamException {
    ModelNode identityConfigurationNode = parseConfig(reader, IDENTITY_CONFIGURATION, COMMON_NAME.getName(), parentNode, IdentityConfigurationResourceDefinition.INSTANCE.getAttributes(), addOperations);
    parseElement(new ElementParser() {

        @Override
        public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException {
            switch(element) {
                case JPA_STORE:
                    parseJPAStoreConfig(reader, parentNode, addOperations);
                    break;
                case FILE_STORE:
                    parseFileStoreConfig(reader, parentNode, addOperations);
                    break;
                case LDAP_STORE:
                    parseLDAPStoreConfig(reader, addOperations, parentNode);
                    break;
            }
        }
    }, IDENTITY_CONFIGURATION, identityConfigurationNode, reader, addOperations);
}
Also used : ModelElement(org.wildfly.extension.picketlink.common.model.ModelElement) XMLStreamException(javax.xml.stream.XMLStreamException) ModelNode(org.jboss.dmr.ModelNode) XMLExtendedStreamReader(org.jboss.staxmapper.XMLExtendedStreamReader)

Example 79 with XMLStreamException

use of javax.xml.stream.XMLStreamException in project wildfly by wildfly.

the class AbstractIDMSubsystemReader method parseSupportedTypesConfig.

private ModelNode parseSupportedTypesConfig(final XMLExtendedStreamReader reader, final ModelNode identityStoreNode, final List<ModelNode> addOperations) throws XMLStreamException {
    ModelNode supportedTypesNode = parseConfig(reader, SUPPORTED_TYPES, null, identityStoreNode, SupportedTypesResourceDefinition.INSTANCE.getAttributes(), addOperations);
    parseElement(new ElementParser() {

        @Override
        public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException {
            switch(element) {
                case SUPPORTED_TYPE:
                    parseSupportedTypeConfig(reader, parentNode, addOperations);
                    break;
            }
        }
    }, SUPPORTED_TYPES, supportedTypesNode, reader, addOperations);
    return supportedTypesNode;
}
Also used : ModelElement(org.wildfly.extension.picketlink.common.model.ModelElement) XMLStreamException(javax.xml.stream.XMLStreamException) ModelNode(org.jboss.dmr.ModelNode) XMLExtendedStreamReader(org.jboss.staxmapper.XMLExtendedStreamReader)

Example 80 with XMLStreamException

use of javax.xml.stream.XMLStreamException in project spring-framework by spring-projects.

the class Jaxb2CollectionHttpMessageConverter method read.

@Override
@SuppressWarnings("unchecked")
public T read(Type type, Class<?> contextClass, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {
    ParameterizedType parameterizedType = (ParameterizedType) type;
    T result = createCollection((Class<?>) parameterizedType.getRawType());
    Class<?> elementClass = (Class<?>) parameterizedType.getActualTypeArguments()[0];
    try {
        Unmarshaller unmarshaller = createUnmarshaller(elementClass);
        XMLStreamReader streamReader = this.inputFactory.createXMLStreamReader(inputMessage.getBody());
        int event = moveToFirstChildOfRootElement(streamReader);
        while (event != XMLStreamReader.END_DOCUMENT) {
            if (elementClass.isAnnotationPresent(XmlRootElement.class)) {
                result.add(unmarshaller.unmarshal(streamReader));
            } else if (elementClass.isAnnotationPresent(XmlType.class)) {
                result.add(unmarshaller.unmarshal(streamReader, elementClass).getValue());
            } else {
                // should not happen, since we check in canRead(Type)
                throw new HttpMessageConversionException("Could not unmarshal to [" + elementClass + "]");
            }
            event = moveToNextElement(streamReader);
        }
        return result;
    } catch (UnmarshalException ex) {
        throw new HttpMessageNotReadableException("Could not unmarshal to [" + elementClass + "]: " + ex.getMessage(), ex);
    } catch (JAXBException ex) {
        throw new HttpMessageConversionException("Could not instantiate JAXBContext: " + ex.getMessage(), ex);
    } catch (XMLStreamException ex) {
        throw new HttpMessageConversionException(ex.getMessage(), ex);
    }
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) JAXBException(javax.xml.bind.JAXBException) XmlType(javax.xml.bind.annotation.XmlType) ParameterizedType(java.lang.reflect.ParameterizedType) HttpMessageNotReadableException(org.springframework.http.converter.HttpMessageNotReadableException) XMLStreamException(javax.xml.stream.XMLStreamException) UnmarshalException(javax.xml.bind.UnmarshalException) HttpMessageConversionException(org.springframework.http.converter.HttpMessageConversionException) Unmarshaller(javax.xml.bind.Unmarshaller)

Aggregations

XMLStreamException (javax.xml.stream.XMLStreamException)442 XMLStreamReader (javax.xml.stream.XMLStreamReader)137 IOException (java.io.IOException)126 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)75 XMLInputFactory (javax.xml.stream.XMLInputFactory)69 InputStream (java.io.InputStream)66 Document (org.w3c.dom.Document)36 JAXBException (javax.xml.bind.JAXBException)35 Fault (org.apache.cxf.interceptor.Fault)34 Element (org.w3c.dom.Element)32 StringReader (java.io.StringReader)30 XMLEvent (javax.xml.stream.events.XMLEvent)28 DOMSource (javax.xml.transform.dom.DOMSource)27 ByteArrayInputStream (java.io.ByteArrayInputStream)25 ArrayList (java.util.ArrayList)23 QName (javax.xml.namespace.QName)23 XMLOutputFactory (javax.xml.stream.XMLOutputFactory)23 Node (org.w3c.dom.Node)22 StringWriter (java.io.StringWriter)21 XMLEventReader (javax.xml.stream.XMLEventReader)20