Package org.jclouds.openstack.swift.v1.domain

Examples of org.jclouds.openstack.swift.v1.domain.Container


      api.getObjectApiForRegionAndContainer(regionId, containerName).delete(directory);
   }

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


   private ToSwiftObject toSwiftObject;

   @Override
   public ObjectList apply(HttpResponse from) {
      List<SwiftObject> objects = Lists.transform(json.apply(from), toSwiftObject);
      Container container = parseContainer.apply(from);
      return ObjectList.create(objects, container);
   }
View Full Code Here

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         assertTrue(api.getContainerApiForRegion("DFW").create("myContainer", anybodyRead().metadata(metadata)));
        
         Container container = api.getContainerApiForRegion("DFW").get("myContainer");
         assertEquals(container.getName(), "myContainer");
         assertEquals(container.getObjectCount(), 42l);
         assertEquals(container.getBytesUsed(), 323479l);
         for (Entry<String, String> entry : container.getMetadata().entrySet()) {
            assertEquals(container.getMetadata().get(entry.getKey().toLowerCase()), entry.getValue());
         }
         assertEquals(server.getRequestCount(), 3);
         assertAuthentication(server);
         assertRequest(server.takeRequest(), "PUT", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/myContainer");
         assertRequest(server.takeRequest(), "HEAD", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/myContainer");
View Full Code Here

            .addHeader(CONTAINER_METADATA_PREFIX + "Apiname", "swift")
            .addHeader(CONTAINER_METADATA_PREFIX + "Apiversion", "v1.1")));

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         Container container = api.getContainerApiForRegion("DFW").get("myContainer");
         assertEquals(container.getName(), "myContainer");
         assertEquals(container.getObjectCount(), 42l);
         assertEquals(container.getBytesUsed(), 323479l);
         for (Entry<String, String> entry : container.getMetadata().entrySet()) {
            assertEquals(container.getMetadata().get(entry.getKey().toLowerCase()), entry.getValue());
         }

         assertEquals(server.getRequestCount(), 2);
         assertAuthentication(server);
         assertRequest(server.takeRequest(), "HEAD", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/myContainer");
View Full Code Here

                                    SwiftHeaders.STATIC_WEB_ERROR, "__error.html");
         CreateContainerOptions opts = new CreateContainerOptions().headers(headers);

         assertNotNull(api.getContainerApiForRegion(regionId).create(name, opts));

         Container container = api.getContainerApiForRegion(regionId).get(name);
         assertNotNull(container);
         assertEquals(container.getName(), name);
         assertEquals(container.getMetadata().size(), 2);
         assertEquals(container.getMetadata().get("web-index"), "__index.html");
         assertEquals(container.getMetadata().get("web-error"), "__error.html");

         assertTrue(api.getContainerApiForRegion(regionId).deleteIfEmpty(name));
      }
   }
View Full Code Here

   public void testCreateWithSpacesAndSpecialCharacters() throws Exception {
      final String nameWithSpaces = "container # ! special";

      for (String regionId : regions) {
         assertTrue(api.getContainerApiForRegion(regionId).create(nameWithSpaces));
         Container container = api.getContainerApiForRegion(regionId).get(nameWithSpaces);
         assertNotNull(container);
         assertEquals(container.getName(), nameWithSpaces);

         assertTrue(api.getContainerApiForRegion(regionId).deleteIfEmpty(nameWithSpaces));
      }
   }
View Full Code Here

   public void testListWithOptions() throws Exception {
      String lexicographicallyBeforeName = name.substring(0, name.length() - 1);
      for (String regionId : regions) {
         ListContainerOptions options = ListContainerOptions.Builder.marker(lexicographicallyBeforeName);
         Container container = api.getContainerApiForRegion(regionId).list(options).get(0);
         assertEquals(container.getName(), name);
         assertTrue(container.getObjectCount() == 0);
         assertTrue(container.getBytesUsed() == 0);
      }
   }
View Full Code Here

                                    SwiftHeaders.STATIC_WEB_ERROR, "__error.html");
         UpdateContainerOptions opts = new UpdateContainerOptions().headers(headers);

         assertNotNull(api.getContainerApiForRegion(regionId).create(name));

         Container container = api.getContainerApiForRegion(regionId).get(name);
         assertNotNull(container);
         assertEquals(container.getName(), name);
         assertTrue(container.getMetadata().isEmpty());

         assertNotNull(api.getContainerApiForRegion(regionId).update(name, opts));

         Container updatedContainer = api.getContainerApiForRegion(regionId).get(name);
         assertNotNull(updatedContainer);
         assertEquals(updatedContainer.getName(), name);
         assertEquals(updatedContainer.getMetadata().size(), 2);
         assertEquals(updatedContainer.getMetadata().get("web-index"), "__index.html");
         assertEquals(updatedContainer.getMetadata().get("web-error"), "__error.html");

         assertTrue(api.getContainerApiForRegion(regionId).deleteIfEmpty(name));
      }
   }
View Full Code Here

      }
   }

   public void testGet() throws Exception {
      for (String regionId : regions) {
         Container container = api.getContainerApiForRegion(regionId).get(name);
         assertEquals(container.getName(), name);
         assertTrue(container.getObjectCount() == 0);
         assertTrue(container.getBytesUsed() == 0);
      }
   }
View Full Code Here

         // update
         assertTrue(containerApi.updateMetadata(name, meta));
         containerHasMetadata(containerApi, name, meta);
         // delete
         assertTrue(containerApi.deleteMetadata(name, meta));
         Container container = containerApi.get(name);
         for (Entry<String, String> entry : meta.entrySet()) {
            // note keys are returned in lower-case!
            assertFalse(container.getMetadata().containsKey(entry.getKey().toLowerCase()));
         }
      }
   }
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.swift.v1.domain.Container

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.