Package org.jclouds.blobstore.options

Examples of org.jclouds.blobstore.options.ListContainerOptions


public class ListContainerOptionsToBlobStoreListContainerOptions
         implements
         Function<org.jclouds.openstack.swift.options.ListContainerOptions[], ListContainerOptions> {
   public ListContainerOptions apply(
            org.jclouds.openstack.swift.options.ListContainerOptions[] optionsList) {
      ListContainerOptions options = new ListContainerOptions();
      if (optionsList.length != 0) {
         if (optionsList[0].getPath() != null && !optionsList[0].getPath().equals("")) {
            options.inDirectory(optionsList[0].getPath());
         }
         if (optionsList[0].getPrefix() != null && !optionsList[0].getPrefix().equals("")) {
            options.inDirectory(optionsList[0].getPrefix());
            options.recursive();
         }
         if (optionsList[0].getMarker() != null) {
            options.afterMarker(optionsList[0].getMarker());
         }
         options.maxResults(optionsList[0].getMaxResults());
      }
      return options;
   }


@Singleton
public class ListBlobsOptionsToListOptions implements
         Function<ListBlobsOptions[], ListContainerOptions> {
   public ListContainerOptions apply(ListBlobsOptions[] 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());
         }
         if (optionsList[0].getIncludeMetadata()) {
            options.withDetails();
         }
      }
      return options;
   }

import com.google.common.base.Function;

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

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

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.