/** * Returns the Azure File's copy state. * * @return A {@link CopyState} object that represents the copy state of the file. */ public CopyState getCopyState() { return this.properties.getCopyState(); }
/** * Returns the Azure File's copy state. * * @return A {@link CopyState} object that represents the copy state of the file. */ public CopyState getCopyState() { return this.properties.getCopyState(); }
@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 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(); } };
/** * Start copying a file and then abort * * @throws StorageException * @throws URISyntaxException * @throws IOException * @throws InterruptedException */ @Test @Category({ DevFabricTests.class, DevStoreTests.class }) public void testCopyFileAbort() throws StorageException, URISyntaxException, IOException { final int length = 128; CloudFile originalFile = FileTestHelper.uploadNewFile(this.share, length, null); CloudFile copyFile = this.share.getRootDirectoryReference().getFileReference(originalFile.getName() + "copyed"); copyFile.startCopy(originalFile); try { copyFile.abortCopy(copyFile.getProperties().getCopyState().getCopyId()); fail(); } catch (StorageException e) { if (!e.getErrorCode().contains("NoPendingCopyOperation")) { throw e; } } }
assertEquals(length, destination.getCopyState().getTotalBytes().intValue()); assertEquals(length, destination.getCopyState().getBytesCopied().intValue()); assertEquals(copyId, destination.getProperties().getCopyState().getCopyId());
assertEquals(data.length(), destination.getCopyState().getTotalBytes().intValue()); assertEquals(data.length(), destination.getCopyState().getBytesCopied().intValue()); assertEquals(copyId, destination.getProperties().getCopyState().getCopyId());