Search in sources :

Example 21 with ParserException

use of org.jboss.as.connector.util.ParserException in project wildfly by wildfly.

the class DsParser method parseDsSecurity_5_0.

private void parseDsSecurity_5_0(XMLExtendedStreamReader reader, final ModelNode operation) throws XMLStreamException, ParserException, ValidateException {
    boolean securityDomainMatched = false;
    while (reader.hasNext()) {
        switch(reader.nextTag()) {
            case END_ELEMENT:
                {
                    if (DataSource.Tag.forName(reader.getLocalName()) == DataSource.Tag.SECURITY) {
                        //it's fine, do nothing
                        return;
                    } else {
                        if (DsSecurity.Tag.forName(reader.getLocalName()) == DsSecurity.Tag.UNKNOWN) {
                            throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName()));
                        }
                    }
                    break;
                }
            case START_ELEMENT:
                {
                    DsSecurity.Tag tag = DsSecurity.Tag.forName(reader.getLocalName());
                    switch(tag) {
                        case PASSWORD:
                            {
                                String value = rawElementText(reader);
                                PASSWORD.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case USER_NAME:
                            {
                                String value = rawElementText(reader);
                                USERNAME.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case SECURITY_DOMAIN:
                            {
                                if (securityDomainMatched) {
                                    throw new ParserException(bundle.unexpectedElement(SECURITY_DOMAIN.getXmlName()));
                                }
                                String value = rawElementText(reader);
                                SECURITY_DOMAIN.parseAndSetParameter(value, operation, reader);
                                securityDomainMatched = true;
                                break;
                            }
                        case ELYTRON_ENABLED:
                            {
                                String value = rawElementText(reader);
                                value = value == null ? "true" : value;
                                ELYTRON_ENABLED.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case AUTHENTICATION_CONTEXT:
                            {
                                String value = rawElementText(reader);
                                AUTHENTICATION_CONTEXT.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case REAUTH_PLUGIN:
                            {
                                parseExtension(reader, tag.getLocalName(), operation, REAUTH_PLUGIN_CLASSNAME, REAUTHPLUGIN_PROPERTIES);
                                break;
                            }
                        case CREDENTIAL_REFERENCE:
                            {
                                CREDENTIAL_REFERENCE.getParser().parseElement(CREDENTIAL_REFERENCE, reader, operation);
                                break;
                            }
                        default:
                            throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
                    }
                    break;
                }
        }
    }
    throw new ParserException(bundle.unexpectedEndOfDocument());
}
Also used : ParserException(org.jboss.as.connector.util.ParserException)

Example 22 with ParserException

use of org.jboss.as.connector.util.ParserException in project wildfly by wildfly.

the class DsParser method parseDsSecurity.

private void parseDsSecurity(XMLExtendedStreamReader reader, final ModelNode operation) throws XMLStreamException, ParserException, ValidateException {
    boolean securityDomainMatched = false;
    while (reader.hasNext()) {
        switch(reader.nextTag()) {
            case END_ELEMENT:
                {
                    if (DataSource.Tag.forName(reader.getLocalName()) == DataSource.Tag.SECURITY) {
                        //it's fine, do nothing
                        return;
                    } else {
                        if (DsSecurity.Tag.forName(reader.getLocalName()) == DsSecurity.Tag.UNKNOWN) {
                            throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName()));
                        }
                    }
                    break;
                }
            case START_ELEMENT:
                {
                    final String localName = reader.getLocalName();
                    DsSecurity.Tag tag = DsSecurity.Tag.forName(localName);
                    if (localName == null)
                        break;
                    if (localName.equals(DsSecurity.Tag.PASSWORD.getLocalName())) {
                        String value = rawElementText(reader);
                        PASSWORD.parseAndSetParameter(value, operation, reader);
                        break;
                    } else if (localName.equals(DsSecurity.Tag.USER_NAME.getLocalName())) {
                        String value = rawElementText(reader);
                        USERNAME.parseAndSetParameter(value, operation, reader);
                        break;
                    } else if (localName.equals(DsSecurity.Tag.SECURITY_DOMAIN.getLocalName())) {
                        if (securityDomainMatched) {
                            throw new ParserException(bundle.unexpectedElement(SECURITY_DOMAIN.getXmlName()));
                        }
                        String value = rawElementText(reader);
                        SECURITY_DOMAIN.parseAndSetParameter(value, operation, reader);
                        securityDomainMatched = true;
                        break;
                    } else if (localName.equals(DsSecurity.Tag.REAUTH_PLUGIN.getLocalName())) {
                        parseExtension(reader, tag.getLocalName(), operation, REAUTH_PLUGIN_CLASSNAME, REAUTHPLUGIN_PROPERTIES);
                        break;
                    } else if (localName.equals(CREDENTIAL_REFERENCE.getXmlName())) {
                        CREDENTIAL_REFERENCE.getParser().parseElement(CREDENTIAL_REFERENCE, reader, operation);
                        break;
                    } else {
                        throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
                    }
                }
        }
    }
    throw new ParserException(bundle.unexpectedEndOfDocument());
}
Also used : ParserException(org.jboss.as.connector.util.ParserException)

Example 23 with ParserException

use of org.jboss.as.connector.util.ParserException in project wildfly by wildfly.

the class DsParser method parseXADataSource_1_0.

private void parseXADataSource_1_0(XMLExtendedStreamReader reader, final List<ModelNode> list, final ModelNode parentAddress) throws XMLStreamException, ParserException, ValidateException {
    String poolName = null;
    final ModelNode operation = new ModelNode();
    operation.get(OP).set(ADD);
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        if (!isNoNamespaceAttribute(reader, i)) {
            throw unexpectedAttribute(reader, i);
        }
        final XaDataSource.Attribute attribute = XaDataSource.Attribute.forName(reader.getAttributeLocalName(i));
        switch(attribute) {
            case ENABLED:
                {
                    final String value = rawAttributeText(reader, ENABLED.getXmlName());
                    if (value != null) {
                        ENABLED.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case JNDI_NAME:
                {
                    final String jndiName = rawAttributeText(reader, JNDI_NAME.getXmlName());
                    JNDI_NAME.parseAndSetParameter(jndiName, operation, reader);
                    break;
                }
            case POOL_NAME:
                {
                    poolName = rawAttributeText(reader, POOLNAME_NAME);
                    break;
                }
            case USE_JAVA_CONTEXT:
                {
                    final String value = rawAttributeText(reader, USE_JAVA_CONTEXT.getXmlName());
                    if (value != null) {
                        USE_JAVA_CONTEXT.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case SPY:
                {
                    final String value = rawAttributeText(reader, SPY.getXmlName());
                    if (value != null) {
                        SPY.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case USE_CCM:
                {
                    final String value = rawAttributeText(reader, USE_CCM.getXmlName());
                    if (value != null) {
                        USE_CCM.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            default:
                throw ParseUtils.unexpectedAttribute(reader, i);
        }
    }
    final ModelNode dsAddress = parentAddress.clone();
    dsAddress.add(XA_DATASOURCE, poolName);
    dsAddress.protect();
    operation.get(OP_ADDR).set(dsAddress);
    List<ModelNode> xadatasourcePropertiesOperations = new ArrayList<ModelNode>(0);
    //elements reading
    while (reader.hasNext()) {
        switch(reader.nextTag()) {
            case END_ELEMENT:
                {
                    if (DataSources.Tag.forName(reader.getLocalName()) == DataSources.Tag.XA_DATASOURCE) {
                        list.add(operation);
                        list.addAll(xadatasourcePropertiesOperations);
                        return;
                    } else {
                        if (XaDataSource.Tag.forName(reader.getLocalName()) == XaDataSource.Tag.UNKNOWN) {
                            throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName()));
                        }
                    }
                    break;
                }
            case START_ELEMENT:
                {
                    switch(XaDataSource.Tag.forName(reader.getLocalName())) {
                        case XA_DATASOURCE_PROPERTY:
                            {
                                String name = rawAttributeText(reader, "name");
                                String value = rawElementText(reader);
                                final ModelNode configOperation = new ModelNode();
                                configOperation.get(OP).set(ADD);
                                final ModelNode configAddress = dsAddress.clone();
                                configAddress.add(XADATASOURCE_PROPERTIES.getName(), name);
                                configAddress.protect();
                                configOperation.get(OP_ADDR).set(configAddress);
                                XADATASOURCE_PROPERTY_VALUE.parseAndSetParameter(value, configOperation, reader);
                                xadatasourcePropertiesOperations.add(configOperation);
                                break;
                            }
                        case XA_DATASOURCE_CLASS:
                            {
                                String value = rawElementText(reader);
                                XA_DATASOURCE_CLASS.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case DRIVER:
                            {
                                String value = rawElementText(reader);
                                DATASOURCE_DRIVER.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case XA_POOL:
                            {
                                parseXaPool(reader, operation);
                                break;
                            }
                        case NEW_CONNECTION_SQL:
                            {
                                String value = rawElementText(reader);
                                NEW_CONNECTION_SQL.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case URL_DELIMITER:
                            {
                                String value = rawElementText(reader);
                                URL_DELIMITER.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case URL_PROPERTY:
                            {
                                String value = rawElementText(reader);
                                URL_PROPERTY.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case URL_SELECTOR_STRATEGY_CLASS_NAME:
                            {
                                String value = rawElementText(reader);
                                URL_SELECTOR_STRATEGY_CLASS_NAME.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case TRANSACTION_ISOLATION:
                            {
                                String value = rawElementText(reader);
                                TRANSACTION_ISOLATION.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case SECURITY:
                            {
                                parseDsSecurity(reader, operation);
                                break;
                            }
                        case STATEMENT:
                            {
                                parseStatementSettings(reader, operation);
                                break;
                            }
                        case TIMEOUT:
                            {
                                parseTimeOutSettings(reader, operation);
                                break;
                            }
                        case VALIDATION:
                            {
                                parseValidationSetting(reader, operation);
                                break;
                            }
                        case RECOVERY:
                            {
                                parseRecovery(reader, operation);
                                break;
                            }
                        default:
                            throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
                    }
                    break;
                }
        }
    }
    throw new ParserException(bundle.unexpectedEndOfDocument());
}
Also used : ParserException(org.jboss.as.connector.util.ParserException) ArrayList(java.util.ArrayList) ModelNode(org.jboss.dmr.ModelNode) XaDataSource(org.jboss.jca.common.api.metadata.ds.XaDataSource)

Example 24 with ParserException

use of org.jboss.as.connector.util.ParserException in project wildfly by wildfly.

the class DsParser method parsePool.

private void parsePool(XMLExtendedStreamReader reader, final ModelNode operation) throws XMLStreamException, ParserException, ValidateException {
    while (reader.hasNext()) {
        switch(reader.nextTag()) {
            case END_ELEMENT:
                {
                    if (DataSource.Tag.forName(reader.getLocalName()) == DataSource.Tag.POOL) {
                        return;
                    //it's fine. Do nothing
                    } else {
                        if (DsPool.Tag.forName(reader.getLocalName()) == DsPool.Tag.UNKNOWN) {
                            throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName()));
                        }
                    }
                    break;
                }
            case START_ELEMENT:
                {
                    switch(DsPool.Tag.forName(reader.getLocalName())) {
                        case MAX_POOL_SIZE:
                            {
                                String value = rawElementText(reader);
                                MAX_POOL_SIZE.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case INITIAL_POOL_SIZE:
                            {
                                String value = rawElementText(reader);
                                INITIAL_POOL_SIZE.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case MIN_POOL_SIZE:
                            {
                                String value = rawElementText(reader);
                                MIN_POOL_SIZE.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case PREFILL:
                            {
                                String value = rawElementText(reader);
                                POOL_PREFILL.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case FAIR:
                            {
                                String value = rawElementText(reader);
                                POOL_FAIR.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case USE_STRICT_MIN:
                            {
                                String value = rawElementText(reader);
                                POOL_USE_STRICT_MIN.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case FLUSH_STRATEGY:
                            {
                                String value = rawElementText(reader);
                                POOL_FLUSH_STRATEGY.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case ALLOW_MULTIPLE_USERS:
                            {
                                String value = rawElementText(reader);
                                ALLOW_MULTIPLE_USERS.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case CAPACITY:
                            {
                                parseCapacity(reader, operation);
                                break;
                            }
                        case CONNECTION_LISTENER:
                            {
                                parseExtension(reader, reader.getLocalName(), operation, CONNECTION_LISTENER_CLASS, CONNECTION_LISTENER_PROPERTIES);
                                break;
                            }
                        case UNKNOWN:
                            {
                                throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
                            }
                        default:
                            {
                                throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
                            }
                    }
                    break;
                }
        }
    }
    throw new ParserException(bundle.unexpectedEndOfDocument());
}
Also used : ParserException(org.jboss.as.connector.util.ParserException)

Example 25 with ParserException

use of org.jboss.as.connector.util.ParserException in project wildfly by wildfly.

the class DsParser method parseXADataSource_4_0.

private void parseXADataSource_4_0(XMLExtendedStreamReader reader, final List<ModelNode> list, final ModelNode parentAddress) throws XMLStreamException, ParserException, ValidateException {
    String poolName = null;
    final ModelNode operation = new ModelNode();
    operation.get(OP).set(ADD);
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        if (!isNoNamespaceAttribute(reader, i)) {
            throw unexpectedAttribute(reader, i);
        }
        final XaDataSource.Attribute attribute = XaDataSource.Attribute.forName(reader.getAttributeLocalName(i));
        switch(attribute) {
            case ENABLED:
                {
                    final String value = rawAttributeText(reader, ENABLED.getXmlName());
                    if (value != null) {
                        ENABLED.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case JNDI_NAME:
                {
                    final String jndiName = rawAttributeText(reader, JNDI_NAME.getXmlName());
                    JNDI_NAME.parseAndSetParameter(jndiName, operation, reader);
                    break;
                }
            case POOL_NAME:
                {
                    poolName = rawAttributeText(reader, POOLNAME_NAME);
                    break;
                }
            case USE_JAVA_CONTEXT:
                {
                    final String value = rawAttributeText(reader, USE_JAVA_CONTEXT.getXmlName());
                    if (value != null) {
                        USE_JAVA_CONTEXT.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case SPY:
                {
                    final String value = rawAttributeText(reader, SPY.getXmlName());
                    if (value != null) {
                        SPY.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case USE_CCM:
                {
                    final String value = rawAttributeText(reader, USE_CCM.getXmlName());
                    if (value != null) {
                        USE_CCM.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case CONNECTABLE:
                {
                    final String value = rawAttributeText(reader, CONNECTABLE.getXmlName());
                    if (value != null) {
                        CONNECTABLE.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case MCP:
                {
                    final String value = rawAttributeText(reader, MCP.getXmlName());
                    if (value != null) {
                        MCP.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case ENLISTMENT_TRACE:
                {
                    final String value = rawAttributeText(reader, ENLISTMENT_TRACE.getXmlName());
                    ENLISTMENT_TRACE.parseAndSetParameter(value, operation, reader);
                    break;
                }
            case TRACKING:
                {
                    final String value = rawAttributeText(reader, TRACKING.getXmlName());
                    if (value != null) {
                        TRACKING.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            default:
                if (Constants.STATISTICS_ENABLED.getName().equals(reader.getAttributeLocalName(i))) {
                    final String value = rawAttributeText(reader, Constants.STATISTICS_ENABLED.getXmlName());
                    if (value != null) {
                        Constants.STATISTICS_ENABLED.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                } else {
                    throw ParseUtils.unexpectedAttribute(reader, i);
                }
        }
    }
    final ModelNode dsAddress = parentAddress.clone();
    dsAddress.add(XA_DATASOURCE, poolName);
    dsAddress.protect();
    operation.get(OP_ADDR).set(dsAddress);
    List<ModelNode> xadatasourcePropertiesOperations = new ArrayList<ModelNode>(0);
    //elements reading
    while (reader.hasNext()) {
        switch(reader.nextTag()) {
            case END_ELEMENT:
                {
                    if (DataSources.Tag.forName(reader.getLocalName()) == DataSources.Tag.XA_DATASOURCE) {
                        list.add(operation);
                        list.addAll(xadatasourcePropertiesOperations);
                        return;
                    } else {
                        if (XaDataSource.Tag.forName(reader.getLocalName()) == XaDataSource.Tag.UNKNOWN) {
                            throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName()));
                        }
                    }
                    break;
                }
            case START_ELEMENT:
                {
                    switch(XaDataSource.Tag.forName(reader.getLocalName())) {
                        case XA_DATASOURCE_PROPERTY:
                            {
                                String name = rawAttributeText(reader, "name");
                                String value = rawElementText(reader);
                                final ModelNode configOperation = new ModelNode();
                                configOperation.get(OP).set(ADD);
                                final ModelNode configAddress = dsAddress.clone();
                                configAddress.add(XADATASOURCE_PROPERTIES.getName(), name);
                                configAddress.protect();
                                configOperation.get(OP_ADDR).set(configAddress);
                                XADATASOURCE_PROPERTY_VALUE.parseAndSetParameter(value, configOperation, reader);
                                xadatasourcePropertiesOperations.add(configOperation);
                                break;
                            }
                        case XA_DATASOURCE_CLASS:
                            {
                                String value = rawElementText(reader);
                                XA_DATASOURCE_CLASS.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case DRIVER:
                            {
                                String value = rawElementText(reader);
                                DATASOURCE_DRIVER.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case XA_POOL:
                            {
                                parseXaPool(reader, operation);
                                break;
                            }
                        case NEW_CONNECTION_SQL:
                            {
                                String value = rawElementText(reader);
                                NEW_CONNECTION_SQL.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case URL_DELIMITER:
                            {
                                String value = rawElementText(reader);
                                URL_DELIMITER.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case URL_PROPERTY:
                            {
                                String value = rawElementText(reader);
                                URL_PROPERTY.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case URL_SELECTOR_STRATEGY_CLASS_NAME:
                            {
                                String value = rawElementText(reader);
                                URL_SELECTOR_STRATEGY_CLASS_NAME.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case TRANSACTION_ISOLATION:
                            {
                                String value = rawElementText(reader);
                                TRANSACTION_ISOLATION.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case SECURITY:
                            {
                                switch(Namespace.forUri(reader.getNamespaceURI())) {
                                    // This method is only called for version 4 and later.
                                    case DATASOURCES_4_0:
                                        parseDsSecurity(reader, operation);
                                        break;
                                    default:
                                        parseDsSecurity_5_0(reader, operation);
                                        break;
                                }
                                break;
                            }
                        case STATEMENT:
                            {
                                parseStatementSettings(reader, operation);
                                break;
                            }
                        case TIMEOUT:
                            {
                                parseTimeOutSettings(reader, operation);
                                break;
                            }
                        case VALIDATION:
                            {
                                parseValidationSetting(reader, operation);
                                break;
                            }
                        case RECOVERY:
                            {
                                parseRecovery(reader, operation);
                                break;
                            }
                        default:
                            throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
                    }
                    break;
                }
        }
    }
    throw new ParserException(bundle.unexpectedEndOfDocument());
}
Also used : ParserException(org.jboss.as.connector.util.ParserException) ArrayList(java.util.ArrayList) ModelNode(org.jboss.dmr.ModelNode) XaDataSource(org.jboss.jca.common.api.metadata.ds.XaDataSource)

Aggregations

ParserException (org.jboss.as.connector.util.ParserException)25 ModelNode (org.jboss.dmr.ModelNode)16 ArrayList (java.util.ArrayList)8 XaDataSource (org.jboss.jca.common.api.metadata.ds.XaDataSource)8 DataSource (org.jboss.jca.common.api.metadata.ds.DataSource)4 ConnectionDefinition (org.jboss.jca.common.api.metadata.resourceadapter.ConnectionDefinition)3 WorkManagerSecurityImpl (org.jboss.as.connector.metadata.resourceadapter.WorkManagerSecurityImpl)2 HashMap (java.util.HashMap)1 Driver (org.jboss.jca.common.api.metadata.ds.Driver)1