/** * Converts the specified {@link DeleteObjectsRequest} object to an XML fragment that * can be sent to Amazon S3. * * @param rq * The {@link DeleteObjectsRequest} */ public byte[] convertToXmlByteArray(DeleteObjectsRequest rq) throws SdkClientException { XmlWriter xml = new XmlWriter(); xml.start("Delete"); if ( rq.getQuiet() ) { xml.start("Quiet").value("true").end(); } for (KeyVersion keyVersion : rq.getKeys()) { writeKeyVersion(xml, keyVersion); } xml.end(); return xml.getBytes(); }
/** * Converts the specified {@link DeleteObjectsRequest} object to an XML * fragment that can be sent to Amazon S3. * * @param rq The {@link DeleteObjectsRequest} */ public byte[] convertToXmlByteArray(DeleteObjectsRequest rq) throws AmazonClientException { XmlWriter xml = new XmlWriter(); xml.start("Delete"); if (rq.getQuiet()) { xml.start("Quiet").value("true").end(); } for (KeyVersion keyVersion : rq.getKeys()) { writeKeyVersion(xml, keyVersion); } xml.end(); return xml.getBytes(); }
@Override public DeleteObjectsResult deleteObjects(DeleteObjectsRequest deleteObjectsRequest) throws AmazonClientException, AmazonServiceException { maybeFail(); for (DeleteObjectsRequest.KeyVersion keyVersion : deleteObjectsRequest.getKeys()) { registerDeleteObject(keyVersion.getKey(), deleteObjectsRequest.getBucketName()); } return super.deleteObjects(deleteObjectsRequest); }
@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); }
/** * Converts the specified {@link DeleteObjectsRequest} object to an XML fragment that * can be sent to Amazon S3. * * @param rq * The {@link DeleteObjectsRequest} */ public byte[] convertToXmlByteArray(DeleteObjectsRequest rq) throws SdkClientException { XmlWriter xml = new XmlWriter(); xml.start("Delete"); if ( rq.getQuiet() ) { xml.start("Quiet").value("true").end(); } for (KeyVersion keyVersion : rq.getKeys()) { writeKeyVersion(xml, keyVersion); } xml.end(); return xml.getBytes(); }
/** * Converts the specified {@link DeleteObjectsRequest} object to an XML * fragment that can be sent to Amazon S3. * * @param rq The {@link DeleteObjectsRequest} */ public byte[] convertToXmlByteArray(DeleteObjectsRequest rq) throws AmazonClientException { XmlWriter xml = new XmlWriter(); xml.start("Delete"); if (rq.getQuiet()) { xml.start("Quiet").value("true").end(); } for (KeyVersion keyVersion : rq.getKeys()) { writeKeyVersion(xml, keyVersion); } xml.end(); return xml.getBytes(); }