/** * 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()); } }
private void updatePropertiesFromResponse(HttpURLConnection request) { if (this.getProperties() == null) { this.properties = new FileShareProperties(); } // ETag this.getProperties().setEtag(request.getHeaderField(Constants.HeaderConstants.ETAG)); // Last Modified if (0 != request.getLastModified()) { final Calendar lastModifiedCalendar = Calendar.getInstance(Utility.LOCALE_US); lastModifiedCalendar.setTimeZone(Utility.UTC_ZONE); lastModifiedCalendar.setTime(new Date(request.getLastModified())); this.getProperties().setLastModified(lastModifiedCalendar.getTime()); } }
private void updatePropertiesFromResponse(HttpURLConnection request) { // ETag this.getProperties().setEtag(request.getHeaderField(Constants.HeaderConstants.ETAG)); // Last Modified if (0 != request.getLastModified()) { final Calendar lastModifiedCalendar = Calendar.getInstance(Utility.LOCALE_US); lastModifiedCalendar.setTimeZone(Utility.UTC_ZONE); lastModifiedCalendar.setTime(new Date(request.getLastModified())); this.getProperties().setLastModified(lastModifiedCalendar.getTime()); } }
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)); } } }
@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; } };
/** * 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()); }
/** * Initializes a new instance of the FileShareAttributes class */ public FileShareAttributes() { this.setMetadata(new HashMap<String, String>()); this.setProperties(new FileShareProperties()); }
/** * Check a share's existence * * @throws StorageException */ @Test public void testCloudFileShareExists() throws StorageException { assertFalse(this.share.exists()); this.share.create(); assertTrue(this.share.exists()); assertNotNull(this.share.getProperties().getEtag()); this.share.delete(); assertFalse(this.share.exists()); }
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)); } } }
@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; } };
/** * 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()); }
/** * Initializes a new instance of the FileShareAttributes class */ public FileShareAttributes() { this.setMetadata(new HashMap<String, String>()); this.setProperties(new FileShareProperties()); }
/** * 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; }
/** * 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()); } }
/** * 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); }
snapshot.setProperties(new FileShareProperties(share.properties));
/** * 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; }
assertNotNull(this.share.getProperties().getShareQuota()); int shareQuota = FileConstants.MAX_SHARE_QUOTA; assertEquals(shareQuota, this.share.getProperties().getShareQuota().intValue()); this.share.getProperties().setShareQuota(shareQuota); 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()); this.share.getProperties().setShareQuota(shareQuota); fail(); } catch (IllegalArgumentException e) {
/** * 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); }