Search in sources :

Example 16 with IOExceptionWithCause

use of org.apache.commons.io.IOExceptionWithCause in project jackrabbit by apache.

the class BundleWriter method writeSmallBinary.

/**
 * Write a small binary value and return the data.
 *
 * @param value the binary value
 * @param state the property state (for error messages)
 * @param i the index (for error messages)
 * @return the data
 * @throws IOException if the data could not be read
 */
private byte[] writeSmallBinary(InternalValue value, NodePropBundle.PropertyEntry state, int i) throws IOException {
    try {
        int size = (int) value.getLength();
        out.writeInt(size);
        byte[] data = new byte[size];
        DataInputStream in = new DataInputStream(value.getStream());
        try {
            in.readFully(data);
        } finally {
            IOUtils.closeQuietly(in);
        }
        out.write(data, 0, data.length);
        return data;
    } catch (Exception e) {
        String msg = "Error while storing blob. id=" + state.getId() + " idx=" + i + " value=" + value;
        log.error(msg, e);
        throw new IOExceptionWithCause(msg, e);
    }
}
Also used : IOExceptionWithCause(org.apache.commons.io.IOExceptionWithCause) DataInputStream(java.io.DataInputStream) IOException(java.io.IOException) RepositoryException(javax.jcr.RepositoryException)

Aggregations

IOExceptionWithCause (org.apache.commons.io.IOExceptionWithCause)16 IOException (java.io.IOException)10 SQLException (java.sql.SQLException)5 TikaException (org.apache.tika.exception.TikaException)5 SAXException (org.xml.sax.SAXException)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 DataInputStream (java.io.DataInputStream)3 InputStream (java.io.InputStream)3 Connection (java.sql.Connection)2 RepositoryException (javax.jcr.RepositoryException)2 InternalValue (org.apache.jackrabbit.core.value.InternalValue)2 BufferedImage (java.awt.image.BufferedImage)1 BufferedInputStream (java.io.BufferedInputStream)1 DataInput (java.io.DataInput)1 OutputStream (java.io.OutputStream)1 Path (java.nio.file.Path)1 ResultSetMetaData (java.sql.ResultSetMetaData)1 Statement (java.sql.Statement)1 PDComplexFileSpecification (org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification)1 PDActionURI (org.apache.pdfbox.pdmodel.interactive.action.PDActionURI)1