/** * Returns a value that indicates whether the share exists. * * @return <code>true</code> if the share exists, otherwise <code>false</code>. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public boolean exists() throws StorageException { return this.exists(null /* accessCondition */, null /* options */, null /* opContext */); }
/** * Returns a value that indicates whether the share exists. * * @return <code>true</code> if the share exists, otherwise <code>false</code>. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public boolean exists() throws StorageException { return this.exists(null /* accessCondition */, null /* options */, null /* opContext */); }
@Override public boolean exists() { try { return this.fileShare.exists() && cloudFile.exists(); } catch (StorageException e) { log.error(MSG_FAIL_CHECK_EXIST, e); throw new StorageRuntimeException(MSG_FAIL_CHECK_EXIST, e); } }
/** * Returns a value that indicates whether the share exists, using the specified request options and operation * context. * * @param accessCondition * An {@link AccessCondition} object that represents the access conditions for the share. * @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. * * @return <code>true</code> if the share exists, otherwise <code>false</code>. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public boolean exists(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException { return this.exists(false, accessCondition, options, opContext); }
/** * Returns a value that indicates whether the share exists, using the specified request options and operation * context. * * @param accessCondition * An {@link AccessCondition} object that represents the access conditions for the share. * @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. * * @return <code>true</code> if the share exists, otherwise <code>false</code>. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public boolean exists(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException { return this.exists(false, accessCondition, options, opContext); }
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient); boolean exists = this.exists(true /* primaryOnly */, null /* accessCondition */, options, opContext); if (exists) { return false;
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient); boolean exists = this.exists(true /* primaryOnly */, null /* accessCondition */, options, opContext); if (exists) { return false;
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient); boolean exists = this.exists(true /* primaryOnly */, accessCondition, options, opContext); if (exists) { try {
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient); boolean exists = this.exists(true /* primaryOnly */, accessCondition, options, opContext); if (exists) { try {
/** * 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()); }
@Override public void eventOccurred(SendingRequestEvent eventArg) { if (((HttpURLConnection) eventArg.getConnectionObject()).getRequestMethod().equals("DELETE")) { try { CloudFileShareTests.this.share.delete(); assertFalse(CloudFileShareTests.this.share.exists()); } catch (StorageException e) { fail("Delete should succeed."); } } } });
@Test public void testDeleteShareSnapshotOptions() throws StorageException, URISyntaxException, IOException { // create share with metadata this.share.create(); assertTrue(this.share.exists()); // verify that exists() call on snapshot populates metadata CloudFileShare snapshot = this.share.createSnapshot(); CloudFileClient client = FileTestHelper.createCloudFileClient(); CloudFileShare snapshotRef = client.getShareReference(snapshot.name, snapshot.snapshotID); assertTrue(snapshotRef.exists()); try { share.delete(); } catch (final StorageException e) { assertEquals(StorageErrorCodeStrings.SHARE_HAS_SNAPSHOTS, e.getErrorCode()); } share.delete(DeleteShareSnapshotsOption.INCLUDE_SNAPSHOTS, null, null, null); assertFalse(share.exists()); assertFalse(snapshot.exists()); }
/** * CreateIfNotExists test. * * @throws StorageException */ @Test public void testCloudFileShareCreateIfNotExists() throws StorageException { assertTrue(this.share.createIfNotExists()); assertTrue(this.share.exists()); assertFalse(this.share.createIfNotExists()); }
assertTrue(this.share.exists()); HashMap<String, String> shareMeta = new HashMap<String, String>(); shareMeta.put("key1", "value1"); CloudFileClient client = FileTestHelper.createCloudFileClient(); CloudFileShare snapshotRef = client.getShareReference(snapshot.name, snapshot.snapshotID); assertTrue(snapshotRef.exists()); assertTrue(snapshotRef.getMetadata().size() == 1 && snapshotRef.getMetadata().get("key1").equals("value1")); CloudFileShare snapshotRef3 = this.share.createSnapshot(shareMeta2, null, null, null); CloudFileShare snapshotRef4 = client.getShareReference(snapshotRef3.name, snapshotRef3.snapshotID); assertTrue(snapshotRef4.exists()); assertTrue(snapshotRef4.getMetadata().size() == 1 && snapshotRef4.getMetadata().get("abc").equals("def")); this.share.getServiceClient().getCredentials()); assertEquals(snapshot.snapshotID, snapshotRef5.snapshotID); assertTrue(snapshotRef5.exists());
/** * DeleteIfExists test. * * @throws StorageException */ @Test public void testCloudFileShareDeleteIfExists() throws StorageException { assertFalse(this.share.deleteIfExists()); this.share.create(); assertTrue(this.share.deleteIfExists()); assertFalse(this.share.exists()); assertFalse(this.share.deleteIfExists()); }
/** * Try to create a share after it is created * * @throws StorageException */ @Test public void testCloudFileShareCreate() throws StorageException { this.share.create(); assertTrue(this.share.exists()); try { this.share.create(); fail("Share already existed but was created anyway."); } catch (StorageException e) { assertEquals(e.getErrorCode(), "ShareAlreadyExists"); assertEquals(e.getHttpStatusCode(), 409); assertEquals(e.getMessage(), "The specified share already exists."); } }
myDir.getFileReference("myfile").create(1024); myDir.getDirectoryReference("yourDir").create(); assertTrue(this.share.exists());