@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(); } } }
@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); }
/** * {@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); }
public MultiObjectDeleteException(Collection<DeleteError> errors, Collection<DeletedObject> deletedObjects) { super("One or more objects could not be deleted"); this.deletedObjects.addAll(deletedObjects); this.errors.addAll(errors); }
public DeleteObjectsResponse() { this(new ArrayList<DeletedObject>(), new ArrayList<DeleteError>()); }
public DeleteObjectsResponse(List<DeletedObject> deletedObjects, List<DeleteError> errors) { this.deletedObjects = deletedObjects; this.errors = errors; }
public List<DeletedObject> getDeletedObjects() { return deletedObjects; }
public void setDeletedObjects(List<DeletedObject> deletedObjects) { this.deletedObjects = deletedObjects; }
/** * Returns the list of successfully deleted objects from this request. If * {@link DeleteObjectsRequest#getQuiet()} is true, only error responses * will be returned from s3. */ public List<DeletedObject> getDeletedObjects() { return deletedObjects; }