Search in sources :

Example 21 with OperationFailedException

use of org.jboss.as.controller.OperationFailedException in project wildfly by wildfly.

the class JMSBridgeRemove method recoverServices.

protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
    final String bridgeName = address.getLastElement().getValue();
    final ServiceRegistry registry = context.getServiceRegistry(true);
    final ServiceName jmsBridgeServiceName = MessagingServices.getJMSBridgeServiceName(bridgeName);
    final ServiceController<?> jmsBridgeServiceController = registry.getService(jmsBridgeServiceName);
    if (jmsBridgeServiceController != null && jmsBridgeServiceController.getState() == ServiceController.State.UP) {
        JMSBridgeService jmsBridgeService = (JMSBridgeService) jmsBridgeServiceController.getService();
        try {
            jmsBridgeService.startBridge();
        } catch (Exception e) {
            throw MessagingLogger.ROOT_LOGGER.failedToRecover(e, bridgeName);
        }
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) OperationFailedException(org.jboss.as.controller.OperationFailedException)

Example 22 with OperationFailedException

use of org.jboss.as.controller.OperationFailedException in project wildfly by wildfly.

the class SecurityDomainAdd method createJSSESecurityDomain.

private JSSESecurityDomain createJSSESecurityDomain(OperationContext context, String securityDomain, ModelNode node) throws OperationFailedException {
    node = peek(node, JSSE, CLASSIC);
    if (node == null) {
        return null;
    }
    final JBossJSSESecurityDomain jsseSecurityDomain = new JBossJSSESecurityDomain(securityDomain);
    processKeyStore(context, node, KEYSTORE, new KeyStoreConfig() {

        public void setKeyStorePassword(String value) throws Exception {
            jsseSecurityDomain.setKeyStorePassword(value);
        }

        public void setKeyStoreType(String value) {
            jsseSecurityDomain.setKeyStoreType(value);
        }

        public void setKeyStoreURL(String value) throws IOException {
            jsseSecurityDomain.setKeyStoreURL(value);
        }

        public void setKeyStoreProvider(String value) {
            jsseSecurityDomain.setKeyStoreProvider(value);
        }

        public void setKeyStoreProviderArgument(String value) {
            jsseSecurityDomain.setKeyStoreProviderArgument(value);
        }
    });
    processKeyStore(context, node, Constants.TRUSTSTORE, new KeyStoreConfig() {

        public void setKeyStorePassword(String value) throws Exception {
            jsseSecurityDomain.setTrustStorePassword(value);
        }

        public void setKeyStoreType(String value) {
            jsseSecurityDomain.setTrustStoreType(value);
        }

        public void setKeyStoreURL(String value) throws IOException {
            jsseSecurityDomain.setTrustStoreURL(value);
        }

        public void setKeyStoreProvider(String value) {
            jsseSecurityDomain.setTrustStoreProvider(value);
        }

        public void setKeyStoreProviderArgument(String value) {
            jsseSecurityDomain.setTrustStoreProviderArgument(value);
        }
    });
    processKeyManager(context, node, Constants.KEY_MANAGER, new KeyManagerConfig() {

        public void setKeyManagerFactoryAlgorithm(String value) {
            jsseSecurityDomain.setKeyManagerFactoryAlgorithm(value);
        }

        public void setKeyManagerFactoryProvider(String value) {
            jsseSecurityDomain.setKeyManagerFactoryProvider(value);
        }
    });
    processKeyManager(context, node, Constants.TRUST_MANAGER, new KeyManagerConfig() {

        public void setKeyManagerFactoryAlgorithm(String value) {
            jsseSecurityDomain.setTrustManagerFactoryAlgorithm(value);
        }

        public void setKeyManagerFactoryProvider(String value) {
            jsseSecurityDomain.setTrustManagerFactoryProvider(value);
        }
    });
    String value;
    if (node.hasDefined(CLIENT_ALIAS)) {
        value = JSSEResourceDefinition.CLIENT_ALIAS.resolveModelAttribute(context, node).asString();
        jsseSecurityDomain.setClientAlias(value);
    }
    if (node.hasDefined(SERVER_ALIAS)) {
        value = JSSEResourceDefinition.SERVER_ALIAS.resolveModelAttribute(context, node).asString();
        jsseSecurityDomain.setServerAlias(value);
    }
    if (node.hasDefined(CLIENT_AUTH)) {
        boolean clientAuth = JSSEResourceDefinition.CLIENT_AUTH.resolveModelAttribute(context, node).asBoolean();
        jsseSecurityDomain.setClientAuth(clientAuth);
    }
    if (node.hasDefined(SERVICE_AUTH_TOKEN)) {
        value = JSSEResourceDefinition.SERVICE_AUTH_TOKEN.resolveModelAttribute(context, node).asString();
        try {
            jsseSecurityDomain.setServiceAuthToken(value);
        } catch (Exception e) {
            throw SecurityLogger.ROOT_LOGGER.runtimeException(e);
        }
    }
    if (node.hasDefined(CIPHER_SUITES)) {
        value = JSSEResourceDefinition.CIPHER_SUITES.resolveModelAttribute(context, node).asString();
        jsseSecurityDomain.setCipherSuites(value);
    }
    if (node.hasDefined(PROTOCOLS)) {
        value = JSSEResourceDefinition.PROTOCOLS.resolveModelAttribute(context, node).asString();
        jsseSecurityDomain.setProtocols(value);
    }
    if (node.hasDefined(ADDITIONAL_PROPERTIES)) {
        Properties properties = new Properties();
        properties.putAll(JSSEResourceDefinition.ADDITIONAL_PROPERTIES.unwrap(context, node));
        jsseSecurityDomain.setAdditionalProperties(properties);
    }
    return jsseSecurityDomain;
}
Also used : IOException(java.io.IOException) Properties(java.util.Properties) JBossJSSESecurityDomain(org.jboss.security.JBossJSSESecurityDomain) OperationFailedException(org.jboss.as.controller.OperationFailedException) IOException(java.io.IOException)

Example 23 with OperationFailedException

use of org.jboss.as.controller.OperationFailedException in project wildfly by wildfly.

the class SecurityDomainAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, final ModelNode model) {
    PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    final String securityDomain = address.getLastElement().getValue();
    // This needs to run after all child resources so that they can detect a fresh state
    context.addStep(new OperationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
            launchServices(context, securityDomain, Resource.Tools.readModel(resource));
            // Rollback handled by the parent step
            context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER);
        }
    }, OperationContext.Stage.RUNTIME);
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) PathAddress(org.jboss.as.controller.PathAddress) OperationFailedException(org.jboss.as.controller.OperationFailedException) Resource(org.jboss.as.controller.registry.Resource) ModelNode(org.jboss.dmr.ModelNode)

Example 24 with OperationFailedException

use of org.jboss.as.controller.OperationFailedException in project wildfly by wildfly.

the class AbstractTimerManagementTestCase method cancelTimer.

protected void cancelTimer() throws Exception {
    final PathAddress address = getTimerAddress();
    final ModelNode operation = Util.createOperation("cancel", address);
    final ModelNode outcome = this.managementClient.getControllerClient().execute(operation);
    if (!Operations.isSuccessfulOutcome(outcome)) {
        throw new OperationFailedException(operation);
    }
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) OperationFailedException(org.jboss.as.controller.OperationFailedException) ModelNode(org.jboss.dmr.ModelNode)

Example 25 with OperationFailedException

use of org.jboss.as.controller.OperationFailedException in project wildfly by wildfly.

the class AbstractTimerManagementTestCase method suspendTimer.

protected void suspendTimer() throws Exception {
    final PathAddress address = getTimerAddress();
    final ModelNode operation = Util.createOperation("suspend", address);
    final ModelNode outcome = this.managementClient.getControllerClient().execute(operation);
    if (!Operations.isSuccessfulOutcome(outcome)) {
        throw new OperationFailedException(operation);
    }
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) OperationFailedException(org.jboss.as.controller.OperationFailedException) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

OperationFailedException (org.jboss.as.controller.OperationFailedException)113 ModelNode (org.jboss.dmr.ModelNode)86 PathAddress (org.jboss.as.controller.PathAddress)51 OperationContext (org.jboss.as.controller.OperationContext)49 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)34 ServiceName (org.jboss.msc.service.ServiceName)33 Resource (org.jboss.as.controller.registry.Resource)26 ServiceController (org.jboss.msc.service.ServiceController)19 ServiceTarget (org.jboss.msc.service.ServiceTarget)15 PathElement (org.jboss.as.controller.PathElement)13 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)12 IOException (java.io.IOException)11 Map (java.util.Map)11 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)11 ArrayList (java.util.ArrayList)9 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)9 ContextNames (org.jboss.as.naming.deployment.ContextNames)7 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)7 List (java.util.List)6 ResourceServiceHandler (org.jboss.as.clustering.controller.ResourceServiceHandler)6