Skip to content

Commit

Permalink
[fix] recycle 500 에러 대응 (#139)
Browse files Browse the repository at this point in the history
* [fix] list 생성 방식 수정 #136

* [chore] spotless 적용 #136
  • Loading branch information
wjdtkdgns authored Aug 25, 2023
1 parent 037165e commit 54df1e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import allchive.server.infrastructure.s3.service.S3DeleteObjectService;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional;

Expand Down Expand Up @@ -60,24 +61,23 @@ public void execute(ClearDeletedObjectRequest request) {

private void deleteS3Object(List<Content> contents, List<Archiving> archivings) {
List<String> imageKeys =
new ArrayList<>(
archivings.stream()
.map(Archiving::getImageUrl)
.filter(url -> !url.isEmpty())
.filter(url -> !url.startsWith("http"))
.toList());
archivings.stream()
.map(Archiving::getImageUrl)
.filter(url -> !url.isEmpty())
.filter(url -> !url.startsWith("http"))
.collect(Collectors.toList());
imageKeys.addAll(
contents.stream()
.filter(content -> content.getContentType().equals(ContentType.IMAGE))
.map(Content::getImageUrl)
.filter(url -> !url.isEmpty())
.filter(url -> !url.startsWith("http"))
.toList());
.collect(Collectors.toList()));
s3DeleteObjectService.deleteS3Object(imageKeys);
}

private List<Long> getContentsId(List<Content> contents, ClearDeletedObjectRequest request) {
List<Long> contentsId = contents.stream().map(Content::getId).toList();
List<Long> contentsId = contents.stream().map(Content::getId).collect(Collectors.toList());
if (!request.getContentIds().isEmpty()) {
if (contentsId.isEmpty()) {
contentsId = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
Expand Down Expand Up @@ -63,19 +64,18 @@ public void executeSchedule() {

private void deleteS3Object(List<Content> contents, List<Archiving> archivings) {
List<String> imageKeys =
new ArrayList<>(
archivings.stream()
.map(Archiving::getImageUrl)
.filter(url -> !url.isEmpty())
.filter(url -> !url.startsWith("http"))
.toList());
archivings.stream()
.map(Archiving::getImageUrl)
.filter(url -> !url.isEmpty())
.filter(url -> !url.startsWith("http"))
.collect(Collectors.toList());
imageKeys.addAll(
contents.stream()
.filter(content -> content.getContentType().equals(ContentType.IMAGE))
.map(Content::getImageUrl)
.filter(url -> !url.isEmpty())
.filter(url -> !url.startsWith("http"))
.toList());
.collect(Collectors.toList()));
s3DeleteObjectService.deleteS3Object(imageKeys);
}

Expand All @@ -91,7 +91,7 @@ private List<Long> getContentsId(List<Recycle> recycles, List<Content> contents)
recycles.stream()
.filter(recycle -> recycle.getRecycleType().equals(RecycleType.CONTENT))
.map(Recycle::getContentId)
.toList();
.collect(Collectors.toList());

if (contentIds.isEmpty()) {
contentIds = new ArrayList<>();
Expand Down

0 comments on commit 54df1e6

Please sign in to comment.