Package com.elasticinbox.core.blob

Examples of com.elasticinbox.core.blob.BlobURI


  @Test
  public void testFromURI1()
  {
    URI testUri = URI.create("blob://aws3-bucket/f1ca99e0-99a0-11e2-95f0-040cced3bd7a:myemail%40elasticinbox.com?c=dfl&e=ekey2");

    BlobURI bu = new BlobURI();
    bu.fromURI(testUri);
   
    assertEquals("aws3-bucket", bu.getProfile());
    assertEquals("f1ca99e0-99a0-11e2-95f0-040cced3bd7a:myemail@elasticinbox.com", bu.getName());
    assertEquals("dfl", bu.getCompression());
    assertEquals("ekey2", bu.getEncryptionKey());
    assertNull(bu.getBlockCount());
  }
View Full Code Here


  @Test
  public void testFromURI2()
  {
    URI testUri = URI.create("blob://db/f1ca99e0-99a0-11e2-95f0-040cced3bd7a?c=gz&b=1");

    BlobURI bu = new BlobURI();
    bu.fromURI(testUri);
   
    assertEquals("db", bu.getProfile());
    assertEquals("f1ca99e0-99a0-11e2-95f0-040cced3bd7a", bu.getName());
    assertEquals("gz", bu.getCompression());
    assertEquals(new Integer(1), bu.getBlockCount());
    assertNull(bu.getEncryptionKey());
  }
View Full Code Here

  @Test(expected=IllegalArgumentException.class)
  public void testFromBadSchemeURI()
  {
    URI testUri = URI.create("notblob://db/f1ca99e0-99a0-11e2-95f0-040cced3bd7a");
    new BlobURI().fromURI(testUri);
  }
View Full Code Here

  @Test
  public void testBuildURI()
  {
    URI testUri = URI.create("blob://my-azure-bs/f1ca99e0-99a0-11e2-95f0-040cced3bd7a?c=dfl&e=k2&b=100");

    BlobURI bu = new BlobURI()
        .setProfile("my-azure-bs")
        .setName("f1ca99e0-99a0-11e2-95f0-040cced3bd7a")
        .setBlockCount(100)
        .setCompression("dfl")
        .setEncryptionKey("k2");

    assertEquals(testUri, bu.buildURI());
  }
View Full Code Here

  }

  public void setLocation(URI uri)
  {
    // validate URI, should throw exception if invalid
    new BlobURI().fromURI(uri);

    this.location = uri;
  }
View Full Code Here

        + " bytes can't be stored in Cassandra. Provided blob size: " + size + " bytes");

    logger.debug("Storing blob {} in Cassandra", messageId);

    // prepare URI
    BlobURI blobUri = new BlobURI()
        .setProfile(DATABASE_PROFILE)
        .setName(messageId.toString()).setBlockCount(1);

    // store blob
    // TODO: currently we allow only single block writes (blockid=0). in future we can split blobs to multiple blocks
View Full Code Here

  @Override
  public BlobDataSource read(final URI uri) throws IOException
  {
    logger.debug("Reading blob {} from Cassandra", uri);

    BlobURI blobUri = new BlobURI().fromURI(uri);
    Assert.isTrue(blobUri.getProfile().equals(DATABASE_PROFILE), "Blob store profile does not match database.");

    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

  @Override
  public void delete(final URI uri) throws IOException
  {
    logger.debug("Deleting blob {}", uri);

    BlobURI blobUri = new BlobURI().fromURI(uri);
    Assert.isTrue(blobUri.getProfile().equals(DATABASE_PROFILE), "Blob store profile does not match database.");

    UUID messageId = UUID.fromString(blobUri.getName());
    BlobPersistence.deleteBlock(messageId, BlobStoreConstants.DATABASE_DEFAULT_BLOCK_ID);
  }
View Full Code Here

    InputStream in1;
    Long updatedSize = size;

    // prepare URI
    BlobURI blobUri = new BlobURI()
        .setProfile(profileName)
        .setName(blobName);

    // encrypt stream
    if (encryptionHandler != null)
    {
      byte[] iv = getCipherIVFromBlobName(blobName);
     
      InputStream encryptedInputStream = this.encryptionHandler.encrypt(in, Configurator.getBlobStoreDefaultEncryptionKey(), iv);
      FileBackedOutputStream fbout = new FileBackedOutputStream(MAX_MEMORY_FILE_SIZE, true);
     
      updatedSize = ByteStreams.copy(encryptedInputStream, fbout);
      in1 = fbout.getSupplier().getInput();

      blobUri.setEncryptionKey(Configurator.getBlobStoreDefaultEncryptionKeyAlias());
    } else {
      in1 = in;
    }

    CloudStoreProxy.write(blobName, profileName, in1, updatedSize);
View Full Code Here

  @Override
  public BlobDataSource read(final URI uri) throws IOException
  {
    InputStream in;
   
    BlobURI blobUri = new BlobURI().fromURI(uri);
    String keyAlias = blobUri.getEncryptionKey();

    if (keyAlias != null)
    {
      // currently we only support AES encryption, use by default
      EncryptionHandler eh = new AESEncryptionHandler();
View Full Code Here

TOP

Related Classes of com.elasticinbox.core.blob.BlobURI

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.