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

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


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

   @Override
   public BlobMetadata blobMetadata(String container, String name) {
      SwiftObject object = api.getObjectApi(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.getObjectApi(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.getStaticLargeObjectApi(regionId, containerName).replaceManifest(
               name, segments, ImmutableMap.of("myfoo", "Bar"));

         assertNotNull(etagOfEtags);

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

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

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

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

         assertEquals(objects, parsedObjectsForUrl(server.getUrl("/").toString()));
         assertEquals(objects.getContainer().getName(), "myContainer");
         assertTrue(objects.getContainer().getAnybodyRead().get());

         // Check MD5 is parsed from the ETag header.
         SwiftObject object1 = objects.get(1);
         assertEquals(base16().lowerCase().decode(object1.getETag()),
               object1.getPayload().getContentMetadata().getContentMD5AsHashCode().asBytes());

         assertEquals(server.getRequestCount(), 2);
         assertAuthentication(server);
         assertRequest(server.takeRequest(), "GET", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/myContainer");
      } 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.getObjectApi("DFW", "myContainer").getWithoutBody("myObject");
         assertEquals(object.getName(), "myObject");
         assertEquals(object.getETag(), "8a964ee2a5e88be344f36c22562a6486");

         // Check MD5 is parsed from the ETag header.
         assertEquals(base16().lowerCase().decode(object.getETag()),
               object.getPayload().getContentMetadata().getContentMD5AsHashCode().asBytes());

         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().getContentType(), "text/plain; charset=UTF-8");
         assertEquals(toStringAndClose(object.getPayload().openStream()), "");

         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.getObjectApi("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());
         }

         Payload payload = object.getPayload();
         assertEquals(payload.getContentMetadata().getContentLength(), Long.valueOf(4));
         assertEquals(payload.getContentMetadata().getContentType(), "text/plain; charset=UTF-8");
         assertEquals(payload.getContentMetadata().getExpires(), dates.rfc822DateParse("Wed, 23 Jul 2014 14:00:00 GMT"));

         assertEquals(toStringAndClose(payload.openStream()), "ABCD");
View Full Code Here

      for (String regionId : regions) {
         assertNotNull(api.getContainerApi(regionId).create(containerName));
         assertNotNull(api.getObjectApi(regionId, containerName).put(objectName, PAYLOAD));

         SwiftObject object = api.getObjectApi(regionId, containerName).get(objectName);
         assertEquals(object.getName(), objectName);
         checkObject(object);
         assertEquals(toStringAndClose(object.getPayload().openStream()), "swifty");

         api.getObjectApi(regionId, containerName).delete(objectName);
         api.getContainerApi(regionId).deleteIfEmpty(containerName);
      }
   }
View Full Code Here

      for (String regionId : regions) {
         String etag = api.getObjectApi(regionId, containerName).put(objectName, payload);
         assertNotNull(etag);

         SwiftObject object = api.getObjectApi(regionId, containerName).get(objectName);
         assertEquals(object.getName(), objectName);
         checkObject(object);
         assertEquals(toStringAndClose(object.getPayload().openStream()), "swifty");

         api.getObjectApi(regionId, containerName).delete(objectName);
      }
   }
View Full Code Here

         ObjectApi srcApi = api.getObjectApi(regionId, sourceContainer);
         ObjectApi destApi = api.getObjectApi(regionId, destinationContainer);

         // Create source object
         assertNotNull(srcApi.put(sourceObjectName, PAYLOAD));
         SwiftObject sourceObject = srcApi.get(sourceObjectName);
         checkObject(sourceObject);

         // Create the destination object
         assertNotNull(destApi.put(destinationObject, PAYLOAD));
         SwiftObject object = destApi.get(destinationObject);
         checkObject(object);

         // check the copy operation
         assertTrue(destApi.copy(destinationObject, sourceContainer, sourceObjectName));
         assertNotNull(destApi.get(destinationObject));

         // now get a real SwiftObject
         SwiftObject destSwiftObject = destApi.get(destinationObject);
         assertEquals(toStringAndClose(destSwiftObject.getPayload().openStream()), "swifty");

         // test exception thrown on bad source name
         try {
            destApi.copy(destinationObject, badSource, sourceObjectName);
            fail("Expected CopyObjectException");
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.