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

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


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

         assertNotNull(etagOfEtags);

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

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


         assertEquals(api.containerApiInRegion(regionId).get(containerName).getObjectCount(), 0);
      }
   }

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

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

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         SwiftObject object = api.objectApiInRegionForContainer("DFW", "myContainer").head("myObject");
         assertEquals(object.getName(), "myObject");
         assertEquals(object.getEtag(), "8a964ee2a5e88be344f36c22562a6486");
         assertEquals(object.getLastModified(), dates.rfc822DateParse("Fri, 12 Jun 2010 13:40:18 GMT"));
         for (Entry<String, String> entry : object.getMetadata().entrySet()) {
            assertEquals(object.getMetadata().get(entry.getKey().toLowerCase()), entry.getValue());
         }
         assertEquals(object.getPayload().getContentMetadata().getContentLength(), new Long(4));
         assertEquals(object.getPayload().getContentMetadata().getContentType(), "text/plain; charset=UTF-8");
         assertEquals(Strings2.toStringAndClose(object.getPayload().getInput()), "");

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

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

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         SwiftObject object = api.objectApiInRegionForContainer("DFW", "myContainer").get("myObject", tail(1));
         assertEquals(object.getName(), "myObject");
         assertEquals(object.getEtag(), "8a964ee2a5e88be344f36c22562a6486");
         assertEquals(object.getLastModified(), dates.rfc822DateParse("Fri, 12 Jun 2010 13:40:18 GMT"));
         for (Entry<String, String> entry : object.getMetadata().entrySet()) {
            assertEquals(object.getMetadata().get(entry.getKey().toLowerCase()), entry.getValue());
         }
         assertEquals(object.getPayload().getContentMetadata().getContentLength(), new Long(4));
         assertEquals(object.getPayload().getContentMetadata().getContentType(), "text/plain; charset=UTF-8");
         // note MWS doesn't process Range header at the moment
         assertEquals(Strings2.toStringAndClose(object.getPayload().getInput()), "ABCD");

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

      return objectApi.replace(blob.getMetadata().getName(), blob.getPayload(), blob.getMetadata().getUserMetadata());
   }

   @Override
   public BlobMetadata blobMetadata(String container, String name) {
      SwiftObject object = api.objectApiInRegionForContainer(region.getId(), container).head(name);
      if (object == null) {
         return null;
      }
      return toBlobMetadata(container).apply(object);
   }
View Full Code Here

   }

   @Override
   public Blob getBlob(String container, String name, GetOptions options) {
      ObjectApi objectApi = api.objectApiInRegionForContainer(region.getId(), container);
      SwiftObject object = objectApi.get(name, toGetOptions.apply(options));
      if (object == null) {
         return null;
      }
      Blob blob = new BlobImpl(toBlobMetadata(container).apply(object));
      blob.setPayload(object.getPayload());
      blob.setAllHeaders(object.getHeaders());
      return blob;
   }
View Full Code Here

      return objectApi.put(blob.getMetadata().getName(), blob.getPayload(), metadata(blob.getMetadata().getUserMetadata()));
   }

   @Override
   public BlobMetadata blobMetadata(String container, String name) {
      SwiftObject object = api.getObjectApiForRegionAndContainer(regionId, container).get(name);
      if (object == null) {
         return null;
      }
      return toBlobMetadata(container).apply(object);
   }
View Full Code Here

   }

   @Override
   public Blob getBlob(String container, String name, GetOptions options) {
      ObjectApi objectApi = api.getObjectApiForRegionAndContainer(regionId, container);
      SwiftObject object = objectApi.get(name, toGetOptions.apply(options));
      if (object == null) {
         return null;
      }
      Blob blob = new BlobImpl(toBlobMetadata(container).apply(object));
      blob.setPayload(object.getPayload());
      blob.setAllHeaders(object.getHeaders());
      return blob;
   }
View Full Code Here

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

         assertNotNull(etagOfEtags);

         SwiftObject bigObject = api.getObjectApiForRegionAndContainer(regionId, containerName).get(name);
         assertEquals(bigObject.getETag(), etagOfEtags);
         assertEquals(bigObject.getPayload().getContentMetadata().getContentLength(), new Long(2 * 1024 * 1024));
         assertEquals(bigObject.getMetadata(), ImmutableMap.of("myfoo", "Bar"));

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

         assertEquals(api.getContainerApiForRegion(regionId).get(containerName).getObjectCount(), 0);
      }
   }

   protected void assertMegabyteAndETagMatches(String regionId, String name, String etag1s) {
      SwiftObject object1s = api.getObjectApiForRegionAndContainer(regionId, containerName).get(name);
      assertEquals(object1s.getETag(), etag1s);
      assertEquals(object1s.getPayload().getContentMetadata().getContentLength(), new Long(1024 * 1024));
   }
View Full Code Here

TOP

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

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.