/** * Retrieves the current {@link FileServiceProperties} for the given storage service. This encapsulates * the CORS configurations. * * @param options * A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying * <code>null</code> will use the default request options from the associated service client * ({@link CloudFileClient}). * @param opContext * An {@link OperationContext} object that represents the context for the current operation. This object * is used to track requests to the storage service, and to provide additional runtime information about * the operation. * * @return A {@link FileServiceProperties} object representing the current configuration of the service. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public final FileServiceProperties downloadServiceProperties(FileRequestOptions options, OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } opContext.initialize(); options = FileRequestOptions.populateAndApplyDefaults(options, this); return new FileServiceProperties(ExecutionEngine.executeWithRetry( this, null, this.downloadServicePropertiesImpl(options, false), options.getRetryPolicyFactory(), opContext)); }
this.uploadServicePropertiesImpl(properties.getServiceProperties(), options, opContext, false), options.getRetryPolicyFactory(), opContext);
if (original.getCors() != null && target.getCors() != null) { assertEquals(original.getCors().getCorsRules().size(), target.getCors().getCorsRules().size()); for (int i = 0; i < original.getCors().getCorsRules().size(); i++) { CorsRule ruleOriginal = original.getCors().getCorsRules().get(i); CorsRule ruleTarget = target.getCors().getCorsRules().get(i); assertNull(original.getCors()); assertNull(target.getCors());
throws StorageException, InterruptedException { final MetricsProperties hours = (props == null) ? fileProps.getHourMetrics() : props.getHourMetrics();
throws StorageException, InterruptedException { final MetricsProperties minutes = (props == null) ? fileProps.getMinuteMetrics() : props.getMinuteMetrics();
/** * Retrieves the current {@link FileServiceProperties} for the given storage service. This encapsulates * the CORS configurations. * * @param options * A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying * <code>null</code> will use the default request options from the associated service client * ({@link CloudFileClient}). * @param opContext * An {@link OperationContext} object that represents the context for the current operation. This object * is used to track requests to the storage service, and to provide additional runtime information about * the operation. * * @return A {@link FileServiceProperties} object representing the current configuration of the service. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public final FileServiceProperties downloadServiceProperties(FileRequestOptions options, OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } opContext.initialize(); options = FileRequestOptions.populateAndApplyDefaults(options, this); return new FileServiceProperties(ExecutionEngine.executeWithRetry( this, null, this.downloadServicePropertiesImpl(options, false), options.getRetryPolicyFactory(), opContext)); }
this.uploadServicePropertiesImpl(properties.getServiceProperties(), options, opContext, false), options.getRetryPolicyFactory(), opContext);
/** * Takes a CorsRule and tries to upload it. Then tries to download it and compares it to the initial CorsRule. */ private void testCorsRules(CorsRule rule, ServiceClient client, ServiceProperties properties, FileServiceProperties fileServiceProperties) throws StorageException, InterruptedException { CorsProperties cors = (fileServiceProperties == null) ? properties.getCors() : fileServiceProperties.getCors(); cors.getCorsRules().clear(); cors.getCorsRules().add(rule); if (fileServiceProperties == null) { callUploadServiceProps(client, properties, null); assertServicePropertiesAreEqual(properties, callDownloadServiceProperties(client)); } else { CloudFileClient fileClient = ((CloudFileClient) client); fileClient.uploadServiceProperties(fileServiceProperties); Thread.sleep(30000); assertFileServicePropertiesAreEqual(fileServiceProperties, fileClient.downloadServiceProperties()); } }
/** * Test CORS with invalid values. */ @Test public void testCorsExpectedExceptions() throws StorageException { ServiceClient client = TestHelper.createCloudBlobClient(); ServiceProperties props = new ServiceProperties(); props.setDefaultServiceVersion(Constants.HeaderConstants.TARGET_STORAGE_VERSION); testCorsExpectedExceptions(client, props, null); client = TestHelper.createCloudQueueClient(); props = new ServiceProperties(); testCorsExpectedExceptions(client, props, null); client = TestHelper.createCloudTableClient(); props = new ServiceProperties(); testCorsExpectedExceptions(client, props, null); client = TestHelper.createCloudFileClient(); testCorsExpectedExceptions(client, null, new FileServiceProperties()); }
/** * Takes a List of CorsRules and tries to upload them. Then tries to download them and compares the list to the * initial CorsRule List. */ private void testCorsRules(List<CorsRule> corsRules, ServiceClient client, ServiceProperties properties, FileServiceProperties fileServiceProperties) throws StorageException, InterruptedException { CorsProperties cors = (fileServiceProperties == null) ? properties.getCors() : fileServiceProperties.getCors(); cors.getCorsRules().clear(); for (CorsRule rule : corsRules) { cors.getCorsRules().add(rule); } if (fileServiceProperties == null) { callUploadServiceProps(client, properties, null); assertServicePropertiesAreEqual(properties, callDownloadServiceProperties(client)); } else { CloudFileClient fileClient = ((CloudFileClient) client); fileClient.uploadServiceProperties(fileServiceProperties); Thread.sleep(30000); assertFileServicePropertiesAreEqual(fileServiceProperties, fileClient.downloadServiceProperties()); } }
/** * Test CORS with different rules. * * @throws StorageException * @throws InterruptedException */ @Test public void testCloudValidCorsRules() throws StorageException, InterruptedException { ServiceClient client = TestHelper.createCloudBlobClient(); ServiceProperties props = new ServiceProperties(); props.setDefaultServiceVersion(Constants.HeaderConstants.TARGET_STORAGE_VERSION); testCloudValidCorsRules(client, props, null); client = TestHelper.createCloudQueueClient(); props = new ServiceProperties(); testCloudValidCorsRules(client, props, null); client = TestHelper.createCloudTableClient(); props = new ServiceProperties(); testCloudValidCorsRules(client, props, null); client = TestHelper.createCloudFileClient(); testCloudValidCorsRules(client, null, new FileServiceProperties()); }
/** * Test CORS with a valid and invalid number of origin values sent to server. * * @throws StorageException * @throws InterruptedException */ @Test public void testCorsMaxOrigins() throws StorageException, InterruptedException { ServiceClient client = TestHelper.createCloudBlobClient(); ServiceProperties props = new ServiceProperties(); props.setDefaultServiceVersion(Constants.HeaderConstants.TARGET_STORAGE_VERSION); testCorsMaxOrigins(client, props, null); client = TestHelper.createCloudQueueClient(); props = new ServiceProperties(); testCorsMaxOrigins(client, props, null); client = TestHelper.createCloudTableClient(); props = new ServiceProperties(); testCorsMaxOrigins(client, props, null); client = TestHelper.createCloudFileClient(); testCorsMaxOrigins(client, null, new FileServiceProperties()); }
/** * Test CORS with a valid and invalid number of header values sent to server. * * @throws StorageException * @throws InterruptedException */ @Test public void testCorsMaxHeaders() throws StorageException, InterruptedException { ServiceClient client = TestHelper.createCloudBlobClient(); ServiceProperties props = new ServiceProperties(); props.setDefaultServiceVersion(Constants.HeaderConstants.TARGET_STORAGE_VERSION); testCorsMaxHeaders(client, props, null); client = TestHelper.createCloudQueueClient(); props = new ServiceProperties(); testCorsMaxHeaders(client, props, null); client = TestHelper.createCloudTableClient(); props = new ServiceProperties(); testCorsMaxHeaders(client, props, null); client = TestHelper.createCloudFileClient(); testCorsMaxHeaders(client, null, new FileServiceProperties()); }
/** * Test Analytics Minute Metrics Level * * @throws StorageException * @throws InterruptedException */ @Test public void testAnalyticsMinuteMetricsLevel() throws StorageException, InterruptedException { ServiceClient client = TestHelper.createCloudBlobClient(); ServiceProperties props = new ServiceProperties(); props.setDefaultServiceVersion(Constants.HeaderConstants.TARGET_STORAGE_VERSION); testAnalyticsMinuteMetricsLevel(client, props, null); client = TestHelper.createCloudQueueClient(); props = new ServiceProperties(); testAnalyticsMinuteMetricsLevel(client, props, null); client = TestHelper.createCloudTableClient(); props = new ServiceProperties(); testAnalyticsMinuteMetricsLevel(client, props, null); client = TestHelper.createCloudFileClient(); FileServiceProperties fileProps = new FileServiceProperties(); testAnalyticsMinuteMetricsLevel(client, null, fileProps); }
/** * Test Analytics Hour Metrics Level * * @throws StorageException * @throws InterruptedException */ @Test public void testAnalyticsHourMetricsLevel() throws StorageException, InterruptedException { ServiceClient client = TestHelper.createCloudBlobClient(); ServiceProperties props = new ServiceProperties(); props.setDefaultServiceVersion(Constants.HeaderConstants.TARGET_STORAGE_VERSION); testAnalyticsHourMetricsLevel(client, props, null); client = TestHelper.createCloudQueueClient(); props = new ServiceProperties(); testAnalyticsHourMetricsLevel(client, props, null); client = TestHelper.createCloudTableClient(); props = new ServiceProperties(); testAnalyticsHourMetricsLevel(client, props, null); client = TestHelper.createCloudFileClient(); FileServiceProperties fileProps = new FileServiceProperties(); testAnalyticsHourMetricsLevel(client, null, fileProps); }