/** * Returns a value that indicates whether the queue exists. * * @return <code>true</code> if the queue exists in the storage service, otherwise <code>false</code>. * * @throws StorageException * If a storage service error occurred during the operation. */ @DoesServiceRequest public boolean exists() throws StorageException { return this.exists(null /* options */, null /* opContext */); }
/** * Returns a value that indicates whether the queue exists. * * @return <code>true</code> if the queue exists in the storage service, otherwise <code>false</code>. * * @throws StorageException * If a storage service error occurred during the operation. */ @DoesServiceRequest public boolean exists() throws StorageException { return this.exists(null /* options */, null /* opContext */); }
/** * Returns a value that indicates whether the queue existse, using the specified request options and operation * context. * * @param options * A {@link QueueRequestOptions} 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 CloudQueueClient}). * @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 queue exists in the storage service, otherwise <code>false</code>. * * @throws StorageException * If a storage service error occurred during the operation. */ @DoesServiceRequest public boolean exists(QueueRequestOptions options, OperationContext opContext) throws StorageException { return this.exists(false, options, opContext); }
/** * Returns a value that indicates whether the queue existse, using the specified request options and operation * context. * * @param options * A {@link QueueRequestOptions} 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 CloudQueueClient}). * @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 queue exists in the storage service, otherwise <code>false</code>. * * @throws StorageException * If a storage service error occurred during the operation. */ @DoesServiceRequest public boolean exists(QueueRequestOptions options, OperationContext opContext) throws StorageException { return this.exists(false, options, opContext); }
@Override public CloudQueue internalGet(Tuple<CloudStorageAccount, String> key) { CloudQueueClient queueClient = key.getFirst().createCloudQueueClient(); try { CloudQueue cloudQueue = queueClient.getQueueReference(key.getSecond()); if (!cloudQueue.exists()) { return null; } return cloudQueue; } catch (URISyntaxException | StorageException e) { throw new RuntimeException("Failed to build queue client", e); } }
options = QueueRequestOptions.populateAndApplyDefaults(options, this.queueServiceClient); boolean exists = this.exists(true, options, opContext); if (exists) { try {
options = QueueRequestOptions.populateAndApplyDefaults(options, this.queueServiceClient); boolean exists = this.exists(true, options, opContext); if (exists) { return false;
options = QueueRequestOptions.populateAndApplyDefaults(options, this.queueServiceClient); boolean exists = this.exists(true, options, opContext); if (exists) { return false;
options = QueueRequestOptions.populateAndApplyDefaults(options, this.queueServiceClient); boolean exists = this.exists(true, options, opContext); if (exists) { try {
@Override public void eventOccurred(SendingRequestEvent eventArg) { if (((HttpURLConnection) eventArg.getConnectionObject()).getRequestMethod().equals("DELETE")) { try { queue.delete(); assertFalse(queue.exists()); } catch (StorageException e) { fail("Delete should succeed."); } } } });
@Test @Category({ DevFabricTests.class, DevStoreTests.class }) public void testQueueExist() throws URISyntaxException, StorageException { final CloudQueue queue = QueueTestHelper.getRandomQueueReference(); final OperationContext existQueueContext1 = new OperationContext(); assertTrue(!queue.exists(null, existQueueContext1)); assertEquals(existQueueContext1.getLastResult().getStatusCode(), HttpURLConnection.HTTP_NOT_FOUND); try { final OperationContext createQueueContext = new OperationContext(); queue.create(null, createQueueContext); assertEquals(createQueueContext.getLastResult().getStatusCode(), HttpURLConnection.HTTP_CREATED); final OperationContext existQueueContext2 = new OperationContext(); assertTrue(queue.exists(null, existQueueContext2)); assertEquals(existQueueContext2.getLastResult().getStatusCode(), HttpURLConnection.HTTP_OK); } finally { queue.deleteIfExists(); } }
@Test @Category({ DevFabricTests.class, DevStoreTests.class }) public void testDeleteNonExistingQueue() throws URISyntaxException, StorageException { final CloudQueue queue = QueueTestHelper.getRandomQueueReference(); final OperationContext existQueueContext1 = new OperationContext(); assertTrue(!queue.exists(null, existQueueContext1)); assertEquals(existQueueContext1.getLastResult().getStatusCode(), HttpURLConnection.HTTP_NOT_FOUND); try { queue.delete(); fail("Queue delete no exsiting queue. "); } catch (StorageException ex) { assertEquals("Expected 404 Exception", ex.getHttpStatusCode(), HttpURLConnection.HTTP_NOT_FOUND); } }
@Test public void testUserAgentString() throws URISyntaxException, StorageException { // Test with a blob request CloudBlobClient blobClient = TestHelper.createCloudBlobClient(); CloudBlobContainer container = blobClient.getContainerReference("container1"); OperationContext sendingRequestEventContext = new OperationContext(); sendingRequestEventContext.getSendingRequestEventHandler().addListener(new StorageEvent<SendingRequestEvent>() { @Override public void eventOccurred(SendingRequestEvent eventArg) { assertEquals( Constants.HeaderConstants.USER_AGENT_PREFIX + "/" + Constants.HeaderConstants.USER_AGENT_VERSION + " " + String.format(Utility.LOCALE_US, "(Android %s; %s; %s)", android.os.Build.VERSION.RELEASE, android.os.Build.BRAND, android.os.Build.MODEL), ((HttpURLConnection) eventArg.getConnectionObject()) .getRequestProperty(Constants.HeaderConstants.USER_AGENT)); } }); container.exists(null, null, sendingRequestEventContext); // Test with a queue request CloudQueueClient queueClient = TestHelper.createCloudQueueClient(); CloudQueue queue = queueClient.getQueueReference("queue1"); queue.exists(null, sendingRequestEventContext); // Test with a table request CloudTableClient tableClient = TestHelper.createCloudTableClient(); CloudTable table = tableClient.getTableReference("table1"); table.exists(null, sendingRequestEventContext); }