@Override public BlobBuilder userMetadata(Map<String, String> userMetadata) { return builder.userMetadata(userMetadata); }
@Override public BlobBuilder userMetadata(Map<String, String> userMetadata) { return builder.userMetadata(userMetadata); }
@Override public BlobBuilder userMetadata(Map<String, String> userMetadata) { return builder.userMetadata(userMetadata); }
@Override public BlobBuilder userMetadata(Map<String, String> userMetadata) { return builder.userMetadata(userMetadata); }
@Override public BlobBuilder userMetadata(Map<String, String> userMetadata) { return builder.userMetadata(userMetadata); }
@Override public BlobBuilder userMetadata(Map<String, String> userMetadata) { return builder.userMetadata(userMetadata); }
@Override public BlobBuilder userMetadata(Map<String, String> userMetadata) { return builder.userMetadata(userMetadata); }
private String emulateCopyBlob(BlobStore blobStore, Response resp, BlobMetadata meta, String destContainer, String destObject, CopyOptions options) { Response.StatusType statusInfo = resp.getStatusInfo(); if (statusInfo.equals(Response.Status.OK)) { ContentMetadata contentMetadata = meta.getContentMetadata(); Map<String, String> newMetadata = new HashMap<>(); newMetadata.putAll(meta.getUserMetadata()); newMetadata.putAll(options.userMetadata()); RESERVED_METADATA.forEach(s -> newMetadata.remove(s)); Blob blob = blobStore.blobBuilder(destObject) .userMetadata(newMetadata) .payload(new InputStreamPayload((InputStream) resp.getEntity())) .contentLength(resp.getLength()) .contentDisposition(contentMetadata.getContentDisposition()) .contentEncoding(contentMetadata.getContentEncoding()) .contentType(contentMetadata.getContentType()) .contentLanguage(contentMetadata.getContentLanguage()) .build(); return blobStore.putBlob(destContainer, blob); } else { throw new ClientErrorException(statusInfo.getReasonPhrase(), statusInfo.getStatusCode()); } }
@Test(groups = { "integration", "live" }) public void testNotWithDetails() throws InterruptedException { String key = "hello"; // NOTE all metadata in jclouds comes out as lowercase, in an effort to normalize the // providers. Blob blob = view.getBlobStore().blobBuilder("hello").userMetadata(ImmutableMap.of("Adrian", "powderpuff")) .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).build(); String containerName = getContainerName(); try { addBlobToContainer(containerName, blob); validateContent(containerName, key); PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName, maxResults(1)); BlobMetadata metadata = (BlobMetadata) getOnlyElement(container); // transient container should be lenient and not return metadata on undetailed listing. assertEquals(metadata.getUserMetadata().size(), 0); } finally { returnContainer(containerName); } }
@Override @Test(groups = { "integration", "live" }) public void testWithDetails() throws InterruptedException, IOException { String key = "hello"; String containerName = getContainerName(); try { addBlobToContainer( containerName, view.getBlobStore().blobBuilder(key).userMetadata(ImmutableMap.of("adrian", "powderpuff")) .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN) .contentMD5(Hashing.md5().newHasher().putString(TEST_STRING, Charsets.UTF_8).hash()).build()); validateContent(containerName, key); PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName, maxResults(1).withDetails()); BlobMetadata metadata = BlobMetadata.class.cast(get(container, 0)); assert metadata.getContentMetadata().getContentType().startsWith("text/plain") : metadata.getContentMetadata() .getContentType(); assertEquals(metadata.getContentMetadata().getContentLength(), Long.valueOf(TEST_STRING.length())); assertEquals(metadata.getUserMetadata().get("adrian"), "powderpuff"); checkMD5(metadata); } finally { returnContainer(containerName); } }
@Test public void testListContainerWithZeroMaxResults() throws Exception { String key = "hello"; String containerName = getContainerName(); try { addBlobToContainer(containerName, // NOTE all metadata in jclouds comes out as lowercase, in an effort to // normalize the providers. view.getBlobStore().blobBuilder(key).userMetadata(ImmutableMap.of("Adrian", "powderpuff")) .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN) .contentMD5(md5().hashString(TEST_STRING, UTF_8).asBytes()) .build()); awaitConsistency(); validateContent(containerName, key); PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName, maxResults(0)); assertThat(container).isEmpty(); } finally { returnContainer(containerName); } }
@Test(dataProvider = "ignoreOnWindows", groups = { "integration", "live" }) public void testNotWithDetails() throws InterruptedException { String key = "hello"; // NOTE all metadata in jclouds comes out as lowercase, in an effort to // normalize the // providers. Blob object = view.getBlobStore().blobBuilder(key).userMetadata(ImmutableMap.of("Adrian", "powderpuff")) .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).build(); String containerName = getContainerName(); try { addBlobToContainer(containerName, object); validateContent(containerName, key); PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName, maxResults(1)); BlobMetadata metadata = (BlobMetadata) Iterables.getOnlyElement(container); // transient container should be lenient and not return metadata on // undetailed listing. assertEquals(metadata.getUserMetadata().size(), 0); } finally { returnContainer(containerName); } }
@Test(groups = { "integration", "live" }) public void testNotWithDetails() throws InterruptedException { String key = "hello"; // NOTE all metadata in jclouds comes out as lowercase, in an effort to normalize the // providers. Blob blob = view.getBlobStore().blobBuilder("hello").userMetadata(ImmutableMap.of("Adrian", "powderpuff")) .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).build(); String containerName = getContainerName(); try { addBlobToContainer(containerName, blob); validateContent(containerName, key); PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName, maxResults(1)); BlobMetadata metadata = (BlobMetadata) getOnlyElement(container); // transient container should be lenient and not return metadata on undetailed listing. assertEquals(metadata.getUserMetadata().size(), 0); } finally { returnContainer(containerName); } }
@Test(groups = { "integration", "live" }) public void testWithDetails() throws InterruptedException, IOException { String key = "hello"; String containerName = getContainerName(); try { addBlobToContainer(containerName, // NOTE all metadata in jclouds comes out as lowercase, in an effort to // normalize the providers. view.getBlobStore().blobBuilder(key).userMetadata(ImmutableMap.of("Adrian", "powderpuff")) .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN) .contentMD5(md5().hashString(TEST_STRING, UTF_8).asBytes()) .build()); awaitConsistency(); validateContent(containerName, key); PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName, maxResults(1).withDetails()); BlobMetadata metadata = BlobMetadata.class.cast(get(container, 0)); assert metadata.getContentMetadata().getContentType().startsWith("text/plain") : metadata.getContentMetadata() .getContentType(); assertEquals(metadata.getContentMetadata().getContentLength(), Long.valueOf(TEST_STRING.length())); assertEquals(metadata.getUserMetadata().get("adrian"), "powderpuff"); checkMD5(metadata); } finally { returnContainer(containerName); } }
@Test(groups = { "integration", "live" }) public void testWithDetails() throws InterruptedException, IOException { String key = "hello"; String containerName = getContainerName(); try { addBlobToContainer(containerName, // NOTE all metadata in jclouds comes out as lowercase, in an effort to // normalize the providers. view.getBlobStore().blobBuilder(key).userMetadata(ImmutableMap.of("Adrian", "powderpuff")) .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).calculateMD5().build()); validateContent(containerName, key); PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName, maxResults(1).withDetails()); BlobMetadata metadata = BlobMetadata.class.cast(get(container, 0)); assert metadata.getContentMetadata().getContentType().startsWith("text/plain") : metadata.getContentMetadata() .getContentType(); assertEquals(metadata.getContentMetadata().getContentLength(), Long.valueOf(TEST_STRING.length())); assertEquals(metadata.getUserMetadata().get("adrian"), "powderpuff"); checkMD5(metadata); } finally { returnContainer(containerName); } }
@Test public void testListMarkerAfterLastKey() throws Exception { String key = "hello"; String containerName = getContainerName(); try { addBlobToContainer(containerName, // NOTE all metadata in jclouds comes out as lowercase, in an effort to // normalize the providers. view.getBlobStore().blobBuilder(key).userMetadata(ImmutableMap.of("Adrian", "powderpuff")) .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN) .contentMD5(md5().hashString(TEST_STRING, UTF_8).asBytes()) .build()); validateContent(containerName, key); awaitConsistency(); PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName, afterMarker(key)); assertThat(container).isEmpty(); } finally { returnContainer(containerName); } }
.userMetadata(ImmutableMap.of("B", "b", "a", "a")) .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN) .contentMD5(md5().hashString(TEST_STRING, Charsets.UTF_8))
@Override public void testMetadata() throws InterruptedException, IOException { String name = "hello"; HashFunction hf = Hashing.md5(); HashCode md5 = hf.newHasher().putString(TEST_STRING, Charsets.UTF_8).hash(); Blob blob = view.getBlobStore().blobBuilder(name).userMetadata(ImmutableMap.of("adrian", "powderpuff")) .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).contentMD5(md5).build(); String container = getContainerName(); try { assertNull(view.getBlobStore().blobMetadata(container, "powderpuff")); addBlobToContainer(container, blob); Blob newObject = validateContent(container, name); BlobMetadata metadata = newObject.getMetadata(); validateMetadata(metadata); validateMetadata(metadata, container, name); validateMetadata(view.getBlobStore().blobMetadata(container, name)); blob.getMetadata().getUserMetadata().put("adrian", "wonderpuff"); blob.getMetadata().getUserMetadata().put("adrian", "powderpuff"); addBlobToContainer(container, blob); validateMetadata(view.getBlobStore().blobMetadata(container, name)); } finally { returnContainer(container); } }
Blob blob = view.getBlobStore().blobBuilder(name).userMetadata(ImmutableMap.of("Adrian", "powderpuff")) .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN) .contentMD5(md5().hashString(TEST_STRING, Charsets.UTF_8).asBytes())
@Test(groups = { "integration", "live" }) public void testMetadata() throws InterruptedException, IOException { String name = "hello"; // NOTE all metadata in jclouds comes out as lowercase, in an effort to // normalize the // providers. Blob blob = view.getBlobStore().blobBuilder(name).userMetadata(ImmutableMap.of("Adrian", "powderpuff")) .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).calculateMD5().build(); String container = getContainerName(); try { assertNull(view.getBlobStore().blobMetadata(container, "powderpuff")); addBlobToContainer(container, blob); Blob newObject = validateContent(container, name); BlobMetadata metadata = newObject.getMetadata(); validateMetadata(metadata); validateMetadata(metadata, container, name); validateMetadata(view.getBlobStore().blobMetadata(container, name)); // write 2 items with the same name to ensure that provider doesn't // accept dupes blob.getMetadata().getUserMetadata().put("Adrian", "wonderpuff"); blob.getMetadata().getUserMetadata().put("Adrian", "powderpuff"); addBlobToContainer(container, blob); validateMetadata(view.getBlobStore().blobMetadata(container, name)); } finally { returnContainer(container); } }