Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/opends 0.4.0 #63

Merged
merged 6 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/.trivyignore
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
# September 20, 2024
# Vulnerability in io.kubernetes java client, may be fixed in 21.0.1 but not sure
CVE-2024-7254
19 changes: 9 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
<description>Backend for orchestration service</description>
<properties>
<java.version>17</java.version>
<apachecommons.version>4.4</apachecommons.version>
<k8s-client-java.version>21.0.0</k8s-client-java.version>
<k8s-client-java.version>22.0.0</k8s-client-java.version>
<json-patch.version>1.13</json-patch.version>
<testcontainers.version>1.19.8</testcontainers.version>
<testcontainers.version>1.20.3</testcontainers.version>
<mockito-inline.version>5.2.0</mockito-inline.version>
<sonar.organization>dissco</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
Expand Down Expand Up @@ -190,13 +189,13 @@
<configuration>
<mainClass>eu.dissco.orchestration.backend.maven.MavenRunner</mainClass>
<arguments>
<argument>https://schemas.dissco.tech/schemas/fdo-type/data-mapping/0.3.0/data-mapping.json</argument>
<argument>https://schemas.dissco.tech/schemas/developer-schema/data-mapping/0.3.0/data-mapping-request.json</argument>
<argument>https://schemas.dissco.tech/schemas/fdo-type/machine-annotation-service/0.3.0/machine-annotation-service.json</argument>
<argument>https://schemas.dissco.tech/schemas/developer-schema/machine-annotation-service/0.3.0/machine-annotation-service-request.json</argument>
<argument>https://schemas.dissco.tech/schemas/fdo-type/source-system/0.3.0/source-system.json</argument>
<argument>https://schemas.dissco.tech/schemas/developer-schema/source-system/0.3.0/source-system-request.json</argument>
<argument>https://schemas.dissco.tech/schemas/fdo-type/create-update-tombstone-event/0.3.0/create-update-tombstone-event.json</argument>
<argument>https://schemas.dissco.tech/schemas/fdo-type/data-mapping/0.4.0/data-mapping.json</argument>
<argument>https://schemas.dissco.tech/schemas/developer-schema/data-mapping/0.4.0/data-mapping-request.json</argument>
<argument>https://schemas.dissco.tech/schemas/fdo-type/machine-annotation-service/0.4.0/machine-annotation-service.json</argument>
<argument>https://schemas.dissco.tech/schemas/developer-schema/machine-annotation-service/0.4.0/machine-annotation-service-request.json</argument>
<argument>https://schemas.dissco.tech/schemas/fdo-type/source-system/0.4.0/source-system.json</argument>
<argument>https://schemas.dissco.tech/schemas/developer-schema/source-system/0.4.0/source-system-request.json</argument>
<argument>https://schemas.dissco.tech/schemas/fdo-type/create-update-tombstone-event/0.4.0/create-update-tombstone-event.json</argument>
</arguments>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package eu.dissco.orchestration.backend.controller;

import static eu.dissco.orchestration.backend.domain.AgentRoleType.CREATOR;
import static eu.dissco.orchestration.backend.domain.AgentRoleType.TOMBSTONER;
import static eu.dissco.orchestration.backend.utils.ControllerUtils.getAgent;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand Down Expand Up @@ -47,10 +49,11 @@ public ResponseEntity<JsonApiWrapper> createDataMapping(Authentication authentic
@RequestBody JsonApiRequestWrapper requestBody, HttpServletRequest servletRequest)
throws JsonProcessingException, ProcessingFailedException, ForbiddenException {
var dataMapping = getDataMappingRequestFromRequest(requestBody);
var user = getAgent(authentication);
log.info("Received create request for data mapping: {} from user: {}", dataMapping, user.getId());
var agent = getAgent(authentication, CREATOR);
log.info("Received create request for data mapping: {} from agent: {}", dataMapping,
agent.getId());
String path = appProperties.getBaseUrl() + servletRequest.getRequestURI();
var result = service.createDataMapping(dataMapping, user, path);
var result = service.createDataMapping(dataMapping, agent, path);
return ResponseEntity.status(HttpStatus.CREATED).body(result);
}

Expand All @@ -61,10 +64,11 @@ public ResponseEntity<JsonApiWrapper> updateDataMapping(Authentication authentic
throws JsonProcessingException, NotFoundException, ProcessingFailedException, ForbiddenException {
var dataMapping = getDataMappingRequestFromRequest(requestBody);
var id = prefix + '/' + suffix;
var user = getAgent(authentication);
log.info("Received update request for data mapping: {} from user: {}", dataMapping, user.getId());
var agent = getAgent(authentication, CREATOR);
log.info("Received update request for data mapping: {} from agent: {}", dataMapping,
agent.getId());
String path = appProperties.getBaseUrl() + servletRequest.getRequestURI();
var result = service.updateDataMapping(id, dataMapping, user, path);
var result = service.updateDataMapping(id, dataMapping, agent, path);
if (result == null) {
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
} else {
Expand All @@ -78,8 +82,8 @@ public ResponseEntity<Void> tombstoneDataMapping(Authentication authentication,
@PathVariable("prefix") String prefix, @PathVariable("suffix") String suffix)
throws NotFoundException, ProcessingFailedException, ForbiddenException {
String id = prefix + "/" + suffix;
var agent = getAgent(authentication);
log.info("Received delete request for mapping: {} from user: {}", id, agent.getId());
var agent = getAgent(authentication, TOMBSTONER);
log.info("Received delete request for mapping: {} from agent: {}", id, agent.getId());
service.tombstoneDataMapping(id, agent);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}
Expand All @@ -103,7 +107,8 @@ public ResponseEntity<JsonApiListWrapper> getDataMappings(
log.info("Received get request for mappings with pageNumber: {} and pageSzie: {}: ", pageNum,
pageSize);
String path = appProperties.getBaseUrl() + servletRequest.getRequestURI();
return ResponseEntity.status(HttpStatus.OK).body(service.getDataMappings(pageNum, pageSize, path));
return ResponseEntity.status(HttpStatus.OK)
.body(service.getDataMappings(pageNum, pageSize, path));
}

private DataMappingRequest getDataMappingRequestFromRequest(JsonApiRequestWrapper requestBody)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package eu.dissco.orchestration.backend.controller;

import static eu.dissco.orchestration.backend.domain.AgentRoleType.CREATOR;
import static eu.dissco.orchestration.backend.domain.AgentRoleType.TOMBSTONER;
import static eu.dissco.orchestration.backend.utils.ControllerUtils.getAgent;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand Down Expand Up @@ -48,11 +50,11 @@ public ResponseEntity<JsonApiWrapper> createMachineAnnotationService(
@RequestBody JsonApiRequestWrapper requestBody, HttpServletRequest servletRequest)
throws JsonProcessingException, ProcessingFailedException, ForbiddenException {
var machineAnnotationService = getMachineAnnotation(requestBody);
var user = getAgent(authentication);
log.info("Received create request for machine annotation service: {} from user: {}",
machineAnnotationService, user.getId());
var agent = getAgent(authentication, CREATOR);
log.info("Received create request for machine annotation service: {} from agent: {}",
machineAnnotationService, agent.getId());
String path = appProperties.getBaseUrl() + servletRequest.getRequestURI();
var result = service.createMachineAnnotationService(machineAnnotationService, user, path);
var result = service.createMachineAnnotationService(machineAnnotationService, agent, path);
return ResponseEntity.status(HttpStatus.CREATED).body(result);
}

Expand All @@ -63,12 +65,12 @@ public ResponseEntity<JsonApiWrapper> updateMachineAnnotationService(
@RequestBody JsonApiRequestWrapper requestBody, HttpServletRequest servletRequest)
throws JsonProcessingException, NotFoundException, ProcessingFailedException, ForbiddenException {
var machineAnnotationService = getMachineAnnotation(requestBody);
var user = getAgent(authentication);
var agent = getAgent(authentication, CREATOR);
var id = prefix + '/' + suffix;
log.info("Received update request for machine annotation service: {} from user: {}", id,
user.getId());
log.info("Received update request for machine annotation service: {} from agent: {}", id,
agent.getId());
String path = appProperties.getBaseUrl() + servletRequest.getRequestURI();
var result = service.updateMachineAnnotationService(id, machineAnnotationService, user, path);
var result = service.updateMachineAnnotationService(id, machineAnnotationService, agent, path);
if (result == null) {
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
} else {
Expand All @@ -82,8 +84,8 @@ public ResponseEntity<Void> tombstoneMachineAnnotationService(Authentication aut
@PathVariable("prefix") String prefix, @PathVariable("suffix") String suffix)
throws NotFoundException, ProcessingFailedException, ForbiddenException {
String id = prefix + "/" + suffix;
var agent = getAgent(authentication);
log.info("Received delete request for machine annotation service: {} from user: {}", id,
var agent = getAgent(authentication, TOMBSTONER);
log.info("Received delete request for machine annotation service: {} from agent: {}", id,
agent.getId());
service.tombstoneMachineAnnotationService(id, agent);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package eu.dissco.orchestration.backend.controller;

import static eu.dissco.orchestration.backend.domain.AgentRoleType.CREATOR;
import static eu.dissco.orchestration.backend.domain.AgentRoleType.TOMBSTONER;
import static eu.dissco.orchestration.backend.utils.ControllerUtils.getAgent;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand Down Expand Up @@ -49,10 +51,10 @@ public ResponseEntity<JsonApiWrapper> createSourceSystem(Authentication authenti
throws IOException, NotFoundException, ProcessingFailedException, ForbiddenException {
var sourceSystemRequest = getSourceSystemFromRequest(requestBody);
String path = appProperties.getBaseUrl() + servletRequest.getRequestURI();
var user = getAgent(authentication);
log.info("Received create request for source system: {} from user: {}", sourceSystemRequest,
user.getId());
var result = service.createSourceSystem(sourceSystemRequest, user, path);
var agent = getAgent(authentication, CREATOR);
log.info("Received create request for source system: {} from agent: {}", sourceSystemRequest,
agent.getId());
var result = service.createSourceSystem(sourceSystemRequest, agent, path);
return ResponseEntity.status(HttpStatus.CREATED).body(result);
}

Expand All @@ -64,10 +66,10 @@ public ResponseEntity<JsonApiWrapper> updateSourceSystem(Authentication authenti
throws IOException, NotFoundException, ProcessingFailedException, ForbiddenException {
var sourceSystemRequest = getSourceSystemFromRequest(requestBody);
var id = prefix + '/' + suffix;
var user = getAgent(authentication);
log.info("Received update request for source system: {} from user: {}", id, user.getId());
var agent = getAgent(authentication, CREATOR);
log.info("Received update request for source system: {} from agent: {}", id, agent.getId());
String path = appProperties.getBaseUrl() + servletRequest.getRequestURI();
var result = service.updateSourceSystem(id, sourceSystemRequest, user, path, trigger);
var result = service.updateSourceSystem(id, sourceSystemRequest, agent, path, trigger);
if (result == null) {
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
} else {
Expand All @@ -81,8 +83,8 @@ public ResponseEntity<Void> tombstoneSourceSystem(Authentication authentication,
@PathVariable("prefix") String prefix, @PathVariable("suffix") String suffix)
throws NotFoundException, ProcessingFailedException, ForbiddenException {
String id = prefix + "/" + suffix;
var agent = getAgent(authentication);
log.info("Received delete request for mapping: {} from user: {}", id, agent.getId());
var agent = getAgent(authentication, TOMBSTONER);
log.info("Received delete request for mapping: {} from agent: {}", id, agent.getId());
service.tombstoneSourceSystem(id, agent);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package eu.dissco.orchestration.backend.domain;

import lombok.Getter;

@Getter
public enum AgentRoleType {

COLLECTOR("collector"),
DATA_TRANSLATOR("data-translator"),
CREATOR("creator"),
IDENTIFIER("identifier"),
GEOREFERENCER("georeferencer"),
RIGHTS_OWNER("rights-owner"),
PROCESSING_SERVICE("processing-service"),
SOURCE_SYSTEM("source-system"),
TOMBSTONER("tombstoner");

private final String name;

AgentRoleType(String name) {
this.name = name;
}
}
Loading
Loading