/** * Generates a new empty AccessCondition. * <p> * For more information, see <a href= 'http://go.microsoft.com/fwlink/?LinkID=224642'>Specifying Conditional Headers * for Blob Service Operations</a>. * * @return An <code>AccessCondition</code> object that has no conditions set. */ public static AccessCondition generateEmptyCondition() { return new AccessCondition(); }
/** * Generates a new empty AccessCondition. * <p> * For more information, see <a href= 'http://go.microsoft.com/fwlink/?LinkID=224642'>Specifying Conditional Headers * for Blob Service Operations</a>. * * @return An <code>AccessCondition</code> object that has no conditions set. */ public static AccessCondition generateEmptyCondition() { return new AccessCondition(); }
/** * Returns an access condition such that an operation will be performed only if resource's current sequence * number is less than or equal to the specified value. This condition only applies to page blobs. * * @param sequenceNumber * The value to compare to the current sequence number. * * @return An <code>AccessCondition</code> object that represents the <i>If-Sequence-Number-LE</i> condition. */ public static AccessCondition generateIfSequenceNumberLessThanOrEqualCondition(long sequenceNumber) { AccessCondition retCondition = new AccessCondition(); retCondition.ifSequenceNumberLessThanOrEqual = sequenceNumber; return retCondition; }
/** * Returns an access condition such that an operation will be performed only if resource's current sequence * number is equal to the specified value. This condition only applies to page blobs. * * @param sequenceNumber * The value to compare to the current sequence number. * * @return An <code>AccessCondition</code> object that represents the <i>If-Sequence-Number-EQ</i> condition. */ public static AccessCondition generateIfSequenceNumberEqualCondition(long sequenceNumber) { AccessCondition retCondition = new AccessCondition(); retCondition.ifSequenceNumberEqual = sequenceNumber; return retCondition; }
/** * Returns an access condition such that an operation will be performed only if resource's current sequence * number is less than the specified value. This condition only applies to page blobs. * * @param sequenceNumber * The value to compare to the current sequence number. * * @return An <code>AccessCondition</code> object that represents the <i>If-Sequence-Number-LT</i> condition. */ public static AccessCondition generateIfSequenceNumberLessThanCondition(long sequenceNumber) { AccessCondition retCondition = new AccessCondition(); retCondition.ifSequenceNumberLessThan = sequenceNumber; return retCondition; }
/** * Returns an access condition such that an operation will be performed only if resource's current sequence * number is less than or equal to the specified value. This condition only applies to page blobs. * * @param sequenceNumber * The value to compare to the current sequence number. * * @return An <code>AccessCondition</code> object that represents the <i>If-Sequence-Number-LE</i> condition. */ public static AccessCondition generateIfSequenceNumberLessThanOrEqualCondition(long sequenceNumber) { AccessCondition retCondition = new AccessCondition(); retCondition.ifSequenceNumberLessThanOrEqual = sequenceNumber; return retCondition; }
/** * Returns an access condition such that an operation will be performed only if resource's current sequence * number is equal to the specified value. This condition only applies to page blobs. * * @param sequenceNumber * The value to compare to the current sequence number. * * @return An <code>AccessCondition</code> object that represents the <i>If-Sequence-Number-EQ</i> condition. */ public static AccessCondition generateIfSequenceNumberEqualCondition(long sequenceNumber) { AccessCondition retCondition = new AccessCondition(); retCondition.ifSequenceNumberEqual = sequenceNumber; return retCondition; }
/** * Returns an access condition such that an operation will be performed only if resource's current sequence * number is less than the specified value. This condition only applies to page blobs. * * @param sequenceNumber * The value to compare to the current sequence number. * * @return An <code>AccessCondition</code> object that represents the <i>If-Sequence-Number-LT</i> condition. */ public static AccessCondition generateIfSequenceNumberLessThanCondition(long sequenceNumber) { AccessCondition retCondition = new AccessCondition(); retCondition.ifSequenceNumberLessThan = sequenceNumber; return retCondition; }
/** * Returns an access condition such that an operation will be performed only if the resource is accessible under the * specified lease ID. * <p> * For more information, see <a href= 'http://go.microsoft.com/fwlink/?LinkID=224642'>Specifying Conditional Headers * for Blob Service Operations</a>. * * @param leaseID * The lease ID to specify. * * @return An <code>AccessCondition</code> object that represents the lease condition. */ public static AccessCondition generateLeaseCondition(final String leaseID) { AccessCondition retCondition = new AccessCondition(); retCondition.leaseID = leaseID; return retCondition; }
/** * Returns an access condition such that an operation will be performed only if the resource is accessible under the * specified lease ID. * <p> * For more information, see <a href= 'http://go.microsoft.com/fwlink/?LinkID=224642'>Specifying Conditional Headers * for Blob Service Operations</a>. * * @param leaseID * The lease ID to specify. * * @return An <code>AccessCondition</code> object that represents the lease condition. */ public static AccessCondition generateLeaseCondition(final String leaseID) { AccessCondition retCondition = new AccessCondition(); retCondition.leaseID = leaseID; return retCondition; }
/** * Returns an access condition such that an operation will be performed only if the resource exists on the service. * <p> * Setting this access condition modifies the request to include the HTTP <i>If-Match</i> conditional header. * <p> * For more information, see <a href= 'http://go.microsoft.com/fwlink/?LinkID=224642'>Specifying Conditional Headers * for Blob Service Operations</a>. * * @return An <code>AccessCondition</code> object that represents the if exists condition. */ public static AccessCondition generateIfExistsCondition() { AccessCondition retCondition = new AccessCondition(); retCondition.setIfMatch("*"); return retCondition; }
/** * Returns an access condition such that an operation will be performed only if the resource exists on the service. * <p> * Setting this access condition modifies the request to include the HTTP <i>If-Match</i> conditional header. * <p> * For more information, see <a href= 'http://go.microsoft.com/fwlink/?LinkID=224642'>Specifying Conditional Headers * for Blob Service Operations</a>. * * @return An <code>AccessCondition</code> object that represents the if exists condition. */ public static AccessCondition generateIfExistsCondition() { AccessCondition retCondition = new AccessCondition(); retCondition.setIfMatch("*"); return retCondition; }
/** * Returns an access condition such that an operation will be performed only if the resource does not exist on the * service. * <p> * Setting this access condition modifies the request to include the HTTP <i>If-None-Match</i> conditional header. * <p> * For more information, see <a href= 'http://go.microsoft.com/fwlink/?LinkID=224642'>Specifying Conditional Headers * for Blob Service Operations</a>. * * @return An <code>AccessCondition</code> object that represents the if not exists condition. */ public static AccessCondition generateIfNotExistsCondition() { AccessCondition retCondition = new AccessCondition(); retCondition.setIfNoneMatch("*"); return retCondition; }
/** * Returns an access condition such that an operation will be performed only if the resource does not exist on the * service. * <p> * Setting this access condition modifies the request to include the HTTP <i>If-None-Match</i> conditional header. * <p> * For more information, see <a href= 'http://go.microsoft.com/fwlink/?LinkID=224642'>Specifying Conditional Headers * for Blob Service Operations</a>. * * @return An <code>AccessCondition</code> object that represents the if not exists condition. */ public static AccessCondition generateIfNotExistsCondition() { AccessCondition retCondition = new AccessCondition(); retCondition.setIfNoneMatch("*"); return retCondition; }
/** * Releases the lease on the container. * * @param leaseID * The lease ID. */ public void releaseLease(String leaseID, String blobKey) throws Exception { AccessCondition accessCondition = new AccessCondition(); accessCondition.setLeaseID(leaseID); getBlobReference(blobKey).releaseLease(accessCondition); }
/** * Releases the lease on the container. * * @param leaseID * The lease ID. */ public void releaseLease(String leaseID, String blobKey) throws Exception { AccessCondition accessCondition = new AccessCondition(); accessCondition.setLeaseID(leaseID); getBlobReference(blobKey).releaseLease(accessCondition); }
@Test public void testContainerReleaseLease() throws StorageException { // 15 sec String proposedLeaseId = UUID.randomUUID().toString(); String leaseId = this.container.acquireLease(15, proposedLeaseId); AccessCondition condition = new AccessCondition(); condition.setLeaseID(leaseId); OperationContext operationContext1 = new OperationContext(); this.container.releaseLease(condition, null/* BlobRequestOptions */, operationContext1); assertTrue(operationContext1.getLastResult().getStatusCode() == HttpURLConnection.HTTP_OK); // infinite leaseId = this.container.acquireLease(); condition = new AccessCondition(); condition.setLeaseID(leaseId); OperationContext operationContext2 = new OperationContext(); this.container.releaseLease(condition, null/* BlobRequestOptions */, operationContext2); assertTrue(operationContext2.getLastResult().getStatusCode() == HttpURLConnection.HTTP_OK); }
@Override public void recoveryAction(OperationContext context) throws IOException { if (this.getETagLockCondition() == null && (!Utility.isNullOrEmpty(this.getLockedETag()))) { AccessCondition etagLockCondition = new AccessCondition(); etagLockCondition.setIfMatch(this.getLockedETag()); if (accessCondition != null) { etagLockCondition.setLeaseID(accessCondition.getLeaseID()); } this.setETagLockCondition(etagLockCondition); } if (this.getCurrentRequestByteCount() > 0) { this.setOffset(startingOffset + this.getCurrentRequestByteCount()); if (length != null) { this.setLength(length - this.getCurrentRequestByteCount()); } } } };
@Override public void recoveryAction(OperationContext context) throws IOException { if (this.getETagLockCondition() == null && (!Utility.isNullOrEmpty(this.getLockedETag()))) { AccessCondition etagLockCondition = new AccessCondition(); etagLockCondition.setIfMatch(this.getLockedETag()); if (accessCondition != null) { etagLockCondition.setLeaseID(accessCondition.getLeaseID()); } this.setETagLockCondition(etagLockCondition); } if (this.getCurrentRequestByteCount() > 0) { this.setOffset(startingOffset + this.getCurrentRequestByteCount()); if (length != null) { this.setLength(length - this.getCurrentRequestByteCount()); } } } };
@Override public void recoveryAction(OperationContext context) throws IOException { if (this.getETagLockCondition() == null && (!Utility.isNullOrEmpty(this.getLockedETag()))) { AccessCondition etagLockCondition = new AccessCondition(); etagLockCondition.setIfMatch(this.getLockedETag()); if (accessCondition != null) { etagLockCondition.setLeaseID(accessCondition.getLeaseID()); } this.setETagLockCondition(etagLockCondition); } if (this.getCurrentRequestByteCount() > 0) { this.setOffset(startingOffset + this.getCurrentRequestByteCount()); if (lengthFinal != null) { this.setLength(lengthFinal - this.getCurrentRequestByteCount()); } } } };