Search in sources :

Example 1 with WritableBlob

use of org.apache.axiom.blob.WritableBlob in project webservices-axiom by apache.

the class PartInputStream method detach.

void detach() throws IOException {
    if (blobFactory == null) {
        throw new IllegalStateException();
    }
    if (in != null) {
        WritableBlob content = blobFactory.createBlob();
        content.readFrom(in);
        this.content = content;
        in = getInputStream(content);
    }
    blobFactory = null;
}
Also used : WritableBlob(org.apache.axiom.blob.WritableBlob)

Example 2 with WritableBlob

use of org.apache.axiom.blob.WritableBlob in project webservices-axiom by apache.

the class BlobOMDataSourceCustomBuilder method create.

@Override
public OMDataSource create(OMElement element) throws OMException {
    try {
        WritableBlob blob = blobFactory.createBlob();
        OutputStream out = blob.getOutputStream();
        try {
            element.serializeAndConsume(out);
        } finally {
            out.close();
        }
        return new BlobOMDataSource(blob, encoding);
    } catch (XMLStreamException ex) {
        throw new OMException(ex);
    } catch (IOException ex) {
        throw new OMException(ex);
    }
}
Also used : BlobOMDataSource(org.apache.axiom.om.ds.BlobOMDataSource) XMLStreamException(javax.xml.stream.XMLStreamException) OutputStream(java.io.OutputStream) WritableBlob(org.apache.axiom.blob.WritableBlob) IOException(java.io.IOException) OMException(org.apache.axiom.om.OMException)

Example 3 with WritableBlob

use of org.apache.axiom.blob.WritableBlob in project webservices-axiom by apache.

the class PartImpl method getInputStream.

@Override
public InputStream getInputStream(boolean preserve) {
    if (!preserve && state == STATE_UNREAD) {
        checkParserState(parser.getState(), EntityState.T_BODY);
        state = STATE_STREAMING;
        partInputStream = new PartInputStream(getDecodedInputStream(), blobFactory);
        return partInputStream;
    } else {
        WritableBlob content = getContent();
        try {
            if (preserve) {
                return content.getInputStream();
            } else {
                return new PartInputStream(content);
            }
        } catch (IOException ex) {
            throw new MIMEException("Failed to retrieve part content from blob", ex);
        }
    }
}
Also used : WritableBlob(org.apache.axiom.blob.WritableBlob) IOException(java.io.IOException)

Aggregations

WritableBlob (org.apache.axiom.blob.WritableBlob)3 IOException (java.io.IOException)2 OutputStream (java.io.OutputStream)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 OMException (org.apache.axiom.om.OMException)1 BlobOMDataSource (org.apache.axiom.om.ds.BlobOMDataSource)1