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);
}
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);
}
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);
}
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;
}
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);
}
}
Aggregations