Package org.jclouds.openstack.swift.domain

Examples of org.jclouds.openstack.swift.domain.MutableObjectInfoWithMetadata


         // Test HEAD of missing object
         assert getApi().getObjectInfo(containerName, "non-existent-object") == null;

         // Test HEAD of object
         MutableObjectInfoWithMetadata metadata = getApi().getObjectInfo(containerName, object.getInfo().getName());
         assertEquals(metadata.getName(), object.getInfo().getName());

         assertEquals(metadata.getBytes(), Long.valueOf(data.length()));
         assert metadata.getContentType().startsWith("text/plain") : metadata.getContentType();

         assertEquals(base16().lowerCase().encode(md5), base16().lowerCase().encode(metadata.getHash()));
         assertEquals(metadata.getHash(), base16().lowerCase().decode(newEtag));
         assertEquals(metadata.getMetadata().entrySet().size(), 1);
         assertEquals(metadata.getMetadata().get("metadata"), "metadata-value");

         // // Test POST to update object's metadata
         Map<String, String> userMetadata = Maps.newHashMap();
         userMetadata.put("New-Metadata-1", "value-1");
         userMetadata.put("New-Metadata-2", "value-2");
View Full Code Here


   /**
    * parses the http response headers to create a new {@link MutableObjectInfoWithMetadata} object.
    */
   public MutableObjectInfoWithMetadata apply(HttpResponse from) {
      BlobMetadata base = blobMetadataParser.apply(from);
      MutableObjectInfoWithMetadata to = blobToObjectInfo.apply(base);
      to.setBytes(attemptToParseSizeAndRangeFromHeaders(from));
      to.setContainer(container);
      to.setUri(base.getUri());
      String eTagHeader = from.getFirstHeaderOrNull(HttpHeaders.ETAG);
      if (eTagHeader != null) {
         to.setHash(ETagUtils.convertHexETagToByteArray(eTagHeader));
      }
      to.setObjectManifest(from.getFirstHeaderOrNull("X-Object-Manifest"));

      return to;
   }
View Full Code Here

      this.infoParser = infoParser;
      this.objectProvider = objectProvider;
   }

   public SwiftObject apply(HttpResponse from) {
      MutableObjectInfoWithMetadata metadata = infoParser.apply(from);
      if (metadata.getHash() != null)
         from.getPayload().getContentMetadata().setContentMD5(metadata.getHash());
      SwiftObject object = objectProvider.create(metadata);
      object.getAllHeaders().putAll(from.getHeaders());
      object.setPayload(from.getPayload());
      return object;
   }
View Full Code Here

         removeObjectsWithPrefix(objectManifest);
      }
   }

   private String getObjectManifestOrNull(String container, String key) {
      MutableObjectInfoWithMetadata objectInfo = sync.getObjectInfo(container, key);
      return objectInfo == null ? null : objectInfo.getObjectManifest();
   }
View Full Code Here

public class ResourceToObjectInfo implements Function<StorageMetadata, MutableObjectInfoWithMetadata> {

   public MutableObjectInfoWithMetadata apply(StorageMetadata from) {
      if (from == null)
         return null;
      MutableObjectInfoWithMetadata to = new MutableObjectInfoWithMetadataImpl();
      if (from.getType() == StorageType.BLOB) {
         to.setContentType(((BlobMetadata) from).getContentMetadata().getContentType());
         to.setBytes(((BlobMetadata) from).getContentMetadata().getContentLength());
         to.setHash(((BlobMetadata) from).getContentMetadata().getContentMD5());
      } else if (from.getType() == StorageType.RELATIVE_PATH) {
         to.setContentType("application/directory");
      }
      if (from.getETag() != null && to.getHash() == null)
         to.setHash(ETagUtils.convertHexETagToByteArray(from.getETag()));
      to.setName(from.getName());
      to.setLastModified(from.getLastModified());
      if (from.getUserMetadata() != null) {
         for (Entry<String, String> entry : from.getUserMetadata().entrySet())
            to.getMetadata().put(entry.getKey().toLowerCase(), entry.getValue());
      }
      return to;
   }
View Full Code Here

   /**
    * parses the http response headers to create a new {@link MutableObjectInfoWithMetadata} object.
    */
   public MutableObjectInfoWithMetadata apply(HttpResponse from) {
      BlobMetadata base = blobMetadataParser.apply(from);
      MutableObjectInfoWithMetadata to = blobToObjectInfo.apply(base);
      to.setBytes(attemptToParseSizeAndRangeFromHeaders(from));
      to.setContainer(container);
      to.setUri(base.getUri());
      String eTagHeader = from.getFirstHeaderOrNull("Etag");
      if (eTagHeader != null) {
         to.setHash(base16().lowerCase().decode(eTagHeader));
      }
      return to;
   }
View Full Code Here

      this.infoParser = infoParser;
      this.objectProvider = objectProvider;
   }

   public SwiftObject apply(HttpResponse from) {
      MutableObjectInfoWithMetadata metadata = infoParser.apply(from);
      if (metadata.getHash() != null)
         from.getPayload().getContentMetadata().setContentMD5(metadata.getHash());
      SwiftObject object = objectProvider.create(metadata);
      object.getAllHeaders().putAll(from.getHeaders());
      object.setPayload(from.getPayload());
      return object;
   }
View Full Code Here

public class ResourceToObjectInfo implements Function<StorageMetadata, MutableObjectInfoWithMetadata> {

   public MutableObjectInfoWithMetadata apply(StorageMetadata from) {
      if (from == null)
         return null;
      MutableObjectInfoWithMetadata to = new MutableObjectInfoWithMetadataImpl();
      if (from.getType() == StorageType.BLOB) {
         to.setContentType(((BlobMetadata) from).getContentMetadata().getContentType());
         to.setBytes(((BlobMetadata) from).getContentMetadata().getContentLength());
         to.setHash(((BlobMetadata) from).getContentMetadata().getContentMD5());
      } else if (from.getType() == StorageType.RELATIVE_PATH) {
         to.setContentType("application/directory");
      }
      if (from.getETag() != null && to.getHash() == null)
         to.setHash(base16().lowerCase().decode(from.getETag()));
      to.setName(from.getName());
      to.setLastModified(from.getLastModified());
      if (from.getUserMetadata() != null) {
         for (Entry<String, String> entry : from.getUserMetadata().entrySet())
            to.getMetadata().put(entry.getKey().toLowerCase(), entry.getValue());
      }
      return to;
   }
View Full Code Here

                                          .addHeader("Last-Modified", "Fri, 12 Jun 2007 13:40:18 GMT")
                                          .addHeader("Content-Length", "0")
                                          .addHeader("Etag", "feb1").build();

      response.getPayload().getContentMetadata().setContentType("text/plain");
      MutableObjectInfoWithMetadata md = parser.apply(response);
      assertNotNull(md.getHash());
   }
View Full Code Here

         // Test HEAD of missing object
         assert getApi().getObjectInfo(containerName, "non-existent-object") == null;

         // Test HEAD of object
         MutableObjectInfoWithMetadata metadata = getApi().getObjectInfo(containerName, object.getInfo().getName());
         assertEquals(metadata.getName(), object.getInfo().getName());

         assertEquals(metadata.getBytes(), Long.valueOf(data.length()));
         assert metadata.getContentType().startsWith("text/plain") : metadata.getContentType();

         assertEquals(base16().lowerCase().encode(md5), base16().lowerCase().encode(metadata.getHash()));
         assertEquals(metadata.getHash(), base16().lowerCase().decode(newEtag));
         assertEquals(metadata.getMetadata().entrySet().size(), 1);
         assertEquals(metadata.getMetadata().get("metadata"), "metadata-value");

         // // Test POST to update object's metadata
         Map<String, String> userMetadata = Maps.newHashMap();
         userMetadata.put("New-Metadata-1", "value-1");
         userMetadata.put("New-Metadata-2", "value-2");
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.swift.domain.MutableObjectInfoWithMetadata

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.