use of org.jboss.as.controller.OperationFailedException in project wildfly by wildfly.
the class ReadAttributeTranslationHandler method execute.
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
ModelNode targetOperation = Operations.createReadAttributeOperation(context.getCurrentAddress(), this.targetAttribute);
String targetName = this.targetAttribute.getName();
// If attribute has no read handler, synthesize one
Optional.ofNullable(context.getResourceRegistration().getAttributeAccess(PathAddress.EMPTY_ADDRESS, targetName).getReadHandler()).orElse((ctx, op) -> {
ModelNode model = ctx.readResource(PathAddress.EMPTY_ADDRESS).getModel();
ModelNode result = ctx.getResult();
if (model.hasDefined(targetName)) {
result.set(model.get(targetName));
} else if (Operations.isIncludeDefaults(op)) {
result.set(this.targetAttribute.getDefinition().getDefaultValue());
}
}).execute(context, targetOperation);
ModelNode result = context.getResult();
result.set(this.translator.translate(context, result));
}
use of org.jboss.as.controller.OperationFailedException in project wildfly by wildfly.
the class MappingModuleDefinition method registerOperations.
@Override
public void registerOperations(ManagementResourceRegistration resourceRegistration) {
super.registerOperations(resourceRegistration);
super.registerAddOperation(resourceRegistration, new AbstractAddStepHandler() {
@Override
protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException {
for (AttributeDefinition attr : getAttributes()) {
attr.validateAndSet(operation, model);
}
}
}, OperationEntry.Flag.RESTART_NONE);
}
use of org.jboss.as.controller.OperationFailedException in project wildfly by wildfly.
the class SecurityDomainAdd method processKeyStore.
private void processKeyStore(OperationContext context, ModelNode node, String name, KeyStoreConfig config) throws OperationFailedException {
final ModelNode value = peek(node, name, PASSWORD);
final ModelNode type = peek(node, name, TYPE);
final ModelNode url = peek(node, name, URL);
final ModelNode provider = peek(node, name, PROVIDER);
final ModelNode providerArgument = peek(node, name, PROVIDER_ARGUMENT);
if (value != null) {
try {
config.setKeyStorePassword(context.resolveExpressions(value).asString());
} catch (Exception e) {
throw SecurityLogger.ROOT_LOGGER.runtimeException(e);
}
}
if (type != null) {
config.setKeyStoreType(context.resolveExpressions(type).asString());
}
if (url != null) {
try {
config.setKeyStoreURL(context.resolveExpressions(url).asString());
} catch (Exception e) {
throw SecurityLogger.ROOT_LOGGER.runtimeException(e);
}
}
if (provider != null) {
config.setKeyStoreProvider(context.resolveExpressions(provider).asString());
}
if (providerArgument != null) {
config.setKeyStoreProviderArgument(context.resolveExpressions(providerArgument).asString());
}
}
use of org.jboss.as.controller.OperationFailedException in project wildfly by wildfly.
the class AbstractTimerManagementTestCase method triggerTimer.
protected void triggerTimer() throws Exception {
final PathAddress address = getTimerAddress();
final ModelNode operation = Util.createOperation("trigger", address);
final ModelNode outcome = this.managementClient.getControllerClient().execute(operation);
if (!Operations.isSuccessfulOutcome(outcome)) {
throw new OperationFailedException(operation);
}
}
use of org.jboss.as.controller.OperationFailedException in project wildfly by wildfly.
the class AbstractTimerManagementTestCase method getTimerDetails.
protected ModelNode getTimerDetails() throws Exception {
final PathAddress address = getTimerAddress();
final ModelNode operation = Util.createOperation("read-resource", address);
operation.get(ModelDescriptionConstants.INCLUDE_RUNTIME).set(Boolean.toString(true));
final ModelNode result = this.managementClient.getControllerClient().execute(operation);
if (!Operations.isSuccessfulOutcome(result)) {
throw new OperationFailedException(result.asString());
}
return result.get(ModelDescriptionConstants.RESULT);
}
Aggregations