diff --git a/deployments/dockerfiles/api-service.Dockerfile b/deployments/dockerfiles/api-service.Dockerfile index 2a8606112035afa5d716850d9e5a6847d647fff2..9cd68167a7908c7d42fd6d861587ce35d8d5ce0b 100644 --- a/deployments/dockerfiles/api-service.Dockerfile +++ b/deployments/dockerfiles/api-service.Dockerfile @@ -1,9 +1,9 @@ -FROM maven:3-openjdk-17 as builder +FROM maven:3-sapmachine-21 as builder WORKDIR /app COPY ./faircommons-services . RUN mvn clean package -FROM openjdk:17 +FROM sapmachine:21-jre-headless-ubuntu WORKDIR /app COPY --from=builder /app/api-service/target/api-service*.jar ./api-service.jar ENTRYPOINT ["java","-jar","./api-service.jar"] \ No newline at end of file diff --git a/deployments/dockerfiles/hashing-service.Dockerfile b/deployments/dockerfiles/hashing-service.Dockerfile index b1fbf45381d5041a2086f4462707c3e6a5d37e0e..8275d0b847f3f4c4c242b7ba1c5f0fc4ffdb28bf 100644 --- a/deployments/dockerfiles/hashing-service.Dockerfile +++ b/deployments/dockerfiles/hashing-service.Dockerfile @@ -1,9 +1,9 @@ -FROM maven:3-openjdk-17 as builder +FROM maven:3-sapmachine-21 as builder WORKDIR /app COPY ./faircommons-services . RUN mvn clean package -FROM openjdk:17 +FROM sapmachine:21-jre-headless-ubuntu WORKDIR /app COPY --from=builder /app/hashing-service/target/hashing-service*.jar ./hashing-service.jar ENTRYPOINT ["java","-jar","./hashing-service.jar"] \ No newline at end of file diff --git a/deployments/dockerfiles/ipfs-service.Dockerfile b/deployments/dockerfiles/ipfs-service.Dockerfile index 70743f7560da3948aaa0b8e5d974948d7dbdacc9..e56101a5872f61a5936e214654e4825e504d2607 100644 --- a/deployments/dockerfiles/ipfs-service.Dockerfile +++ b/deployments/dockerfiles/ipfs-service.Dockerfile @@ -1,9 +1,9 @@ -FROM maven:3-openjdk-17 as builder +FROM maven:3-sapmachine-21 as builder WORKDIR /app COPY ./faircommons-services . RUN mvn clean package -FROM openjdk:17 +FROM sapmachine:21-jre-headless-ubuntu WORKDIR /app COPY --from=builder /app/ipfs-service/target/ipfs-service*.jar ./ipfs-service.jar ENTRYPOINT ["java","-jar","./ipfs-service.jar"] \ No newline at end of file diff --git a/deployments/dockerfiles/post-registration-service.Dockerfile b/deployments/dockerfiles/post-registration-service.Dockerfile index ca3d972a5d6588095ef59392edb2dc4a48b7a89d..a4007e5f441234c1ddd482066c1be7f6bc3d755b 100644 --- a/deployments/dockerfiles/post-registration-service.Dockerfile +++ b/deployments/dockerfiles/post-registration-service.Dockerfile @@ -1,9 +1,9 @@ -FROM maven:3-openjdk-17 as builder +FROM maven:3-sapmachine-21 as builder WORKDIR /app COPY ./faircommons-services . RUN mvn clean package -FROM openjdk:17 +FROM sapmachine:21-jre-headless-ubuntu WORKDIR /app COPY --from=builder /app/post-registration-service/target/post-registration-service*.jar ./post-registration-service.jar ENTRYPOINT ["java","-jar","./post-registration-service.jar"] \ No newline at end of file diff --git a/faircommons-services/api-service/pom.xml b/faircommons-services/api-service/pom.xml index 79883957b2cb088f0395622cd1c7647e09e15fe8..e7ee3d5238458036d6fa8179285e367a2971f876 100644 --- a/faircommons-services/api-service/pom.xml +++ b/faircommons-services/api-service/pom.xml @@ -19,19 +19,16 @@ </dependency> </dependencies> + <properties> + <maven.compiler.source>${java.version}</maven.compiler.source> + <maven.compiler.target>${java.version}</maven.compiler.target> + </properties> + <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> - <configuration> - <excludes> - <exclude> - <groupId>org.projectlombok</groupId> - <artifactId>lombok</artifactId> - </exclude> - </excludes> - </configuration> </plugin> </plugins> </build> diff --git a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/api/PublicWorkApi.java b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/api/PublicWorkApi.java index 84ce20179f77fbdd37e1191332691605fa948be5..7940016548c91ab822b5b3d52793f5619a9c3e8d 100644 --- a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/api/PublicWorkApi.java +++ b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/api/PublicWorkApi.java @@ -1,16 +1,12 @@ package eu.fairkom.faircommons.api_service.api; import eu.fairkom.faircommons.api_service.service.WorkService; -import eu.fairkom.faircommons.common.models.DownloadFileResponse; import eu.fairkom.faircommons.common.models.WorkFilter; import eu.fairkom.faircommons.common.models.views.PublicWorkView; import jakarta.persistence.EntityNotFoundException; import org.springdoc.core.annotations.ParameterObject; -import org.springframework.core.io.InputStreamResource; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -35,13 +31,6 @@ public class PublicWorkApi { return ResponseEntity.of(workService.getPublicWorkByGrid(grid)); } - private ResponseEntity<InputStreamResource> createDownloadResponseEntity(DownloadFileResponse fileResponse) { - return ResponseEntity.ok() - .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + fileResponse.getFilename()) - .contentType(MediaType.APPLICATION_OCTET_STREAM) - .body(fileResponse.getInputStreamResource()); - } - @ExceptionHandler(EntityNotFoundException.class) public ResponseEntity<?> handleEntityNotFound() { return ResponseEntity.notFound().build(); diff --git a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/api/WorkFileApi.java b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/api/WorkFileApi.java index 821a02cb1e69079c624cec347911a514531644b7..b2eced5194405ea64aa0f5401e539e3c5f074bed 100644 --- a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/api/WorkFileApi.java +++ b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/api/WorkFileApi.java @@ -46,9 +46,9 @@ public class WorkFileApi { private ResponseEntity<InputStreamResource> createDownloadResponseEntity(DownloadFileResponse fileResponse) { return ResponseEntity.ok() - .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + fileResponse.getFilename()) + .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + fileResponse.filename()) .contentType(MediaType.APPLICATION_OCTET_STREAM) - .body(fileResponse.getInputStreamResource()); + .body(fileResponse.inputStreamResource()); } @ExceptionHandler(EntityNotFoundException.class) diff --git a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/listener/WorkRegisteredEventListener.java b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/listener/WorkRegisteredEventListener.java index 45c850d6178aeb735e3454cfd3458f298ffda71c..ba911947e5454cd0a1ad023923fe102439ec82ad 100644 --- a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/listener/WorkRegisteredEventListener.java +++ b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/listener/WorkRegisteredEventListener.java @@ -23,6 +23,6 @@ public class WorkRegisteredEventListener { @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) public void handleWorkRegisteredEvent(WorkFileMessage message) { rabbitTemplate.convertAndSend(HASHING_QUEUE, message); - logger.info("Message sent to hashing queue for work ID: {}", message.getWorkId()); + logger.info("Message sent to hashing queue for work ID: {}", message.workId()); } } diff --git a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/listener/WorkStatusListener.java b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/listener/WorkStatusListener.java index fe4b2f04ba13eff2a7efd4596314faaf4f332013..6c096252354eceeea78bd10daeaa9441cacec59b 100644 --- a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/listener/WorkStatusListener.java +++ b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/listener/WorkStatusListener.java @@ -1,6 +1,5 @@ package eu.fairkom.faircommons.api_service.listener; -import com.fasterxml.jackson.core.JsonProcessingException; import eu.fairkom.faircommons.api_service.service.WorkMessageDispatcher; import eu.fairkom.faircommons.common.rabbitmq.RabbitMqListener; import eu.fairkom.faircommons.common.rabbitmq.messages.StatusEvent; @@ -24,10 +23,10 @@ public class WorkStatusListener implements RabbitMqListener<StatusEvent> { @Override public void receive(StatusEvent event) { try { - logger.info("Received status message with type: {} and work ID: {}", event.getStatus().getType(), event.getWorkId()); + logger.info("Received status message with type: {} and work ID: {}", event.status().type(), event.workId()); workMessageDispatcher.handleStatusEvent(event); } catch (Throwable e) { - logger.error("Error processing status event with work ID: {}. Message: {}", event.getWorkId(), e.getMessage(), e); + logger.error("Error processing status event with work ID: {}. Message: {}", event.workId(), e.getMessage(), e); throw e; } } diff --git a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/repository/WorkRepository.java b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/repository/WorkRepository.java index ff1a8129f637e7bbe2c73ff6e94b31164abe386c..3db6fb0fc497167eab45d3bf65255ff6b6958ace 100644 --- a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/repository/WorkRepository.java +++ b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/repository/WorkRepository.java @@ -41,23 +41,23 @@ public interface WorkRepository extends JpaRepository<Work, UUID>, JpaSpecificat predicates.add(criteriaBuilder.equal(root.get(Work_.visibility), WorkVisibility.PUBLIC)); // Add predicate for type attribute - if (workFilter.getType() != null) { - predicates.add(criteriaBuilder.equal(root.get(Work_.TYPE), workFilter.getType())); + if (workFilter.type() != null) { + predicates.add(criteriaBuilder.equal(root.get(Work_.TYPE), workFilter.type())); } // Add predicate for title attribute - if (workFilter.getTitle() != null) { - predicates.add(criteriaBuilder.like(criteriaBuilder.lower(root.get(Work_.TITLE)), "%" + workFilter.getTitle().toLowerCase() + "%")); + if (workFilter.title() != null) { + predicates.add(criteriaBuilder.like(criteriaBuilder.lower(root.get(Work_.TITLE)), "%" + workFilter.title().toLowerCase() + "%")); } // Add predicate for license identifier attribute - if (workFilter.getLicenseIdentifier() != null) { - predicates.add(criteriaBuilder.equal(root.get(Work_.LICENSE).get("identifier"), workFilter.getLicenseIdentifier())); + if (workFilter.licenseIdentifier() != null) { + predicates.add(criteriaBuilder.equal(root.get(Work_.LICENSE).get("identifier"), workFilter.licenseIdentifier())); } // Add predicate for tags - if (workFilter.getTags() != null && !workFilter.getTags().isEmpty()) { + if (workFilter.tags() != null && !workFilter.tags().isEmpty()) { var tagsJoin = root.join(Work_.TAGS, JoinType.INNER); - predicates.add(tagsJoin.get(Tag_.NAME).in(workFilter.getTags())); + predicates.add(tagsJoin.get(Tag_.NAME).in(workFilter.tags())); } return criteriaBuilder.and(predicates.toArray(new Predicate[0])); diff --git a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/service/WorkFileService.java b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/service/WorkFileService.java index b258a582d19c82f5e4c9bacaf321a5f4f67304fd..ae899688461d801b1f07e752982865764dd6544f 100644 --- a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/service/WorkFileService.java +++ b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/service/WorkFileService.java @@ -36,11 +36,7 @@ public class WorkFileService { var prefix = ZonedDateTime.now().format(ISO_OFFSET_DATE_TIME); var uploadUrl = minioService.generatePresignedUploadUrl(userId, prefix + "/" + filename); - return FileUploadView.builder() - .prefix(prefix) - .filename(filename) - .url(uploadUrl) - .build(); + return new FileUploadView(prefix, filename, uploadUrl); } public DownloadFileResponse downloadRegistrationCertificate(UUID workId) { @@ -49,10 +45,7 @@ public class WorkFileService { var inputStream = minioService.downloadRegistrationCertificate(work.getRegistrar(), work.getWorkFile().getPrefix()); - return DownloadFileResponse.builder() - .filename(REGISTRATION_CERTIFICATE_NAME) - .inputStreamResource(new InputStreamResource(inputStream)) - .build(); + return new DownloadFileResponse(new InputStreamResource(inputStream), REGISTRATION_CERTIFICATE_NAME); } public DownloadFileResponse downloadWorkById(UUID workId) { @@ -72,10 +65,7 @@ public class WorkFileService { private DownloadFileResponse downLoadFile(Work work) { var inputStream = minioService.downloadFile(work.getRegistrar(), work.getWorkFile().getFilenameWithPrefix()); - return DownloadFileResponse.builder() - .filename(work.getWorkFile().getFilename()) - .inputStreamResource(new InputStreamResource(inputStream)) - .build(); + return new DownloadFileResponse(new InputStreamResource(inputStream), work.getWorkFile().getFilename()); } private EntityNotFoundException workNotFoundException(UUID workId) { diff --git a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/service/WorkMessageDispatcher.java b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/service/WorkMessageDispatcher.java index c391bee08f04636071b4ec4808c7132cbe8dc416..b148a467a39cd30f99b4b68d41dc131d5c288ec1 100644 --- a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/service/WorkMessageDispatcher.java +++ b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/service/WorkMessageDispatcher.java @@ -1,6 +1,5 @@ package eu.fairkom.faircommons.api_service.service; -import com.fasterxml.jackson.core.JsonProcessingException; import eu.fairkom.faircommons.api_service.strategy.MessageDispatchStrategy; import eu.fairkom.faircommons.common.models.entities.WorkStatus; import eu.fairkom.faircommons.common.rabbitmq.messages.StatusEvent; @@ -29,8 +28,8 @@ public class WorkMessageDispatcher { @Transactional public void handleStatusEvent(StatusEvent event) { - logger.info("Handling status event for work ID: {}", event.getWorkId()); - var workStatus = workStatusService.saveStatus(event.getStatus()); + logger.info("Handling status event for work ID: {}", event.workId()); + var workStatus = workStatusService.saveStatus(event.status()); var work = workService.updateWork(workStatus, workStatus.getType()); var strategy = dispatchStrategies.get(workStatus.getType()); diff --git a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/service/WorkService.java b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/service/WorkService.java index e629a050109ae5d36de119e542901e1b55832116..8eac92c5afbd68ef548f4ad08e9d7ebb68615ae1 100644 --- a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/service/WorkService.java +++ b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/service/WorkService.java @@ -47,15 +47,15 @@ public class WorkService { @Transactional public UUID registerWork(WorkCreateView workCreateView) { - logger.info("Registering work for user: {}", workCreateView.getRegistrar()); + logger.info("Registering work for user: {}", workCreateView.registrar()); var work = workRepository.save(createWorkEntity(workCreateView)); logger.debug("Work saved with ID: {}", work.getId()); - var message = WorkFileMessage.builder() - .workId(work.getId()) - .workFile(workCreateView.getWorkFile()) - .userId(workCreateView.getRegistrar()) - .build(); + var message = new WorkFileMessage( + work.getId(), + workCreateView.workFile(), + workCreateView.registrar() + ); eventPublisher.publishEvent(message); return work.getId(); @@ -101,7 +101,7 @@ public class WorkService { } private Work createWorkEntity(WorkCreateView view) { - var tags = view.getTags() + var tags = view.tags() .stream() .distinct() .map(name -> tagRepository.findTagByName(name) @@ -112,15 +112,15 @@ public class WorkService { workEntity.setTags(tags); //TODO remove after migration - if (view.getGrid() != null) { - workEntity.setGrid(view.getGrid()); + if (view.grid() != null) { + workEntity.setGrid(view.grid()); } else { workEntity.setGrid(IdentifierGenerator.generateGlobalReleaseIdentifier()); } //TODO remove after migration - if (view.getRegistrationDate() != null) { - workEntity.setRegistrationDate(view.getRegistrationDate()); + if (view.registrationDate() != null) { + workEntity.setRegistrationDate(view.registrationDate()); } return workEntity; diff --git a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/service/WorkStatusService.java b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/service/WorkStatusService.java index 476ef11572f50c4491f3e42bfdd6583fd81e0b66..ba7173fdd01e9b7990e8a8387631df6a29b53fd6 100644 --- a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/service/WorkStatusService.java +++ b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/service/WorkStatusService.java @@ -22,7 +22,7 @@ public class WorkStatusService { @Transactional public WorkStatus saveStatus(WorkStatusView workStatusView) { - logger.info("Saving work status for work ID: {}", workStatusView.getWorkId()); + logger.info("Saving work status for work ID: {}", workStatusView.workId()); var workStatus = workStatusMapper.toEntity(workStatusView); return workStatusRepository.save(workStatus); } diff --git a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/strategy/AbstractMessageDispatcher.java b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/strategy/AbstractMessageDispatcher.java index 162163d54823c9a4444cc7aadb17f55904277dea..090b86f805c780a5bfccbf6b580658e7126d9e0d 100644 --- a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/strategy/AbstractMessageDispatcher.java +++ b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/strategy/AbstractMessageDispatcher.java @@ -25,20 +25,21 @@ public abstract class AbstractMessageDispatcher implements MessageDispatchStrate protected WorkFileMessage buildWorkFileMessage(Work work) { var workFileView = workMapper.toWorkFileView(work.getWorkFile()); - return WorkFileMessage.builder() - .workFile(workFileView) - .workId(work.getId()) - .userId(work.getRegistrar()) - .build(); + return new WorkFileMessage( + work.getId(), + workFileView, + work.getRegistrar() + ); } protected MetaDataMessage buildMetaDataMessage(Work work) throws MessageBuildingException { try { var metaData = workMapper.toMetaDataView(work); - return MetaDataMessage.builder() - .workId(work.getId()) - .metaData(objectMapper.writeValueAsString(metaData)) - .build(); + + return new MetaDataMessage( + work.getId(), + objectMapper.writeValueAsString(metaData) + ); } catch (JsonProcessingException e) { throw new MessageBuildingException("Error while building MetaDataMessage for Work with ID: " + work.getId(), e); } diff --git a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/strategy/MetaIpfsDoneDispatcher.java b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/strategy/MetaIpfsDoneDispatcher.java index 63b8342390b2e6d59b8f3bb6a083475eb79bf35a..77889ffff904c951137b5020c7b3880ae444aaf7 100644 --- a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/strategy/MetaIpfsDoneDispatcher.java +++ b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/strategy/MetaIpfsDoneDispatcher.java @@ -22,14 +22,12 @@ public class MetaIpfsDoneDispatcher extends AbstractMessageDispatcher { @Override public void dispatch(Work work) { - var status = WorkStatusView.builder() - .workId(work.getId()) - .type(REGISTRATION_DONE) - .build(); - var event = StatusEvent.builder() - .workId(work.getId()) - .status(status) - .build(); + var event = new StatusEvent( + work.getId(), + new WorkStatusView( + work.getId(), + REGISTRATION_DONE + )); rabbitTemplate.convertAndSend(STATUS_QUEUE, event); } diff --git a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/strategy/RegistrationDoneDispatcher.java b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/strategy/RegistrationDoneDispatcher.java index 94f34f2107ffa840759fcab4f344a8fed4738bd5..d3a53af679db16933cf1e41035a3580b1859b4ea 100644 --- a/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/strategy/RegistrationDoneDispatcher.java +++ b/faircommons-services/api-service/src/main/java/eu/fairkom/faircommons/api_service/strategy/RegistrationDoneDispatcher.java @@ -21,9 +21,8 @@ public class RegistrationDoneDispatcher extends AbstractMessageDispatcher { @Override public void dispatch(Work work) { - var message = PostRegistrationMessage.builder() - .work(workMapper.toView(work)) - .build(); + var message = new PostRegistrationMessage(workMapper.toView(work)); + rabbitTemplate.convertAndSend(POST_REGISTRATION_EXCHANGE, POST_REGISTRATION_QUEUE, message); } diff --git a/faircommons-services/common/pom.xml b/faircommons-services/common/pom.xml index 4c5060b06263b60dac5f669f90a7f8af199d09de..19fc5c1b9815e49e068a457e31dfa4eec0268e85 100644 --- a/faircommons-services/common/pom.xml +++ b/faircommons-services/common/pom.xml @@ -11,6 +11,11 @@ <artifactId>common</artifactId> <packaging>jar</packaging> + <properties> + <maven.compiler.source>${java.version}</maven.compiler.source> + <maven.compiler.target>${java.version}</maven.compiler.target> + </properties> + <dependencies> <dependency> <groupId>io.minio</groupId> diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/Constants.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/Constants.java index ce7135a2280fe993ebf5d88a7c9f9f7aba043e39..3662dac2cd7176bdcdedd30f63efa4a51c646814 100644 --- a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/Constants.java +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/Constants.java @@ -1,6 +1,8 @@ package eu.fairkom.faircommons.common; -public class Constants { +public final class Constants { public static final String REGISTRATION_CERTIFICATE_NAME = "fairregister-certificate.pdf"; public static final String REGISTRATION_CERTIFICATE_FOLDER = "certificate"; + private Constants() { + } } diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/IdentifierGenerator.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/IdentifierGenerator.java index 151917d3a12e2cb494b1e72cac8b8717b82b429c..5bddbd23b63782edbbbfd54b6d8c96fc6f03221e 100644 --- a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/IdentifierGenerator.java +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/IdentifierGenerator.java @@ -16,15 +16,13 @@ public class IdentifierGenerator { var releaseNumber = generateReleaseNumber(); var checkCharacter = calculateCheckCharacter(releaseNumber); - return new StringBuilder() - .append(IDENTIFIER_SCHEME) - .append("-") - .append(ISSUER_CODE) - .append("-") - .append(releaseNumber) - .append("-") - .append(checkCharacter) - .toString(); + return IDENTIFIER_SCHEME + + "-" + + ISSUER_CODE + + "-" + + releaseNumber + + "-" + + checkCharacter; } private static String generateReleaseNumber() { diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/mappers/EntityMapper.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/mappers/EntityMapper.java index 449cb6abafebe336f2c57a039f03300993d61736..d03f415bd7279989c32797481770c2033f852d29 100644 --- a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/mappers/EntityMapper.java +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/mappers/EntityMapper.java @@ -28,8 +28,8 @@ final class EntityMapper { @ObjectFactory public <ID extends Serializable, T> T getOrCreate(@TargetType Class<T> entityClass, IdentifiableView<ID> view) { - return view.getId() != null - ? entityManager.getReference(entityClass, view.getId()) + return view.id() != null + ? entityManager.getReference(entityClass, view.id()) : BeanUtils.instantiateClass(entityClass); } } diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/mappers/EntityObjectFactory.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/mappers/EntityObjectFactory.java index a01b17dcd84e7a80a8d82e772fe35ff684f9530b..ef64c589d039461d830d623b9f42a437aaeeaaac 100644 --- a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/mappers/EntityObjectFactory.java +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/mappers/EntityObjectFactory.java @@ -19,8 +19,8 @@ public class EntityObjectFactory { @ObjectFactory public <ID extends Serializable, T> T getOrCreate(@TargetType Class<T> entityClass, IdentifiableView<ID> view) { - return view.getId() != null - ? entityManager.getReference(entityClass, view.getId()) + return view.id() != null + ? entityManager.getReference(entityClass, view.id()) : BeanUtils.instantiateClass(entityClass); } } diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/mappers/WorkStatusMapper.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/mappers/WorkStatusMapper.java index 955d98bd5be55fd21775915a3c0069d290a5c9d5..c75b9f54f4bacbc5f18cdfac868f41bb232f7da5 100644 --- a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/mappers/WorkStatusMapper.java +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/mappers/WorkStatusMapper.java @@ -12,6 +12,7 @@ import org.mapstruct.Mapping; @Mapper(config = MappingConfig.class) public interface WorkStatusMapper { @Mapping(target = "work", source = "workId") + @Mapping(target = "hashCode", source = "hash") @Mapping(target = "created", ignore = true) @Mapping(target = "id", ignore = true) WorkStatus toEntity(WorkStatusView workStatusView); diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/minio/MinioConfiguration.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/minio/MinioConfiguration.java index 0afb0d28ab0c098c36277a8475d40a741e0f262c..1841848ccb5f413e38af6e5bbe0feeb0efda2617 100644 --- a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/minio/MinioConfiguration.java +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/minio/MinioConfiguration.java @@ -7,7 +7,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -@Configuration +@Configuration(proxyBeanMethods = false) @ConditionalOnClass(MinioClient.class) @EnableConfigurationProperties(MinioConfigurationProperties.class) public class MinioConfiguration { @@ -20,9 +20,9 @@ public class MinioConfiguration { @Bean public MinioClient minioClient() { return MinioClient.builder() - .endpoint(properties.getUrl()) - .region(properties.getRegion()) - .credentials(properties.getAccessKey(), properties.getSecretKey()) + .endpoint(properties.url()) + .region(properties.region()) + .credentials(properties.accessKey(), properties.secretKey()) .build(); } } diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/minio/MinioService.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/minio/MinioService.java index f41a976309b8ac3541655e1f5cb1f131a3d5dcf3..2b88753a8e48245d914aa0c2ca2c3edf3afceee5 100644 --- a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/minio/MinioService.java +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/minio/MinioService.java @@ -2,8 +2,6 @@ package eu.fairkom.faircommons.common.minio; import io.minio.*; import io.minio.http.Method; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/minio/models/MinioConfigurationProperties.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/minio/models/MinioConfigurationProperties.java new file mode 100644 index 0000000000000000000000000000000000000000..637221914c175940d13860726c6e428b9d910a25 --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/minio/models/MinioConfigurationProperties.java @@ -0,0 +1,14 @@ +package eu.fairkom.faircommons.common.minio.models; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties("minio") +public record MinioConfigurationProperties( + String url, + String accessKey, + String secretKey, + boolean secure, + String bucketPrefix, + String region +) { +} diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/DownloadFileResponse.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/DownloadFileResponse.java new file mode 100644 index 0000000000000000000000000000000000000000..c1b1dd39ae6e98f09be3b9316d411399e738a7cc --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/DownloadFileResponse.java @@ -0,0 +1,8 @@ +package eu.fairkom.faircommons.common.models; + +import org.springframework.core.io.InputStreamResource; + +public record DownloadFileResponse( + InputStreamResource inputStreamResource, + String filename) { +} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/MessageBuildingException.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/MessageBuildingException.java similarity index 100% rename from faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/MessageBuildingException.java rename to faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/MessageBuildingException.java diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/StorageOption.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/StorageOption.java similarity index 100% rename from faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/StorageOption.java rename to faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/StorageOption.java diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/WorkFilter.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/WorkFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..6cbf189d6284f0854dba52a68097f4ed4cee5ed2 --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/WorkFilter.java @@ -0,0 +1,10 @@ +package eu.fairkom.faircommons.common.models; + +import java.util.List; + +public record WorkFilter( + WorkType type, + String title, + List<String> tags, + String licenseIdentifier) { +} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/WorkType.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/WorkType.java similarity index 100% rename from faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/WorkType.java rename to faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/WorkType.java diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/WorkVisibility.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/WorkVisibility.java similarity index 100% rename from faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/WorkVisibility.java rename to faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/WorkVisibility.java diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/Author.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/Author.java new file mode 100644 index 0000000000000000000000000000000000000000..dae8f8cbca92f5db06d85a294a596d1f9ace8010 --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/Author.java @@ -0,0 +1,70 @@ +package eu.fairkom.faircommons.common.models.entities; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import org.hibernate.annotations.UuidGenerator; + +import java.util.UUID; + +@Entity +public class Author extends Identifiable<UUID> { + @Id + @GeneratedValue + @UuidGenerator + private UUID id; + private String firstName; + private String lastName; + private String email; + private String pseudonym; + private String url; + + @Override + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPseudonym() { + return pseudonym; + } + + public void setPseudonym(String pseudonym) { + this.pseudonym = pseudonym; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } +} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/Collection.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/Collection.java similarity index 55% rename from faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/Collection.java rename to faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/Collection.java index ee25a685206f9ed65464697160eb72363d89be74..ee48f5027f18b4cda89dc7a07b97be498bee7901 100644 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/Collection.java +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/Collection.java @@ -1,19 +1,13 @@ package eu.fairkom.faircommons.common.models.entities; import jakarta.persistence.*; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; import org.hibernate.annotations.UuidGenerator; import java.util.HashSet; import java.util.Set; import java.util.UUID; -@Getter -@Setter @Entity -@NoArgsConstructor public class Collection extends Identifiable<UUID> { @Id @GeneratedValue @@ -24,4 +18,29 @@ public class Collection extends Identifiable<UUID> { @OneToMany(mappedBy = "collection", fetch = FetchType.LAZY, cascade = CascadeType.ALL) private Set<Work> works = new HashSet<>(); + + @Override + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public Set<Work> getWorks() { + return works; + } + + public void setWorks(Set<Work> works) { + this.works = works; + } } diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/Contributor.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/Contributor.java new file mode 100644 index 0000000000000000000000000000000000000000..a363ca8691ee41847df88c9df739adf561fe0c5d --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/Contributor.java @@ -0,0 +1,67 @@ +package eu.fairkom.faircommons.common.models.entities; + +import jakarta.persistence.*; +import org.hibernate.annotations.UuidGenerator; + +import java.util.UUID; + +@Entity +public class Contributor extends Identifiable<UUID> { + @Id + @GeneratedValue + @UuidGenerator + private UUID id; + + @OneToOne(mappedBy = "creator", fetch = FetchType.LAZY) + private Work workAsCreator; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "work_as_contributor_id") + private Work workAsContributor; + + @ManyToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "author_id", nullable = false) + private Author author; + private Integer percentage; + + @Override + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public Work getWorkAsCreator() { + return workAsCreator; + } + + public void setWorkAsCreator(Work workAsCreator) { + this.workAsCreator = workAsCreator; + } + + public Work getWorkAsContributor() { + return workAsContributor; + } + + public void setWorkAsContributor(Work workAsContributor) { + this.workAsContributor = workAsContributor; + } + + public Author getAuthor() { + return author; + } + + public void setAuthor(Author author) { + this.author = author; + } + + public Integer getPercentage() { + return percentage; + } + + public void setPercentage(Integer percentage) { + this.percentage = percentage; + } +} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/Identifiable.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/Identifiable.java similarity index 100% rename from faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/Identifiable.java rename to faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/Identifiable.java diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/Tag.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/Tag.java similarity index 51% rename from faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/Tag.java rename to faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/Tag.java index cb79e63de042b41252226de44d2d26f97109f309..9e25fb247cfd301dbd4af1f57ec58b551dc5710c 100644 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/Tag.java +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/Tag.java @@ -1,18 +1,29 @@ package eu.fairkom.faircommons.common.models.entities; import jakarta.persistence.*; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -@Getter -@Setter @Entity -@NoArgsConstructor public class Tag extends Identifiable<Long> { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(unique = true) private String name; + + @Override + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } } \ No newline at end of file diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/Work.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/Work.java similarity index 52% rename from faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/Work.java rename to faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/Work.java index 266967c4d32fcdee04f9ea996d6832d1ae63acc7..27875cc01791a8afe5fbcba43b307feed10e4d7d 100644 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/Work.java +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/Work.java @@ -5,18 +5,12 @@ import eu.fairkom.faircommons.common.models.WorkType; import eu.fairkom.faircommons.common.models.WorkVisibility; import eu.fairkom.faircommons.common.models.entities.embedded.*; import jakarta.persistence.*; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; import org.hibernate.annotations.UuidGenerator; import java.time.ZonedDateTime; import java.util.*; -@Getter -@Setter @Entity -@NoArgsConstructor @NamedEntityGraph( name = "work.public", attributeNodes = { @@ -150,4 +144,221 @@ public class Work extends Identifiable<UUID> { public void addContributor(Contributor contributor) { addBidirectional(this, contributor, Work::getContributors, Contributor::setWorkAsContributor); } + + @Override + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public WorkType getType() { + return type; + } + + public void setType(WorkType type) { + this.type = type; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getRegistrar() { + return registrar; + } + + public void setRegistrar(String registrar) { + this.registrar = registrar; + } + + public ZonedDateTime getRegistrationDate() { + return registrationDate; + } + + public void setRegistrationDate(ZonedDateTime registrationDate) { + this.registrationDate = registrationDate; + } + + public WorkFile getWorkFile() { + return workFile; + } + + public void setWorkFile(WorkFile workFile) { + this.workFile = workFile; + } + + public List<Tag> getTags() { + return tags; + } + + public void setTags(List<Tag> tags) { + this.tags = tags; + } + + public String getLanguage() { + return language; + } + + public void setLanguage(String language) { + this.language = language; + } + + public ZonedDateTime getCreationDate() { + return creationDate; + } + + public void setCreationDate(ZonedDateTime creationDate) { + this.creationDate = creationDate; + } + + public ZonedDateTime getPublishingDate() { + return publishingDate; + } + + public void setPublishingDate(ZonedDateTime publishingDate) { + this.publishingDate = publishingDate; + } + + public String getPublisher() { + return publisher; + } + + public void setPublisher(String publisher) { + this.publisher = publisher; + } + + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + public WorkVisibility getVisibility() { + return visibility; + } + + public void setVisibility(WorkVisibility visibility) { + this.visibility = visibility; + } + + public Contributor getCreator() { + return creator; + } + + public void setCreator(Contributor creator) { + this.creator = creator; + } + + public Set<Contributor> getContributors() { + return contributors; + } + + public void setContributors(Set<Contributor> contributors) { + this.contributors = contributors; + } + + public License getLicense() { + return license; + } + + public void setLicense(License license) { + this.license = license; + } + + public Revocation getRevocation() { + return revocation; + } + + public void setRevocation(Revocation revocation) { + this.revocation = revocation; + } + + public HashCode getHashFile() { + return hashFile; + } + + public void setHashFile(HashCode hashFile) { + this.hashFile = hashFile; + } + + public HashCode getHashMeta() { + return hashMeta; + } + + public void setHashMeta(HashCode hashMeta) { + this.hashMeta = hashMeta; + } + + public IpfsEntry getIpfsFile() { + return ipfsFile; + } + + public void setIpfsFile(IpfsEntry ipfsFile) { + this.ipfsFile = ipfsFile; + } + + public IpfsEntry getIpfsMeta() { + return ipfsMeta; + } + + public void setIpfsMeta(IpfsEntry ipfsMeta) { + this.ipfsMeta = ipfsMeta; + } + + public Collection getCollection() { + return collection; + } + + public void setCollection(Collection collection) { + this.collection = collection; + } + + public WorkStatus getStatus() { + return status; + } + + public void setStatus(WorkStatus status) { + this.status = status; + } + + public Set<WorkStatus> getStatuses() { + return statuses; + } + + public void setStatuses(Set<WorkStatus> statuses) { + this.statuses = statuses; + } + + public Set<StorageOption> getStorageOptions() { + return storageOptions; + } + + public void setStorageOptions(Set<StorageOption> storageOptions) { + this.storageOptions = storageOptions; + } + + public String getGrid() { + return grid; + } + + public void setGrid(String grid) { + this.grid = grid; + } } diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/WorkStatus.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/WorkStatus.java similarity index 59% rename from faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/WorkStatus.java rename to faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/WorkStatus.java index a29f6238cdf9730f6625c55dfca557163c2624ca..25cbdcefb9dac67a9c5a61d135241b3d7b59376b 100644 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/WorkStatus.java +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/WorkStatus.java @@ -3,17 +3,11 @@ package eu.fairkom.faircommons.common.models.entities; import eu.fairkom.faircommons.common.models.entities.embedded.HashCode; import eu.fairkom.faircommons.common.models.entities.embedded.IpfsEntry; import jakarta.persistence.*; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; import org.springframework.data.annotation.Immutable; import java.time.ZonedDateTime; -@Getter -@Setter @Entity -@NoArgsConstructor @Immutable public class WorkStatus extends Identifiable<Long> { @Id @@ -41,6 +35,55 @@ public class WorkStatus extends Identifiable<Long> { private WorkStatusType type; + @Override + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Work getWork() { + return work; + } + + public void setWork(Work work) { + this.work = work; + } + + public ZonedDateTime getCreated() { + return created; + } + + public void setCreated(ZonedDateTime created) { + this.created = created; + } + + public HashCode getHashCode() { + return hashCode; + } + + public void setHashCode(HashCode hashCode) { + this.hashCode = hashCode; + } + + public IpfsEntry getIpfsEntry() { + return ipfsEntry; + } + + public void setIpfsEntry(IpfsEntry ipfsEntry) { + this.ipfsEntry = ipfsEntry; + } + + public WorkStatusType getType() { + return type; + } + + public void setType(WorkStatusType type) { + this.type = type; + } + public enum WorkStatusType { FILE_HASHING_DONE, META_HASHING_DONE, FILE_IPFS_DONE, META_IPFS_DONE, REGISTRATION_DONE, ERROR } diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/embedded/HashCode.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/embedded/HashCode.java new file mode 100644 index 0000000000000000000000000000000000000000..1854a8b0613c3af86f8a996193cf98f0996f2be0 --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/embedded/HashCode.java @@ -0,0 +1,29 @@ +package eu.fairkom.faircommons.common.models.entities.embedded; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; + +@Embeddable +public class HashCode { + @Column(updatable = false) + private String algorithm; + + @Column(updatable = false) + private String hexValue; + + public String getAlgorithm() { + return algorithm; + } + + public void setAlgorithm(String algorithm) { + this.algorithm = algorithm; + } + + public String getHexValue() { + return hexValue; + } + + public void setHexValue(String hexValue) { + this.hexValue = hexValue; + } +} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/embedded/IpfsEntry.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/embedded/IpfsEntry.java similarity index 53% rename from faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/embedded/IpfsEntry.java rename to faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/embedded/IpfsEntry.java index 60ab5d7e8071d7b3b0f4a76241d5df11b1667ffa..65767134128a9e83e473a4b7742da0eb268f4043 100644 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/embedded/IpfsEntry.java +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/embedded/IpfsEntry.java @@ -2,13 +2,7 @@ package eu.fairkom.faircommons.common.models.entities.embedded; import jakarta.persistence.Column; import jakarta.persistence.Embeddable; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -@Getter -@Setter -@NoArgsConstructor @Embeddable public class IpfsEntry { @Column(updatable = false) @@ -16,4 +10,20 @@ public class IpfsEntry { @Column(updatable = false) private String path; + + public String getCid() { + return cid; + } + + public void setCid(String cid) { + this.cid = cid; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } } diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/embedded/License.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/embedded/License.java new file mode 100644 index 0000000000000000000000000000000000000000..1a08e50b3d450b71fb99525b31b853a38d4cd3e7 --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/embedded/License.java @@ -0,0 +1,45 @@ +package eu.fairkom.faircommons.common.models.entities.embedded; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; + +@Embeddable +public class License { + @Column(updatable = false) + private String identifier; //immutable SPDX + private String addons; + private String dual; + private String dalicc; + + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + public String getAddons() { + return addons; + } + + public void setAddons(String addons) { + this.addons = addons; + } + + public String getDual() { + return dual; + } + + public void setDual(String dual) { + this.dual = dual; + } + + public String getDalicc() { + return dalicc; + } + + public void setDalicc(String dalicc) { + this.dalicc = dalicc; + } +} diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/embedded/Revocation.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/embedded/Revocation.java new file mode 100644 index 0000000000000000000000000000000000000000..5928cb855d3b90ff5443d6a276d13829f9f10994 --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/embedded/Revocation.java @@ -0,0 +1,27 @@ +package eu.fairkom.faircommons.common.models.entities.embedded; + +import jakarta.persistence.Embeddable; + +import java.time.ZonedDateTime; + +@Embeddable +public class Revocation { + private ZonedDateTime date; + private String note; + + public ZonedDateTime getDate() { + return date; + } + + public void setDate(ZonedDateTime date) { + this.date = date; + } + + public String getNote() { + return note; + } + + public void setNote(String note) { + this.note = note; + } +} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/embedded/WorkFile.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/embedded/WorkFile.java similarity index 55% rename from faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/embedded/WorkFile.java rename to faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/embedded/WorkFile.java index e12342180ba7aa684b7d86a6ccf9e2ab1c526837..346724becd5c7d0eeb9cd175c71c2e4ded4be8cf 100644 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/embedded/WorkFile.java +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/entities/embedded/WorkFile.java @@ -2,13 +2,7 @@ package eu.fairkom.faircommons.common.models.entities.embedded; import jakarta.persistence.Column; import jakarta.persistence.Embeddable; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -@Getter -@Setter -@NoArgsConstructor @Embeddable public class WorkFile { @Column(updatable = false) @@ -19,4 +13,20 @@ public class WorkFile { public String getFilenameWithPrefix() { return prefix + "/" + filename; } + + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + public String getFilename() { + return filename; + } + + public void setFilename(String filename) { + this.filename = filename; + } } diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/AuthorView.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/AuthorView.java new file mode 100644 index 0000000000000000000000000000000000000000..ac15b587f1fe11324c4f8b0d22d8be57f9d6420c --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/AuthorView.java @@ -0,0 +1,16 @@ +package eu.fairkom.faircommons.common.models.views; + +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Size; + +import java.util.UUID; + +public record AuthorView( + UUID id, + @Size(max = 255) @NotBlank String firstName, + @Size(max = 255) @NotBlank String lastName, + @Size(max = 255) @Email String email, + @Size(max = 255) @NotBlank String pseudonym, + @Size(max = 255) String url) implements IdentifiableView<UUID> { +} \ No newline at end of file diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/ContributorView.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/ContributorView.java new file mode 100644 index 0000000000000000000000000000000000000000..198ff9823ecd3f5ac0741ba204b864011951bc0f --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/ContributorView.java @@ -0,0 +1,13 @@ +package eu.fairkom.faircommons.common.models.views; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; + +import java.util.UUID; + +public record ContributorView( + UUID id, + @Valid AuthorView author, + @NotNull Integer percentage) implements IdentifiableView<UUID> { + +} \ No newline at end of file diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/FileUploadView.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/FileUploadView.java new file mode 100644 index 0000000000000000000000000000000000000000..f86628891de820e043c8188aa721d4e520b7559e --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/FileUploadView.java @@ -0,0 +1,7 @@ +package eu.fairkom.faircommons.common.models.views; + +public record FileUploadView( + String prefix, + String filename, + String url) { +} \ No newline at end of file diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/HashCodeView.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/HashCodeView.java new file mode 100644 index 0000000000000000000000000000000000000000..dfd21cbbaf24f250ae47bdea4de03d5a9f5bfdd2 --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/HashCodeView.java @@ -0,0 +1,8 @@ +package eu.fairkom.faircommons.common.models.views; + +import java.io.Serializable; + +public record HashCodeView( + String algorithm, + String hexValue) implements Serializable { +} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/IdentifiableView.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/IdentifiableView.java similarity index 91% rename from faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/IdentifiableView.java rename to faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/IdentifiableView.java index df50245c3f1a7c3ba72013819c2d596e7f5d5398..3daee0b98dde89d55fbc7a49ee3cc78a07d9dc96 100644 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/IdentifiableView.java +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/IdentifiableView.java @@ -3,5 +3,5 @@ package eu.fairkom.faircommons.common.models.views; import java.io.Serializable; public interface IdentifiableView<ID extends Serializable> extends Serializable { - ID getId(); + ID id(); } diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/IpfsEntryView.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/IpfsEntryView.java new file mode 100644 index 0000000000000000000000000000000000000000..9f22a802b0f58c967fb335e66e0a20f822d3cdf6 --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/IpfsEntryView.java @@ -0,0 +1,12 @@ +package eu.fairkom.faircommons.common.models.views; + +import java.io.Serializable; + +public record IpfsEntryView( + String cid, + String path) implements Serializable { + + public IpfsEntryView(String cid) { + this(cid, ""); + } +} \ No newline at end of file diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/LicenseView.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/LicenseView.java new file mode 100644 index 0000000000000000000000000000000000000000..eca5ab76e7a29acb1d68ccf425a47d0d1d4e26bc --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/LicenseView.java @@ -0,0 +1,14 @@ +package eu.fairkom.faircommons.common.models.views; + + +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.Size; + +import java.io.Serializable; + +public record LicenseView( + @Size(max = 255) @NotEmpty String identifier, + @Size(max = 255) String addons, + @Size(max = 255) String dual, + @Size(max = 255) String dalicc) implements Serializable { +} diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/MetaDataView.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/MetaDataView.java new file mode 100644 index 0000000000000000000000000000000000000000..07286def67a102d98be42c961fbdbaeb0ba2821e --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/MetaDataView.java @@ -0,0 +1,23 @@ +package eu.fairkom.faircommons.common.models.views; + +import eu.fairkom.faircommons.common.models.entities.embedded.HashCode; +import eu.fairkom.faircommons.common.models.entities.embedded.IpfsEntry; + +import java.io.Serializable; +import java.time.ZonedDateTime; +import java.util.UUID; + +public record MetaDataView( + UUID workId, + String title, + String description, + ZonedDateTime creationDate, + ZonedDateTime registrationDate, + String registrar, + WorkFileView workFile, + HashCode hashFile, + HashCode hashMeta, + IpfsEntry ipfsFile, + IpfsEntry ipfsMeta, + String licenseIdentifier) implements Serializable { +} \ No newline at end of file diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/PublicAuthorView.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/PublicAuthorView.java new file mode 100644 index 0000000000000000000000000000000000000000..62183a0c71af004c431fa3e6742954f5779a9042 --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/PublicAuthorView.java @@ -0,0 +1,6 @@ +package eu.fairkom.faircommons.common.models.views; + +public record PublicAuthorView( + String pseudonym, + String url) { +} \ No newline at end of file diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/PublicContributorView.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/PublicContributorView.java new file mode 100644 index 0000000000000000000000000000000000000000..7f27f495c70859f32b3f62aec738ef95d51ef3e7 --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/PublicContributorView.java @@ -0,0 +1,6 @@ +package eu.fairkom.faircommons.common.models.views; + +public record PublicContributorView( + PublicAuthorView author, + Integer percentage) { +} \ No newline at end of file diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/PublicWorkView.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/PublicWorkView.java new file mode 100644 index 0000000000000000000000000000000000000000..b179138f69c4307861c445d39cc3526a3aab00d9 --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/PublicWorkView.java @@ -0,0 +1,23 @@ +package eu.fairkom.faircommons.common.models.views; + +import eu.fairkom.faircommons.common.models.WorkType; + +import java.time.ZonedDateTime; +import java.util.List; + +public record PublicWorkView( + WorkType type, + String title, + String description, + List<String> tags, + String registrar, + ZonedDateTime registrationDate, + ZonedDateTime creationDate, + String publisher, + String identifier, + String language, + PublicContributorView creator, + LicenseView license, + String grid, + String filename) { +} diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/RevocationView.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/RevocationView.java new file mode 100644 index 0000000000000000000000000000000000000000..bd97e801671bea75e2028a8a39ef7767e22dbc69 --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/RevocationView.java @@ -0,0 +1,9 @@ +package eu.fairkom.faircommons.common.models.views; + +import java.io.Serializable; +import java.time.ZonedDateTime; + +public record RevocationView( + ZonedDateTime date, + String note) implements Serializable { +} diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/TagView.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/TagView.java new file mode 100644 index 0000000000000000000000000000000000000000..ad2125945523eda9cfed18d701ea2d8e9a634131 --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/TagView.java @@ -0,0 +1,6 @@ +package eu.fairkom.faircommons.common.models.views; + +public record TagView( + Long id, + String name) implements IdentifiableView<Long> { +} diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/WorkCreateView.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/WorkCreateView.java new file mode 100644 index 0000000000000000000000000000000000000000..620b0d1fb96d362f7b22ab500c20b4a3029abde6 --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/WorkCreateView.java @@ -0,0 +1,40 @@ +package eu.fairkom.faircommons.common.models.views; + +import eu.fairkom.faircommons.common.models.StorageOption; +import eu.fairkom.faircommons.common.models.WorkType; +import eu.fairkom.faircommons.common.models.WorkVisibility; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Pattern; +import jakarta.validation.constraints.Size; + +import java.time.ZonedDateTime; +import java.util.List; + +public record WorkCreateView( + @NotNull WorkType type, + @Size(max = 100) @NotBlank String title, + @Size(max = 2000) @NotBlank String description, + List<String> tags, + @Size(max = 2) String language, + ZonedDateTime creationDate, + @Size(max = 36) @NotBlank String registrar, + @Valid ContributorView creator, + @Valid List<ContributorView> contributors, + @Size(max = 255) String publisher, + @Size(max = 255) String identifier, + @Valid WorkFileView workFile, + @NotNull WorkVisibility visibility, + List<StorageOption> storageOptions, + @Valid LicenseView license, + @Pattern(regexp = "RC-(01|FAREG)-(LIZ\\d{10}|\\d{10})-([A-Z]|\\d)(?=$)") String grid, + ZonedDateTime registrationDate +) { + + public WorkCreateView { + if (storageOptions == null) { + storageOptions = List.of(StorageOption.FAIRREGISTER_FILE_SYSTEM); + } + } +} diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/WorkFileView.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/WorkFileView.java new file mode 100644 index 0000000000000000000000000000000000000000..5d8b18cbbbd2a99476195a864a910de75d3e336d --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/WorkFileView.java @@ -0,0 +1,15 @@ +package eu.fairkom.faircommons.common.models.views; + +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.Size; + +import java.io.Serializable; + +public record WorkFileView( + @Size(max = 255) @NotEmpty String prefix, + @Size(max = 255) @NotEmpty String filename) implements Serializable { + + public String filenameWithPrefix() { + return prefix() + "/" + filename(); + } +} diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/WorkStatusView.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/WorkStatusView.java new file mode 100644 index 0000000000000000000000000000000000000000..bae43b5ae7e8cb4a4e0067ac7e1f50e341715f11 --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/WorkStatusView.java @@ -0,0 +1,32 @@ +package eu.fairkom.faircommons.common.models.views; + +import eu.fairkom.faircommons.common.models.entities.WorkStatus; + +import java.io.Serializable; +import java.time.ZonedDateTime; +import java.util.UUID; + +public record WorkStatusView( + UUID workId, + ZonedDateTime created, + HashCodeView hash, + IpfsEntryView ipfsEntry, + String errorMessage, + WorkStatus.WorkStatusType type) implements Serializable { + + public WorkStatusView(UUID workId, WorkStatus.WorkStatusType type) { + this(workId, null, null, null, null, type); + } + + public WorkStatusView(UUID workId, HashCodeView hash, WorkStatus.WorkStatusType type) { + this(workId, null, hash, null, null, type); + } + + public WorkStatusView(UUID workId, IpfsEntryView ipfsEntry, WorkStatus.WorkStatusType type) { + this(workId, null, null, ipfsEntry, null, type); + } + + public WorkStatusView(UUID workId, String errorMessage, WorkStatus.WorkStatusType type) { + this(workId, null, null, null, errorMessage, type); + } +} diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/WorkView.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/WorkView.java new file mode 100644 index 0000000000000000000000000000000000000000..189e5d337bd6709916015b6bdb3f8adeaf880ef8 --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/models/views/WorkView.java @@ -0,0 +1,40 @@ +package eu.fairkom.faircommons.common.models.views; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import eu.fairkom.faircommons.common.models.StorageOption; +import eu.fairkom.faircommons.common.models.WorkType; +import eu.fairkom.faircommons.common.models.WorkVisibility; + +import java.time.ZonedDateTime; +import java.util.List; +import java.util.Set; +import java.util.UUID; + +public record WorkView( + UUID id, + WorkType type, + String title, + String description, + String filename, + ZonedDateTime registrationDate, + ZonedDateTime creationDate, + String status, + String language, + String identifier, + List<String> tags, + LicenseView license, + ContributorView creator, + List<ContributorView> contributors, + String publisher, + IpfsEntryView ipfsFile, + IpfsEntryView ipfsMeta, + HashCodeView hashFile, + HashCodeView hashMeta, + @JsonIgnore Set<StorageOption> storageOptions, + @JsonIgnore WorkFileView workFile, + String registrar, + WorkVisibility visibility, + RevocationView revocation, + ZonedDateTime publishingDate, + String grid) implements IdentifiableView<UUID> { +} diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/rabbitmq/MessageHandler.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/rabbitmq/MessageHandler.java index c77a603776978a0e4dcc73ac74d650003c41b82b..412ca0a146618ec76b1aaac14304dd95d07b4012 100644 --- a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/rabbitmq/MessageHandler.java +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/rabbitmq/MessageHandler.java @@ -26,83 +26,43 @@ public abstract class MessageHandler { public abstract void handleMetaDataMessage(MetaDataMessage message); public void handleError(UUID workId, Throwable e) { - rabbitTemplate.convertAndSend(STATUS_EXCHANGE, STATUS_QUEUE, buildStatusEventError(workId, e.getMessage())); + var statusEvent = new StatusEvent( + workId, + new WorkStatusView( + workId, + e.getMessage(), + WorkStatus.WorkStatusType.ERROR + ) + ); + + rabbitTemplate.convertAndSend(STATUS_EXCHANGE, STATUS_QUEUE, statusEvent); } protected void sendStatusEvent(UUID workId, HashCodeView hashCode, WorkStatus.WorkStatusType statusType) { - var statusEvent = buildStatusEvent(workId, hashCode, statusType); + var statusEvent = new StatusEvent( + workId, + new WorkStatusView( + workId, + hashCode, + statusType + ) + ); rabbitTemplate.convertAndSend(STATUS_EXCHANGE, STATUS_QUEUE, statusEvent); } protected void sendStatusEvent(UUID workId, IpfsEntryView ipfsEntry, WorkStatus.WorkStatusType statusType) { - var statusEvent = buildStatusEvent(workId, ipfsEntry, statusType); + var statusEvent = new StatusEvent( + workId, + new WorkStatusView( + workId, + ipfsEntry, + statusType + ) + ); rabbitTemplate.convertAndSend(STATUS_EXCHANGE, STATUS_QUEUE, statusEvent); } - - protected HashCodeView buildHashCodeView(String algorithm, String hexValue) { - return HashCodeView.builder() - .algorithm(algorithm) - .hexValue(hexValue) - .build(); - } - - protected IpfsEntryView buildIpfsEntryView(String path, String cid) { - return IpfsEntryView.builder() - .path(path) - .cid(cid) - .build(); - } - - private StatusEvent buildStatusEvent(UUID workId, - HashCodeView hashCode, - WorkStatus.WorkStatusType statusType) { - var status = buildWorkStatusView(hashCode, statusType, workId); - return StatusEvent.builder() - .workId(workId) - .status(status) - .build(); - } - - private StatusEvent buildStatusEvent(UUID workId, - IpfsEntryView ipfsEntry, - WorkStatus.WorkStatusType statusType) { - var status = buildWorkStatusView(ipfsEntry, statusType, workId); - return StatusEvent.builder() - .workId(workId) - .status(status) - .build(); - } - - private StatusEvent buildStatusEventError(UUID workId, String errorMessage) { - var errorStatus = WorkStatusView.builder() - .workId(workId) - .type(WorkStatus.WorkStatusType.ERROR) - .errorMessage(errorMessage) - .build(); - - return StatusEvent.builder() - .workId(workId) - .status(errorStatus) - .build(); - } - - private WorkStatusView buildWorkStatusView(HashCodeView hashCode, WorkStatus.WorkStatusType statusType, UUID workId) { - return WorkStatusView.builder() - .hashCode(hashCode) - .type(statusType) - .workId(workId) - .build(); - } - - private WorkStatusView buildWorkStatusView(IpfsEntryView ipfsEntry, WorkStatus.WorkStatusType statusType, UUID workId) { - return WorkStatusView.builder() - .ipfsEntry(ipfsEntry) - .type(statusType) - .workId(workId) - .build(); - } } diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/rabbitmq/messages/Message.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/rabbitmq/messages/Message.java new file mode 100644 index 0000000000000000000000000000000000000000..837411a7434b9e81eadbb3eb68a41e9c7c2eeb8f --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/rabbitmq/messages/Message.java @@ -0,0 +1,10 @@ +package eu.fairkom.faircommons.common.rabbitmq.messages; + +import java.io.Serializable; +import java.util.UUID; + +public interface Message extends Serializable { + MessageType type(); + + UUID workId(); +} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/rabbitmq/messages/MessageType.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/rabbitmq/messages/MessageType.java similarity index 100% rename from faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/rabbitmq/messages/MessageType.java rename to faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/rabbitmq/messages/MessageType.java diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/rabbitmq/messages/MetaDataMessage.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/rabbitmq/messages/MetaDataMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..eb550f802e60b77893c550bf84cf3ccc90d7a887 --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/rabbitmq/messages/MetaDataMessage.java @@ -0,0 +1,13 @@ +package eu.fairkom.faircommons.common.rabbitmq.messages; + +import java.util.UUID; + +public record MetaDataMessage( + UUID workId, + String metaData, + MessageType type) implements Message { + + public MetaDataMessage(UUID workId, String metaData) { + this(workId, metaData, MessageType.META); + } +} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/rabbitmq/messages/PostRegistrationMessage.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/rabbitmq/messages/PostRegistrationMessage.java similarity index 51% rename from faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/rabbitmq/messages/PostRegistrationMessage.java rename to faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/rabbitmq/messages/PostRegistrationMessage.java index 03fdd8e27aaf609967577605fad13fe0310fd8a7..bcf03c2fafe90e92ddbef894ecb1d649b5e59d65 100644 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/rabbitmq/messages/PostRegistrationMessage.java +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/rabbitmq/messages/PostRegistrationMessage.java @@ -1,13 +1,8 @@ package eu.fairkom.faircommons.common.rabbitmq.messages; import eu.fairkom.faircommons.common.models.views.WorkView; -import lombok.Builder; -import lombok.Value; import java.io.Serializable; -@Builder -@Value -public class PostRegistrationMessage implements Serializable { - WorkView work; +public record PostRegistrationMessage(WorkView work) implements Serializable { } diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/rabbitmq/messages/StatusEvent.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/rabbitmq/messages/StatusEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..92492a570057633d778b3083581eac48ac5b047c --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/rabbitmq/messages/StatusEvent.java @@ -0,0 +1,15 @@ +package eu.fairkom.faircommons.common.rabbitmq.messages; + +import eu.fairkom.faircommons.common.models.views.WorkStatusView; + +import java.util.UUID; + +public record StatusEvent( + UUID workId, + WorkStatusView status, + MessageType type) implements Message { + + public StatusEvent(UUID workId, WorkStatusView status) { + this(workId, status, MessageType.SUCCESS); + } +} diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/rabbitmq/messages/WorkFileMessage.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/rabbitmq/messages/WorkFileMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..3cc0c7debce2069cdec62362430e45a133931cf4 --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/rabbitmq/messages/WorkFileMessage.java @@ -0,0 +1,17 @@ +package eu.fairkom.faircommons.common.rabbitmq.messages; + +import eu.fairkom.faircommons.common.models.views.WorkFileView; + +import java.util.UUID; + + +public record WorkFileMessage( + UUID workId, + WorkFileView workFile, + String userId, + MessageType type) implements Message { + + public WorkFileMessage(UUID workId, WorkFileView workFile, String userId) { + this(workId, workFile, userId, MessageType.FILE); + } +} diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/ActuatorAutoConfigurer.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/ActuatorAutoConfigurer.java index b7d284ce0748eee289d338fef788b88dc295e631..ee7cc07eb51872b7718ee9f4d0ed63c22e015e12 100644 --- a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/ActuatorAutoConfigurer.java +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/ActuatorAutoConfigurer.java @@ -1,5 +1,8 @@ package eu.fairkom.faircommons.common.security; +import eu.fairkom.faircommons.common.security.models.ActuatorProperties; +import eu.fairkom.faircommons.common.security.models.ConfigurerOrders; +import eu.fairkom.faircommons.common.security.models.WebSecurityProperties; import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; @@ -51,8 +54,8 @@ public class ActuatorAutoConfigurer { public UserDetailsService userDetailsService() { var encoder = PasswordEncoderFactories.createDelegatingPasswordEncoder(); - var user = User.withUsername(actuatorProperties.getUsername()) - .password(encoder.encode(actuatorProperties.getPassword())) + var user = User.withUsername(actuatorProperties.username()) + .password(encoder.encode(actuatorProperties.password())) .authorities(List.of()) .build(); diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/ResourceServerAutoConfigurer.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/ResourceServerAutoConfigurer.java index 312f05b2c1196eadd6b5936e82d251f75192cf2e..55dacbfa13071c2a1e7296ae6c37ae0e0647bd74 100644 --- a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/ResourceServerAutoConfigurer.java +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/ResourceServerAutoConfigurer.java @@ -1,6 +1,9 @@ package eu.fairkom.faircommons.common.security; +import eu.fairkom.faircommons.common.security.models.ConfigurerOrders; +import eu.fairkom.faircommons.common.security.models.ResourceProperties; +import eu.fairkom.faircommons.common.security.models.WebSecurityProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -63,9 +66,9 @@ public class ResourceServerAutoConfigurer { } private void configureDefaultAuth(AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry authorize) { - if (resourceProperties.getDefaultScope() != null) { - logger.trace("Securing all remaining requests with {}", resourceProperties.getDefaultScope()); - authorize.anyRequest().hasAuthority("SCOPE_" + resourceProperties.getDefaultScope()); + if (resourceProperties.defaultScope() != null) { + logger.trace("Securing all remaining requests with {}", resourceProperties.defaultScope()); + authorize.anyRequest().hasAuthority("SCOPE_" + resourceProperties.defaultScope()); } else { logger.info("Securing all remaining requests with authenticated user."); authorize.anyRequest().authenticated(); @@ -73,10 +76,11 @@ public class ResourceServerAutoConfigurer { } private void configureCustomAuth(AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry authorize) { - resourceProperties.getPaths().forEach(path -> { + resourceProperties.paths().forEach(securedPath -> { logger.info("Securing {} requests to {} with {}", - path.getMethods(), path.getPath(), path.getScopes()); - authorize.requestMatchers(matcher(path)).hasAnyAuthority(asAuthorities(path.getScopes())) + securedPath.methods(), securedPath.path(), securedPath.scopes()); + authorize.requestMatchers(matcher(securedPath)) + .hasAnyAuthority(asAuthorities(securedPath.scopes())) .anyRequest().authenticated(); }); } @@ -88,8 +92,8 @@ public class ResourceServerAutoConfigurer { } private RequestMatcher matcher(ResourceProperties.SecuredPath securedPath) { - return securedPath.getMethods().stream() - .map(method -> new AntPathRequestMatcher(securedPath.getPath(), method.name())) + return securedPath.methods().stream() + .map(method -> new AntPathRequestMatcher(securedPath.path(), method.name())) .collect(collectingAndThen(Collectors.<RequestMatcher>toList(), OrRequestMatcher::new)); } } \ No newline at end of file diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/UnsecuredAutoConfigurer.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/UnsecuredAutoConfigurer.java index 02eb1f53710c615571935eb9de60a0c4475c8633..7d3ec5ba8896a555b92d5a90a2d2dc98ebad3832 100644 --- a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/UnsecuredAutoConfigurer.java +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/UnsecuredAutoConfigurer.java @@ -1,5 +1,8 @@ package eu.fairkom.faircommons.common.security; +import eu.fairkom.faircommons.common.security.models.ConfigurerOrders; +import eu.fairkom.faircommons.common.security.models.UnsecuredProperties; +import eu.fairkom.faircommons.common.security.models.WebSecurityProperties; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -45,7 +48,7 @@ public class UnsecuredAutoConfigurer { } private RequestMatcher buildUnsecuredRequestMatcher() { - return unsecuredProperties.getPaths().stream() + return unsecuredProperties.paths().stream() .map(AntPathRequestMatcher::new) .collect(collectingAndThen(Collectors.<RequestMatcher>toList(), OrRequestMatcher::new)); } diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/security/ActuatorProperties.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/models/ActuatorProperties.java similarity index 78% rename from faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/security/ActuatorProperties.java rename to faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/models/ActuatorProperties.java index 64e1486f5f0b118a544f01e4933a86155306ccc1..a8815c2717cdbf074240c9489d36d29d01a4b9e1 100644 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/security/ActuatorProperties.java +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/models/ActuatorProperties.java @@ -1,17 +1,15 @@ -package eu.fairkom.faircommons.common.security; +package eu.fairkom.faircommons.common.security.models; -import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.util.Assert; import org.springframework.validation.Errors; import org.springframework.validation.Validator; -@Data @ConfigurationProperties(ActuatorProperties.PREFIX) -public class ActuatorProperties implements Validator { +public record ActuatorProperties( + String username, + String password) implements Validator { public static final String PREFIX = WebSecurityProperties.PREFIX + ".actuator"; - private String username; - private String password; @Override public boolean supports(Class<?> clazz) { diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/security/ConfigurerOrders.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/models/ConfigurerOrders.java similarity index 53% rename from faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/security/ConfigurerOrders.java rename to faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/models/ConfigurerOrders.java index 12bc019a23feae19a528f59e8dba08f9dae3cac2..5c7b881639e558808408b42d41c42c4e71f91768 100644 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/security/ConfigurerOrders.java +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/models/ConfigurerOrders.java @@ -1,10 +1,10 @@ -package eu.fairkom.faircommons.common.security; +package eu.fairkom.faircommons.common.security.models; -import lombok.experimental.UtilityClass; +public final class ConfigurerOrders { -@UtilityClass -public class ConfigurerOrders { public static final int UNSECURED = 0; public static final int ACTUATOR = UNSECURED + 1; public static final int RESOURCE = ACTUATOR + 1; + private ConfigurerOrders() { + } } \ No newline at end of file diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/models/ResourceProperties.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/models/ResourceProperties.java new file mode 100644 index 0000000000000000000000000000000000000000..575b4037b8697da93f38be4522b199d558f12a91 --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/models/ResourceProperties.java @@ -0,0 +1,30 @@ +package eu.fairkom.faircommons.common.security.models; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.bind.DefaultValue; +import org.springframework.http.HttpMethod; + +import java.util.List; +import java.util.Set; + +@ConfigurationProperties(ResourceProperties.PREFIX) +public record ResourceProperties( + @DefaultValue List<SecuredPath> paths, + String defaultScope) { + public static final String PREFIX = WebSecurityProperties.PREFIX + ".resource"; + + public record SecuredPath( + String path, + List<String> scopes, + @DefaultValue({ + "GET", + "HEAD", + "POST", + "PUT", + "PATCH", + "DELETE", + "OPTIONS", + "TRACE"}) Set<HttpMethod> methods + ) { + } +} diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/models/UnsecuredProperties.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/models/UnsecuredProperties.java new file mode 100644 index 0000000000000000000000000000000000000000..c5ddceb9169db29473759adde6ff748528324dc7 --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/models/UnsecuredProperties.java @@ -0,0 +1,15 @@ +package eu.fairkom.faircommons.common.security.models; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.bind.DefaultValue; + +import java.util.List; + +@ConfigurationProperties(UnsecuredProperties.PREFIX) +public record UnsecuredProperties( + @DefaultValue({"/swagger-ui.html", + "/swagger-ui/**", + "/v3/api-docs/**", + "/actuator/health"}) List<String> paths) { + public static final String PREFIX = WebSecurityProperties.PREFIX + ".unsecured"; +} diff --git a/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/models/WebSecurityProperties.java b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/models/WebSecurityProperties.java new file mode 100644 index 0000000000000000000000000000000000000000..5b40a2ddab902d9712ac3f1b43cc3e5fc3e6302b --- /dev/null +++ b/faircommons-services/common/src/main/java/eu/fairkom/faircommons/common/security/models/WebSecurityProperties.java @@ -0,0 +1,9 @@ +package eu.fairkom.faircommons.common.security.models; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.bind.DefaultValue; + +@ConfigurationProperties(WebSecurityProperties.PREFIX) +public record WebSecurityProperties(@DefaultValue("true") boolean enabled) { + public static final String PREFIX = "security.web"; +} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/minio/models/MinioConfigurationProperties.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/minio/models/MinioConfigurationProperties.java deleted file mode 100644 index ce5ef44a8e9867fb4e35a33f005d89105b0aa829..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/minio/models/MinioConfigurationProperties.java +++ /dev/null @@ -1,16 +0,0 @@ -package eu.fairkom.faircommons.common.minio.models; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; - -@Data -@ConfigurationProperties("minio") -public class MinioConfigurationProperties { - private String url; - private String accessKey; - private String secretKey; - private boolean secure; - private String bucketPrefix; - private String region; - -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/DownloadFileResponse.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/DownloadFileResponse.java deleted file mode 100644 index 427ab6f64d066bad9ebcaa65e86b0c6e24218787..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/DownloadFileResponse.java +++ /dev/null @@ -1,12 +0,0 @@ -package eu.fairkom.faircommons.common.models; - -import lombok.Builder; -import lombok.Value; -import org.springframework.core.io.InputStreamResource; - -@Value -@Builder -public class DownloadFileResponse { - InputStreamResource inputStreamResource; - String filename; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/WorkFilter.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/WorkFilter.java deleted file mode 100644 index ce58627a99ab1259d1ee9108d3f59b13a48a2324..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/WorkFilter.java +++ /dev/null @@ -1,17 +0,0 @@ -package eu.fairkom.faircommons.common.models; - -import lombok.Builder; -import lombok.Value; -import lombok.extern.jackson.Jacksonized; - -import java.util.List; - -@Value -@Builder -@Jacksonized -public class WorkFilter { - WorkType type; - String title; - List<String> tags; - String licenseIdentifier; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/Author.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/Author.java deleted file mode 100644 index 541b7a5bccad9eb8718c9a2af8c12e65b92b4f2e..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/Author.java +++ /dev/null @@ -1,27 +0,0 @@ -package eu.fairkom.faircommons.common.models.entities; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hibernate.annotations.UuidGenerator; - -import java.util.UUID; - -@Getter -@Setter -@Entity -@NoArgsConstructor -public class Author extends Identifiable<UUID> { - @Id - @GeneratedValue - @UuidGenerator - private UUID id; - private String firstName; - private String lastName; - private String email; - private String pseudonym; - private String url; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/Contributor.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/Contributor.java deleted file mode 100644 index 86dc5d8bdb75d20d5bdd1d705bfac00af9d791bd..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/Contributor.java +++ /dev/null @@ -1,32 +0,0 @@ -package eu.fairkom.faircommons.common.models.entities; - -import jakarta.persistence.*; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hibernate.annotations.UuidGenerator; - -import java.util.UUID; - -@Getter -@Setter -@Entity -@NoArgsConstructor -public class Contributor extends Identifiable<UUID> { - @Id - @GeneratedValue - @UuidGenerator - private UUID id; - - @OneToOne(mappedBy = "creator", fetch = FetchType.LAZY) - private Work workAsCreator; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "work_as_contributor_id") - private Work workAsContributor; - - @ManyToOne(cascade = CascadeType.ALL) - @JoinColumn(name = "author_id", nullable = false) - private Author author; - private Integer percentage; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/embedded/HashCode.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/embedded/HashCode.java deleted file mode 100644 index 3f3f520b6a199152a4e8c5ccf47fafe6a43a3a60..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/embedded/HashCode.java +++ /dev/null @@ -1,19 +0,0 @@ -package eu.fairkom.faircommons.common.models.entities.embedded; - -import jakarta.persistence.Column; -import jakarta.persistence.Embeddable; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Getter -@Setter -@NoArgsConstructor -@Embeddable -public class HashCode { - @Column(updatable = false) - private String algorithm; - - @Column(updatable = false) - private String hexValue; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/embedded/License.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/embedded/License.java deleted file mode 100644 index 3d56437926c40ba07eb8644125f15bddd5eada7e..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/embedded/License.java +++ /dev/null @@ -1,19 +0,0 @@ -package eu.fairkom.faircommons.common.models.entities.embedded; - -import jakarta.persistence.Column; -import jakarta.persistence.Embeddable; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Getter -@Setter -@NoArgsConstructor -@Embeddable -public class License { - @Column(updatable = false) - private String identifier; //immutable SPDX - private String addons; - private String dual; - private String dalicc; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/embedded/Revocation.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/embedded/Revocation.java deleted file mode 100644 index 1ca5362d57cbf591d82d01966e385a87d3f39d23..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/entities/embedded/Revocation.java +++ /dev/null @@ -1,17 +0,0 @@ -package eu.fairkom.faircommons.common.models.entities.embedded; - -import jakarta.persistence.Embeddable; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import java.time.ZonedDateTime; - -@Getter -@Setter -@NoArgsConstructor -@Embeddable -public class Revocation { - private ZonedDateTime date; - private String note; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/AuthorView.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/AuthorView.java deleted file mode 100644 index b052f6c0ec95b9232862027c4cd13526bc013a3b..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/AuthorView.java +++ /dev/null @@ -1,22 +0,0 @@ -package eu.fairkom.faircommons.common.models.views; - -import jakarta.validation.constraints.Email; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.Size; -import lombok.Builder; -import lombok.Value; -import lombok.extern.jackson.Jacksonized; - -import java.util.UUID; - -@Value -@Builder -@Jacksonized -public class AuthorView implements IdentifiableView<UUID> { - UUID id; - @Size(max = 255) @NotBlank String firstName; - @Size(max = 255) @NotBlank String lastName; - @Size(max = 255) @Email String email; - @Size(max = 255) @NotBlank String pseudonym; - @Size(max = 255) String url; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/ContributorView.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/ContributorView.java deleted file mode 100644 index 291c3a4ef1edb5cb17ba74e4a741eeb087531d42..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/ContributorView.java +++ /dev/null @@ -1,18 +0,0 @@ -package eu.fairkom.faircommons.common.models.views; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; -import lombok.Builder; -import lombok.Value; -import lombok.extern.jackson.Jacksonized; - -import java.util.UUID; - -@Value -@Builder -@Jacksonized -public class ContributorView implements IdentifiableView<UUID> { - UUID id; - @Valid AuthorView author; - @NotNull Integer percentage; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/FileUploadView.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/FileUploadView.java deleted file mode 100644 index 634c34b53ec0cec77cec780437c8c5c84270ecc0..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/FileUploadView.java +++ /dev/null @@ -1,14 +0,0 @@ -package eu.fairkom.faircommons.common.models.views; - -import lombok.Builder; -import lombok.Value; -import lombok.extern.jackson.Jacksonized; - -@Value -@Builder -@Jacksonized -public class FileUploadView { - String prefix; - String filename; - String url; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/HashCodeView.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/HashCodeView.java deleted file mode 100644 index 84919550d4f880f1cf9d0d4bee0c7ae5a6075b2f..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/HashCodeView.java +++ /dev/null @@ -1,15 +0,0 @@ -package eu.fairkom.faircommons.common.models.views; - -import lombok.Builder; -import lombok.Value; -import lombok.extern.jackson.Jacksonized; - -import java.io.Serializable; - -@Value -@Builder -@Jacksonized -public class HashCodeView implements Serializable { - String algorithm; - String hexValue; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/IpfsEntryView.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/IpfsEntryView.java deleted file mode 100644 index 0d69d623b2e0249395611db4093b201aef9048ce..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/IpfsEntryView.java +++ /dev/null @@ -1,15 +0,0 @@ -package eu.fairkom.faircommons.common.models.views; - -import lombok.Builder; -import lombok.Value; -import lombok.extern.jackson.Jacksonized; - -import java.io.Serializable; - -@Value -@Builder -@Jacksonized -public class IpfsEntryView implements Serializable { - String cid; - String path; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/LicenseView.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/LicenseView.java deleted file mode 100644 index 2e126d19abdec44dc99a3dd6020cc528c09cfcdd..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/LicenseView.java +++ /dev/null @@ -1,20 +0,0 @@ -package eu.fairkom.faircommons.common.models.views; - - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.Size; -import lombok.Builder; -import lombok.Value; -import lombok.extern.jackson.Jacksonized; - -import java.io.Serializable; - -@Value -@Builder -@Jacksonized -public class LicenseView implements Serializable { - @Size(max = 255) @NotEmpty String identifier; //immutable SPDX - @Size(max = 255) String addons; - @Size(max = 255) String dual; - @Size(max = 255) String dalicc; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/MetaDataView.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/MetaDataView.java deleted file mode 100644 index ae81d80e3e9d09a9ecf55ae4af72c7d819408128..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/MetaDataView.java +++ /dev/null @@ -1,31 +0,0 @@ -package eu.fairkom.faircommons.common.models.views; - -import eu.fairkom.faircommons.common.models.entities.embedded.HashCode; -import eu.fairkom.faircommons.common.models.entities.embedded.IpfsEntry; -import lombok.Builder; -import lombok.Value; -import lombok.extern.jackson.Jacksonized; - -import java.io.Serializable; -import java.time.ZonedDateTime; -import java.util.UUID; - -//all attributes immutable - -@Value -@Builder -@Jacksonized -public class MetaDataView implements Serializable { - UUID workId; - String title; - String description; - ZonedDateTime creationDate; - ZonedDateTime registrationDate; - String registrar; - WorkFileView workFile; - HashCode hashFile; - HashCode hashMeta; - IpfsEntry ipfsFile; - IpfsEntry ipfsMeta; - String licenseIdentifier; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/PublicAuthorView.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/PublicAuthorView.java deleted file mode 100644 index 98fa5d0874837c0f0cf0acbb60bb393cbaa2f9bd..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/PublicAuthorView.java +++ /dev/null @@ -1,13 +0,0 @@ -package eu.fairkom.faircommons.common.models.views; - -import lombok.Builder; -import lombok.Value; -import lombok.extern.jackson.Jacksonized; - -@Value -@Builder -@Jacksonized -public class PublicAuthorView { - String pseudonym; - String url; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/PublicContributorView.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/PublicContributorView.java deleted file mode 100644 index 8e22591e1708134d3993d0f031a53618306585ca..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/PublicContributorView.java +++ /dev/null @@ -1,13 +0,0 @@ -package eu.fairkom.faircommons.common.models.views; - -import lombok.Builder; -import lombok.Value; -import lombok.extern.jackson.Jacksonized; - -@Value -@Builder -@Jacksonized -public class PublicContributorView { - PublicAuthorView author; - Integer percentage; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/PublicWorkView.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/PublicWorkView.java deleted file mode 100644 index 8a4b219fff70b34d31f9163e013b36f29b857a33..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/PublicWorkView.java +++ /dev/null @@ -1,29 +0,0 @@ -package eu.fairkom.faircommons.common.models.views; - -import eu.fairkom.faircommons.common.models.WorkType; -import lombok.Builder; -import lombok.Value; -import lombok.extern.jackson.Jacksonized; - -import java.time.ZonedDateTime; -import java.util.List; - -@Value -@Builder -@Jacksonized -public class PublicWorkView { - WorkType type; - String title; - String description; - List<String> tags; - String registrar; - ZonedDateTime registrationDate; - ZonedDateTime creationDate; - String publisher; - String identifier; - String language; - PublicContributorView creator; - LicenseView license; - String grid; - String filename; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/RevocationView.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/RevocationView.java deleted file mode 100644 index 06027e666a712c8d4f4ed14b20267f343e80e5e0..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/RevocationView.java +++ /dev/null @@ -1,16 +0,0 @@ -package eu.fairkom.faircommons.common.models.views; - -import lombok.Builder; -import lombok.Value; -import lombok.extern.jackson.Jacksonized; - -import java.io.Serializable; -import java.time.ZonedDateTime; - -@Value -@Builder -@Jacksonized -public class RevocationView implements Serializable { - ZonedDateTime date; - String note; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/TagView.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/TagView.java deleted file mode 100644 index dd05dd23263a09f8b4effdc41480977bbe8b5d5e..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/TagView.java +++ /dev/null @@ -1,13 +0,0 @@ -package eu.fairkom.faircommons.common.models.views; - -import lombok.Builder; -import lombok.Value; -import lombok.extern.jackson.Jacksonized; - -@Value -@Builder -@Jacksonized -public class TagView implements IdentifiableView<Long> { - Long id; - String name; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/WorkCreateView.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/WorkCreateView.java deleted file mode 100644 index 40c7cfb6b2b5812a688c3c918b8b981dd933c779..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/WorkCreateView.java +++ /dev/null @@ -1,41 +0,0 @@ -package eu.fairkom.faircommons.common.models.views; - -import eu.fairkom.faircommons.common.models.StorageOption; -import eu.fairkom.faircommons.common.models.WorkType; -import eu.fairkom.faircommons.common.models.WorkVisibility; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Pattern; -import jakarta.validation.constraints.Size; -import lombok.Builder; -import lombok.Value; -import lombok.extern.jackson.Jacksonized; - -import java.time.ZonedDateTime; -import java.util.List; - -@Value -@Builder -@Jacksonized -public class WorkCreateView { - @NotNull WorkType type; - @Size(max = 100) @NotBlank String title; //immutable - @Size(max = 2000) @NotBlank String description; //immutable - List<String> tags; - @Size(max = 2) String language; - ZonedDateTime creationDate; - @Size(max = 36) @NotBlank String registrar; //immutable, keycloakUserId - @Valid ContributorView creator; - @Valid List<ContributorView> contributors; - @Size(max = 255) String publisher; - @Size(max = 255) String identifier; - @Valid WorkFileView workFile; //immutable - @NotNull WorkVisibility visibility; - @Builder.Default - List<StorageOption> storageOptions = List.of(StorageOption.FAIRREGISTER_FILE_SYSTEM); - @Valid LicenseView license; - @Pattern(regexp = "RC-(01|FAREG)-(LIZ\\d{10}|\\d{10})-([A-Z]|\\d)(?=$)") - String grid; //TODO remove after migration - ZonedDateTime registrationDate; //TODO remove after migration -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/WorkFileView.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/WorkFileView.java deleted file mode 100644 index abf04ffb8abd6508b7e9458f061bbde24ca12cd2..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/WorkFileView.java +++ /dev/null @@ -1,23 +0,0 @@ -package eu.fairkom.faircommons.common.models.views; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.Size; -import lombok.Builder; -import lombok.Value; -import lombok.extern.jackson.Jacksonized; - -import java.io.Serializable; - -@Value -@Builder -@Jacksonized -public class WorkFileView implements Serializable { - @Size(max = 255) @NotEmpty String prefix; - @Size(max = 255) @NotEmpty String filename; - - @JsonIgnore - public String getFilenameWithPrefix() { - return prefix + "/" + filename; - } -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/WorkStatusView.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/WorkStatusView.java deleted file mode 100644 index b050e3fb767781d388eedb5b6a765a3651dc738a..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/WorkStatusView.java +++ /dev/null @@ -1,22 +0,0 @@ -package eu.fairkom.faircommons.common.models.views; - -import eu.fairkom.faircommons.common.models.entities.WorkStatus; -import lombok.Builder; -import lombok.Value; -import lombok.extern.jackson.Jacksonized; - -import java.io.Serializable; -import java.time.ZonedDateTime; -import java.util.UUID; - -@Value -@Builder -@Jacksonized -public class WorkStatusView implements Serializable { - UUID workId; - ZonedDateTime created; - HashCodeView hashCode; - IpfsEntryView ipfsEntry; - String errorMessage; - WorkStatus.WorkStatusType type; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/WorkView.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/WorkView.java deleted file mode 100644 index 544d828b6f4afb7a638bdc8416bccf9e964e56b3..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/models/views/WorkView.java +++ /dev/null @@ -1,48 +0,0 @@ -package eu.fairkom.faircommons.common.models.views; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import eu.fairkom.faircommons.common.models.StorageOption; -import eu.fairkom.faircommons.common.models.WorkType; -import eu.fairkom.faircommons.common.models.WorkVisibility; -import lombok.Builder; -import lombok.Value; -import lombok.extern.jackson.Jacksonized; - -import java.time.ZonedDateTime; -import java.util.List; -import java.util.Set; -import java.util.UUID; - -@Value -@Builder -@Jacksonized -public class WorkView implements IdentifiableView<UUID> { - UUID id; - WorkType type; - String title; - String description; - String filename; - ZonedDateTime registrationDate; - ZonedDateTime creationDate; - String status; - String language; - String identifier; - List<String> tags; - LicenseView license; - ContributorView creator; - List<ContributorView> contributors; - String publisher; - IpfsEntryView ipfsFile; - IpfsEntryView ipfsMeta; - HashCodeView hashFile; - HashCodeView hashMeta; - @JsonIgnore - Set<StorageOption> storageOptions; - @JsonIgnore - WorkFileView workFile; - String registrar; - WorkVisibility visibility; - RevocationView revocation; - ZonedDateTime publishingDate; - String grid; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/rabbitmq/messages/Message.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/rabbitmq/messages/Message.java deleted file mode 100644 index 0c2438c1277ffcfa3ae5395777bbc5f96e0f6c8e..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/rabbitmq/messages/Message.java +++ /dev/null @@ -1,14 +0,0 @@ -package eu.fairkom.faircommons.common.rabbitmq.messages; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.io.Serializable; -import java.util.UUID; - -@Getter -@AllArgsConstructor -public abstract class Message implements Serializable { - MessageType type; - UUID workId; -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/rabbitmq/messages/MetaDataMessage.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/rabbitmq/messages/MetaDataMessage.java deleted file mode 100644 index f6726bfe776dd80cc87e01de31488b59b5c6d103..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/rabbitmq/messages/MetaDataMessage.java +++ /dev/null @@ -1,17 +0,0 @@ -package eu.fairkom.faircommons.common.rabbitmq.messages; - -import lombok.Builder; -import lombok.Getter; - -import java.util.UUID; - -@Getter -public class MetaDataMessage extends Message { - private final String metaData; - - @Builder - public MetaDataMessage(UUID workId, String metaData) { - super(MessageType.META, workId); - this.metaData = metaData; - } -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/rabbitmq/messages/StatusEvent.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/rabbitmq/messages/StatusEvent.java deleted file mode 100644 index da279201319cbce5c81c1cc3764f43209f52f345..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/rabbitmq/messages/StatusEvent.java +++ /dev/null @@ -1,18 +0,0 @@ -package eu.fairkom.faircommons.common.rabbitmq.messages; - -import eu.fairkom.faircommons.common.models.views.WorkStatusView; -import lombok.Builder; -import lombok.Getter; - -import java.util.UUID; - -@Getter -public class StatusEvent extends Message { - private final WorkStatusView status; - - @Builder - public StatusEvent(UUID workId, WorkStatusView status) { - super(MessageType.SUCCESS, workId); - this.status = status; - } -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/rabbitmq/messages/WorkFileMessage.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/rabbitmq/messages/WorkFileMessage.java deleted file mode 100644 index 101f74179fce6354538b59a7531de8885f3dc336..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/rabbitmq/messages/WorkFileMessage.java +++ /dev/null @@ -1,20 +0,0 @@ -package eu.fairkom.faircommons.common.rabbitmq.messages; - -import eu.fairkom.faircommons.common.models.views.WorkFileView; -import lombok.Builder; -import lombok.Getter; - -import java.util.UUID; - -@Getter -public class WorkFileMessage extends Message { - private final WorkFileView workFile; - private final String userId; - - @Builder - public WorkFileMessage(UUID workId, WorkFileView workFile, String userId) { - super(MessageType.FILE, workId); - this.workFile = workFile; - this.userId = userId; - } -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/security/ResourceProperties.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/security/ResourceProperties.java deleted file mode 100644 index 9c85d25c0c091e2c3b62512c5ab2d5618c1fcb53..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/security/ResourceProperties.java +++ /dev/null @@ -1,25 +0,0 @@ -package eu.fairkom.faircommons.common.security; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.http.HttpMethod; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -@Data -@ConfigurationProperties(ResourceProperties.PREFIX) -public class ResourceProperties { - public static final String PREFIX = WebSecurityProperties.PREFIX + ".resource"; - private List<SecuredPath> paths = List.of(); - private String defaultScope; - - @Data - public static class SecuredPath { - private String path; - private List<String> scopes; - private Set<HttpMethod> methods = new HashSet<>(Arrays.asList(HttpMethod.values())); - } -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/security/UnsecuredProperties.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/security/UnsecuredProperties.java deleted file mode 100644 index 1398ee543db1b91ff55011f50888daf72abdeb06..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/security/UnsecuredProperties.java +++ /dev/null @@ -1,19 +0,0 @@ -package eu.fairkom.faircommons.common.security; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; - -import java.util.List; - -@Data -@ConfigurationProperties(UnsecuredProperties.PREFIX) -public class UnsecuredProperties { - public static final String PREFIX = WebSecurityProperties.PREFIX + ".unsecured"; - - private List<String> paths = List.of( - "/swagger-ui.html", - "/swagger-ui/**", - "/v3/api-docs/**", - "/actuator/health" - ); -} diff --git a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/security/WebSecurityProperties.java b/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/security/WebSecurityProperties.java deleted file mode 100644 index 695424e69f83c796c64de64191a28d828cbf2e3a..0000000000000000000000000000000000000000 --- a/faircommons-services/common/src/main/lombok/eu/fairkom/faircommons/common/security/WebSecurityProperties.java +++ /dev/null @@ -1,11 +0,0 @@ -package eu.fairkom.faircommons.common.security; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; - -@Data -@ConfigurationProperties(WebSecurityProperties.PREFIX) -public class WebSecurityProperties { - public static final String PREFIX = "security.web"; - private boolean enabled = true; -} diff --git a/faircommons-services/hashing-service/pom.xml b/faircommons-services/hashing-service/pom.xml index 36e1370373b09e64f344978ce1e2e703826852ab..9f4a877e4705c93fe2e498861caa07f593110251 100644 --- a/faircommons-services/hashing-service/pom.xml +++ b/faircommons-services/hashing-service/pom.xml @@ -20,8 +20,8 @@ </dependencies> <properties> - <maven.compiler.source>17</maven.compiler.source> - <maven.compiler.target>17</maven.compiler.target> + <maven.compiler.source>${java.version}</maven.compiler.source> + <maven.compiler.target>${java.version}</maven.compiler.target> </properties> <build> @@ -29,14 +29,6 @@ <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> - <configuration> - <excludes> - <exclude> - <groupId>org.projectlombok</groupId> - <artifactId>lombok</artifactId> - </exclude> - </excludes> - </configuration> </plugin> </plugins> </build> diff --git a/faircommons-services/hashing-service/src/main/java/eu/fairkom/faircommons/hashing_service/listener/HashingServiceListener.java b/faircommons-services/hashing-service/src/main/java/eu/fairkom/faircommons/hashing_service/listener/HashingServiceListener.java index c7a462efa942c98f91955f274d61af6d092fe05e..1c076d52bbcc34dfa2aac647e92c56004f6e4909 100644 --- a/faircommons-services/hashing-service/src/main/java/eu/fairkom/faircommons/hashing_service/listener/HashingServiceListener.java +++ b/faircommons-services/hashing-service/src/main/java/eu/fairkom/faircommons/hashing_service/listener/HashingServiceListener.java @@ -26,18 +26,18 @@ public class HashingServiceListener implements RabbitMqListener<Message> { @Override public void receive(Message message) { try { - logger.info("Received message of type: {} for work ID: {}", message.getType(), message.getWorkId()); - switch (message.getType()) { + logger.info("Received message of type: {} for work ID: {}", message.type(), message.workId()); + switch (message.type()) { case FILE -> messageHandler.handleWorkFileMessage((WorkFileMessage) message); case META -> messageHandler.handleMetaDataMessage((MetaDataMessage) message); default -> logger.error("Unknown message type."); } } catch (MinioException e) { - logger.error("Could not download work file for work ID: {}", message.getWorkId(), e); - messageHandler.handleError(message.getWorkId(), e); + logger.error("Could not download work file for work ID: {}", message.workId(), e); + messageHandler.handleError(message.workId(), e); } catch (Throwable e) { - logger.error("Unexpected error during hashing for work ID: {}", message.getWorkId(), e); - messageHandler.handleError(message.getWorkId(), e); + logger.error("Unexpected error during hashing for work ID: {}", message.workId(), e); + messageHandler.handleError(message.workId(), e); } } } diff --git a/faircommons-services/hashing-service/src/main/java/eu/fairkom/faircommons/hashing_service/service/HashingServiceMessageHandler.java b/faircommons-services/hashing-service/src/main/java/eu/fairkom/faircommons/hashing_service/service/HashingServiceMessageHandler.java index 850547fc62f058abcf32861d769ff919279cd5e7..e571b238b38cfc6c6e0a9d748d1b72fcbaf5d4d3 100644 --- a/faircommons-services/hashing-service/src/main/java/eu/fairkom/faircommons/hashing_service/service/HashingServiceMessageHandler.java +++ b/faircommons-services/hashing-service/src/main/java/eu/fairkom/faircommons/hashing_service/service/HashingServiceMessageHandler.java @@ -2,6 +2,7 @@ package eu.fairkom.faircommons.hashing_service.service; import eu.fairkom.faircommons.common.minio.MinioService; import eu.fairkom.faircommons.common.models.entities.WorkStatus; +import eu.fairkom.faircommons.common.models.views.HashCodeView; import eu.fairkom.faircommons.common.rabbitmq.MessageHandler; import eu.fairkom.faircommons.common.rabbitmq.messages.MetaDataMessage; import eu.fairkom.faircommons.common.rabbitmq.messages.WorkFileMessage; @@ -35,19 +36,19 @@ public class HashingServiceMessageHandler extends MessageHandler { @Override public void handleWorkFileMessage(WorkFileMessage message) { - var userId = message.getUserId(); - var filename = message.getWorkFile().getFilenameWithPrefix(); + var userId = message.userId(); + var filename = message.workFile().filenameWithPrefix(); try (var workFileStream = minioService.downloadFile(userId, filename)) { var hashValue = hashingService.getChecksum(workFileStream, algorithm); - var hashCode = buildHashCodeView(algorithm, hashValue); + var hashCode = new HashCodeView(algorithm, hashValue); - logger.info("Work File hashing done. Sending success event for work ID {}", message.getWorkId()); - sendStatusEvent(message.getWorkId(), hashCode, + logger.info("Work File hashing done. Sending success event for work ID {}", message.workId()); + sendStatusEvent(message.workId(), hashCode, WorkStatus.WorkStatusType.FILE_HASHING_DONE); } catch (IOException e) { - logger.error("Error while processing work file message with work ID {}: {}", message.getWorkId(), + logger.error("Error while processing work file message with work ID {}: {}", message.workId(), e.getMessage(), e); throw new UncheckedIOException(e); } @@ -55,16 +56,16 @@ public class HashingServiceMessageHandler extends MessageHandler { @Override public void handleMetaDataMessage(MetaDataMessage message) { - try (var metaDataStream = new ByteArrayInputStream(message.getMetaData().getBytes(StandardCharsets.UTF_8))) { + try (var metaDataStream = new ByteArrayInputStream(message.metaData().getBytes(StandardCharsets.UTF_8))) { var hashValue = hashingService.getChecksum(metaDataStream, algorithm); - var hashCode = buildHashCodeView(algorithm, hashValue); + var hashCode = new HashCodeView(algorithm, hashValue); - logger.info("Meta Data hashing done. Sending success event for work ID {}", message.getWorkId()); - sendStatusEvent(message.getWorkId(), + logger.info("Meta Data hashing done. Sending success event for work ID {}", message.workId()); + sendStatusEvent(message.workId(), hashCode, WorkStatus.WorkStatusType.META_HASHING_DONE); } catch (IOException e) { - logger.error("Error while processing meta data message with work ID {}: {}", message.getWorkId(), + logger.error("Error while processing meta data message with work ID {}: {}", message.workId(), e.getMessage(), e); throw new UncheckedIOException(e); } diff --git a/faircommons-services/ipfs-service/pom.xml b/faircommons-services/ipfs-service/pom.xml index 7e2b8da9b981a63d5ee1574174683e7f833b6ba9..76161ba56b5278549013a88b33e289eafbb8b263 100644 --- a/faircommons-services/ipfs-service/pom.xml +++ b/faircommons-services/ipfs-service/pom.xml @@ -12,8 +12,8 @@ <artifactId>ipfs-service</artifactId> <properties> - <maven.compiler.source>17</maven.compiler.source> - <maven.compiler.target>17</maven.compiler.target> + <maven.compiler.source>${java.version}</maven.compiler.source> + <maven.compiler.target>${java.version}</maven.compiler.target> </properties> <dependencies> @@ -42,14 +42,6 @@ <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> - <configuration> - <excludes> - <exclude> - <groupId>org.projectlombok</groupId> - <artifactId>lombok</artifactId> - </exclude> - </excludes> - </configuration> </plugin> </plugins> </build> diff --git a/faircommons-services/ipfs-service/src/main/java/eu/fairkom/faircommons/ipfs_service/listener/IpfsServiceListener.java b/faircommons-services/ipfs-service/src/main/java/eu/fairkom/faircommons/ipfs_service/listener/IpfsServiceListener.java index 82ffe5eb5ea7d9d6da86a89210220bae546c6bbe..80685b0e05d5942bcdd7dae46cae9ad89beacd1c 100644 --- a/faircommons-services/ipfs-service/src/main/java/eu/fairkom/faircommons/ipfs_service/listener/IpfsServiceListener.java +++ b/faircommons-services/ipfs-service/src/main/java/eu/fairkom/faircommons/ipfs_service/listener/IpfsServiceListener.java @@ -24,12 +24,12 @@ public class IpfsServiceListener implements RabbitMqListener<Message> { @Override public void receive(Message message) { - logger.info("Received message of type: {} for work ID: {}", message.getType(), message.getWorkId()); + logger.info("Received message of type: {} for work ID: {}", message.type(), message.workId()); - switch (message.getType()) { + switch (message.type()) { case FILE -> messageHandler.handleWorkFileMessage((WorkFileMessage) message); case META -> messageHandler.handleMetaDataMessage((MetaDataMessage) message); - default -> logger.error("Unknown message type: {}", message.getType()); + default -> logger.error("Unknown message type: {}", message.type()); } } } diff --git a/faircommons-services/ipfs-service/src/main/java/eu/fairkom/faircommons/ipfs_service/models/IpfsAddView.java b/faircommons-services/ipfs-service/src/main/java/eu/fairkom/faircommons/ipfs_service/models/IpfsAddView.java new file mode 100644 index 0000000000000000000000000000000000000000..8c26c092ca0c8173c022afae880a03ffcb74ed4c --- /dev/null +++ b/faircommons-services/ipfs-service/src/main/java/eu/fairkom/faircommons/ipfs_service/models/IpfsAddView.java @@ -0,0 +1,10 @@ +package eu.fairkom.faircommons.ipfs_service.models; + +import java.util.List; + +public record IpfsAddView( + String name, + String cid, + int size, + List<String> allocations) { +} diff --git a/faircommons-services/ipfs-service/src/main/java/eu/fairkom/faircommons/ipfs_service/service/IpfsClusterService.java b/faircommons-services/ipfs-service/src/main/java/eu/fairkom/faircommons/ipfs_service/service/IpfsClusterService.java index f3e10fc4055cbd1443fb31f001e328c770156bc8..7707279ae364f1ca9c4ecd94fdb184d3b1a3dcc9 100644 --- a/faircommons-services/ipfs-service/src/main/java/eu/fairkom/faircommons/ipfs_service/service/IpfsClusterService.java +++ b/faircommons-services/ipfs-service/src/main/java/eu/fairkom/faircommons/ipfs_service/service/IpfsClusterService.java @@ -16,6 +16,7 @@ import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; import java.io.InputStream; +import java.util.Objects; @Service @ConditionalOnProperty(prefix = "ipfs", name = "service", havingValue = "cluster") @@ -32,6 +33,7 @@ public class IpfsClusterService implements IpfsService { /** * Uploads a file to IPFS. + * * @param inputStream The InputStream of the file to upload. * @return the CID of the uploaded file. */ @@ -47,8 +49,8 @@ public class IpfsClusterService implements IpfsService { var requestEntity = new HttpEntity<>(body, headers); var response = restTemplate.postForEntity(UPLOAD_ENDPOINT, requestEntity, IpfsAddView.class); - return response.getBody().getCid(); - } catch (RestClientException e) { + return Objects.requireNonNull(response.getBody()).cid(); + } catch (RestClientException | NullPointerException e) { logger.error("Error uploading file to IPFS", e); throw new RuntimeException("Failed to upload file to IPFS.", e); } diff --git a/faircommons-services/ipfs-service/src/main/java/eu/fairkom/faircommons/ipfs_service/service/IpfsServiceMessageHandler.java b/faircommons-services/ipfs-service/src/main/java/eu/fairkom/faircommons/ipfs_service/service/IpfsServiceMessageHandler.java index c4dbaecda8a6b4a77b938e43050449986990d296..c98c33fe8dea24c0581d39bc25ec935cd99629c5 100644 --- a/faircommons-services/ipfs-service/src/main/java/eu/fairkom/faircommons/ipfs_service/service/IpfsServiceMessageHandler.java +++ b/faircommons-services/ipfs-service/src/main/java/eu/fairkom/faircommons/ipfs_service/service/IpfsServiceMessageHandler.java @@ -2,6 +2,7 @@ package eu.fairkom.faircommons.ipfs_service.service; import eu.fairkom.faircommons.common.minio.MinioService; import eu.fairkom.faircommons.common.models.entities.WorkStatus; +import eu.fairkom.faircommons.common.models.views.IpfsEntryView; import eu.fairkom.faircommons.common.rabbitmq.MessageHandler; import eu.fairkom.faircommons.common.rabbitmq.messages.MetaDataMessage; import eu.fairkom.faircommons.common.rabbitmq.messages.WorkFileMessage; @@ -31,15 +32,15 @@ public class IpfsServiceMessageHandler extends MessageHandler { @Override public void handleWorkFileMessage(WorkFileMessage message) { - var userId = message.getUserId(); - var filename = message.getWorkFile().getFilenameWithPrefix(); + var userId = message.userId(); + var filename = message.workFile().filenameWithPrefix(); try (var workFileStream = minioService.downloadFile(userId, filename)) { var cid = ipfsService.uploadFile(workFileStream); - var ipfsEntry = buildIpfsEntryView("", cid); + var ipfsEntry = new IpfsEntryView(cid); - logger.info("Work File successfully saved to IPFS. Sending success event for work ID {}", message.getWorkId()); - sendStatusEvent(message.getWorkId(), ipfsEntry, WorkStatus.WorkStatusType.FILE_IPFS_DONE); + logger.info("Work File successfully saved to IPFS. Sending success event for work ID {}", message.workId()); + sendStatusEvent(message.workId(), ipfsEntry, WorkStatus.WorkStatusType.FILE_IPFS_DONE); } catch (IOException e) { throw new UncheckedIOException(e); } @@ -47,13 +48,13 @@ public class IpfsServiceMessageHandler extends MessageHandler { @Override public void handleMetaDataMessage(MetaDataMessage message) { - try (var metaDataStream = new ByteArrayInputStream(message.getMetaData().getBytes(StandardCharsets.UTF_8))) { + try (var metaDataStream = new ByteArrayInputStream(message.metaData().getBytes(StandardCharsets.UTF_8))) { var cid = ipfsService.uploadFile(metaDataStream); - var ipfsEntry = buildIpfsEntryView("", cid); + var ipfsEntry = new IpfsEntryView(cid); - logger.info("Meta Data successfully saved to IPFS. Sending success event for work ID {}", message.getWorkId()); - sendStatusEvent(message.getWorkId(), ipfsEntry, WorkStatus.WorkStatusType.META_IPFS_DONE); + logger.info("Meta Data successfully saved to IPFS. Sending success event for work ID {}", message.workId()); + sendStatusEvent(message.workId(), ipfsEntry, WorkStatus.WorkStatusType.META_IPFS_DONE); } catch (IOException e) { throw new UncheckedIOException(e); } diff --git a/faircommons-services/ipfs-service/src/main/lombok/eu/fairkom/faircommons/ipfs_service/models/IpfsAddView.java b/faircommons-services/ipfs-service/src/main/lombok/eu/fairkom/faircommons/ipfs_service/models/IpfsAddView.java deleted file mode 100644 index 08c4f150597408f63856ab5279db3eefb8958292..0000000000000000000000000000000000000000 --- a/faircommons-services/ipfs-service/src/main/lombok/eu/fairkom/faircommons/ipfs_service/models/IpfsAddView.java +++ /dev/null @@ -1,17 +0,0 @@ -package eu.fairkom.faircommons.ipfs_service.models; - -import lombok.Builder; -import lombok.Value; -import lombok.extern.jackson.Jacksonized; - -import java.util.List; - -@Value -@Builder -@Jacksonized -public class IpfsAddView { - String name; - String cid; - int size; - List<String> allocations; -} diff --git a/faircommons-services/pom.xml b/faircommons-services/pom.xml index 59e758f7df84773354cdec30b780fe9460dfcd18..8bf7ff66a3d739901ba4b82680a80652a5258b23 100644 --- a/faircommons-services/pom.xml +++ b/faircommons-services/pom.xml @@ -6,7 +6,7 @@ <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> - <version>3.1.2</version> + <version>3.1.4</version> <relativePath/> <!-- lookup parent from repository --> </parent> @@ -23,13 +23,11 @@ </modules> <properties> - <java.version>17</java.version> - <mapstruct.version>1.5.3.Final</mapstruct.version> - <lombok-maven.version>1.18.20.0</lombok-maven.version> - <lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version> - <springdoc-openapi.version>2.1.0</springdoc-openapi.version> - <minio.version>8.5.2</minio.version> - <hibernate.version>6.2.0.Final</hibernate.version> + <java.version>21</java.version> + <mapstruct.version>1.5.5.Final</mapstruct.version> + <springdoc-openapi.version>2.2.0</springdoc-openapi.version> + <minio.version>8.5.6</minio.version> + <hibernate.version>6.3.1.Final</hibernate.version> </properties> <dependencies> @@ -58,12 +56,6 @@ <artifactId>spring-security-oauth2-jose</artifactId> </dependency> - <dependency> - <groupId>org.projectlombok</groupId> - <artifactId>lombok</artifactId> - <scope>provided</scope> - </dependency> - <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> @@ -108,13 +100,6 @@ <version>${mapstruct.version}</version> </dependency> - <!-- Compat library for lombok <-> mapstruct --> - <dependency> - <groupId>org.projectlombok</groupId> - <artifactId>lombok-mapstruct-binding</artifactId> - <version>${lombok-mapstruct-binding.version}</version> - </dependency> - <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> @@ -133,50 +118,4 @@ <scope>test</scope> </dependency> </dependencies> - - <build> - <pluginManagement> - <plugins> - <plugin> - <groupId>org.projectlombok</groupId> - <artifactId>lombok-maven-plugin</artifactId> - <version>${lombok-maven.version}</version> - </plugin> - </plugins> - </pluginManagement> - <plugins> - <plugin> - <groupId>org.projectlombok</groupId> - <artifactId>lombok-maven-plugin</artifactId> - <version>${lombok-maven.version}</version> - </plugin> - </plugins> - </build> - - <profiles> - <profile> - <id>delombok</id> - <activation> - <file> - <exists>src/main/lombok</exists> - </file> - </activation> - <build> - <plugins> - <plugin> - <artifactId>lombok-maven-plugin</artifactId> - <groupId>org.projectlombok</groupId> - <executions> - <execution> - <id>delombok</id> - <goals> - <goal>delombok</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> </project> diff --git a/faircommons-services/post-registration-service/pom.xml b/faircommons-services/post-registration-service/pom.xml index fa3517542a3a620cc5f3506d3a6f687ba733a4e7..4fe5ad1fb0dc55c57332aff4e4a8dc232d5a8355 100644 --- a/faircommons-services/post-registration-service/pom.xml +++ b/faircommons-services/post-registration-service/pom.xml @@ -35,8 +35,8 @@ </dependencies> <properties> - <maven.compiler.source>17</maven.compiler.source> - <maven.compiler.target>17</maven.compiler.target> + <maven.compiler.source>${java.version}</maven.compiler.source> + <maven.compiler.target>${java.version}</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> @@ -45,14 +45,6 @@ <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> - <configuration> - <excludes> - <exclude> - <groupId>org.projectlombok</groupId> - <artifactId>lombok</artifactId> - </exclude> - </excludes> - </configuration> </plugin> </plugins> </build> diff --git a/faircommons-services/post-registration-service/src/main/java/eu/fairkom/faircommons/post_registration/listener/PostRegistrationListener.java b/faircommons-services/post-registration-service/src/main/java/eu/fairkom/faircommons/post_registration/listener/PostRegistrationListener.java index a4eaffb5cd68d79bcdcbed0d240ae38821bae94a..c4c0180ceafe1ca7f18e72b1b68bb7ac0f362f20 100644 --- a/faircommons-services/post-registration-service/src/main/java/eu/fairkom/faircommons/post_registration/listener/PostRegistrationListener.java +++ b/faircommons-services/post-registration-service/src/main/java/eu/fairkom/faircommons/post_registration/listener/PostRegistrationListener.java @@ -23,10 +23,10 @@ public class PostRegistrationListener implements RabbitMqListener<PostRegistrati @Override public void receive(PostRegistrationMessage message) { - logger.info("Received message for work ID: {}", message.getWork().getId()); - var work = message.getWork(); + logger.info("Received message for work ID: {}", message.work().id()); + var work = message.work(); - if (postRegistrationService.isOwnStorageOptionPresent(work.getStorageOptions())) { + if (postRegistrationService.isOwnStorageOptionPresent(work.storageOptions())) { postRegistrationService.removeWorkFile(work); } diff --git a/faircommons-services/post-registration-service/src/main/java/eu/fairkom/faircommons/post_registration/service/PostRegistrationService.java b/faircommons-services/post-registration-service/src/main/java/eu/fairkom/faircommons/post_registration/service/PostRegistrationService.java index 70cfccb26530be2b20ffe5d58520492a04ad6ab8..992d1422b8a4f74acb56d57cb000cea1d055501e 100644 --- a/faircommons-services/post-registration-service/src/main/java/eu/fairkom/faircommons/post_registration/service/PostRegistrationService.java +++ b/faircommons-services/post-registration-service/src/main/java/eu/fairkom/faircommons/post_registration/service/PostRegistrationService.java @@ -19,7 +19,7 @@ public class PostRegistrationService { } public void removeWorkFile(WorkView work) { - minioService.removeFile(work.getRegistrar(), work.getWorkFile().getFilenameWithPrefix()); + minioService.removeFile(work.registrar(), work.workFile().filenameWithPrefix()); } public boolean isOwnStorageOptionPresent(Set<StorageOption> storageOptions) { @@ -29,6 +29,6 @@ public class PostRegistrationService { public void generateRegistrationCertificate(WorkView work) { var certificate = registrationCertificateService.generateCertificate(work); - minioService.uploadRegistrationCertificate(work.getRegistrar(), work.getWorkFile().getPrefix(), certificate); + minioService.uploadRegistrationCertificate(work.registrar(), work.workFile().prefix(), certificate); } }