use of org.apache.activemq.artemis.core.server.ActiveMQServer in project wildfly by wildfly.
the class JMSQueueRemove method performRuntime.
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
final String name = address.getLastElement().getValue();
ServiceController<?> service = context.getServiceRegistry(false).getService(serviceName);
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
JMSServerControl control = JMSServerControl.class.cast(server.getManagementService().getResource(ResourceNames.JMS_SERVER));
if (control != null) {
try {
control.destroyQueue(name, true);
} catch (Exception e) {
throw new OperationFailedException(e);
}
}
context.removeService(JMSServices.getJmsQueueBaseServiceName(serviceName).append(name));
for (String entry : CommonAttributes.DESTINATION_ENTRIES.unwrap(context, model)) {
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(entry);
ServiceName binderServiceName = bindInfo.getBinderServiceName();
context.removeService(binderServiceName);
}
for (String legacyEntry : CommonAttributes.LEGACY_ENTRIES.unwrap(context, model)) {
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(legacyEntry);
ServiceName binderServiceName = bindInfo.getBinderServiceName();
context.removeService(binderServiceName);
}
}
use of org.apache.activemq.artemis.core.server.ActiveMQServer in project wildfly by wildfly.
the class SecurityRoleAdd method rollbackRuntime.
@Override
protected void rollbackRuntime(OperationContext context, ModelNode operation, Resource resource) {
final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
final ActiveMQServer server = getServer(context, operation);
final String match = address.getElement(address.size() - 2).getValue();
final String roleName = address.getLastElement().getValue();
SecurityRoleRemove.removeRole(server, match, roleName);
}
use of org.apache.activemq.artemis.core.server.ActiveMQServer in project wildfly by wildfly.
the class SecurityRoleAttributeHandler method revertUpdateToRuntime.
@Override
protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Set<Role> handback) throws OperationFailedException {
if (handback != null) {
final ActiveMQServer server = getActiveMQServer(context, operation);
if (server != null) {
final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
final String match = address.getElement(address.size() - 2).getValue();
server.getSecurityRepository().addMatch(match, handback);
}
}
}
use of org.apache.activemq.artemis.core.server.ActiveMQServer in project wildfly by wildfly.
the class SecurityRoleAttributeHandler method applyUpdateToRuntime.
@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode newValue, ModelNode currentValue, HandbackHolder<Set<Role>> handbackHolder) throws OperationFailedException {
final ActiveMQServer server = getActiveMQServer(context, operation);
if (server != null) {
final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
final String match = address.getElement(address.size() - 2).getValue();
final String roleName = address.getLastElement().getValue();
final Set<Role> newRoles = new HashSet<Role>();
final Set<Role> roles = server.getSecurityRepository().getMatch(match);
handbackHolder.setHandback(roles);
for (final Role role : roles) {
if (!roleName.equals(role.getName())) {
newRoles.add(role);
}
}
final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
final ModelNode subModel = resource.getModel();
final Role updatedRole = SecurityRoleDefinition.transform(context, roleName, subModel);
newRoles.add(updatedRole);
server.getSecurityRepository().addMatch(match, newRoles);
}
return false;
}
use of org.apache.activemq.artemis.core.server.ActiveMQServer in project wildfly by wildfly.
the class SecurityRoleReadAttributeHandler method executeRuntimeStep.
@Override
public void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
final String attributeName = operation.require(ModelDescriptionConstants.NAME).asString();
PathAddress pathAddress = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
String addressName = pathAddress.getElement(pathAddress.size() - 2).getValue();
String roleName = pathAddress.getLastElement().getValue();
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
ServiceController<?> service = context.getServiceRegistry(false).getService(serviceName);
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
AddressControl control = AddressControl.class.cast(server.getManagementService().getResource(ResourceNames.CORE_ADDRESS + addressName));
if (control == null) {
PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(address);
}
try {
String rolesAsJSON = control.getRolesAsJSON();
ModelNode res = ModelNode.fromJSONString(rolesAsJSON);
ModelNode roles = ManagementUtil.convertSecurityRole(res);
ModelNode matchedRole = findRole(roleName, roles);
if (matchedRole == null || !matchedRole.hasDefined(attributeName)) {
throw MessagingLogger.ROOT_LOGGER.unsupportedAttribute(attributeName);
}
boolean value = matchedRole.get(attributeName).asBoolean();
context.getResult().set(value);
} catch (Exception e) {
context.getFailureDescription().set(e.getLocalizedMessage());
}
}
Aggregations