Package org.jclouds.openstack.swift.v1.options

Examples of org.jclouds.openstack.swift.v1.options.ListContainerOptions$Builder


      api.objectApiInRegionForContainer(region.getId(), containerName).delete(directory);
   }

   @Override
   public long countBlobs(String containerName) {
      Container container = api.containerApiInRegion(region.getId()).get(containerName);
      // undefined if container doesn't exist, so default to zero
      return container != null ? container.objectCount() : 0;
   }
View Full Code Here


      }
   }

   public void extractArchive() throws Exception {
      for (String regionId : regions) {
         ExtractArchiveResponse extractResponse = api.bulkApiInRegion(regionId).extractArchive(containerName,
               Payloads.newPayload(tarGz), "tar.gz");
         assertEquals(extractResponse.created(), OBJECT_COUNT);
         assertTrue(extractResponse.errors().isEmpty());
         assertEquals(api.containerApiInRegion(regionId).get(containerName).objectCount(), OBJECT_COUNT);

         // repeat the command
         extractResponse = api.bulkApiInRegion(regionId).extractArchive(containerName, Payloads.newPayload(tarGz),
               "tar.gz");
         assertEquals(extractResponse.created(), OBJECT_COUNT);
         assertTrue(extractResponse.errors().isEmpty());
      }
   }
View Full Code Here

      server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
      server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody("{\"Number Files Created\": 10, \"Errors\": []}")));

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         ExtractArchiveResponse response = api.bulkApiInRegion("DFW").extractArchive("myContainer",
               newByteArrayPayload(tarGz), "tar.gz");
         assertEquals(response.created(), 10);
         assertTrue(response.errors().isEmpty());

         assertEquals(server.getRequestCount(), 2);
         assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
         RecordedRequest extractRequest = server.takeRequest();
         assertEquals(extractRequest.getRequestLine(),
View Full Code Here

            .addHeader("X-Container-Read", ".r:*,.rlistings") //
            .setBody(objectList)));

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         ObjectList objects = api.objectApiInRegionForContainer("DFW", "myContainer").list(new ListContainerOptions());
         assertEquals(objects, parsedObjectsForUrl(server.getUrl("/").toString()));
         assertEquals(objects.container().name(), "myContainer");
         assertTrue(objects.container().anybodyRead().get());

         assertEquals(server.getRequestCount(), 2);
         assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
         assertEquals(server.takeRequest().getRequestLine(),
               "GET /v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/myContainer/?format=json HTTP/1.1");
View Full Code Here

      server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
      server.enqueue(addCommonHeaders(containerResponse().setBody(objectList)));

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         ObjectList objects = api.objectApiInRegionForContainer("DFW", "myContainer").list(marker("test"));
         assertEquals(objects, parsedObjectsForUrl(server.getUrl("/").toString()));

         assertEquals(server.getRequestCount(), 2);
         assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
         assertEquals(server.takeRequest().getRequestLine(),
View Full Code Here

   }

   public void list() throws Exception {
      for (String regionId : regions) {
         ObjectApi objectApi = api.objectApiInRegionForContainer(regionId, containerName);
         ObjectList response = objectApi.list(new ListContainerOptions());
         assertEquals(response.container(), api.containerApiInRegion(regionId).get(containerName));
         assertNotNull(response);
         for (SwiftObject object : response) {
            checkObject(object);
         }
      }
View Full Code Here

      setIfTestSystemPropertyPresent(props, LocationConstants.PROPERTY_REGION);
      return props;
   }

   protected void deleteAllObjectsInContainer(String regionId, final String containerName) {
      ObjectList objects = api.objectApiInRegionForContainer(regionId, containerName).list(new ListContainerOptions());
      if (objects == null) {
         return;
      }
      List<String> pathsToDelete = Lists.transform(objects, new Function<SwiftObject, String>() {
         public String apply(SwiftObject input) {
View Full Code Here

   }

   @Override
   public PageSet<? extends StorageMetadata> list(final String container, ListContainerOptions options) {
      ObjectApi objectApi = api.objectApiInRegionForContainer(region.getId(), container);
      ObjectList objects = objectApi.list(toListContainerOptions.apply(options));
      if (objects == null) {
         containerCache.put(container, Optional.<Container> absent());
         return new PageSetImpl<StorageMetadata>(ImmutableList.<StorageMetadata> of(), null);
      } else {
         containerCache.put(container, Optional.of(objects.container()));
         List<? extends StorageMetadata> list = transform(objects, toBlobMetadata(container));
         int limit = Optional.fromNullable(options.getMaxResults()).or(10000);
         String marker = list.size() == limit ? list.get(limit - 1).getName() : null;
         // TODO: we should probably deprecate this option
         if (options.isDetailed()) {
View Full Code Here

         String etagOfEtags = api.staticLargeObjectApiInRegionForContainer(regionId, containerName).replaceManifest(
               name, segments, ImmutableMap.of("myfoo", "Bar"));

         assertNotNull(etagOfEtags);

         SwiftObject bigObject = api.objectApiInRegionForContainer(regionId, containerName).head(name);
         assertNotEquals(bigObject.etag(), etagOfEtags);
         assertEquals(bigObject.payload().getContentMetadata().getContentLength(), new Long(2 * 1024 * 1024));
         assertEquals(bigObject.metadata(), ImmutableMap.of("myfoo", "Bar"));

         // segments are visible
         assertEquals(api.containerApiInRegion(regionId).get(containerName).objectCount(), 3);
      }
   }
View Full Code Here

      }
      super.tearDown();
   }

   protected void assertMegabyteAndETagMatches(String regionId, String name, String etag1s) {
      SwiftObject object1s = api.objectApiInRegionForContainer(regionId, containerName).head(name);
      assertEquals(object1s.etag(), etag1s);
      assertEquals(object1s.payload().getContentMetadata().getContentLength(), new Long(1024 * 1024));
   }
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.swift.v1.options.ListContainerOptions$Builder

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.