/** * Downloads the container's attributes, which consist of metadata and properties. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public void downloadAttributes() throws StorageException { this.downloadAttributes(null /* accessCondition */, null /* options */, null /* opContext */); }
/** * Downloads the container's attributes, which consist of metadata and properties. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public void downloadAttributes() throws StorageException { this.downloadAttributes(null /* accessCondition */, null /* options */, null /* opContext */); }
@Override public void downloadAttributes(OperationContext opContext) throws StorageException { container.downloadAttributes(AccessCondition.generateEmptyCondition(), null, opContext); }
@Override public void downloadAttributes(OperationContext opContext) throws StorageException { container.downloadAttributes(AccessCondition.generateEmptyCondition(), null, opContext); }
container.downloadAttributes(); HashMap<String, String> md = container.getMetadata(); if (md.size() == 0)
if(containerService.isContainer(file)) { final CloudBlobContainer container = session.getClient().getContainerReference(containerService.getContainer(file).getName()); container.downloadAttributes(); return container.getMetadata();
@Test @Category({ DevFabricTests.class, DevStoreTests.class }) public void testCloudBlobContainerUploadMetadata() throws StorageException, URISyntaxException { this.container.create(); CloudBlobContainer container2 = this.container.getServiceClient().getContainerReference( this.container.getName()); container2.downloadAttributes(); assertEquals(0, container2.getMetadata().size()); this.container.getMetadata().put("key1", "value1"); this.container.uploadMetadata(); container2.downloadAttributes(); assertEquals(1, container2.getMetadata().size()); assertEquals("value1", container2.getMetadata().get("key1")); Iterable<CloudBlobContainer> containers = this.container.getServiceClient().listContainers( this.container.getName(), ContainerListingDetails.METADATA, null, null); for (CloudBlobContainer container3 : containers) { assertEquals(1, container3.getMetadata().size()); assertEquals("value1", container3.getMetadata().get("key1")); } this.container.getMetadata().clear(); this.container.uploadMetadata(); container2.downloadAttributes(); assertEquals(0, container2.getMetadata().size()); }
container.downloadAttributes(); assertEquals(CloudBlobContainer.class, container.getClass()); containerList.remove(container.getName());
final PathAttributes attributes = new PathAttributes(); final CloudBlobContainer container = session.getClient().getContainerReference(containerService.getContainer(file).getName()); container.downloadAttributes(null, null, context); final BlobContainerProperties properties = container.getProperties(); attributes.setETag(properties.getEtag());
container.downloadAttributes(null, options, null); fail(); container.downloadAttributes(null, options, null); fail(); container.downloadAttributes(null, options, null); fail();
container2.downloadAttributes(); assertEquals(accessType, container2.properties.getPublicAccess());
container.downloadAttributes(null, eventOptions, eventContext); fail();
container.downloadAttributes(null, eventOptions, eventContext); fail(); container.downloadAttributes(null, eventOptions, null); fail(); container.downloadAttributes(null, eventOptions, eventContext); fail();
@Test @Category({ DevFabricTests.class, DevStoreTests.class }) public void testCloudBlobContainerInvalidMetadata() throws StorageException{ // test client-side fails correctly testMetadataFailures(this.container, null, "value1", true); testMetadataFailures(this.container, "", "value1", true); testMetadataFailures(this.container, " ", "value1", true); testMetadataFailures(this.container, "\n \t", "value1", true); testMetadataFailures(this.container, "key1", null, false); testMetadataFailures(this.container, "key1", "", false); testMetadataFailures(this.container, "key1", " ", false); testMetadataFailures(this.container, "key1", "\n \t", false); // test client can get empty metadata this.container.create(); OperationContext opContext = new OperationContext(); opContext.getSendingRequestEventHandler().addListener(new StorageEvent<SendingRequestEvent>() { // insert a metadata element with an empty value @Override public void eventOccurred(SendingRequestEvent eventArg) { HttpURLConnection request = (HttpURLConnection) eventArg.getConnectionObject(); request.setRequestProperty(Constants.HeaderConstants.PREFIX_FOR_STORAGE_METADATA + "key1", ""); } }); this.container.uploadMetadata(null, null, opContext); this.container.downloadAttributes(); assertEquals(1, this.container.getMetadata().size()); assertEquals("", this.container.getMetadata().get("key1")); }
private static void testContainerDownloadAttributes(LocationMode optionsLocationMode, LocationMode clientLocationMode, StorageLocation initialLocation, List<RetryContext> retryContextList, List<RetryInfo> retryInfoList) throws URISyntaxException, StorageException { CloudBlobContainer container = BlobTestHelper.getRandomContainerReference(); MultiLocationTestHelper helper = new MultiLocationTestHelper(container.getServiceClient().getStorageUri(), initialLocation, retryContextList, retryInfoList); container.getServiceClient().getDefaultRequestOptions().setLocationMode(clientLocationMode); BlobRequestOptions options = new BlobRequestOptions(); options.setLocationMode(optionsLocationMode); options.setRetryPolicyFactory(helper.retryPolicy); try { container.downloadAttributes(null, options, helper.operationContext); } catch (StorageException ex) { assertEquals(HttpURLConnection.HTTP_NOT_FOUND, ex.getHttpStatusCode()); } finally { helper.close(); } }
@Test @Category({ DevFabricTests.class, DevStoreTests.class, SecondaryTests.class }) public void testBlobMaximumExecutionTime() throws URISyntaxException, StorageException { OperationContext opContext = new OperationContext(); setDelay(opContext, 2500); // set the maximum execution time BlobRequestOptions options = new BlobRequestOptions(); options.setMaximumExecutionTimeInMs(2000); // set the location mode to secondary, secondary request should fail // so set the timeout low to save time failing (or fail with a timeout) options.setLocationMode(LocationMode.SECONDARY_THEN_PRIMARY); options.setTimeoutIntervalInMs(1000); CloudBlobClient blobClient = TestHelper.createCloudBlobClient(); CloudBlobContainer container = blobClient.getContainerReference(generateRandomName("container")); try { // 1. download attributes will fail as the container does not exist // 2. the executor will attempt to retry as it is accessing secondary // 3. maximum execution time should prevent the retry from being made container.downloadAttributes(null, options, opContext); fail("Maximum execution time was reached but request did not fail."); } catch (StorageException e) { assertEquals(SR.MAXIMUM_EXECUTION_TIMEOUT_EXCEPTION, e.getMessage()); } }
containerRef3.downloadAttributes(); assertEquals(accessType, containerRef3.properties.getPublicAccess());