private void getProperties(String currentNode, String value) throws ParseException { if (currentNode.equals(Constants.LAST_MODIFIED_ELEMENT)) { this.attributes.getProperties().setLastModified(Utility.parseRFC1123DateFromStringInGMT(value)); } else if (currentNode.equals(Constants.ETAG_ELEMENT)) { this.attributes.getProperties().setEtag(Utility.formatETag(value)); } else if (currentNode.equals(FileConstants.SHARE_QUOTA_ELEMENT)) { this.attributes.getProperties().setShareQuota(Utility.isNullOrEmpty(value) ? null : Integer.parseInt(value)); } } }
private void getProperties(String currentNode, String value) throws ParseException { if (currentNode.equals(Constants.LAST_MODIFIED_ELEMENT)) { this.attributes.getProperties().setLastModified(Utility.parseRFC1123DateFromStringInGMT(value)); } else if (currentNode.equals(Constants.ETAG_ELEMENT)) { this.attributes.getProperties().setEtag(Utility.formatETag(value)); } else if (currentNode.equals(FileConstants.SHARE_QUOTA_ELEMENT)) { this.attributes.getProperties().setShareQuota(Utility.isNullOrEmpty(value) ? null : Integer.parseInt(value)); } } }
/** * 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()); } }
/** * Gets the FileShareAttributes from the given request. * * @param request * the request to get attributes from * @param usePathStyleUris * a value indicating if the account is using pathSytleUris * @return the FileShareAttributes from the given request. * @throws StorageException */ public static FileShareAttributes getFileShareAttributes(final HttpURLConnection request, final boolean usePathStyleUris) throws StorageException { final FileShareAttributes shareAttributes = new FileShareAttributes(); final FileShareProperties shareProperties = shareAttributes.getProperties(); shareProperties.setEtag(BaseResponse.getEtag(request)); shareProperties.setShareQuota(parseShareQuota(request)); shareProperties.setLastModified(new Date(request.getLastModified())); shareAttributes.setMetadata(getMetadata(request)); return shareAttributes; }
/** * Gets the FileShareAttributes from the given request. * * @param request * the request to get attributes from * @param usePathStyleUris * a value indicating if the account is using pathSytleUris * @return the FileShareAttributes from the given request. * @throws StorageException */ public static FileShareAttributes getFileShareAttributes(final HttpURLConnection request, final boolean usePathStyleUris) throws StorageException { final FileShareAttributes shareAttributes = new FileShareAttributes(); final FileShareProperties shareProperties = shareAttributes.getProperties(); shareProperties.setEtag(BaseResponse.getEtag(request)); shareProperties.setShareQuota(parseShareQuota(request)); shareProperties.setLastModified(new Date(request.getLastModified())); shareAttributes.setMetadata(getMetadata(request)); return shareAttributes; }
@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; } };
/** * 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()); } }
this.share.getProperties().setShareQuota(shareQuota); this.share.uploadProperties(); this.share.downloadAttributes(); this.share.getProperties().setShareQuota(shareQuota); this.share.create(); assertNotNull(this.share.getProperties().getShareQuota()); this.share.getProperties().setShareQuota(shareQuota); fail(); } catch (IllegalArgumentException e) {