com.amazonaws.services.s3.model.DeleteObjectsResult.DeletedObject Java Examples
The following examples show how to use
com.amazonaws.services.s3.model.DeleteObjectsResult.DeletedObject.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeleteMultipleObjectsVersionEnabledBucket.java From aws-doc-sdk-examples with Apache License 2.0 | 5 votes |
private static void multiObjectVersionedDeleteRemoveDeleteMarkers(DeleteObjectsResult response) { List<KeyVersion> keyList = new ArrayList<KeyVersion>(); for (DeletedObject deletedObject : response.getDeletedObjects()) { // Note that the specified version ID is the version ID for the delete marker. keyList.add(new KeyVersion(deletedObject.getKey(), deletedObject.getDeleteMarkerVersionId())); } // Create a request to delete the delete markers. DeleteObjectsRequest deleteRequest = new DeleteObjectsRequest(VERSIONED_BUCKET_NAME).withKeys(keyList); // Delete the delete markers, leaving the objects intact in the bucket. DeleteObjectsResult delObjRes = S3_CLIENT.deleteObjects(deleteRequest); int successfulDeletes = delObjRes.getDeletedObjects().size(); System.out.println(successfulDeletes + " delete markers successfully deleted"); }
Example #2
Source File: MockS3OperationsImpl.java From herd with Apache License 2.0 | 5 votes |
@Override public DeleteObjectsResult deleteObjects(DeleteObjectsRequest deleteObjectsRequest, AmazonS3 s3Client) { LOGGER.debug("deleteObjects(): deleteObjectRequest.getBucketName() = " + deleteObjectsRequest.getBucketName() + ", deleteObjectRequest.getKeys() = " + deleteObjectsRequest.getKeys()); List<DeletedObject> deletedObjects = new ArrayList<>(); MockS3Bucket mockS3Bucket = mockS3Buckets.get(deleteObjectsRequest.getBucketName()); for (KeyVersion keyVersion : deleteObjectsRequest.getKeys()) { String s3ObjectKey = keyVersion.getKey(); String s3ObjectVersion = keyVersion.getVersion(); String s3ObjectKeyVersion = s3ObjectKey + (s3ObjectVersion != null ? s3ObjectVersion : ""); mockS3Bucket.getObjects().remove(s3ObjectKey); if (mockS3Bucket.getVersions().remove(s3ObjectKeyVersion) != null) { DeletedObject deletedObject = new DeletedObject(); deletedObject.setKey(s3ObjectKey); deletedObject.setVersionId(s3ObjectVersion); deletedObjects.add(deletedObject); } } return new DeleteObjectsResult(deletedObjects); }
Example #3
Source File: AmazonS3Stub.java From aws-java-sdk-stubs with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} * * The stub does not currently support versions so this stub only supports full deletes of the objects. Passing in a * list of KeyVersion specs to be deleted will completely delete those objects from the stubs. * * @see com.amazonaws.services.s3.AmazonS3#deleteObjects(com.amazonaws.services.s3.model.DeleteObjectsRequest) */ @Override public DeleteObjectsResult deleteObjects(final DeleteObjectsRequest deleteObjectsRequest) { final List<DeleteObjectsResult.DeletedObject> deletedObjects = new ArrayList<DeletedObject>(); final BucketInfo bucket = getBucketInfo(deleteObjectsRequest.getBucketName()); for (final KeyVersion key : deleteObjectsRequest.getKeys()) { final boolean found = bucket.deleteObject(key.getKey()); if (!deleteObjectsRequest.getQuiet() && found) { final DeleteObjectsResult.DeletedObject result = new DeleteObjectsResult.DeletedObject(); result.setKey(key.getKey()); deletedObjects.add(result); } } return new DeleteObjectsResult(deletedObjects); }
Example #4
Source File: XmlResponsesSaxParser.java From flink with Apache License 2.0 | 5 votes |
@Override protected void doStartElement( String uri, String name, String qName, Attributes attrs) { if (in("DeleteResult")) { if (name.equals("Deleted")) { currentDeletedObject = new DeletedObject(); } else if (name.equals("Error")) { currentError = new DeleteError(); } } }