use of org.apache.hadoop.ozone.s3.endpoint.MultiDeleteResponse.DeletedObject in project ozone by apache.
the class BucketEndpoint method multiDelete.
/**
* Implement multi delete.
* <p>
* see: https://docs.aws.amazon
* .com/AmazonS3/latest/API/multiobjectdeleteapi.html
*/
@POST
@Produces(MediaType.APPLICATION_XML)
public MultiDeleteResponse multiDelete(@PathParam("bucket") String bucketName, @QueryParam("delete") String delete, MultiDeleteRequest request) throws OS3Exception, IOException {
S3GAction s3GAction = S3GAction.MULTI_DELETE;
OzoneBucket bucket = getBucket(bucketName);
MultiDeleteResponse result = new MultiDeleteResponse();
if (request.getObjects() != null) {
for (DeleteObject keyToDelete : request.getObjects()) {
try {
bucket.deleteKey(keyToDelete.getKey());
if (!request.isQuiet()) {
result.addDeleted(new DeletedObject(keyToDelete.getKey()));
}
} catch (OMException ex) {
if (ex.getResult() == ResultCodes.PERMISSION_DENIED) {
result.addError(new Error(keyToDelete.getKey(), "PermissionDenied", ex.getMessage()));
} else if (ex.getResult() != ResultCodes.KEY_NOT_FOUND) {
result.addError(new Error(keyToDelete.getKey(), "InternalError", ex.getMessage()));
} else if (!request.isQuiet()) {
result.addDeleted(new DeletedObject(keyToDelete.getKey()));
}
} catch (Exception ex) {
result.addError(new Error(keyToDelete.getKey(), "InternalError", ex.getMessage()));
}
}
}
if (result.getErrors().size() != 0) {
AUDIT.logWriteFailure(buildAuditMessageForFailure(s3GAction, getAuditParameters(), new Exception("MultiDelete Exception")));
} else {
AUDIT.logWriteSuccess(buildAuditMessageForSuccess(s3GAction, getAuditParameters()));
}
return result;
}
Aggregations