Package org.jclouds.blobstore.domain

Examples of org.jclouds.blobstore.domain.MutableBlobMetadata


   }

   public MutableBlobMetadata apply(ObjectMetadata from) {
      if (from == null)
         return null;
      MutableBlobMetadata to = new MutableBlobMetadataImpl();
      HttpUtils.copy(from.getContentMetadata(), to.getContentMetadata());
      try {
         AccessControlList bucketAcl = bucketAcls.getUnchecked(from.getBucket());
         if (bucketAcl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ))
            to.setPublicUri(from.getUri());
      } catch (CacheLoader.InvalidCacheLoadException e) {
         // nulls not permitted from cache loader
      }
      to.setUri(from.getUri());
      to.setContainer(from.getBucket());
      to.setETag(from.getETag());
      to.setName(from.getKey());
      to.setLastModified(from.getLastModified());
      to.setUserMetadata(from.getUserMetadata());
      to.setLocation(locationOfBucket.apply(from.getBucket()));
      String directoryName = ifDirectoryReturnName.execute(to);
      if (directoryName != null) {
         to.setName(directoryName);
         to.setType(StorageType.RELATIVE_PATH);
      } else {
         to.setType(StorageType.BLOB);
      }
      return to;
   }
View Full Code Here


   public void testCreateParentIfNeededAsyncNoPath() {
      AsyncBlobStore asyncBlobStore = createMock(AsyncBlobStore.class);
      String container = "container";
      Blob blob = createMock(Blob.class);
      MutableBlobMetadata md = createMock(MutableBlobMetadata.class);

      expect(blob.getMetadata()).andReturn(md).atLeastOnce();
      expect(md.getName()).andReturn("hello").atLeastOnce();

      replay(asyncBlobStore);
      replay(blob);
      replay(md);
View Full Code Here

   public void testCreateParentIfNeededAsyncSinglePath() {
      AsyncBlobStore asyncBlobStore = createMock(AsyncBlobStore.class);
      String container = "container";
      Blob blob = createMock(Blob.class);
      MutableBlobMetadata md = createMock(MutableBlobMetadata.class);

      expect(blob.getMetadata()).andReturn(md).atLeastOnce();
      expect(md.getName()).andReturn("rootpath/hello").atLeastOnce();
      expect(asyncBlobStore.createDirectory("container", "rootpath")).andReturn(null);

      replay(asyncBlobStore);
      replay(blob);
      replay(md);
View Full Code Here

   public void testCreateParentIfNeededAsyncNestedPath() {
      AsyncBlobStore asyncBlobStore = createMock(AsyncBlobStore.class);
      String container = "container";
      Blob blob = createMock(Blob.class);
      MutableBlobMetadata md = createMock(MutableBlobMetadata.class);

      expect(blob.getMetadata()).andReturn(md).atLeastOnce();
      expect(md.getName()).andReturn("rootpath/subpath/hello").atLeastOnce();
      expect(asyncBlobStore.createDirectory("container", "rootpath/subpath")).andReturn(null);

      replay(asyncBlobStore);
      replay(blob);
      replay(md);
View Full Code Here

        assertEquals(expectedFile.read(), ByteStreams2.toByteArrayAndClose(resultBlob.getPayload().openStream()),
                "Blob payload differs from file content");
        // metadata are verified in the test for blobMetadata, so no need to
        // perform a complete test here
        assertNotNull(resultBlob.getMetadata(), "Metadata null");
        MutableBlobMetadata metadata = resultBlob.getMetadata();
        assertEquals(blobKey, metadata.getName(), "Wrong blob metadata");
    }
View Full Code Here

      String container = "test-container";
      String blobName = "test-blob";
      long oneMB = 1048576L;
      AzureBlobClient client = createMock(AzureBlobClient.class);
      PayloadSlicer slicer = createMock(PayloadSlicer.class);
      MutableBlobMetadata metadata = new MutableBlobMetadataImpl();
      MutableContentMetadata contentMetadata = new BaseMutableContentMetadata();
      contentMetadata.setContentLength(MultipartUploadStrategy.MAX_BLOCK_SIZE * 3 + oneMB);
      metadata.setName(blobName);
      metadata.setContentMetadata(contentMetadata);
      Blob blob = new BlobImpl(metadata);
      Payload payload = new StringPayload("ABCD");
      payload.setContentMetadata(contentMetadata);
      blob.setPayload(payload);

View Full Code Here

   }

   public MutableBlobMetadata apply(ObjectInfo from) {
      if (from == null)
         return null;
      MutableBlobMetadata to = new MutableBlobMetadataImpl();
      to.getContentMetadata().setContentMD5(from.getHash());
      if (from.getContentType() != null)
         to.getContentMetadata().setContentType(from.getContentType());
      if (from.getHash() != null)
         to.setETag(base16().lowerCase().encode(from.getHash()));
      to.setName(from.getName());
      to.setContainer(from.getContainer());
      to.setUri(from.getUri());
      to.getContentMetadata().setContentLength(from.getBytes());
      if (from.getLastModified() != null)
         to.setLastModified(from.getLastModified());
      if (from instanceof MutableObjectInfoWithMetadata)
         to.setUserMetadata(((MutableObjectInfoWithMetadata) from).getMetadata());
      String directoryName = ifDirectoryReturnName.execute(to);
      if (directoryName != null) {
         to.setName(directoryName);
         to.setType(StorageType.RELATIVE_PATH);
      } else {
         to.setType(StorageType.BLOB);
      }
      return to;
   }
View Full Code Here

   @Override
   public MutableBlobMetadata apply(SwiftObject from) {
      if (from == null)
         return null;
      MutableBlobMetadata to = new MutableBlobMetadataImpl();
      to.setContainer(container.getName());
      if (container.getAnybodyRead().isPresent()) {
         to.setPublicUri(from.getUri());
      }
      to.setUri(from.getUri());
      to.setETag(from.getEtag());
      to.setName(from.getName());
      to.setLastModified(from.getLastModified());
      to.setContentMetadata(from.getPayload().getContentMetadata());
      to.getContentMetadata().setContentMD5(base16().lowerCase().decode(from.getEtag()));
      to.setUserMetadata(from.getMetadata());
      String directoryName = ifDirectoryReturnName.execute(to);
      if (directoryName != null) {
         to.setName(directoryName);
         to.setType(StorageType.RELATIVE_PATH);
      } else {
         to.setType(StorageType.BLOB);
      }
      return to;
   }
View Full Code Here

   }

   public MutableBlobMetadata apply(ObjectInfo from) {
      if (from == null)
         return null;
      MutableBlobMetadata to = super.apply(from);
      to.setPublicUri(publicUriForObjectInfo.apply(from));

      return to;
   }
View Full Code Here

public class FileInfoToBlobMetadata implements Function<FileInfo, MutableBlobMetadata> {
   public static final Pattern OBJECTS_PATTERN = Pattern.compile(".*objects/");

   @Override
   public MutableBlobMetadata apply(FileInfo from) {
      MutableBlobMetadata to = new MutableBlobMetadataImpl();
      if (from.getUrl() != null) {
         to.setId(Strings2.replaceAll(from.getUrl().getPath(), OBJECTS_PATTERN, ""));
      }
      to.setUri(from.getUrl());
      to.setName(from.getName());
      if (from.getMimeType() != null)
         to.getContentMetadata().setContentType(from.getMimeType());
      if (from.getModified() != null)
         to.setLastModified(from.getModified());
      if (from.getBytes() != null)
         to.getContentMetadata().setContentLength(from.getBytes());
      to.setType(StorageType.BLOB);
      return to;
   }
View Full Code Here

TOP

Related Classes of org.jclouds.blobstore.domain.MutableBlobMetadata

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.