Package org.jclouds.blobstore.options

Examples of org.jclouds.blobstore.options.ListContainerOptions


   }

   @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);


   public void testLargerThanOnePageNoOptions() {
      blobstore.createContainerInLocation(null, "goodies");
      for (int i = 0; i < 1001; i++) {
         blobstore.putBlob("goodies", blobstore.blobBuilder(i + "").payload(i + "").build());
      }
      Iterable<? extends StorageMetadata> listing = concatter.execute("goodies", new ListContainerOptions());
      assertEquals(Iterables.size(listing), 1001);
   }

         blobstore.putBlob("foo", blobstore.blobBuilder(i + "").payload(i + "").build());
      }
      for (int i = 0; i < 1001; i++) {
         blobstore.putBlob("foo", blobstore.blobBuilder("dir/" + i + "").payload(i + "").build());
      }
      Iterable<? extends StorageMetadata> listing = concatter.execute("foo", new ListContainerOptions());
      // TODO: this looks broke.  seems we should have 1002 (1001 + directory foo), not 1003
      assertEquals(Iterables.size(listing), 1003);
      listing = concatter.execute("foo", ListContainerOptions.Builder.inDirectory("dir"));
      assertEquals(Iterables.size(listing), 1001);
      listing = concatter.execute("foo", ListContainerOptions.Builder.recursive());

* @author Adrian Cole
*/
@Singleton
public class BucketToContainerListOptions implements Function<ListBucketOptions[], ListContainerOptions> {
   public ListContainerOptions apply(ListBucketOptions[] optionsList) {
      ListContainerOptions options = new ListContainerOptions();
      if (optionsList.length != 0) {
         if (optionsList[0].getDelimiter() == null) {
            options.recursive();
         } else if (!optionsList[0].getDelimiter().equals("/")) {
            throw new IllegalArgumentException("only '/' is allowed as a blobstore delimiter");
         }
         if (optionsList[0].getMarker() != null) {
            options.afterMarker(optionsList[0].getMarker());
         }
         if (optionsList[0].getMaxResults() != null) {
            options.maxResults(optionsList[0].getMaxResults());
         }
         if (optionsList[0].getPrefix() != null) {
            options.inDirectory(optionsList[0].getPrefix());
         }
      }
      return options;
   }

      return blobStore.createContainerInLocation(new LocationBuilder().scope(LocationScope.REGION).id(region)
               .description(region).build(), name);
   }

   public ListenableFuture<ListBucketResponse> listBucket(final String name, ListBucketOptions... optionsList) {
      ListContainerOptions options = bucket2ContainerListOptions.apply(optionsList);
      return transform(blobStore.list(name, options), resource2BucketList, userExecutor);
   }

      return blobStore.createContainerInLocation(new LocationBuilder().scope(LocationScope.REGION).id(region)
               .description(region).build(), name);
   }

   public ListenableFuture<ListBucketResponse> listBucket(final String name, ListBucketOptions... optionsList) {
      ListContainerOptions options = bucket2ContainerListOptions.apply(optionsList);
      return transform(blobStore.list(name, options), resource2BucketList, userExecutor);
   }

      throw new UnsupportedOperationException();
   }

   public ListenableFuture<PageSet<ObjectInfo>> listObjects(String container,
            org.jclouds.openstack.swift.options.ListContainerOptions... optionsList) {
      ListContainerOptions options = container2ContainerListOptions.apply(optionsList);
      return transform(blobStore.list(container, options), resource2ObjectList, userExecutor);
   }

        pendingExchanges = 0;

        Queue<Exchange> queue = new LinkedList<Exchange>();
        String directory = endpoint.getDirectory();

        ListContainerOptions opt = new ListContainerOptions();

        if (!Strings.isNullOrEmpty(directory)) {
            opt = opt.inDirectory(directory);
        }

        for (StorageMetadata md : blobStore.list(container, opt.maxResults(maxMessagesPerPoll).recursive())) {
            String blobName = md.getName();
            if (md.getType().equals(StorageType.BLOB)) {
                if (!Strings.isNullOrEmpty(blobName)) {
                    InputStream body = JcloudsBlobStoreHelper.readBlob(blobStore, container, blobName);
                    if (body != null) {

    private void checkForContainerContent(final String containerName, Set<String> expectedBlobKeys) {
        checkForContainerContent(containerName, null, expectedBlobKeys);
    }

    private void checkForContainerContent(final String containerName, String inDirectory, Set<String> expectedBlobKeys) {
        ListContainerOptions options = ListContainerOptions.Builder.recursive();
        if (null != inDirectory && !"".equals(inDirectory))
            options.inDirectory(inDirectory);

        PageSet<? extends StorageMetadata> blobsRetrieved = blobStore.list(containerName, options);
        for (Iterator<? extends StorageMetadata> it = blobsRetrieved.iterator(); it.hasNext();) {
           // TODO: FluentIterable
           if (it.next().getType() != StorageType.BLOB) {

@Singleton
public class ListOptionsToBlobStoreListOptions implements
         Function<org.jclouds.atmos.options.ListOptions[], ListContainerOptions> {
   public ListContainerOptions apply(org.jclouds.atmos.options.ListOptions[] optionsList) {
      ListContainerOptions options = new ListContainerOptions();
      if (optionsList.length != 0) {
         if (optionsList[0].getToken() != null) {
            options.afterMarker(optionsList[0].getToken());
         }
         if (optionsList[0].getLimit() != null) {
            options.maxResults(optionsList[0].getLimit());
         }
         if (optionsList[0].metaIncluded()) {
            options.withDetails();
         }
      }
      return options;
   }

TOP

Related Classes of org.jclouds.blobstore.options.ListContainerOptions

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.