Examples of BlobDataSource


Examples of com.elasticinbox.core.blob.BlobDataSource

    // Write blob
    long origSize = testWrite(bs);

    // Read blob back
    BlobDataSource ds = bs.read(blobUri);
    long newSize = IOUtils.getInputStreamSize(ds.getUncompressedInputStream());

    // Check written Blob URI
    assertThat(blobUri.toString(), equalTo(expextedBlobUrl));

    // Check written Blob size
View Full Code Here

Examples of com.elasticinbox.core.blob.BlobDataSource

    // Check Blob URI
    assertThat(blobUri.toString(), equalTo(expextedBlobUrl));

    // Read blob back
    BlobDataSource ds = bs.read(blobUri);

    // Read blob back again
    ds = bs.read(blobUri);
    long newSize = IOUtils.getInputStreamSize(ds.getUncompressedInputStream());

    // Check Blob size
    assertThat(newSize, equalTo(origSize));

    // Delete
View Full Code Here

Examples of com.elasticinbox.core.blob.BlobDataSource

    // Check written Blob URI
    assertThat(blobUri.toString(), equalTo(expextedBlobUrl));

    // Read blob back
    BlobDataSource ds = bs.read(blobUri);
    long newSize = IOUtils.getInputStreamSize(ds.getUncompressedInputStream());

    // Check written Blob size
    assertThat(newSize, equalTo(origSize));

    // Delete
View Full Code Here

Examples of com.elasticinbox.core.blob.BlobDataSource

    UUID messageId = UUID.fromString(blobUri.getName());
    byte[] messageBlock = BlobPersistence.readBlock(messageId, DATABASE_DEFAULT_BLOCK_ID);
    InputStream in = ByteStreams.newInputStreamSupplier(messageBlock).getInput();

    return new BlobDataSource(uri, in);
  }
View Full Code Here

Examples of com.elasticinbox.core.blob.BlobDataSource

      }
    } else {
      in = CloudStoreProxy.read(uri);
    }

    return new BlobDataSource(uri, in);
  }
View Full Code Here

Examples of com.elasticinbox.core.blob.BlobDataSource

  public BlobDataSource read(final URI uri) throws IOException
  {
    // check if blob was stored for the message
    Assert.notNull(uri, "URI cannot be null");

    BlobDataSource blobDS;
    BlobURI blobUri = new BlobURI().fromURI(uri);

    if (blobUri.getProfile().equals(DatabaseConstants.DATABASE_PROFILE)) {
      blobDS = dbBlobStorage.read(uri);
    } else {
      blobDS = cloudBlobStorage.read(uri);
    }

    // if compressed, add compression handler to data source
    if ((blobUri.getCompression() != null && blobUri.getCompression()
        .equals(DeflateCompressionHandler.COMPRESSION_TYPE_DEFLATE)) ||
        // TODO: deprecated suffix based compression detection
        // kept for backward compatibility with 0.3
        blobUri.getName().endsWith(BlobStoreConstants.COMPRESS_SUFFIX))
    {
      CompressionHandler ch = new DeflateCompressionHandler();
      return new BlobDataSource(uri, blobDS.getInputStream(), ch);
    } else {
      return blobDS;
    }
  }
View Full Code Here

Examples of com.elasticinbox.core.blob.BlobDataSource

    Mailbox mailbox = new Mailbox(user, domain);

    Response response;

    try {
      BlobDataSource blobDS = messageDAO.getRaw(mailbox, messageId);

      if (acceptEncoding != null && acceptEncoding.contains("deflate")
          && blobDS.isCompressed())
      {
        response = Response
            .ok(blobDS.getInputStream(), MediaType.TEXT_PLAIN)
            .header(HttpHeaders.CONTENT_ENCODING, "deflate").build();
      } else {
        response = Response.ok(blobDS.getUncompressedInputStream(),
            MediaType.TEXT_PLAIN).build();
      }
    } catch (IllegalArgumentException iae) {
      throw new BadRequestException(iae.getMessage());
    } catch (Exception e) {
View Full Code Here

Examples of org.apache.axiom.util.blob.BlobDataSource

                }
                out.close();
            } catch (IOException ex) {
                throw new XMLStreamException("Error during base64 decoding", ex);
            }
            return new DataHandler(new BlobDataSource(blob, "application/octet-string"));
        }
    }
View Full Code Here

Examples of org.apache.axiom.util.blob.BlobDataSource

            parent.write(b);
        }
       
        public void close() throws IOException {
            parent.close();
            writePart(new DataHandler(new BlobDataSource(blob, contentType)),
                    contentTransferEncoding, contentID);
        }
View Full Code Here

Examples of org.apache.axiom.util.blob.BlobDataSource

                }
                out.close();
            } catch (IOException ex) {
                throw new XMLStreamException("Error during base64 decoding", ex);
            }
            return new DataHandler(new BlobDataSource(blob, "application/octet-string"));
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.