From 92757417f7ab1b599ef2b662d3b6580ed1a31f95 Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Mon, 18 Dec 2023 16:33:28 +0100 Subject: [PATCH] The bitstream is removed from the S3 and local assetstore --- .../storage/bitstore/ClarinS3BitStoreService.java | 14 ++++++++++++++ .../dspace/storage/bitstore/S3BitStoreService.java | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/dspace-api/src/main/java/org/dspace/storage/bitstore/ClarinS3BitStoreService.java b/dspace-api/src/main/java/org/dspace/storage/bitstore/ClarinS3BitStoreService.java index 5ca5affe4cb3..8aeef77ae6fd 100644 --- a/dspace-api/src/main/java/org/dspace/storage/bitstore/ClarinS3BitStoreService.java +++ b/dspace-api/src/main/java/org/dspace/storage/bitstore/ClarinS3BitStoreService.java @@ -71,4 +71,18 @@ public void put(Bitstream bitstream, InputStream in) throws IOException { } } } + + @Override + public void remove(Bitstream bitstream) throws IOException { + String key = getFullKey(bitstream.getInternalId()); + try { + // Remove file from S3 + s3Service.deleteObject(getBucketName(), key); + // Remove file from local assetstore + dsBitStoreService.remove(bitstream); + } catch (AmazonClientException e) { + log.error("remove(" + key + ")", e); + throw new IOException(e); + } + } } diff --git a/dspace-api/src/main/java/org/dspace/storage/bitstore/S3BitStoreService.java b/dspace-api/src/main/java/org/dspace/storage/bitstore/S3BitStoreService.java index afae56e964cc..1ad4c33f8213 100644 --- a/dspace-api/src/main/java/org/dspace/storage/bitstore/S3BitStoreService.java +++ b/dspace-api/src/main/java/org/dspace/storage/bitstore/S3BitStoreService.java @@ -110,7 +110,7 @@ public class S3BitStoreService extends BaseBitStoreService { /** * S3 service */ - private AmazonS3 s3Service = null; + protected AmazonS3 s3Service = null; /** * S3 transfer manager