@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { // Put an entry in the log that the test driver can use to verify a complete log logPropValue(context); String path; if (context.getProcessType().isServer()) { path = System.getProperty("jboss.server.log.dir") + File.separatorChar + "server.log"; } else { path = System.getProperty("jboss.domain.log.dir") + File.separatorChar + "host-controller.log"; } File f = new File(path); try { String uuid = context.attachResultStream("text/plain", new FileInputStream(f)); context.getResult().set(uuid); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final String name = context.getCurrentAddressValue(); final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); validateFile(context, logDir, name); final Path path = Paths.get(logDir, name); try { String uuid = context.attachResultStream("text/plain", Files.newInputStream(path)); context.getResult().set(uuid); } catch (IOException e) { throw new RuntimeException(e); } } };
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final String name = context.getCurrentAddressValue(); final String logDir = pathManager.getPathEntry(ServerEnvironment.SERVER_LOG_DIR).resolvePath(); validateFile(context, logDir, name); final Path path = Paths.get(logDir, name); try { String uuid = context.attachResultStream("text/plain", Files.newInputStream(path)); context.getResult().set(uuid); } catch (IOException e) { throw new RuntimeException(e); } } };
@Override public void attachResult(OperationContext context) throws OperationFailedException { if (record) { try (InputStream content = getContent()) { context.attachResultStream(getMimeType(), content); } catch (IOException ex) { throw ControllerLogger.MGMT_OP_LOGGER.failedToBuildReport(ex); } } } }
@Override public void attachResult(OperationContext context) throws OperationFailedException { if (record) { try (InputStream content = getContent()) { context.attachResultStream(getMimeType(), content); } catch (IOException ex) { throw ControllerLogger.MGMT_OP_LOGGER.failedToBuildReport(ex); } } } }
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); Resource resource = context.getOriginalRootResource(); for (final PathElement element : address) { resource = resource.getChild(element); } byte[] contentHash = resource.getModel().get(CONTENT).asBytes(); try { TypedInputStream inputStream = contentRepository.readContent(contentHash, ""); String uuid = context.attachResultStream(inputStream.getContentType(), inputStream); context.getResult().get(UUID).set(uuid); } catch (ExplodedContentException ex) { throw new RuntimeException(ex.getMessage(), ex); } } }
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); Resource resource = context.getOriginalRootResource(); for (final PathElement element : address) { resource = resource.getChild(element); } byte[] contentHash = resource.getModel().get(CONTENT).asBytes(); try { TypedInputStream inputStream = contentRepository.readContent(contentHash, ""); String uuid = context.attachResultStream(inputStream.getContentType(), inputStream); context.getResult().get(UUID).set(uuid); } catch (ExplodedContentException ex) { throw new RuntimeException(ex.getMessage(), ex); } } }
/** * Deal with streams attached to an operation response from a proxied domain process. * * @param context the context of the operation * @param responseNode the DMR response from the proxied process * @param streams the streams associated with the response */ public static void handleDomainOperationResponseStreams(final OperationContext context, final ModelNode responseNode, final List<OperationResponse.StreamEntry> streams) { if (responseNode.hasDefined(RESPONSE_HEADERS)) { ModelNode responseHeaders = responseNode.get(RESPONSE_HEADERS); // Strip out any stream header as the header created by this process is what counts responseHeaders.remove(ATTACHED_STREAMS); if (responseHeaders.asInt() == 0) { responseNode.remove(RESPONSE_HEADERS); } } for (OperationResponse.StreamEntry streamEntry : streams) { context.attachResultStream(streamEntry.getUUID(), streamEntry.getMimeType(), streamEntry.getStream()); } }
/** * Deal with streams attached to an operation response from a proxied domain process. * * @param context the context of the operation * @param responseNode the DMR response from the proxied process * @param streams the streams associated with the response */ public static void handleDomainOperationResponseStreams(final OperationContext context, final ModelNode responseNode, final List<OperationResponse.StreamEntry> streams) { if (responseNode.hasDefined(RESPONSE_HEADERS)) { ModelNode responseHeaders = responseNode.get(RESPONSE_HEADERS); // Strip out any stream header as the header created by this process is what counts responseHeaders.remove(ATTACHED_STREAMS); if (responseHeaders.asInt() == 0) { responseNode.remove(RESPONSE_HEADERS); } } for (OperationResponse.StreamEntry streamEntry : streams) { context.attachResultStream(streamEntry.getUUID(), streamEntry.getMimeType(), streamEntry.getStream()); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (context.getProcessType() == ProcessType.SELF_CONTAINED) { throw ServerLogger.ROOT_LOGGER.cannotReadContentFromSelfContainedServer(); } final Resource deploymentResource = context.readResource(PathAddress.EMPTY_ADDRESS); ModelNode contentItemNode = getContentItem(deploymentResource); // Validate this op is available if (!isManaged(contentItemNode)) { throw ServerLogger.ROOT_LOGGER.cannotReadContentFromUnmanagedDeployment(); } final byte[] deploymentHash = CONTENT_HASH.resolveModelAttribute(context, contentItemNode).asBytes(); final ModelNode contentPath = CONTENT_PATH.resolveModelAttribute(context, operation); final String path = contentPath.isDefined() ? contentPath.asString() : ""; try { TypedInputStream inputStream = contentRepository.readContent(deploymentHash, path); String uuid = context.attachResultStream(inputStream.getContentType(), inputStream); context.getResult().get(UUID).set(uuid); } catch (ExplodedContentException ex) { throw createFailureException(ex.toString()); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (context.getProcessType() == ProcessType.SELF_CONTAINED) { throw DomainControllerLogger.ROOT_LOGGER.cannotReadContentFromSelfContainedServer(); } final Resource deploymentResource = context.readResource(PathAddress.EMPTY_ADDRESS); ModelNode contentItemNode = getContentItem(deploymentResource); // Validate this op is available if (!isManaged(contentItemNode)) { throw DomainControllerLogger.ROOT_LOGGER.cannotReadContentFromUnmanagedDeployment(); } final byte[] deploymentHash = CONTENT_HASH.resolveModelAttribute(context, contentItemNode).asBytes(); final ModelNode contentPath = CONTENT_PATH.resolveModelAttribute(context, operation); final String path = contentPath.isDefined() ? contentPath.asString() : ""; try { TypedInputStream inputStream = contentRepository.readContent(deploymentHash, path); String uuid = context.attachResultStream(inputStream.getContentType(), inputStream); context.getResult().get(UUID).set(uuid); } catch (ExplodedContentException ex) { throw new OperationFailedException(ex.getMessage()); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (context.getProcessType() == ProcessType.SELF_CONTAINED) { throw ServerLogger.ROOT_LOGGER.cannotReadContentFromSelfContainedServer(); } final Resource deploymentResource = context.readResource(PathAddress.EMPTY_ADDRESS); ModelNode contentItemNode = getContentItem(deploymentResource); // Validate this op is available if (!isManaged(contentItemNode)) { throw ServerLogger.ROOT_LOGGER.cannotReadContentFromUnmanagedDeployment(); } final byte[] deploymentHash = CONTENT_HASH.resolveModelAttribute(context, contentItemNode).asBytes(); final ModelNode contentPath = CONTENT_PATH.resolveModelAttribute(context, operation); final String path = contentPath.isDefined() ? contentPath.asString() : ""; try { TypedInputStream inputStream = contentRepository.readContent(deploymentHash, path); String uuid = context.attachResultStream(inputStream.getContentType(), inputStream); context.getResult().get(UUID).set(uuid); } catch (ExplodedContentException ex) { throw createFailureException(ex.toString()); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (context.getProcessType() == ProcessType.SELF_CONTAINED) { throw DomainControllerLogger.ROOT_LOGGER.cannotReadContentFromSelfContainedServer(); } final Resource deploymentResource = context.readResource(PathAddress.EMPTY_ADDRESS); ModelNode contentItemNode = getContentItem(deploymentResource); // Validate this op is available if (!isManaged(contentItemNode)) { throw DomainControllerLogger.ROOT_LOGGER.cannotReadContentFromUnmanagedDeployment(); } final byte[] deploymentHash = CONTENT_HASH.resolveModelAttribute(context, contentItemNode).asBytes(); final ModelNode contentPath = CONTENT_PATH.resolveModelAttribute(context, operation); final String path = contentPath.isDefined() ? contentPath.asString() : ""; try { TypedInputStream inputStream = contentRepository.readContent(deploymentHash, path); String uuid = context.attachResultStream(inputStream.getContentType(), inputStream); context.getResult().get(UUID).set(uuid); } catch (ExplodedContentException ex) { throw new OperationFailedException(ex.getMessage()); } }