Java Code Examples for org.jboss.as.controller.registry.Resource#NoSuchResourceException
The following examples show how to use
org.jboss.as.controller.registry.Resource#NoSuchResourceException .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeploymentRemoveHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void removeContent(OperationContext context, List<byte[]> removedHashes, String name) { Set<String> newHash; try { newHash = DeploymentUtils.getDeploymentHexHash(context.readResource(PathAddress.EMPTY_ADDRESS, false).getModel()); } catch (Resource.NoSuchResourceException ex) { newHash = Collections.emptySet(); } for (byte[] hash : removedHashes) { try { if (newHash.isEmpty() || !newHash.contains(HashUtil.bytesToHexString(hash))) { contentRepository.removeContent(ModelContentReference.fromDeploymentName(name, hash)); } else { ServerLogger.ROOT_LOGGER.undeployingDeploymentHasBeenRedeployed(name); } } catch (Exception e) { //TODO ServerLogger.ROOT_LOGGER.failedToRemoveDeploymentContent(e, HashUtil.bytesToHexString(hash)); } } }
Example 2
Source File: GlobalOperationHandlers.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void executeSingleTargetChild(PathAddress base, PathElement currentElement, PathAddress newRemaining, OperationContext context, boolean ignoreMissing) { final PathAddress next = base.append(currentElement); // Either require the child or a remote target final Resource resource = context.readResource(base, false); final ImmutableManagementResourceRegistration nr = context.getResourceRegistration().getSubModel(next); if (resource.hasChild(currentElement) || (nr != null && nr.isRemote())) { safeExecute(next, newRemaining, context, nr, ignoreMissing); } //if we are on the wrong host no need to do anything else if(!resource.hasChild(currentElement)) { throw new Resource.NoSuchResourceException(currentElement); } }
Example 3
Source File: ResourceNotAddressableExceptionTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Test that the exception message is what we expect to prevent this exception * looking different from a non-authorization triggered exception */ @Test public void testFailureDescription() { PathAddress pa = PathAddress.pathAddress(PathElement.pathElement("key", "value")); ResourceNotAddressableException rnae = new ResourceNotAddressableException(pa); @SuppressWarnings("ThrowableResultOfMethodCallIgnored") Resource.NoSuchResourceException nsre = ControllerLogger.ROOT_LOGGER.managementResourceNotFound(pa); Assert.assertEquals(nsre.getFailureDescription(), rnae.getFailureDescription()); }
Example 4
Source File: AbstractRemoveStepHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static boolean hasResource (OperationContext context) { try { context.readResource(PathAddress.EMPTY_ADDRESS, false); return true; } catch (Resource.NoSuchResourceException nsre) { return false; } }
Example 5
Source File: RestartParentResourceHandlerBase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private ModelNode getOriginalModel(OperationContext ctx, PathAddress address) { try { Resource resource = ctx.getOriginalRootResource().navigate(address); return Resource.Tools.readModel(resource); } catch (Resource.NoSuchResourceException e) { return null; } }
Example 6
Source File: RestartParentResourceHandlerBase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private ModelNode getModel(OperationContext ctx, PathAddress address) { try { Resource resource = ctx.readResourceFromRoot(address); return Resource.Tools.readModel(resource); } catch (Resource.NoSuchResourceException e) { return null; } }
Example 7
Source File: ReadResourceDescriptionHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private boolean addParentResource(OperationContext context, List<PathAddress> addresses, PathAddress address) { try { context.readResourceFromRoot(address); } catch (Resource.NoSuchResourceException nsre) { // Don't include the result return false; } catch (UnauthorizedException ue) { //We are not allowed to read it, but still we know it exists } return true; }
Example 8
Source File: ReadResourceDescriptionHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
void doExecute(OperationContext context, ModelNode operation, ReadResourceDescriptionAccessControlContext accessControlContext) throws OperationFailedException { if (accessControlContext.parentAddresses == null) { doExecuteInternal(context, operation, accessControlContext); } else { try { doExecuteInternal(context, operation, accessControlContext); } catch (Resource.NoSuchResourceException | UnauthorizedException nsre) { context.getResult().set(new ModelNode()); } } }
Example 9
Source File: GlobalOperationHandlers.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { try { wrapped.execute(context, operation); } catch (Resource.NoSuchResourceException e) { availableResponse.unavailable = true; } }
Example 10
Source File: AuthenticationValidatingHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static boolean hasResource (OperationContext context) { try { context.readResource(PathAddress.EMPTY_ADDRESS, false); return true; } catch (Resource.NoSuchResourceException nsre) { return false; } }
Example 11
Source File: ReadResourceHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override void doExecute(OperationContext context, ModelNode operation, FilteredData filteredData, boolean ignoreMissingResource) throws OperationFailedException { if (filteredData == null) { doExecuteInternal(context, operation, ignoreMissingResource); } else { try { if (overrideHandler == null) { doExecuteInternal(context, operation, ignoreMissingResource); } else { overrideHandler.execute(context, operation); } } catch (ResourceNotAddressableException rnae) { // Just report the failure to the filter and complete normally reportInaccesible(context, operation, filteredData); ControllerLogger.MGMT_OP_LOGGER.tracef("Caught ResourceNotAddressableException in %s", this); } catch (Resource.NoSuchResourceException nsre) { // It's possible this is a remote failure, in which case we // don't get ResourceNotAddressableException. So see if // it was due to any authorization denial AuthorizationResult.Decision decision = context.authorize(operation, EnumSet.of(Action.ActionEffect.ADDRESS)).getDecision(); ControllerLogger.MGMT_OP_LOGGER.tracef("Caught NoSuchResourceException in %s. Authorization decision is %s", this ,decision); if (decision == AuthorizationResult.Decision.DENY) { // Just report the failure to the filter and complete normally reportInaccesible(context, operation, filteredData); } else if (!ignoreMissingResource) { throw nsre; } } catch (UnauthorizedException ue) { // Just report the failure to the filter and complete normally PathAddress pa = PathAddress.pathAddress(operation.get(OP_ADDR)); filteredData.addReadRestrictedResource(pa); context.getResult().set(new ModelNode()); ControllerLogger.MGMT_OP_LOGGER.tracef("Caught UnauthorizedException in %s", this); } } }
Example 12
Source File: ReadFeatureDescriptionHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override void doExecute(OperationContext context, ModelNode operation, FilteredData filteredData, boolean ignoreMissingResource) throws OperationFailedException { if (!forChild) { doExecuteInternal(context, operation); } else { try { doExecuteInternal(context, operation); } catch (Resource.NoSuchResourceException | UnauthorizedException nsre) { context.getResult().set(new ModelNode()); } } }
Example 13
Source File: RestartParentWriteAttributeHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private ModelNode getOriginalModel(OperationContext ctx, PathAddress address) { try { Resource resource = ctx.getOriginalRootResource().navigate(address); return Resource.Tools.readModel(resource); } catch (Resource.NoSuchResourceException e) { return null; } }
Example 14
Source File: RestartParentWriteAttributeHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private ModelNode getModel(OperationContext ctx, PathAddress address) { try { Resource resource = ctx.readResourceFromRoot(address); return Resource.Tools.readModel(resource); } catch (Resource.NoSuchResourceException e) { return null; } }
Example 15
Source File: RemotingEndpointAdd.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected Resource createResource(OperationContext context) { // If the resource is already there, just use it // We do this because RemotingSubsystemAdd/WorkerThreadPoolVsEndpointHandler will end up adding a resource if // one isn't added in the same op. So if a user adds one in a separate op, we're forgiving about it. // Mostly we do this to allow transformers tests to pass which call ModelTestUtils.checkFailedTransformedBootOperations // which calls this OSH in a separate op from the one that calls RemotingSubystemAdd try { return context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS); } catch (Resource.NoSuchResourceException ignored) { // } return super.createResource(context); }
Example 16
Source File: SyslogAuditLogProtocolResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { PathAddress handlerAddress = SyslogAuditLogHandlerResourceDefinition.getAffectedHandlerAddress(context); try { Resource handleResource = context.readResourceFromRoot(handlerAddress); String name = Util.getNameFromAddress(handlerAddress); auditLogger.getUpdater().updateHandler(SyslogAuditLogHandlerResourceDefinition.createHandler(pathManager, context, name, handleResource, environmentReader)); } catch (Resource.NoSuchResourceException ignored) { // WFCORE-810 handler resource has been removed in this same op, so we do nothing } }
Example 17
Source File: ControllerLogger.java From wildfly-core with GNU Lesser General Public License v2.1 | 2 votes |
/** * Creates an exception indicating a resource cannot be found. * * @param pathAddress the address for the resource. * * @return an {@link OperationFailedRuntimeException} for the error. */ @Message(id = 216, value = "Management resource '%s' not found") Resource.NoSuchResourceException managementResourceNotFound(PathAddress pathAddress);
Example 18
Source File: LoggingLogger.java From wildfly-core with GNU Lesser General Public License v2.1 | 2 votes |
/** * Creates an exception indicating the file was found in the log directory. * * @param name the name of the file that was not found * @param directoryProperty the name of the property used to resolved the log directory * * @return an {@link OperationFailedException} for the error */ @Message(id = 80, value = "File '%s' was not found and cannot be found in the %s directory.") Resource.NoSuchResourceException logFileNotFound(String name, String directoryProperty);