-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix : fix DatasetResources.java and DatasetService in it
- Loading branch information
1 parent
1e1c45d
commit 05224a7
Showing
1 changed file
with
11 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
|
@@ -30,8 +31,9 @@ | |
@ConditionalOnExpression("'${fr.insee.rmes.bauhaus.activeModules}'.contains('datasets')") | ||
public class DatasetResources { | ||
|
||
final DatasetService datasetService; | ||
private final DatasetService datasetService; | ||
|
||
@Autowired | ||
public DatasetResources(DatasetService datasetService) { | ||
this.datasetService = datasetService; | ||
} | ||
|
@@ -40,21 +42,21 @@ public DatasetResources(DatasetService datasetService) { | |
@Operation(operationId = "getDatasets", summary = "List of datasets", | ||
responses = {@ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Dataset.class))))}) | ||
public String getDatasets() throws RmesException { | ||
return this.datasetService.getDatasets(); | ||
return datasetService.getDatasets(); | ||
} | ||
|
||
@GetMapping(value = "/{id}", produces = "application/json") | ||
@Operation(operationId = "getDataset", summary = "Get a dataset", | ||
responses = {@ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Dataset.class))))}) | ||
public Dataset getDataset(@PathVariable(Constants.ID) String id) throws RmesException { | ||
return this.datasetService.getDatasetByID(id); | ||
return datasetService.getDatasetByID(id); | ||
} | ||
|
||
@GetMapping("/{id}/distributions") | ||
@Operation(operationId = "getDistributionsByDataset", summary = "List of distributions for a dataset", | ||
responses = {@ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Dataset.class))))}) | ||
public String getDistributionsByDataset(@PathVariable(Constants.ID) String id) throws RmesException { | ||
return this.datasetService.getDistributions(id); | ||
return datasetService.getDistributions(id); | ||
} | ||
|
||
@PreAuthorize("isAdmin() || isDatasetContributor()") | ||
|
@@ -63,7 +65,7 @@ public String getDistributionsByDataset(@PathVariable(Constants.ID) String id) t | |
@ResponseStatus(HttpStatus.CREATED) | ||
public String setDataset( | ||
@Parameter(description = "Dataset", required = true) @RequestBody String body) throws RmesException { | ||
return this.datasetService.create(body); | ||
return datasetService.create(body); | ||
} | ||
|
||
@PreAuthorize("isAdmin() || isDatasetContributorWithStamp(#datasetId)") | ||
|
@@ -73,21 +75,21 @@ public String setDataset( | |
@PathVariable("id") String datasetId, | ||
@Parameter(description = "Dataset", required = true) @RequestBody String body) throws RmesException { | ||
|
||
return this.datasetService.update(datasetId, body); | ||
return datasetService.update(datasetId, body); | ||
Check failure Code scanning / SonarCloud Endpoints should not be vulnerable to reflected cross-site scripting (XSS) attacks High
Change this code to not reflect user-controlled data. See more on SonarCloud
|
||
} | ||
|
||
@PreAuthorize("isAdmin() || isDatasetContributorWithStamp(#datasetId)") | ||
@PutMapping("/{id}/validate") | ||
@Operation(operationId = "publishDataset", summary = "Publish a dataset", | ||
responses = {@ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Distribution.class))))}) | ||
public String publishDataset(@PathVariable(Constants.ID) String datasetId) throws RmesException { | ||
return this.datasetService.publishDataset(datasetId); | ||
return datasetService.publishDataset(datasetId); | ||
Check failure Code scanning / SonarCloud Endpoints should not be vulnerable to reflected cross-site scripting (XSS) attacks High
Change this code to not reflect user-controlled data. See more on SonarCloud
|
||
} | ||
|
||
@GetMapping(value = "/archivageUnits", consumes = APPLICATION_JSON_VALUE) | ||
@Operation(operationId = "getArchivageUnits", summary = "Get all archivage units") | ||
public String getArchivageUnits() throws RmesException { | ||
return this.datasetService.getArchivageUnits(); | ||
return datasetService.getArchivageUnits(); | ||
} | ||
|
||
@PreAuthorize("isAdmin() || isDatasetContributorWithStamp(#datasetId)") | ||
|
@@ -97,7 +99,7 @@ public void patchDataset( | |
@PathVariable("id") String datasetId, | ||
@RequestBody PatchDataset dataset | ||
) throws RmesException { | ||
this.datasetService.patchDataset(datasetId, dataset); | ||
datasetService.patchDataset(datasetId, dataset); | ||
} | ||
|
||
@PreAuthorize("isAdmin() || isDatasetContributorWithStamp(#datasetId)") | ||
|