Package org.jclouds.blobstore.domain

Examples of org.jclouds.blobstore.domain.StorageMetadata


    * http://code.google.com/p/jclouds/issues/detail?id=992
    */
   public void testUseBucketWithUpperCaseName() throws Exception {
      String bucketName = CONTAINER_PREFIX + "-TestBucket";
      String blobName = "TestBlob.txt";
      StorageMetadata container = null;
      BlobStore store = view.getBlobStore();

      // Create and use a valid bucket name with uppercase characters in the bucket name (US regions only)
      try {
         store.createContainerInLocation(null, bucketName);
View Full Code Here


      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();
            }
View Full Code Here

   @Test
   public void testListAllWhenOnePage() throws Exception {
      BlobStore blobStore = createMock(BlobStore.class);
      ListContainerOptions options = ListContainerOptions.NONE;
      StorageMetadata v1 = createMock(StorageMetadata.class);
      PageSet<StorageMetadata> pageSet = new PageSetImpl<StorageMetadata>(ImmutableList.of(v1), null);

      EasyMock.<PageSet<? extends StorageMetadata>> expect(blobStore.list(containerName, options)).andReturn(pageSet)
               .once();
      EasyMock.replay(blobStore);
View Full Code Here

   @Test
   public void testListAllWhenTwoPages() throws Exception {
      BlobStore blobStore = createMock(BlobStore.class);
      ListContainerOptions options = ListContainerOptions.NONE;
      ListContainerOptions options2 = ListContainerOptions.Builder.afterMarker("marker1");
      StorageMetadata v1 = createMock(StorageMetadata.class);
      StorageMetadata v2 = createMock(StorageMetadata.class);
      PageSet<StorageMetadata> pageSet = new PageSetImpl<StorageMetadata>(ImmutableList.of(v1), "marker1");
      PageSet<StorageMetadata> pageSet2 = new PageSetImpl<StorageMetadata>(ImmutableList.of(v2), null);

      EasyMock.<PageSet<? extends StorageMetadata>> expect(blobStore.list(containerName, options)).andReturn(pageSet)
               .once();
View Full Code Here

   @Test
   public void test1() {
      MutableBlobMetadata md = blobMetadataProvider.get();
      md.setName("dir/");
      md.setId("dir/");
      StorageMetadata rd = parser.apply(md);
      assertEquals(rd.getName(), "dir");
      assertEquals(rd.getProviderId(), "dir/");
      assertEquals(rd.getType(), StorageType.RELATIVE_PATH);
   }
View Full Code Here

   @Test
   public void test2() {
      MutableBlobMetadata md = blobMetadataProvider.get();
      md.setName("dir_$folder$");
      md.setId("dir_$folder$");
      StorageMetadata rd = parser.apply(md);
      assertEquals(rd.getName(), "dir");
      assertEquals(rd.getProviderId(), "dir_$folder$");
      assertEquals(rd.getType(), StorageType.RELATIVE_PATH);
   }
View Full Code Here

   @Test
   public void testNoNameChange() {
      MutableBlobMetadata md = blobMetadataProvider.get();
      md.setName("dir");
      md.setId("dir");
      StorageMetadata rd = parser.apply(md);
      assertEquals(rd.getName(), "dir");
      assertEquals(rd.getProviderId(), "dir");
      assertEquals(rd.getType(), StorageType.RELATIVE_PATH);
   }
View Full Code Here

    public boolean deleteChunks(List<String> chunkIds, long maxLastModifiedTime) throws Exception {
        Preconditions.checkNotNull(context);

        for (String chunkId : chunkIds) {
            final org.jclouds.blobstore.BlobStore blobStore = context.getBlobStore();
            StorageMetadata metadata = blobStore.blobMetadata(cloudContainer, chunkId);
            if ((maxLastModifiedTime <= 0)
                    || (metadata.getLastModified().getTime() <= maxLastModifiedTime)) {
                blobStore.removeBlob(cloudContainer, chunkId);
                return true;
            }
        }
        return true;
View Full Code Here

        }

        private void loadElements(PageSet<? extends StorageMetadata> set) {
            Iterator<? extends StorageMetadata> iter = set.iterator();
            while (iter.hasNext()) {
                StorageMetadata metadata = iter.next();
                if ((maxLastModifiedTime <= 0)
                        || (metadata.getLastModified().getTime() <= maxLastModifiedTime)) {
                    queue.add(metadata.getName());
                } else {
                    queue.add(metadata.getName());
                }
            }
        }
View Full Code Here

    @Override
    public boolean deleteChunk(String chunkId, long maxLastModifiedTime) throws Exception {
        Preconditions.checkNotNull(context);

        final org.jclouds.blobstore.BlobStore blobStore = context.getBlobStore();
        StorageMetadata metadata = blobStore.blobMetadata(cloudContainer, chunkId);
        if ((maxLastModifiedTime <= 0)
                || (metadata.getLastModified().getTime() <= maxLastModifiedTime)) {
            blobStore.removeBlob(cloudContainer, chunkId);
            return true;
        }
        return true;
    }
View Full Code Here

TOP

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

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.