Java Code Examples for org.jboss.as.controller.OperationContext#getAttachmentStream()

The following examples show how to use org.jboss.as.controller.OperationContext#getAttachmentStream() . 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: DeploymentUploadStreamAttachmentHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected InputStream getContentInputStream(OperationContext operationContext, ModelNode operation) throws OperationFailedException {
    int streamIndex = operation.get(INPUT_STREAM_INDEX).asInt();
    int maxIndex = operationContext.getAttachmentStreamCount();
    if (streamIndex > maxIndex) {
        throw new OperationFailedException(DomainControllerLogger.ROOT_LOGGER.invalidValue(INPUT_STREAM_INDEX, streamIndex, maxIndex));
    }

    InputStream in = operationContext.getAttachmentStream(streamIndex);
    if (in == null) {
        throw new OperationFailedException(DomainControllerLogger.ROOT_LOGGER.nullStream(streamIndex));
    }

    return in;
}
 
Example 2
Source File: DeploymentUploadStreamAttachmentHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected InputStream getContentInputStream(OperationContext operationContext, ModelNode operation) throws IOException, OperationFailedException {
    // Get the attached stream
    final int streamIndex = operation.require(INPUT_STREAM_INDEX).asInt();
    final InputStream in = operationContext.getAttachmentStream(streamIndex);
    if (in == null) {
        throw ServerLogger.ROOT_LOGGER.nullStreamAttachment(streamIndex);
    }
    return in;
}