Package org.jclouds.blobstore.domain.internal

Examples of org.jclouds.blobstore.domain.internal.MutableBlobMetadataImpl


   }

   public MutableBlobMetadata apply(BlobProperties from) {
      if (from == null)
         return null;
      MutableBlobMetadata to = new MutableBlobMetadataImpl();
      HttpUtils.copy(from.getContentMetadata(), to.getContentMetadata());
      to.setUserMetadata(from.getMetadata());
      to.setETag(from.getETag());
      to.setLastModified(from.getLastModified());
      to.setName(from.getName());
      to.setContainer(from.getContainer());
      to.setUri(from.getUrl());
      if (from.getContainer() != null)
         try {
            PublicAccess containerAcl = containerAcls.getUnchecked(from.getContainer());
            if (containerAcl != PublicAccess.PRIVATE)
               to.setPublicUri(from.getUrl());
         } catch (CacheLoader.InvalidCacheLoadException e) {
            // nulls not permitted from cache loader
         }
      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(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

      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 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

* @author Adrian Cole
*/
@Singleton
public class BlobToContentMetadata implements Function<BlobMetadata, MutableContentMetadata> {
   public MutableContentMetadata apply(BlobMetadata base) {
      MutableBlobMetadataImpl to = new MutableBlobMetadataImpl();
      HttpUtils.copy(base.getContentMetadata(), to.getContentMetadata());
      return new DelegatingMutableContentMetadata(base.getUri(), base.getName(), base.getUri() != null ? base.getUri()
               .getPath() : null, to.getContentMetadata());
   }
View Full Code Here

   }

   public MutableBlobMetadata apply(AtmosObject from) {
      if (from == null)
         return null;
      MutableBlobMetadata to = new MutableBlobMetadataImpl();
      to.setId(from.getSystemMetadata().getObjectID());
      to.setLastModified(from.getSystemMetadata().getLastUserDataModification());
      HttpUtils.copy(from.getContentMetadata(), to.getContentMetadata());
      to.setName(objectName.apply(from));
      to.setUri(from.getContentMetadata().getUri());
      to.setContainer(Iterables.get(Splitter.on('/').split(from.getContentMetadata().getPath()),0));
      if (from.getAllHeaders().containsEntry("x-emc-groupacl", "other=READ"))
         to.setPublicUri(shareUrl.apply(from.getContentMetadata().getPath()));
      if (from.getSystemMetadata().getType() == FileType.DIRECTORY) {
         to.setType(StorageType.FOLDER);
      } else {
         to.setType(StorageType.BLOB);
      }
      Map<String, String> lowerKeyMetadata = Maps.newHashMap();
      for (Entry<String, String> entry : from.getUserMetadata().getMetadata().entrySet()) {
         String key = entry.getKey().toLowerCase();
         if (!systemMetadata.contains(key))
            lowerKeyMetadata.put(key, entry.getValue());
      }
      to.setUserMetadata(lowerKeyMetadata);
      return to;
   }
View Full Code Here

   }

   public MutableBlobMetadata apply(BlobProperties from) {
      if (from == null)
         return null;
      MutableBlobMetadata to = new MutableBlobMetadataImpl();
      HttpUtils.copy(from.getContentMetadata(), to.getContentMetadata());
      to.setUserMetadata(from.getMetadata());
      to.setETag(from.getETag());
      to.setLastModified(from.getLastModified());
      to.setName(from.getName());
      to.setContainer(from.getContainer());
      to.setUri(from.getUrl());
      if (from.getContainer() != null)
         try {
            PublicAccess containerAcl = containerAcls.getUnchecked(from.getContainer());
            if (containerAcl != PublicAccess.PRIVATE)
               to.setPublicUri(from.getUrl());
         } catch (CacheLoader.InvalidCacheLoadException e) {
            // nulls not permitted from cache loader
         }
      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 = 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

TOP

Related Classes of org.jclouds.blobstore.domain.internal.MutableBlobMetadataImpl

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.