Package org.apache.jackrabbit.core.value

Examples of org.apache.jackrabbit.core.value.BLOBFileValue


            initParser();
        }

        InternalValue[] values = data.getValues();
        if (values.length > 0) {
            final BLOBFileValue blob = (BLOBFileValue) values[0].internalValue();

            LazyReader reader = new LazyReader() {
                protected void initializeReader() throws IOException {
                    InputStream in;
                    try {
                        in = blob.getStream();
                    } catch (RepositoryException e) {
                        throw new IOException(e.getMessage());
                    }
                    try {
                        ZipInputStream zis = new ZipInputStream(in);
View Full Code Here


        out.writeInt(values.length); // count
        for (int i = 0; i < values.length; i++) {
            InternalValue val = values[i];
            switch (state.getType()) {
                case PropertyType.BINARY:
                    BLOBFileValue blobVal = val.getBLOBFileValue();
                    long size = blobVal.getLength();
                    if (InternalValue.USE_DATA_STORE && dataStore != null) {
                        int maxMemorySize = dataStore.getMinRecordLength() - 1;
                        if (size < maxMemorySize) {
                            writeSmallBinary(out, blobVal, state, i);
                        } else {
                            out.writeInt(BINARY_IN_DATA_STORE);
                            try {
                                val.store(dataStore);
                            } catch (RepositoryException e) {
                                String msg = "Error while storing blob. id="
                                    + state.getId() + " idx=" + i + " size=" + val.getBLOBFileValue().getLength();
                                log.error(msg, e);
                                throw new IOException(msg);
                            }
                            out.writeUTF(val.toString());
                        }
                        break;
                    }
                    // special handling required for binary value:
                    // spool binary value to file in blob store
                    if (size < 0) {
                        log.warn("Blob has negative size. Potential loss of data. "
                                + "id={} idx={}", state.getId(), String.valueOf(i));
                        out.writeInt(0);
                        values[i] = InternalValue.create(new byte[0]);
                        blobVal.discard();
                    } else if (size > minBlobSize) {
                        out.writeInt(BINARY_IN_BLOB_STORE);
                        String blobId = state.getBlobId(i);
                        if (blobId == null) {
                            try {
                                InputStream in = blobVal.getStream();
                                try {
                                    blobId = blobStore.createId(state.getId(), i);
                                    blobStore.put(blobId, in, size);
                                    state.setBlobId(blobId, i);
                                } finally {
                                    IOUtils.closeQuietly(in);
                                }
                            } catch (Exception e) {
                                String msg = "Error while storing blob. id="
                                        + state.getId() + " idx=" + i + " size=" + size;
                                log.error(msg, e);
                                throw new IOException(msg);
                            }
                            try {
                                // replace value instance with value
                                // backed by resource in blob store and delete temp file
                                if (blobStore instanceof ResourceBasedBLOBStore) {
                                    values[i] = InternalValue.create(((ResourceBasedBLOBStore) blobStore).getResource(blobId));
                                } else {
                                    values[i] = InternalValue.create(blobStore.get(blobId));
                                }
                            } catch (Exception e) {
                                log.error("Error while reloading blob. truncating. id="
                                        + state.getId() + " idx=" + i + " size=" + size, e);
                                values[i] = InternalValue.create(new byte[0]);
                            }
                            blobVal.discard();
                        }
                        // store id of blob as property value
                        out.writeUTF(blobId);   // value
                    } else {
                        // delete evt. blob
                        byte[] data = writeSmallBinary(out, blobVal, state, i);
                        // replace value instance with value
                        // backed by resource in blob store and delete temp file
                        values[i] = InternalValue.create(data);
                        blobVal.discard();
                    }
                    break;
                case PropertyType.DOUBLE:
                    out.writeDouble(val.getDouble());
                    break;
View Full Code Here

            initParser();
        }

        InternalValue[] values = data.getValues();
        if (values.length > 0) {
            final BLOBFileValue blob = (BLOBFileValue) values[0].internalValue();

            LazyReader reader = new LazyReader() {
                protected void initializeReader() throws IOException {
                    InputStream in;
                    try {
                        in = blob.getStream();
                    } catch (RepositoryException e) {
                        throw new IOException(e.getMessage());
                    }
                    try {
                        ZipInputStream zis = new ZipInputStream(in);
View Full Code Here

            initParser();
        }

        InternalValue[] values = data.getValues();
        if (values.length > 0) {
            final BLOBFileValue blob = (BLOBFileValue) values[0].internalValue();
            LazyReader reader = new LazyReader() {
                protected void initializeReader() throws IOException {
                    InputStream in;
                    try {
                        in = blob.getStream();
                    } catch (RepositoryException e) {
                        throw new IOException(e.getMessage());
                    }
                    try {
                        SAXSource source =
View Full Code Here

  public Map doFilter(PropertyState data, String encoding)
      throws RepositoryException {
    InternalValue[] values = data.getValues();

    if (values.length == 1) {
      final BLOBFileValue blob = (BLOBFileValue) values[0].internalValue();

            LazyReader reader = new LazyReader() {
                protected void initializeReader() throws IOException {
                    InputStream in;
                    try {
                        in = blob.getStream();
                    } catch (RepositoryException e) {
                        throw new IOException(e.getMessage());
                    }
                    try {
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

    public Map doFilter(PropertyState data, String encoding)
            throws RepositoryException {

        InternalValue[] values = data.getValues();
        if (values.length > 0) {
            final BLOBFileValue blob = (BLOBFileValue) values[0].internalValue();
            LazyReader reader = new LazyReader() {
                protected void initializeReader() throws IOException {
                    InputStream in;
                    try {
                        in = blob.getStream();
                    } catch (RepositoryException e) {
                        throw new IOException(e.getMessage());
                    }
                    try {
                        doc.remove(0, doc.getLength());
View Full Code Here

     */
    public Map doFilter(PropertyState data, String encoding)
            throws RepositoryException {
        InternalValue[] values = data.getValues();
        if (values.length > 0) {
            final BLOBFileValue blob = (BLOBFileValue) values[0].internalValue();

            LazyReader reader = new LazyReader() {
                protected void initializeReader() throws IOException {
                    InputStream in;
                    try {
                        in = blob.getStream();
                    } catch (RepositoryException e) {
                        throw new IOException(e.getMessage());
                    }
                    try {
                        WordExtractor extractor = new WordExtractor();
View Full Code Here

     * contain valid MS Excel document.
     */
    public Map doFilter(PropertyState data, String encoding) throws RepositoryException {
        InternalValue[] values = data.getValues();
        if (values.length > 0) {
            final BLOBFileValue blob = (BLOBFileValue) values[0].internalValue();
            LazyReader reader = new LazyReader() {
                protected void initializeReader() throws IOException {
                    CharArrayWriter writer = new CharArrayWriter();

                    InputStream in;
                    try {
                        in = blob.getStream();
                    } catch (RepositoryException e) {
                        throw new IOException(e.getMessage());
                    }

                    try {
View Full Code Here

     * contain valid PDF document.
     */
    public Map doFilter(PropertyState data, String encoding) throws RepositoryException {
        InternalValue[] values = data.getValues();
        if (values.length > 0) {
            final BLOBFileValue blob = (BLOBFileValue) values[0].internalValue();
            LazyReader reader = new LazyReader() {
                protected void initializeReader() throws IOException {
                    PDFParser parser;
                    InputStream in;
                    try {
                        in = blob.getStream();
                    } catch (RepositoryException e) {
                        throw new IOException(e.getMessage());
                    }

                    try {
View Full Code Here

     */
    public Map doFilter(PropertyState data, String encoding)
            throws RepositoryException {
        InternalValue[] values = data.getValues();
        if (values.length > 0) {
            final BLOBFileValue blob = (BLOBFileValue) values[0].internalValue();
            LazyReader reader = new LazyReader() {
                protected void initializeReader() throws IOException {
                    try {
                        StringBuffer buffer = new StringBuffer();
                        XMLParser parser = new XMLParser(buffer);

                        SAXParserFactory saxParserFactory =
                            SAXParserFactory.newInstance();
                        saxParserFactory.setValidating(false);
                        SAXParser saxParser = saxParserFactory.newSAXParser();
                        XMLReader xmlReader = saxParser.getXMLReader();
                        xmlReader.setContentHandler(parser);
                        xmlReader.setErrorHandler(parser);

                        InputStream in = blob.getStream();
                        try {
                            InputSource source = new InputSource(in);
                            xmlReader.parse(source);
                            delegate = new StringReader(buffer.toString());
                        } finally {
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.core.value.BLOBFileValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.