Package org.jclouds.blobstore.domain

Examples of org.jclouds.blobstore.domain.MutableBlobMetadata


   }

   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 = super.apply(from);
      to.setPublicUri(publicUriForObjectInfo.apply(from));
      return to;
   }
View Full Code Here

        assertTrue(ByteStreams.equal(expectedFile, resultBlob.getPayload()),
                "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

   }

   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

               public StorageMetadata apply(String key) {
                  Blob oldBlob = loadBlob(container, key);
                  checkState(oldBlob != null, "blob " + key + " is not present although it was in the list of "
                        + container);
                  checkState(oldBlob.getMetadata() != null, "blob " + container + "/" + key + " has no metadata");
                  MutableBlobMetadata md = BlobStoreUtils.copy(oldBlob.getMetadata());
                  String directoryName = ifDirectoryReturnName.execute(md);
                  if (directoryName != null) {
                     md.setName(directoryName);
                     md.setType(StorageType.RELATIVE_PATH);
                  }
                  return md;
               }
            }));

      String marker = null;
      if (options != null) {
         if (options.getMarker() != null) {
            final String finalMarker = options.getMarker();
            StorageMetadata lastMarkerMetadata = find(contents, new Predicate<StorageMetadata>() {
               public boolean apply(StorageMetadata metadata) {
                  return metadata.getName().compareTo(finalMarker) > 0;
               }
            });
            contents = contents.tailSet(lastMarkerMetadata);
         }

         final String prefix = options.getDir();
         if (prefix != null) {
            contents = newTreeSet(filter(contents, new Predicate<StorageMetadata>() {
               public boolean apply(StorageMetadata o) {
                  return o != null && o.getName().startsWith(prefix) && !o.getName().equals(prefix);
               }
            }));
         }

         int maxResults = options.getMaxResults() != null ? options.getMaxResults() : 1000;
         if (!contents.isEmpty()) {
            StorageMetadata lastElement = contents.last();
            contents = newTreeSet(Iterables.limit(contents, maxResults));
            if (!contents.contains(lastElement)) {
               // Partial listing
               marker = contents.last().getName();
            }
         }

         if (!options.isRecursive()) {
            String delimiter = storageStrategy.getSeparator();
            SortedSet<String> commonPrefixes = newTreeSet(
                   transform(contents, new CommonPrefixes(prefix, delimiter)));
            commonPrefixes.remove(CommonPrefixes.NO_PREFIX);

            contents = newTreeSet(filter(contents, new DelimiterFilter(prefix, delimiter)));

            for (String o : commonPrefixes) {
               MutableStorageMetadata md = new MutableStorageMetadataImpl();
               md.setType(StorageType.RELATIVE_PATH);
               md.setName(o);
               contents.add(md);
            }
         }

         // trim metadata, if the response isn't supposed to be detailed.
         if (!options.isDetailed()) {
            for (StorageMetadata md : contents) {
               md.getUserMetadata().clear();
            }
         }
      }

      return Futures.<PageSet<? extends StorageMetadata>> immediateFuture(new PageSetImpl<StorageMetadata>(contents,
View Full Code Here

         return Futures.immediateFuture(null);
      }
   }
  
   public static MutableBlobMetadata copy(MutableBlobMetadata in) {
      MutableBlobMetadata metadata = new MutableBlobMetadataImpl(in);
      convertUserMetadataKeysToLowercase(metadata);
      return metadata;
   }
View Full Code Here

      convertUserMetadataKeysToLowercase(metadata);
      return metadata;
   }

   public static MutableBlobMetadata copy(MutableBlobMetadata in, String newKey) {
      MutableBlobMetadata newMd = BlobStoreUtils.copy(in);
      newMd.setName(newKey);
      return newMd;
   }
View Full Code Here

   public void testSetLastModified() {
      HttpResponse from = HttpResponse.builder()
                                      .statusCode(200).message("ok")
                                      .payload("")
                                      .addHeader(HttpHeaders.LAST_MODIFIED, "Wed, 09 Sep 2009 19:50:23 GMT").build();
      MutableBlobMetadata metadata = blobMetadataProvider.get();
      parser.parseLastModifiedOrThrowException(from, metadata);
      assertEquals(metadata.getLastModified(), new SimpleDateFormatDateService()
               .rfc822DateParse("Wed, 09 Sep 2009 19:50:23 GMT"));
   }
View Full Code Here

   public void testSetLastModifiedIso8601() {
      HttpResponse from = HttpResponse.builder()
                                      .statusCode(200).message("ok")
                                      .payload("")
                                      .addHeader(HttpHeaders.LAST_MODIFIED, "2011-01-28T17:35:08.000Z").build();
      MutableBlobMetadata metadata = blobMetadataProvider.get();
      parser.parseLastModifiedOrThrowException(from, metadata);
      assertEquals(metadata.getLastModified(), new SimpleDateFormatDateService()
               .iso8601DateParse("2011-01-28T17:35:08.000Z"));
   }
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.