properties.setCopyState(FileResponse.getCopyState(request)); properties.setServerEncrypted( Constants.TRUE.equals(request.getHeaderField(Constants.HeaderConstants.SERVER_ENCRYPTED)));
@Override public Boolean preProcessResponse(CloudFile file, CloudFileClient client, OperationContext context) throws Exception { if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { final FileAttributes retrievedAttributes = FileResponse.getFileAttributes(this.getConnection(), file.getStorageUri()); file.properties = retrievedAttributes.getProperties(); file.metadata = retrievedAttributes.getMetadata(); return Boolean.valueOf(true); } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { return Boolean.valueOf(false); } else { this.setNonExceptionedRetryableFailure(true); // return false instead of null to avoid SCA issues return false; } } };
@Override public Boolean preProcessResponse(CloudFileShare share, CloudFileClient client, OperationContext context) throws Exception { if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { share.updatePropertiesFromResponse(this.getConnection()); final FileShareAttributes attributes = FileResponse.getFileShareAttributes(this.getConnection(), client.isUsePathStyleUris()); share.metadata = attributes.getMetadata(); share.properties = attributes.getProperties(); return Boolean.valueOf(true); } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { return Boolean.valueOf(false); } else { this.setNonExceptionedRetryableFailure(true); // return false instead of null to avoid SCA issues return false; } } };
/** * 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 Boolean preProcessResponse(CloudFileDirectory directory, CloudFileClient client, OperationContext context) throws Exception { if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { directory.updatePropertiesFromResponse(this.getConnection()); // Set properties final FileDirectoryAttributes attributes = FileResponse.getFileDirectoryAttributes(this.getConnection(), client.isUsePathStyleUris()); directory.setMetadata(attributes.getMetadata()); directory.setProperties(attributes.getProperties()); return Boolean.valueOf(true); } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { return Boolean.valueOf(false); } else { this.setNonExceptionedRetryableFailure(true); // return false instead of null to avoid SCA issues return false; } } };
@Override public CloudFileShare preProcessResponse(CloudFileShare share, CloudFileClient client, OperationContext context) throws Exception { if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); return null; } final String snapshotTime = FileResponse.getSnapshotTime(this.getConnection()); CloudFileShare snapshot = new CloudFileShare(share.getName(), snapshotTime, client); snapshot.setProperties(new FileShareProperties(share.properties)); // use the specified metadata if not null : otherwise share's metadata snapshot.setMetadata(metadata != null ? metadata : share.metadata); snapshot.updatePropertiesFromResponse(this.getConnection()); return snapshot; } };
/** * Gets the FileDirectoryAttributes 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 FileDirectoryAttributes from the given request. * @throws StorageException */ public static FileDirectoryAttributes getFileDirectoryAttributes(final HttpURLConnection request, final boolean usePathStyleUris) throws StorageException { final FileDirectoryAttributes directoryAttributes = new FileDirectoryAttributes(); URI tempURI; try { tempURI = PathUtility.stripSingleURIQueryAndFragment(request.getURL().toURI()); } catch (final URISyntaxException e) { final StorageException wrappedUnexpectedException = Utility.generateNewUnexpectedStorageException(e); throw wrappedUnexpectedException; } directoryAttributes.setName(PathUtility.getDirectoryNameFromURI(tempURI, usePathStyleUris)); final FileDirectoryProperties directoryProperties = directoryAttributes.getProperties(); directoryProperties.setEtag(BaseResponse.getEtag(request)); directoryProperties.setLastModified(new Date(request.getLastModified())); directoryAttributes.setMetadata(getMetadata(request)); directoryProperties.setServerEncrypted( Constants.TRUE.equals(request.getHeaderField(Constants.HeaderConstants.SERVER_ENCRYPTED))); return directoryAttributes; }
/** * 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 Boolean preProcessResponse(CloudFileDirectory directory, CloudFileClient client, OperationContext context) throws Exception { if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { directory.updatePropertiesFromResponse(this.getConnection()); // Set properties final FileDirectoryAttributes attributes = FileResponse.getFileDirectoryAttributes(this.getConnection(), client.isUsePathStyleUris()); directory.setMetadata(attributes.getMetadata()); directory.setProperties(attributes.getProperties()); return Boolean.valueOf(true); } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { return Boolean.valueOf(false); } else { this.setNonExceptionedRetryableFailure(true); // return false instead of null to avoid SCA issues return false; } } };
@Override public CloudFileShare preProcessResponse(CloudFileShare share, CloudFileClient client, OperationContext context) throws Exception { if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); return null; } final String snapshotTime = FileResponse.getSnapshotTime(this.getConnection()); CloudFileShare snapshot = new CloudFileShare(share.getName(), snapshotTime, client); snapshot.setProperties(new FileShareProperties(share.properties)); // use the specified metadata if not null : otherwise share's metadata snapshot.setMetadata(metadata != null ? metadata : share.metadata); snapshot.updatePropertiesFromResponse(this.getConnection()); return snapshot; } };
/** * Gets the FileDirectoryAttributes 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 FileDirectoryAttributes from the given request. * @throws StorageException */ public static FileDirectoryAttributes getFileDirectoryAttributes(final HttpURLConnection request, final boolean usePathStyleUris) throws StorageException { final FileDirectoryAttributes directoryAttributes = new FileDirectoryAttributes(); URI tempURI; try { tempURI = PathUtility.stripSingleURIQueryAndFragment(request.getURL().toURI()); } catch (final URISyntaxException e) { final StorageException wrappedUnexpectedException = Utility.generateNewUnexpectedStorageException(e); throw wrappedUnexpectedException; } directoryAttributes.setName(PathUtility.getDirectoryNameFromURI(tempURI, usePathStyleUris)); final FileDirectoryProperties directoryProperties = directoryAttributes.getProperties(); directoryProperties.setEtag(BaseResponse.getEtag(request)); directoryProperties.setLastModified(new Date(request.getLastModified())); directoryAttributes.setMetadata(getMetadata(request)); directoryProperties.setServerEncrypted( Constants.TRUE.equals(request.getHeaderField(Constants.HeaderConstants.SERVER_ENCRYPTED))); return directoryAttributes; }
@Override public Void preProcessResponse(CloudFileDirectory directory, CloudFileClient client, OperationContext context) throws Exception { if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); return null; } // Set properties final FileDirectoryAttributes attributes = FileResponse.getFileDirectoryAttributes(this.getConnection(), client.isUsePathStyleUris()); directory.setMetadata(attributes.getMetadata()); directory.setProperties(attributes.getProperties()); return null; } };
@Override public Boolean preProcessResponse(CloudFileShare share, CloudFileClient client, OperationContext context) throws Exception { if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { share.updatePropertiesFromResponse(this.getConnection()); final FileShareAttributes attributes = FileResponse.getFileShareAttributes(this.getConnection(), client.isUsePathStyleUris()); share.metadata = attributes.getMetadata(); share.properties = attributes.getProperties(); return Boolean.valueOf(true); } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { return Boolean.valueOf(false); } else { this.setNonExceptionedRetryableFailure(true); // return false instead of null to avoid SCA issues return false; } } };
@Override public Boolean preProcessResponse(CloudFile file, CloudFileClient client, OperationContext context) throws Exception { if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { final FileAttributes retrievedAttributes = FileResponse.getFileAttributes(this.getConnection(), file.getStorageUri()); file.properties = retrievedAttributes.getProperties(); file.metadata = retrievedAttributes.getMetadata(); return Boolean.valueOf(true); } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { return Boolean.valueOf(false); } else { this.setNonExceptionedRetryableFailure(true); // return false instead of null to avoid SCA issues return false; } } };
properties.setCopyState(FileResponse.getCopyState(request)); properties.setServerEncrypted( Constants.TRUE.equals(request.getHeaderField(Constants.HeaderConstants.SERVER_ENCRYPTED)));
@Override public Void preProcessResponse(CloudFileDirectory directory, CloudFileClient client, OperationContext context) throws Exception { if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); return null; } // Set properties final FileDirectoryAttributes attributes = FileResponse.getFileDirectoryAttributes(this.getConnection(), client.isUsePathStyleUris()); directory.setMetadata(attributes.getMetadata()); directory.setProperties(attributes.getProperties()); return null; } };
@Override public Void preProcessResponse(CloudFileShare share, CloudFileClient client, OperationContext context) throws Exception { if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); return null; } // Set attributes final FileShareAttributes attributes = FileResponse.getFileShareAttributes(this.getConnection(), client.isUsePathStyleUris()); share.metadata = attributes.getMetadata(); share.properties = attributes.getProperties(); return null; } };
@Override public Void preProcessResponse(CloudFile file, CloudFileClient client, OperationContext context) throws Exception { if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { this.setNonExceptionedRetryableFailure(true); return null; } // Set attributes final FileAttributes retrievedAttributes = FileResponse.getFileAttributes(this.getConnection(), file.getStorageUri()); file.properties = retrievedAttributes.getProperties(); file.metadata = retrievedAttributes.getMetadata(); return null; } };
@Override public String preProcessResponse(CloudFile file, CloudFileClient client, OperationContext context) throws Exception { if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { this.setNonExceptionedRetryableFailure(true); return null; } file.updateEtagAndLastModifiedFromResponse(this.getConnection()); file.properties.setCopyState(FileResponse.getCopyState(this.getConnection())); return file.properties.getCopyState().getCopyId(); } };
@Override public Void preProcessResponse(CloudFileDirectory directory, CloudFileClient client, OperationContext context) throws Exception { if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { this.setNonExceptionedRetryableFailure(true); return null; } // Set attributes final FileDirectoryAttributes attributes = FileResponse .getFileDirectoryAttributes(this.getConnection(), client.isUsePathStyleUris()); directory.setProperties(attributes.getProperties()); this.getResult().setRequestServiceEncrypted(BaseResponse.isServerRequestEncrypted(this.getConnection())); return null; } };