Skip to content

Commit

Permalink
#115656 fix S3 File upload (#1439)
Browse files Browse the repository at this point in the history
  • Loading branch information
Klaas-Ritense authored Jun 24, 2024
1 parent 36214fc commit ff776b4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,12 @@ public RelatedJsonSchemaDocumentAvailableEventListenerImpl relatedDocumentAvaila
}

@Bean
@ConditionalOnBean(ResourceService.class)
@ConditionalOnMissingBean(DocumentRelatedFileSubmittedEventListenerImpl.class)
public DocumentRelatedFileSubmittedEventListenerImpl documentRelatedFileSubmittedEventListener(
final DocumentService documentService,
final ResourceService resourceService
final Optional<ResourceService> resourceServiceOpt
) {
return new DocumentRelatedFileSubmittedEventListenerImpl(documentService, resourceService);
return new DocumentRelatedFileSubmittedEventListenerImpl(documentService, resourceServiceOpt);
}

//API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,29 @@
import com.ritense.valtimo.contract.document.event.DocumentRelatedFileSubmittedEvent;
import com.ritense.valtimo.contract.listener.DocumentRelatedFileEventListener;
import com.ritense.valtimo.contract.utils.SecurityUtils;
import java.util.Optional;

public class DocumentRelatedFileSubmittedEventListenerImpl implements DocumentRelatedFileEventListener {

private final DocumentService documentService;
private final ResourceService resourceService;
private final Optional<ResourceService> resourceServiceOpt;

public DocumentRelatedFileSubmittedEventListenerImpl(DocumentService documentService, ResourceService resourceService) {
public DocumentRelatedFileSubmittedEventListenerImpl(DocumentService documentService, Optional<ResourceService> resourceServiceOpt) {
this.documentService = documentService;
this.resourceService = resourceService;
this.resourceServiceOpt = resourceServiceOpt;
}

@Override
public void handle(DocumentRelatedFileSubmittedEvent event) {
var resource = resourceService.getResource(event.getResourceId());
runWithoutAuthorization(() -> {
documentService.assignRelatedFile(
JsonSchemaDocumentId.existingId(event.getDocumentId()),
JsonSchemaRelatedFile.from(resource).withCreatedBy(SecurityUtils.getCurrentUserLogin())
);
return null;
resourceServiceOpt.ifPresent(resourceService -> {
var resource = resourceService.getResource(event.getResourceId());
runWithoutAuthorization(() -> {
documentService.assignRelatedFile(
JsonSchemaDocumentId.existingId(event.getDocumentId()),
JsonSchemaRelatedFile.from(resource).withCreatedBy(SecurityUtils.getCurrentUserLogin())
);
return null;
});
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.ritense.resource.service

import com.ritense.resource.BaseIntegrationTest
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.assertThrows
Expand All @@ -34,6 +35,7 @@ class TemporaryResourceStorageDeletionServiceIntegrationTest @Autowired construc
private val temporaryResourceStorageDeletionService: TemporaryResourceStorageDeletionService
) : BaseIntegrationTest() {

@Disabled("https://github.com/gradle/gradle/issues/27871")
@Test
fun `should delete files older that 60 minutes`() {
val resourceId = temporaryResourceStorageService.store("My file data".byteInputStream())
Expand Down

0 comments on commit ff776b4

Please sign in to comment.