Package org.jclouds.blobstore.domain

Examples of org.jclouds.blobstore.domain.MutableBlobMetadata


   @Test(expectedExceptions = HttpException.class)
   public void testSetLastModifiedException() {
      HttpResponse from = HttpResponse.builder()
                                      .statusCode(200).message("ok")
                                      .payload("").build();
      MutableBlobMetadata metadata = blobMetadataProvider.get();
      parser.parseLastModifiedOrThrowException(from, metadata);
   }
View Full Code Here


   public void testAddETagTo() {
      HttpResponse from = HttpResponse.builder()
                                      .statusCode(200).message("ok")
                                      .payload("")
                                      .addHeader(HttpHeaders.ETAG, "0xfeb").build();
      MutableBlobMetadata metadata = blobMetadataProvider.get();
      parser.addETagTo(from, metadata);
      assertEquals(metadata.getETag(), "0xfeb");
   }
View Full Code Here

   public void testAddUserMetadataTo() {
      HttpResponse from = HttpResponse.builder()
                                      .statusCode(200).message("ok")
                                      .payload("")
                                      .addHeader("prefix" + "key", "value").build();
      MutableBlobMetadata metadata = blobMetadataProvider.get();
      parser.addUserMetadataTo(from, metadata);
      assertEquals(metadata.getUserMetadata().get("key"), "value");
   }
View Full Code Here

   }

   public MutableBlobMetadata apply(ObjectMetadata from) {
      if (from == null)
         return null;
      MutableBlobMetadata to = new MutableBlobMetadataImpl();
      HttpUtils.copy(from.getContentMetadata(), to.getContentMetadata());
      try {
         AccessControlList bucketAcl = bucketAcls.getUnchecked(from.getBucket());
         if (bucketAcl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ))
            to.setPublicUri(from.getUri());
      } catch (CacheLoader.InvalidCacheLoadException e) {
         // nulls not permitted from cache loader
      }
      to.setUri(from.getUri());
      to.setContainer(from.getBucket());
      to.setETag(from.getETag());
      to.setName(from.getKey());
      to.setLastModified(from.getLastModified());
      to.setUserMetadata(from.getUserMetadata());
      to.setLocation(locationOfBucket.apply(from.getBucket()));
      String directoryName = ifDirectoryReturnName.execute(to);
      if (directoryName != null) {
         to.setName(directoryName);
         to.setType(StorageType.RELATIVE_PATH);
      } else {
         to.setType(StorageType.BLOB);
      }
      return to;
   }
View Full Code Here

   }

   public Iterable<? extends BlobMetadata> list() {
      return transform(listStrategy.execute(containerName, options), new Function<BlobMetadata, BlobMetadata>() {
         public BlobMetadata apply(BlobMetadata from) {
            MutableBlobMetadata md = new MutableBlobMetadataImpl(from);
            if (options.getDir() != null)
               md.setName(pathStripper.apply(from.getName()));
            return md;
         }

      });
   }
View Full Code Here

      this.blobFactory = checkNotNull(blobFactory, "blobFactory");
   }

   public Blob apply(HttpResponse from) {
      checkNotNull(from, "request");
      MutableBlobMetadata metadata = metadataParser.apply(from);
      Blob blob = blobFactory.create(metadata);
      blob.getAllHeaders().putAll(from.getHeaders());
      blob.setPayload(from.getPayload());
      return blob;
   }
View Full Code Here

   public MutableBlobMetadata apply(HttpResponse from) {
      checkNotNull(from, "request");
      checkState(name != null, "name must be initialized by now");

      MutableBlobMetadata to = metadataFactory.get();
      to.setName(name);
      to.setUri(endpoint);
      if (from.getPayload() != null)
         HttpUtils.copy(from.getPayload().getContentMetadata(), to.getContentMetadata());
      addETagTo(from, to);
      parseLastModifiedOrThrowException(from, to);
      addUserMetadataTo(from, to);
      return to;
   }
View Full Code Here

                                          .addHeader("Content-Range", "0-10485759/20232760").build();

      response.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_JSON);
      response.getPayload().getContentMetadata().setContentLength(10485760l);

      MutableBlobMetadata meta = blobMetadataProvider.get();
      expect(metadataParser.apply(response)).andReturn(meta);
      replay(metadataParser);

      Blob object = callable.apply(response);
      assertEquals(object.getPayload().getContentMetadata().getContentLength(), Long.valueOf(10485760));
View Full Code Here

            Date unmodifiedSince = dateService.rfc822DateParse(options.getIfUnmodifiedSince());
            if (unmodifiedSince.before(object.getMetadata().getLastModified()))
               return immediateFailedFuture(LocalAsyncBlobStore.returnResponseException(412));
         }
         Blob sourceS3 = source.get(sourceObject);
         MutableBlobMetadata newMd = BlobStoreUtils.copy(sourceS3.getMetadata(), destinationObject);
         if (options.getAcl() != null)
            keyToAcl.put(destinationBucket + "/" + destinationObject, options.getAcl());

         newMd.setLastModified(new Date());
         Blob newBlob = blobProvider.create(newMd);
         newBlob.setPayload(sourceS3.getPayload());
         dest.put(destinationObject, newBlob);
         return immediateFuture((ObjectMetadata) blob2ObjectMetadata.apply(BlobStoreUtils.copy(newMd)));
      }
View Full Code Here

   };

   @Test
   public void test1() {
      MutableBlobMetadata md = blobMetadataProvider.get();
      md.setName("dir/");
      md.setId("dir/");
      StorageMetadata rd = parser.apply(md);
      assertEquals(rd.getName(), "dir");
      assertEquals(rd.getProviderId(), "dir/");
      assertEquals(rd.getType(), StorageType.RELATIVE_PATH);
   }
View Full Code Here

TOP

Related Classes of org.jclouds.blobstore.domain.MutableBlobMetadata

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.