Skip to content
This repository was archived by the owner on Jul 19, 2024. It is now read-only.

Commit e8c9edb

Browse files
rickle-msftzezha-msft
authored andcommitted
soft delete server updates
1 parent 8b69f61 commit e8c9edb

File tree

11 files changed

+14
-252
lines changed

11 files changed

+14
-252
lines changed

microsoft-azure-storage-test/src/com/microsoft/azure/storage/ServicePropertiesTests.java

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -408,20 +408,20 @@ public void testValidDeleteRetentionPolicy() throws StorageException, Interrupte
408408
ServiceClient client = TestHelper.createCloudBlobClient();
409409

410410
// average setting
411-
testValidDeleteRetentionPolicy(client, true, 5, 3);
411+
testValidDeleteRetentionPolicy(client, true, 5);
412412

413413
// minimum setting
414-
testValidDeleteRetentionPolicy(client, true, 1, 1);
414+
testValidDeleteRetentionPolicy(client, true, 1);
415415

416416
// maximum setting
417-
testValidDeleteRetentionPolicy(client, true, 365, 10);
417+
testValidDeleteRetentionPolicy(client, true, 365);
418418

419419
// disable setting
420-
testValidDeleteRetentionPolicy(client, false, 5, 3);
420+
testValidDeleteRetentionPolicy(client, false, 5);
421421
}
422422

423423
private void testValidDeleteRetentionPolicy(ServiceClient client, boolean enabled,
424-
Integer interval, Integer retainedVersionsPerBlob)
424+
Integer interval)
425425
throws StorageException, InterruptedException {
426426

427427
try {
@@ -431,14 +431,12 @@ private void testValidDeleteRetentionPolicy(ServiceClient client, boolean enable
431431
if (enabled) {
432432
expectedServiceProperties.getDeleteRetentionPolicy().setEnabled(true);
433433
expectedServiceProperties.getDeleteRetentionPolicy().setRetentionIntervalInDays(interval);
434-
expectedServiceProperties.getDeleteRetentionPolicy().setRetainedVersionsPerBlob(retainedVersionsPerBlob);
435434
callUploadServiceProps(client, expectedServiceProperties, null);
436435
} else {
437436
// interval and retained versions per blob would both be ignored by the service in case the policy is not enabled
438437
ServiceProperties propertiesToUpload = new ServiceProperties();
439438
propertiesToUpload.getDeleteRetentionPolicy().setEnabled(false);
440439
propertiesToUpload.getDeleteRetentionPolicy().setRetentionIntervalInDays(interval);
441-
propertiesToUpload.getDeleteRetentionPolicy().setRetainedVersionsPerBlob(retainedVersionsPerBlob);
442440

443441
expectedServiceProperties.getDeleteRetentionPolicy().setEnabled(false);
444442
callUploadServiceProps(client, propertiesToUpload, null);
@@ -466,32 +464,21 @@ public void testInvalidDeleteRetentionPolicy() throws StorageException, Interrup
466464
ServiceClient client = TestHelper.createCloudBlobClient();
467465

468466
// Should not work with 0 days
469-
testInvalidDeleteRetentionPolicy(client, true, 0, 1);
467+
testInvalidDeleteRetentionPolicy(client, true, 0);
470468

471469
// Should not work with <0 days
472-
testInvalidDeleteRetentionPolicy(client, true, 0, -1);
473-
474-
// Should not work with 0 retained versions per blob
475-
testInvalidDeleteRetentionPolicy(client, true, 1, 0);
476-
477-
// Should not work with <0 retained versions per blob
478-
testInvalidDeleteRetentionPolicy(client, true, -1, 0);
470+
testInvalidDeleteRetentionPolicy(client, true, -1);
479471

480472
// Should not work with 366 days
481-
testInvalidDeleteRetentionPolicy(client, true, 366, 1);
473+
testInvalidDeleteRetentionPolicy(client, true, 366);
482474

483-
// Should not work with 11 retained_versions_per_blob
484-
testInvalidDeleteRetentionPolicy(client, true, 1, 11);
485475

486476
// Should not work with interval as null
487-
testInvalidDeleteRetentionPolicy(client, true, null, 1);
488-
489-
// Should not work with retained versions per blob as null
490-
testInvalidDeleteRetentionPolicy(client, true, 1, null);
477+
testInvalidDeleteRetentionPolicy(client, true, null);
491478
}
492479

493480
private void testInvalidDeleteRetentionPolicy(ServiceClient client, boolean enabled,
494-
Integer interval, Integer retainedVersionsPerBlob)
481+
Integer interval)
495482
throws StorageException, InterruptedException {
496483

497484
// Arrange
@@ -505,7 +492,6 @@ private void testInvalidDeleteRetentionPolicy(ServiceClient client, boolean enab
505492
serviceProperties.getDeleteRetentionPolicy().setEnabled(false);
506493
}
507494
serviceProperties.getDeleteRetentionPolicy().setRetentionIntervalInDays(interval);
508-
serviceProperties.getDeleteRetentionPolicy().setRetainedVersionsPerBlob(retainedVersionsPerBlob);
509495

510496
// Failure is expected since the retention policy is invalid
511497
try {
@@ -539,7 +525,6 @@ public void testEmptyDeleteRetentionPolicy() throws StorageException, Interrupte
539525
currentServiceProperties.setDefaultServiceVersion(Constants.HeaderConstants.TARGET_STORAGE_VERSION);
540526
currentServiceProperties.getDeleteRetentionPolicy().setEnabled(true);
541527
currentServiceProperties.getDeleteRetentionPolicy().setRetentionIntervalInDays(5);
542-
currentServiceProperties.getDeleteRetentionPolicy().setRetainedVersionsPerBlob(3);
543528
callUploadServiceProps(client, currentServiceProperties, null);
544529

545530
// verify
@@ -1141,7 +1126,6 @@ private static void assertServicePropertiesAreEqual(ServiceProperties propsA, Se
11411126
if (propsA.getDeleteRetentionPolicy() != null && propsB.getDeleteRetentionPolicy() != null) {
11421127
assertEquals(propsA.getDeleteRetentionPolicy().getEnabled(), propsB.getDeleteRetentionPolicy().getEnabled());
11431128
assertEquals(propsA.getDeleteRetentionPolicy().getRetentionIntervalInDays(), propsB.getDeleteRetentionPolicy().getRetentionIntervalInDays());
1144-
assertEquals(propsA.getDeleteRetentionPolicy().getRetainedVersionsPerBlob(), propsB.getDeleteRetentionPolicy().getRetainedVersionsPerBlob());
11451129
}
11461130
else {
11471131
assertNull(propsA.getDeleteRetentionPolicy());

microsoft-azure-storage-test/src/com/microsoft/azure/storage/blob/BlobTestHelper.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,6 @@ public static void enableSoftDelete() throws StorageException, URISyntaxExceptio
442442
ServiceProperties serviceProperties = new ServiceProperties();
443443
serviceProperties.getDeleteRetentionPolicy().setEnabled(true);
444444
serviceProperties.getDeleteRetentionPolicy().setRetentionIntervalInDays(3);
445-
serviceProperties.getDeleteRetentionPolicy().setRetainedVersionsPerBlob(3);
446445

447446
CloudBlobClient bClient = TestHelper.createCloudBlobClient();
448447
bClient.uploadServiceProperties(serviceProperties);

microsoft-azure-storage-test/src/com/microsoft/azure/storage/blob/CloudBlockBlobTests.java

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,6 @@ public void testSoftDeleteBlockBlobWithoutSnapshot() throws StorageException, UR
213213
count++;
214214
}
215215
assertEquals(count, 1);
216-
217-
// permanently delete the blob after soft-deleting it first
218-
blob.delete();
219-
blob.deletePermanently();
220-
assertTrue(blob.deleted);
221-
222-
// the list call should return nothing now
223-
assertFalse(this.container.listBlobs(null, true, EnumSet.allOf(BlobListingDetails.class), null,
224-
null).iterator().hasNext());
225216
}
226217
finally {
227218
BlobTestHelper.disableSoftDelete();
@@ -283,22 +274,6 @@ public void testSoftDeleteSingleBlobSnapshot() throws StorageException, URISynta
283274
count++;
284275
}
285276
assertEquals(count, 2);
286-
287-
// permanently delete the snapshot after soft-deleting it first
288-
snapshot.delete();
289-
snapshot.deletePermanently();
290-
assertTrue(snapshot.deleted);
291-
292-
// the list call should return just the blob now
293-
count = 0;
294-
for (ListBlobItem listBlobItem : this.container.listBlobs(null, true, EnumSet.allOf(BlobListingDetails.class), null,
295-
null)) {
296-
CloudBlockBlob blobItem = (CloudBlockBlob) listBlobItem;
297-
assertEquals(blobItem.getName(), blob.getName());
298-
assertBlobNotDeleted(blobItem);
299-
count++;
300-
}
301-
assertEquals(count, 1);
302277
}
303278
finally {
304279
BlobTestHelper.disableSoftDelete();
@@ -363,21 +338,6 @@ public void testSoftDeleteOnlyBlobSnapshots() throws StorageException, URISyntax
363338
count++;
364339
}
365340
assertEquals(count, 3);
366-
367-
// permanently delete the snapshots after soft-deleting them first
368-
blob.delete(DeleteSnapshotsOption.DELETE_SNAPSHOTS_ONLY, null, null, null);
369-
blob.deletePermanently(DeleteSnapshotsOption.DELETE_SNAPSHOTS_ONLY, null, null, null);
370-
371-
// the list call should return just the blob now
372-
count = 0;
373-
for (ListBlobItem listBlobItem : this.container.listBlobs(null, true, EnumSet.allOf(BlobListingDetails.class), null,
374-
null)) {
375-
CloudBlockBlob blobItem = (CloudBlockBlob) listBlobItem;
376-
assertEquals(blobItem.getName(), blob.getName());
377-
assertBlobNotDeleted(blobItem);
378-
count++;
379-
}
380-
assertEquals(count, 1);
381341
}
382342
finally {
383343
BlobTestHelper.disableSoftDelete();
@@ -438,15 +398,6 @@ public void testSoftDeleteBlobIncludingSnapshots() throws StorageException, URIS
438398
count++;
439399
}
440400
assertEquals(count, 3);
441-
442-
// permanently delete the blob and snapshots after soft-deleting them first
443-
blob.delete(DeleteSnapshotsOption.INCLUDE_SNAPSHOTS, null, null, null);
444-
blob.deletePermanently(DeleteSnapshotsOption.INCLUDE_SNAPSHOTS, null, null, null);
445-
assertTrue(blob.deleted);
446-
447-
// the list call should return nothing now
448-
assertFalse(this.container.listBlobs(null, true, EnumSet.allOf(BlobListingDetails.class), null,
449-
null).iterator().hasNext());
450401
}
451402
finally {
452403
BlobTestHelper.disableSoftDelete();
@@ -514,15 +465,6 @@ public void testSoftDeleteBlobWithLease() throws StorageException, URISyntaxExce
514465
count++;
515466
}
516467
assertEquals(count, 1);
517-
518-
// permanently delete the blob after soft-deleting it first
519-
blob.delete();
520-
blob.deletePermanently();
521-
assertTrue(blob.deleted);
522-
523-
// the list call should return nothing now
524-
assertFalse(this.container.listBlobs(null, true, EnumSet.allOf(BlobListingDetails.class), null,
525-
null).iterator().hasNext());
526468
}
527469
finally {
528470
BlobTestHelper.disableSoftDelete();

microsoft-azure-storage/src/com/microsoft/azure/storage/Constants.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,6 @@ public static class AnalyticsConstants {
227227
* The XML element for the delete retention policy.
228228
*/
229229
public static final String DELETE_RETENTION_POLICY_ELEMENT = "DeleteRetentionPolicy";
230-
231-
/**
232-
* The XML element for the retained versions per blob.
233-
*/
234-
public static final String RETAINED_VERSIONS_PER_BLOB = "RetainedVersionsPerBlob";
235-
236230
}
237231

238232
/**
@@ -833,16 +827,6 @@ public static class QueryConstants {
833827
*/
834828
public static final String UNDELETE = "undelete";
835829

836-
/**
837-
* The query component for delete type.
838-
*/
839-
public static final String DELETE_TYPE = "deletetype";
840-
841-
/**
842-
* The query component for permanent delete type.
843-
*/
844-
public static final String PERMANENT_DELETE = "permanent";
845-
846830
/**
847831
* The query component for the SAS start partition key.
848832
*/

microsoft-azure-storage/src/com/microsoft/azure/storage/DeleteRetentionPolicy.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@ public class DeleteRetentionPolicy {
3131
*/
3232
private Integer retentionIntervalInDays;
3333

34-
/**
35-
* Required only if Enabled is true. Indicates the number of deleted version of each blob should be retained.
36-
* After reaching this limit blob service permanently deletes the oldest deleted version of blob.
37-
* The minimum value you can specify is 1; the largest value is 10.
38-
*/
39-
private Integer retainedVersionsPerBlob;
40-
4134
/**
4235
* Return a Boolean indicating whether the DeleteRetentionPolicy is enabled.
4336
*
@@ -56,15 +49,6 @@ public Integer getRetentionIntervalInDays() {
5649
return this.retentionIntervalInDays;
5750
}
5851

59-
/**
60-
* Get the number of versions retained for each deleted blob.
61-
*
62-
* @return An <code>Integer</code> which contains the number of versions retained for each deleted blob.
63-
*/
64-
public Integer getRetainedVersionsPerBlob() {
65-
return this.retainedVersionsPerBlob;
66-
}
67-
6852
/**
6953
* Set the Boolean indicating whether the DeleteRetentionPolicy is enabled.
7054
* @param enabled indicates whether the DeleteRetentionPolicy is enabled.
@@ -80,12 +64,4 @@ public void setEnabled(boolean enabled) {
8064
public void setRetentionIntervalInDays(final Integer retentionIntervalInDays) {
8165
this.retentionIntervalInDays = retentionIntervalInDays;
8266
}
83-
84-
/**
85-
* Set the number of versions of a deleted blob to keep.
86-
* @param retainedVersionsPerBlob represents the number of versions to retain for a deleted blob.
87-
*/
88-
public void setRetainedVersionsPerBlob(final Integer retainedVersionsPerBlob) {
89-
this.retainedVersionsPerBlob = retainedVersionsPerBlob;
90-
}
9167
}

microsoft-azure-storage/src/com/microsoft/azure/storage/ServicePropertiesHandler.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,6 @@ else if (Constants.AnalyticsConstants.DAYS_ELEMENT.equals(currentNode)) {
232232
this.props.getDeleteRetentionPolicy().setRetentionIntervalInDays(Integer.parseInt(value));
233233
}
234234
}
235-
else if (Constants.AnalyticsConstants.RETAINED_VERSIONS_PER_BLOB.equals(currentNode)) {
236-
if (value != null) {
237-
this.props.getDeleteRetentionPolicy().setRetainedVersionsPerBlob(Integer.parseInt(value));
238-
}
239-
}
240235
}
241236

242237
this.bld = new StringBuilder();

microsoft-azure-storage/src/com/microsoft/azure/storage/ServicePropertiesSerializer.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,6 @@ private static void writeDeleteRetentionPolicy(final XMLStreamWriter xmlw, final
118118
xmlw.writeStartElement(Constants.AnalyticsConstants.DAYS_ELEMENT);
119119
xmlw.writeCharacters(deleteRetentionPolicy.getRetentionIntervalInDays().toString());
120120
xmlw.writeEndElement();
121-
122-
xmlw.writeStartElement(Constants.AnalyticsConstants.RETAINED_VERSIONS_PER_BLOB);
123-
xmlw.writeCharacters(deleteRetentionPolicy.getRetainedVersionsPerBlob().toString());
124-
xmlw.writeEndElement();
125121
}
126122

127123
// end deleteRetentionPolicy

microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobRequest.java

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,6 @@ public static HttpURLConnection createContainer(final URI uri, final BlobRequest
313313
*
314314
* @param uri
315315
* The absolute URI to the container.
316-
* @param timeout
317-
* The server timeout interval.
318316
* @param query
319317
* The query builder to use.
320318
* @param blobOptions
@@ -351,8 +349,6 @@ private static HttpURLConnection createURLConnection(final URI uri, final UriQue
351349
* The snapshot version, if the blob is a snapshot.
352350
* @param deleteSnapshotsOption
353351
* A set of options indicating whether to delete only blobs, only snapshots, or both.
354-
* @param deleteType
355-
* The option to indicate whether the delete is permanent or not.
356352
* @return a HttpURLConnection to use to perform the operation.
357353
* @throws IOException
358354
* if there is an error opening the connection
@@ -364,7 +360,7 @@ private static HttpURLConnection createURLConnection(final URI uri, final UriQue
364360
*/
365361
public static HttpURLConnection deleteBlob(final URI uri, final BlobRequestOptions blobOptions,
366362
final OperationContext opContext, final AccessCondition accessCondition, final String snapshotVersion,
367-
final DeleteSnapshotsOption deleteSnapshotsOption, final DeleteType deleteType)
363+
final DeleteSnapshotsOption deleteSnapshotsOption)
368364
throws IOException, URISyntaxException, StorageException {
369365

370366
if (snapshotVersion != null && deleteSnapshotsOption != DeleteSnapshotsOption.NONE) {
@@ -375,15 +371,6 @@ public static HttpURLConnection deleteBlob(final URI uri, final BlobRequestOptio
375371
final UriQueryBuilder builder = new UriQueryBuilder();
376372
BlobRequest.addSnapshot(builder, snapshotVersion);
377373

378-
switch (deleteType) {
379-
case NONE: // the delete type should be ignored if it's none
380-
break;
381-
case PERMANENT:
382-
builder.add(Constants.QueryConstants.DELETE_TYPE, Constants.QueryConstants.PERMANENT_DELETE);
383-
default:
384-
break;
385-
}
386-
387374
final HttpURLConnection request = BaseRequest.delete(uri, blobOptions, builder, opContext);
388375

389376
if (accessCondition != null) {
@@ -474,8 +461,6 @@ public static HttpURLConnection deleteContainer(final URI uri, final BlobRequest
474461
*
475462
* @param uri
476463
* The absolute URI to the container.
477-
* @param timeout
478-
* The server timeout interval.
479464
* @param accessCondition
480465
* An {@link AccessCondition} object that represents the access conditions for the container.
481466
* @param opContext
@@ -872,9 +857,6 @@ private static HttpURLConnection getProperties(final URI uri, final BlobRequestO
872857
* @param breakPeriodInSeconds
873858
* Specifies the amount of time to allow the lease to remain, in seconds.
874859
* If null, the break period is the remainder of the current lease, or zero for infinite leases.
875-
* @param visibilityTimeoutInSeconds
876-
* Specifies the the span of time for which to acquire the lease, in seconds.
877-
* If null, an infinite lease will be acquired. If not null, this must be greater than zero.
878860
* @return a HttpURLConnection to use to perform the operation.
879861
* @throws IOException
880862
* if there is an error opening the connection
@@ -947,9 +929,6 @@ private static HttpURLConnection lease(final URI uri, final BlobRequestOptions b
947929
* @param breakPeriodInSeconds
948930
* Specifies the amount of time to allow the lease to remain, in seconds.
949931
* If null, the break period is the remainder of the current lease, or zero for infinite leases.
950-
* @param visibilityTimeoutInSeconds
951-
* Specifies the the span of time for which to acquire the lease, in seconds.
952-
* If null, an infinite lease will be acquired. If not null, this must be greater than zero.
953932
* @return a HttpURLConnection to use to perform the operation.
954933
* @throws IOException
955934
* if there is an error opening the connection
@@ -993,9 +972,6 @@ public static HttpURLConnection leaseBlob(final URI uri, final BlobRequestOption
993972
* @param breakPeriodInSeconds
994973
* Specifies the amount of time to allow the lease to remain, in seconds.
995974
* If null, the break period is the remainder of the current lease, or zero for infinite leases.
996-
* @param visibilityTimeoutInSeconds
997-
* Specifies the the span of time for which to acquire the lease, in seconds.
998-
* If null, an infinite lease will be acquired. If not null, this must be greater than zero.
999975
* @return a HttpURLConnection to use to perform the operation.
1000976
* @throws IOException
1001977
* if there is an error opening the connection

0 commit comments

Comments
 (0)