-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1567 from thehyve/refactoring/FAIRSPC-81
Refactoring/fairspc 81
- Loading branch information
Showing
91 changed files
with
1,857 additions
and
984 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
projects/saturn/src/main/java/io/fairspace/saturn/config/SaturnSparkFilter.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
projects/saturn/src/main/java/io/fairspace/saturn/config/SparkFilterConfig.java
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
projects/saturn/src/main/java/io/fairspace/saturn/config/SparkFilterFactory.java
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
projects/saturn/src/main/java/io/fairspace/saturn/controller/FeaturesController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.fairspace.saturn.controller; | ||
|
||
import java.util.Set; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import io.fairspace.saturn.config.Feature; | ||
import io.fairspace.saturn.config.properties.FeatureProperties; | ||
|
||
@RestController | ||
@RequestMapping("/features") | ||
@RequiredArgsConstructor | ||
public class FeaturesController { | ||
|
||
private final FeatureProperties featureProperties; | ||
|
||
@GetMapping("/") | ||
public ResponseEntity<Set<Feature>> getFeatures() { | ||
return ResponseEntity.ok(featureProperties.getFeatures()); | ||
} | ||
} |
17 changes: 0 additions & 17 deletions
17
projects/saturn/src/main/java/io/fairspace/saturn/controller/GlobalExceptionHandler.java
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
projects/saturn/src/main/java/io/fairspace/saturn/controller/MaintenanceController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.fairspace.saturn.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import io.fairspace.saturn.config.Services; | ||
|
||
@RestController | ||
@RequestMapping("/maintenance") | ||
@RequiredArgsConstructor | ||
public class MaintenanceController { | ||
|
||
private final Services services; | ||
|
||
@PostMapping("/reindex") | ||
public ResponseEntity<Void> startReindex() { | ||
services.getMaintenanceService().startRecreateIndexTask(); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
|
||
@PostMapping("/compact") | ||
public ResponseEntity<Void> compactRdfStorage() { | ||
services.getMaintenanceService().compactRdfStorageTask(); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
|
||
@GetMapping("/status") | ||
public ResponseEntity<String> getStatus() { | ||
var status = services.getMaintenanceService().active() ? "active" : "inactive"; | ||
return ResponseEntity.ok(status); | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
projects/saturn/src/main/java/io/fairspace/saturn/controller/MetadataController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package io.fairspace.saturn.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.log4j.Log4j2; | ||
import org.apache.jena.rdf.model.Model; | ||
import org.apache.jena.rdf.model.ResourceFactory; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import io.fairspace.saturn.config.Services; | ||
import io.fairspace.saturn.controller.validation.ValidIri; | ||
|
||
import static io.fairspace.saturn.controller.enums.CustomMediaType.APPLICATION_LD_JSON; | ||
import static io.fairspace.saturn.controller.enums.CustomMediaType.APPLICATION_N_TRIPLES; | ||
import static io.fairspace.saturn.controller.enums.CustomMediaType.TEXT_TURTLE; | ||
import static io.fairspace.saturn.services.metadata.Serialization.deserialize; | ||
import static io.fairspace.saturn.services.metadata.Serialization.getFormat; | ||
import static io.fairspace.saturn.services.metadata.Serialization.serialize; | ||
|
||
@Log4j2 | ||
@RestController | ||
@RequestMapping("/metadata") | ||
@RequiredArgsConstructor | ||
@Validated | ||
public class MetadataController { | ||
|
||
private static final String DO_VIEWS_UPDATE = "doViewsUpdate"; | ||
|
||
public static final String DO_VIEWS_UPDATE_DEFAULT_VALUE = "true"; | ||
|
||
private final Services services; | ||
|
||
@GetMapping( | ||
value = "/", | ||
produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_LD_JSON, TEXT_TURTLE, APPLICATION_N_TRIPLES}) | ||
public ResponseEntity<String> getMetadata( | ||
@RequestParam(required = false) String subject, | ||
@RequestParam(name = "withValueProperties", defaultValue = "false") boolean withValueProperties, | ||
@RequestHeader(value = HttpHeaders.ACCEPT, required = false) String acceptHeader) { | ||
var model = services.getMetadataService().get(subject, withValueProperties); | ||
var format = getFormat(acceptHeader); | ||
var metadata = serialize(model, format); | ||
return ResponseEntity.ok(metadata); | ||
} | ||
|
||
@PutMapping( | ||
value = "/", | ||
consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_LD_JSON, TEXT_TURTLE, APPLICATION_N_TRIPLES}) | ||
@ResponseStatus(HttpStatus.NO_CONTENT) | ||
public void putMetadata( | ||
@RequestBody String body, | ||
@RequestHeader(value = HttpHeaders.CONTENT_TYPE, required = false) String contentType, | ||
@RequestParam(name = DO_VIEWS_UPDATE, defaultValue = DO_VIEWS_UPDATE_DEFAULT_VALUE) | ||
boolean doMaterializedViewsRefresh) { | ||
Model model = deserialize(body, contentType); | ||
services.getMetadataService().put(model, doMaterializedViewsRefresh); | ||
} | ||
|
||
@PatchMapping( | ||
value = "/", | ||
consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_LD_JSON, TEXT_TURTLE, APPLICATION_N_TRIPLES}) | ||
@ResponseStatus(HttpStatus.NO_CONTENT) | ||
public void patchMetadata( | ||
@RequestBody String body, | ||
@RequestHeader(value = HttpHeaders.CONTENT_TYPE, required = false) String contentType, | ||
@RequestParam(name = DO_VIEWS_UPDATE, defaultValue = DO_VIEWS_UPDATE_DEFAULT_VALUE) boolean doViewsUpdate) { | ||
Model model = deserialize(body, contentType); | ||
services.getMetadataService().patch(model, doViewsUpdate); | ||
} | ||
|
||
@DeleteMapping("/") | ||
@ResponseStatus(HttpStatus.NO_CONTENT) | ||
public void deleteMetadata( | ||
@RequestParam(required = false) @ValidIri String subject, | ||
@RequestBody(required = false) String body, | ||
@RequestHeader(value = HttpHeaders.CONTENT_TYPE, required = false) String contentType, | ||
@RequestParam(name = DO_VIEWS_UPDATE, defaultValue = DO_VIEWS_UPDATE_DEFAULT_VALUE) | ||
boolean doMaterializedViewsRefresh) { | ||
if (subject != null) { | ||
if (!services.getMetadataService().softDelete(ResourceFactory.createResource(subject))) { | ||
throw new IllegalArgumentException("Subject could not be deleted"); | ||
} | ||
} else { | ||
Model model = deserialize(body, contentType); | ||
services.getMetadataService().delete(model, doMaterializedViewsRefresh); | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
projects/saturn/src/main/java/io/fairspace/saturn/controller/SearchController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.fairspace.saturn.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import io.fairspace.saturn.config.Services; | ||
import io.fairspace.saturn.controller.dto.SearchResultsDto; | ||
import io.fairspace.saturn.controller.dto.request.FileSearchRequest; | ||
import io.fairspace.saturn.controller.dto.request.LookupSearchRequest; | ||
|
||
@RestController | ||
@RequestMapping("/search") | ||
@RequiredArgsConstructor | ||
public class SearchController { | ||
|
||
private final Services services; | ||
|
||
@PostMapping(value = "/files") | ||
public ResponseEntity<SearchResultsDto> searchFiles(@RequestBody FileSearchRequest request) { | ||
var searchResult = services.getFileSearchService().searchFiles(request); | ||
var resultDto = SearchResultsDto.builder() | ||
.results(searchResult) | ||
.query(request.getQuery()) | ||
.build(); | ||
return ResponseEntity.ok(resultDto); | ||
} | ||
|
||
@PostMapping(value = "/lookup") | ||
public ResponseEntity<SearchResultsDto> lookupSearch(@RequestBody LookupSearchRequest request) { | ||
var results = services.getSearchService().getLookupSearchResults(request); | ||
return ResponseEntity.ok(results); | ||
} | ||
} |
Oops, something went wrong.