/** * Adds the properties. * * @param request * The request * @param properties * The share properties */ private static void addProperties(final HttpURLConnection request, FileShareProperties properties) { final Integer shareQuota = properties.getShareQuota(); BaseRequest.addOptionalHeader( request, FileConstants.SHARE_QUOTA_HEADER, shareQuota == null ? null : shareQuota.toString()); }
/** * Adds the properties. * * @param request * The request * @param properties * The share properties */ private static void addProperties(final HttpURLConnection request, FileShareProperties properties) { final Integer shareQuota = properties.getShareQuota(); BaseRequest.addOptionalHeader( request, FileConstants.SHARE_QUOTA_HEADER, shareQuota == null ? null : shareQuota.toString()); }
/** * Creates an instance of the <code>FileShareProperties</code> class by copying values from another * <code>FileShareProperties</code> instance. * * @param other * A {@link FileShareProperties} object which represents the file share properties to copy. */ public FileShareProperties(final FileShareProperties other) { if (other != null) { this.setEtag(other.getEtag()); this.setLastModified(other.getLastModified()); this.setShareQuota(other.getShareQuota()); } }
/** * Creates an instance of the <code>FileShareProperties</code> class by copying values from another * <code>FileShareProperties</code> instance. * * @param other * A {@link FileShareProperties} object which represents the file share properties to copy. */ public FileShareProperties(final FileShareProperties other) { if (other != null) { this.setEtag(other.getEtag()); this.setLastModified(other.getLastModified()); this.setShareQuota(other.getShareQuota()); } }
/** * Creates the share using the specified options and operation context. * * @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. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public void create(FileRequestOptions options, OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } assertNoSnapshot(); if (this.properties != null && this.properties.getShareQuota() != null) { Utility.assertInBounds("Share Quota", this.properties.getShareQuota(), 1, FileConstants.MAX_SHARE_QUOTA); } opContext.initialize(); options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient); ExecutionEngine.executeWithRetry(this.fileServiceClient, this, createImpl(options), options.getRetryPolicyFactory(), opContext); }
assertNoSnapshot(); if (this.properties != null && this.properties.getShareQuota() != null) { Utility.assertInBounds("Share Quota", this.properties.getShareQuota(), 1, FileConstants.MAX_SHARE_QUOTA);
/** * Creates the share using the specified options and operation context. * * @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. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public void create(FileRequestOptions options, OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } assertNoSnapshot(); if (this.properties != null && this.properties.getShareQuota() != null) { Utility.assertInBounds("Share Quota", this.properties.getShareQuota(), 1, FileConstants.MAX_SHARE_QUOTA); } opContext.initialize(); options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient); ExecutionEngine.executeWithRetry(this.fileServiceClient, this, createImpl(options), options.getRetryPolicyFactory(), opContext); }
assertNoSnapshot(); if (this.properties != null && this.properties.getShareQuota() != null) { Utility.assertInBounds("Share Quota", this.properties.getShareQuota(), 1, FileConstants.MAX_SHARE_QUOTA);
@Override public Void preProcessResponse(CloudFileShare share, CloudFileClient client, OperationContext context) throws Exception { if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); return null; } // Set attributes final FileShareAttributes attributes = FileResponse.getFileShareAttributes(this.getConnection(), client.isUsePathStyleUris()); // The response from the service does not include the share quota. // Instead, we keep the existing value. Integer oldShareQuota = share.properties.getShareQuota(); share.properties = attributes.getProperties(); share.properties.setShareQuota(oldShareQuota); return null; } };
@Override public Void preProcessResponse(CloudFileShare share, CloudFileClient client, OperationContext context) throws Exception { if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); return null; } // Set attributes final FileShareAttributes attributes = FileResponse.getFileShareAttributes(this.getConnection(), client.isUsePathStyleUris()); // The response from the service does not include the share quota. // Instead, we keep the existing value. Integer oldShareQuota = share.properties.getShareQuota(); share.properties = attributes.getProperties(); share.properties.setShareQuota(oldShareQuota); return null; } };
assertNotNull(this.share.getProperties().getShareQuota()); int shareQuota = FileConstants.MAX_SHARE_QUOTA; assertEquals(shareQuota, this.share.getProperties().getShareQuota().intValue()); this.share.uploadProperties(); this.share.downloadAttributes(); assertNotNull(this.share.getProperties().getShareQuota()); assertEquals(shareQuota, this.share.getProperties().getShareQuota().intValue()); this.share.delete(); this.share.getProperties().setShareQuota(shareQuota); this.share.create(); assertNotNull(this.share.getProperties().getShareQuota()); assertEquals(shareQuota, this.share.getProperties().getShareQuota().intValue()); this.share.downloadAttributes(); assertNotNull(this.share.getProperties().getShareQuota()); assertEquals(shareQuota, this.share.getProperties().getShareQuota().intValue());
/** * Test that Share Quota can be set, but only to allowable values. * * @throws StorageException * @throws URISyntaxException */ @Test public void testCloudFileShareQuotaListing() throws StorageException, URISyntaxException { int shareQuota = 16; this.share.getProperties().setShareQuota(shareQuota); this.share.createIfNotExists(); Iterable<CloudFileShare> shares = this.share.getServiceClient().listShares(this.share.getName()); for (CloudFileShare fileShare : shares) { assertEquals(shareQuota, fileShare.getProperties().getShareQuota().intValue()); } }