From 8bca4e7cefdf3291a221adf18e6acbae8b868155 Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Wed, 6 Feb 2013 11:52:16 -0800 Subject: [PATCH 1/4] Removed leaseId from function signature - it isn't used by the service. --- .../windowsazure/services/blob/BlobContract.java | 12 +++++------- .../implementation/BlobExceptionProcessor.java | 8 ++++---- .../implementation/BlobOperationRestProxy.java | 14 ++++++++------ .../services/blob/models/AcquireLeaseResult.java | 2 +- .../services/blob/BlobServiceIntegrationTest.java | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java index 2cac537f9456f..bdeb33b1d4d69 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java @@ -1441,16 +1441,15 @@ void releaseLease(String container, String blob, String leaseId, BlobServiceOpti * A lease that has been broken but has not yet expired can also be released, in which case another client may * immediately acquire a new lease on the blob. * + * * @param container * A {@link String} containing the name of the blob's container. * @param blob * A {@link String} containing the name of the blob to break a lease on. - * @param leaseId - * A {@link String} containing an optional lease ID. * @throws ServiceException * if an error occurs accessing the storage service. */ - void breakLease(String container, String blob, String leaseId) throws ServiceException; + void breakLease(String container, String blob) throws ServiceException; /** * Breaks an active lease on a blob, using the specified options. @@ -1466,16 +1465,15 @@ void releaseLease(String container, String blob, String leaseId, BlobServiceOpti * A lease that has been broken but has not yet expired can also be released, in which case another client may * immediately acquire a new lease on the blob. * + * * @param container * A {@link String} containing the name of the blob's container. * @param blob * A {@link String} containing the name of the blob to break a lease on. - * @param leaseId - * A {@link String} containing an optional lease ID. * @param options - * A {@link BlobServiceOptions} instance containing options for the request. + * A {@link com.microsoft.windowsazure.services.blob.models.BlobServiceOptions} instance containing options for the request. * @throws ServiceException * if an error occurs accessing the storage service. */ - void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException; + void breakLease(String container, String blob, BlobServiceOptions options) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java index 8bae36798a8c7..6417ed53b5f01 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java @@ -888,9 +888,9 @@ public void releaseLease(String container, String blob, String leaseId, BlobServ } @Override - public void breakLease(String container, String blob, String leaseId) throws ServiceException { + public void breakLease(String container, String blob) throws ServiceException { try { - service.breakLease(container, blob, leaseId); + service.breakLease(container, blob); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -901,10 +901,10 @@ public void breakLease(String container, String blob, String leaseId) throws Ser } @Override - public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) + public void breakLease(String container, String blob, BlobServiceOptions options) throws ServiceException { try { - service.breakLease(container, blob, leaseId, options); + service.breakLease(container, blob, options); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java index b07f42f63f29d..88c79d62f0833 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java @@ -801,14 +801,14 @@ public void releaseLease(String container, String blob, String leaseId, BlobServ } @Override - public void breakLease(String container, String blob, String leaseId) throws ServiceException { - breakLease(container, blob, leaseId, new BlobServiceOptions()); + public void breakLease(String container, String blob) throws ServiceException { + breakLease(container, blob, new BlobServiceOptions()); } @Override - public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) - throws ServiceException { - putLeaseImpl("break", container, blob, leaseId, options, null/* accessCondition */); + public void breakLease(String container, String blob, BlobServiceOptions options) + throws ServiceException { + putLeaseImpl("break", container, blob, null, options, null/* accessCondition */); } private AcquireLeaseResult putLeaseImpl(String leaseAction, String container, String blob, String leaseId, @@ -817,7 +817,9 @@ private AcquireLeaseResult putLeaseImpl(String leaseAction, String container, St WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "lease"); Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", leaseId); + if (leaseId != null) { + builder = addOptionalHeader(builder, "x-ms-lease-id", leaseId); + } builder = addOptionalHeader(builder, "x-ms-lease-action", leaseAction); builder = addOptionalAccessConditionHeader(builder, accessCondition); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseResult.java index 044833ada7ba8..d8c9905babee3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseResult.java @@ -18,7 +18,7 @@ /** * A wrapper class for the response returned from a Blob Service REST API Lease Blob operation. This is returned by - * calls to implementations of {@link BlobContract#breakLease(String, String, String, BlobServiceOptions)}, + * calls to implementations of {@link BlobContract#breakLease(String, String, BlobServiceOptions)}, * {@link BlobContract#releaseLease(String, String, String, BlobServiceOptions)} and * {@link BlobContract#renewLease(String, String, String, BlobServiceOptions)}. *

diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java index 01040883db402..64e220b75342d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java @@ -1595,7 +1595,7 @@ public void breakLeaseWorks() throws Exception { String content = "some content2"; service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "test6", new ByteArrayInputStream(content.getBytes("UTF-8"))); String leaseId = service.acquireLease(TEST_CONTAINER_FOR_BLOBS, "test6").getLeaseId(); - service.breakLease(TEST_CONTAINER_FOR_BLOBS, "test6", leaseId); + service.breakLease(TEST_CONTAINER_FOR_BLOBS, "test6"); service.releaseLease(TEST_CONTAINER_FOR_BLOBS, "test6", leaseId); // Assert From 939e60ccf693a9704634961679d77f48f4e17083 Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Wed, 6 Feb 2013 17:57:13 -0800 Subject: [PATCH 2/4] Added return value for breakLease. Also fixed some warnings in the blob integration fixture. --- .../services/blob/BlobContract.java | 10 ++++-- .../BlobExceptionProcessor.java | 9 ++--- .../BlobOperationRestProxy.java | 26 +++++++++----- .../blob/models/BreakLeaseResult.java | 35 +++++++++++++++++++ .../blob/BlobServiceIntegrationTest.java | 11 +++--- 5 files changed, 73 insertions(+), 18 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BreakLeaseResult.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java index bdeb33b1d4d69..e4ff9b3813dd5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java @@ -21,6 +21,7 @@ import com.microsoft.windowsazure.services.blob.models.AcquireLeaseResult; import com.microsoft.windowsazure.services.blob.models.BlobServiceOptions; import com.microsoft.windowsazure.services.blob.models.BlockList; +import com.microsoft.windowsazure.services.blob.models.BreakLeaseResult; import com.microsoft.windowsazure.services.blob.models.CommitBlobBlocksOptions; import com.microsoft.windowsazure.services.blob.models.ContainerACL; import com.microsoft.windowsazure.services.blob.models.CopyBlobOptions; @@ -1442,14 +1443,17 @@ void releaseLease(String container, String blob, String leaseId, BlobServiceOpti * immediately acquire a new lease on the blob. * * + * * @param container * A {@link String} containing the name of the blob's container. * @param blob * A {@link String} containing the name of the blob to break a lease on. * @throws ServiceException * if an error occurs accessing the storage service. + * + * @return result containing time remaining before a new lease can be acquired */ - void breakLease(String container, String blob) throws ServiceException; + BreakLeaseResult breakLease(String container, String blob) throws ServiceException; /** * Breaks an active lease on a blob, using the specified options. @@ -1466,6 +1470,7 @@ void releaseLease(String container, String blob, String leaseId, BlobServiceOpti * immediately acquire a new lease on the blob. * * + * * @param container * A {@link String} containing the name of the blob's container. * @param blob @@ -1474,6 +1479,7 @@ void releaseLease(String container, String blob, String leaseId, BlobServiceOpti * A {@link com.microsoft.windowsazure.services.blob.models.BlobServiceOptions} instance containing options for the request. * @throws ServiceException * if an error occurs accessing the storage service. + * @return result containing time remaining before a new lease can be acquired */ - void breakLease(String container, String blob, BlobServiceOptions options) throws ServiceException; + BreakLeaseResult breakLease(String container, String blob, BlobServiceOptions options) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java index 6417ed53b5f01..bb220bbf9fb1a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java @@ -27,6 +27,7 @@ import com.microsoft.windowsazure.services.blob.models.AcquireLeaseResult; import com.microsoft.windowsazure.services.blob.models.BlobServiceOptions; import com.microsoft.windowsazure.services.blob.models.BlockList; +import com.microsoft.windowsazure.services.blob.models.BreakLeaseResult; import com.microsoft.windowsazure.services.blob.models.CommitBlobBlocksOptions; import com.microsoft.windowsazure.services.blob.models.ContainerACL; import com.microsoft.windowsazure.services.blob.models.CopyBlobOptions; @@ -888,9 +889,9 @@ public void releaseLease(String container, String blob, String leaseId, BlobServ } @Override - public void breakLease(String container, String blob) throws ServiceException { + public BreakLeaseResult breakLease(String container, String blob) throws ServiceException { try { - service.breakLease(container, blob); + return service.breakLease(container, blob); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -901,10 +902,10 @@ public void breakLease(String container, String blob) throws ServiceException { } @Override - public void breakLease(String container, String blob, BlobServiceOptions options) + public BreakLeaseResult breakLease(String container, String blob, BlobServiceOptions options) throws ServiceException { try { - service.breakLease(container, blob, options); + return service.breakLease(container, blob, options); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java index 88c79d62f0833..93196ecd460eb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java @@ -26,6 +26,7 @@ import com.microsoft.windowsazure.services.blob.models.BlobProperties; import com.microsoft.windowsazure.services.blob.models.BlobServiceOptions; import com.microsoft.windowsazure.services.blob.models.BlockList; +import com.microsoft.windowsazure.services.blob.models.BreakLeaseResult; import com.microsoft.windowsazure.services.blob.models.CommitBlobBlocksOptions; import com.microsoft.windowsazure.services.blob.models.ContainerACL; import com.microsoft.windowsazure.services.blob.models.ContainerACL.PublicAccessType; @@ -801,18 +802,30 @@ public void releaseLease(String container, String blob, String leaseId, BlobServ } @Override - public void breakLease(String container, String blob) throws ServiceException { - breakLease(container, blob, new BlobServiceOptions()); + public BreakLeaseResult breakLease(String container, String blob) throws ServiceException { + return breakLease(container, blob, new BlobServiceOptions()); } @Override - public void breakLease(String container, String blob, BlobServiceOptions options) + public BreakLeaseResult breakLease(String container, String blob, BlobServiceOptions options) throws ServiceException { - putLeaseImpl("break", container, blob, null, options, null/* accessCondition */); + ClientResponse response = doLeaseOperation("break", container, blob, null, options, null); + + BreakLeaseResult result = new BreakLeaseResult(); + result.setRemainingLeaseTimeInSeconds(Integer.parseInt(response.getHeaders().getFirst("x-ms-lease-time"))); + return result; } private AcquireLeaseResult putLeaseImpl(String leaseAction, String container, String blob, String leaseId, BlobServiceOptions options, AccessCondition accessCondition) throws ServiceException { + ClientResponse response = doLeaseOperation(leaseAction, container, blob, leaseId, options, accessCondition); + + AcquireLeaseResult result = new AcquireLeaseResult(); + result.setLeaseId(response.getHeaders().getFirst("x-ms-lease-id")); + return result; + } + + private ClientResponse doLeaseOperation(String leaseAction, String container, String blob, String leaseId, BlobServiceOptions options, AccessCondition accessCondition) { String path = createPathFromContainer(container); WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "lease"); @@ -826,10 +839,7 @@ private AcquireLeaseResult putLeaseImpl(String leaseAction, String container, St // Note: Add content type here to enable proper HMAC signing ClientResponse response = builder.put(ClientResponse.class, ""); ThrowIfError(response); - - AcquireLeaseResult result = new AcquireLeaseResult(); - result.setLeaseId(response.getHeaders().getFirst("x-ms-lease-id")); - return result; + return response; } @Override diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BreakLeaseResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BreakLeaseResult.java new file mode 100644 index 0000000000000..d76f5e6564a1a --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BreakLeaseResult.java @@ -0,0 +1,35 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.blob.models; + +/** + * A wrapper class for the response returned from a Blob Service REST API Break Lease Blob operation. This is returned by + * calls to implementations of {@link com.microsoft.windowsazure.services.blob.BlobContract#breakLease(String, String, BlobServiceOptions)}, + *

+ * See the Lease Blob documentation on + * MSDN for details of the underlying Blob Service REST API operation. + */ +public class BreakLeaseResult { + private int remainingLeaseTimeInSeconds; + + public int getRemainingLeaseTimeInSeconds() { + return remainingLeaseTimeInSeconds; + } + + public void setRemainingLeaseTimeInSeconds(int remainingLeaseTimeInSeconds) { + this.remainingLeaseTimeInSeconds = remainingLeaseTimeInSeconds; + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java index 64e220b75342d..49f73558f7609 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java @@ -42,6 +42,7 @@ import com.microsoft.windowsazure.services.blob.models.AccessCondition; import com.microsoft.windowsazure.services.blob.models.BlobProperties; import com.microsoft.windowsazure.services.blob.models.BlockList; +import com.microsoft.windowsazure.services.blob.models.BreakLeaseResult; import com.microsoft.windowsazure.services.blob.models.ContainerACL; import com.microsoft.windowsazure.services.blob.models.ContainerACL.PublicAccessType; import com.microsoft.windowsazure.services.blob.models.CopyBlobResult; @@ -325,7 +326,7 @@ public void deleteContainerWorks() throws Exception { // Assert for (Container container : listContainerResult.getContainers()) { - assertTrue(!container.getName().equals(container)); + assertTrue(!container.getName().equals(containerName)); } } @@ -1263,7 +1264,7 @@ public void getBlobWithIfNotModifiedSinceAccessConditionWorks() throws Exception Date lastModifiedBase = (Date) props.getProperties().getLastModified().clone(); // +1 second - Date lastModifiedNext = new Date(lastModifiedBase.getTime() + 1 * 1000); + Date lastModifiedNext = new Date(lastModifiedBase.getTime() + 1000); while (true) { HashMap metadata = new HashMap(); @@ -1492,7 +1493,7 @@ public void deleteBlobSnapshotSuccess() throws Exception { ListBlobsResult listBlobsResult = service.listBlobs(TEST_CONTAINER_FOR_BLOBS); List blobEntry = listBlobsResult.getBlobs(); for (BlobEntry blobEntryItem : blobEntry) { - assertTrue(blobEntryItem.getSnapshot() != snapshot); + assertTrue(blobEntryItem.getSnapshot() == null || !blobEntryItem.getSnapshot().equals(snapshot)); } assertTrue(true); } @@ -1595,11 +1596,13 @@ public void breakLeaseWorks() throws Exception { String content = "some content2"; service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "test6", new ByteArrayInputStream(content.getBytes("UTF-8"))); String leaseId = service.acquireLease(TEST_CONTAINER_FOR_BLOBS, "test6").getLeaseId(); - service.breakLease(TEST_CONTAINER_FOR_BLOBS, "test6"); + BreakLeaseResult breakResult = service.breakLease(TEST_CONTAINER_FOR_BLOBS, "test6"); service.releaseLease(TEST_CONTAINER_FOR_BLOBS, "test6", leaseId); // Assert assertNotNull(leaseId); + assertNotNull(breakResult); + assertTrue(breakResult.getRemainingLeaseTimeInSeconds() > 0); } class RetryPolicyObserver implements ServiceFilter { From 3e8b32b888f07c5ea88d210a6ec046b0bba82282 Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Wed, 6 Feb 2013 18:01:20 -0800 Subject: [PATCH 3/4] Updated doc comments --- .../services/blob/models/AcquireLeaseResult.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseResult.java index d8c9905babee3..4c4803afeb0f1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseResult.java @@ -18,9 +18,10 @@ /** * A wrapper class for the response returned from a Blob Service REST API Lease Blob operation. This is returned by - * calls to implementations of {@link BlobContract#breakLease(String, String, BlobServiceOptions)}, - * {@link BlobContract#releaseLease(String, String, String, BlobServiceOptions)} and - * {@link BlobContract#renewLease(String, String, String, BlobServiceOptions)}. + * calls to implementations of {@link BlobContract#acquireLease(String, String)}, + * {@link BlobContract#acquireLease(String, String, AcquireLeaseOptions)}, + * {@link BlobContract#renewLease(String, String, String, BlobServiceOptions)}, and + * {@link BlobContract#renewLease(String, String, String)}. *

* See the Lease Blob documentation on * MSDN for details of the underlying Blob Service REST API operation. From 11dc82d2293a021d7aa5fb952586dea5f18ea8b8 Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Thu, 7 Feb 2013 10:29:44 -0800 Subject: [PATCH 4/4] Added back original overloads of breakLease to keep back compat, marked them deprecated. --- .../services/blob/BlobContract.java | 65 +++++++++++++++++++ .../BlobExceptionProcessor.java | 12 ++++ .../BlobOperationRestProxy.java | 12 ++++ 3 files changed, 89 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java index e4ff9b3813dd5..ac52417127140 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java @@ -1429,6 +1429,71 @@ AcquireLeaseResult renewLease(String container, String blob, String leaseId, Blo void releaseLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException; + /** + * Breaks an active lease on a blob. + *

+ * This method breaks the lease on the blob specified by the blob and container parameters. The + * leaseId parameter is not used by the server. + *

+ * Once a lease is broken, it cannot be renewed. Any authorized request can break the lease; the request is not + * required to specify a matching lease ID. When a lease is broken, the remaining time on the lease is allowed to + * elapse, during which time no lease operation may be performed on the blob. + *

+ * A lease that has been broken but has not yet expired can also be released, in which case another client may + * immediately acquire a new lease on the blob. + * + * @deprecated Server ignores the leaseId parameter, replaced by {@link #breakLease(String, String)} without + * the useless parameter. + * + * @param container + * A {@link String} containing the name of the blob's container. + * @param blob + * A {@link String} containing the name of the blob to break a lease on. + * + * @param leaseId lease id to break. Ignored. + * + * @throws ServiceException + * if an error occurs accessing the storage service. + * + * @return result containing time remaining before a new lease can be acquired + */ + @Deprecated() + void breakLease(String container, String blob, String leaseId) throws ServiceException; + + /** + * Breaks an active lease on a blob, using the specified options. + *

+ * This method breaks the lease on the blob specified by the blob and container parameters. The + * leaseId parameter is not used by the server. Use the {@link BlobServiceOptions options} parameter to + * specify the server timeout for the operation. + *

+ * Once a lease is broken, it cannot be renewed. Any authorized request can break the lease; the request is not + * required to specify a matching lease ID. When a lease is broken, the remaining time on the lease is allowed to + * elapse, during which time no lease operation may be performed on the blob. + *

+ * A lease that has been broken but has not yet expired can also be released, in which case another client may + * immediately acquire a new lease on the blob. + * + * @deprecated Server ignores the leaseId parameter, replaced by + * {@link #breakLease(String, String, com.microsoft.windowsazure.services.blob.models.BlobServiceOptions)} + * without the useless parameter. + * + * + * @param container + * A {@link String} containing the name of the blob's container. + * @param blob + * A {@link String} containing the name of the blob to break a lease on. + * @param options + * A {@link com.microsoft.windowsazure.services.blob.models.BlobServiceOptions} instance containing options for the request. + * @param leaseId lease id to break. Ignored. + * + * @throws ServiceException + * if an error occurs accessing the storage service. + * @return result containing time remaining before a new lease can be acquired + */ + @Deprecated() + void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException; + /** * Breaks an active lease on a blob. *

diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java index bb220bbf9fb1a..3b0689cff0083 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java @@ -888,6 +888,18 @@ public void releaseLease(String container, String blob, String leaseId, BlobServ } } + @Override + @Deprecated + public void breakLease(String container, String blob, String leaseId) throws ServiceException { + breakLease(container, blob); + } + + @Override + @Deprecated + public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { + breakLease(container, blob, options); + } + @Override public BreakLeaseResult breakLease(String container, String blob) throws ServiceException { try { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java index 93196ecd460eb..9951bb03ca624 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java @@ -801,6 +801,18 @@ public void releaseLease(String container, String blob, String leaseId, BlobServ putLeaseImpl("release", container, blob, leaseId, options, null/* accessCondition */); } + @Override + @Deprecated + public void breakLease(String container, String blob, String leaseId) throws ServiceException { + breakLease(container, blob); + } + + @Override + @Deprecated + public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { + breakLease(container, blob, options); + } + @Override public BreakLeaseResult breakLease(String container, String blob) throws ServiceException { return breakLease(container, blob, new BlobServiceOptions());