Skip to content

Commit

Permalink
[backend] clean
Browse files Browse the repository at this point in the history
  • Loading branch information
savacano28 committed Oct 16, 2024
1 parent dba6676 commit 6bb204f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions openbas-api/src/main/java/io/openbas/opencti/OpenCTIApi.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.openbas.opencti;

import io.openbas.aop.LogExecutionTime;
import io.openbas.rest.exercise.form.ExerciseSimple;
import io.openbas.service.ScenarioService;
import io.swagger.v3.oas.annotations.Operation;
Expand Down Expand Up @@ -33,6 +34,7 @@ public class OpenCTIApi {
}),
@ApiResponse(responseCode = "404", description = "Exercise not found", content = @Content)
})
@LogExecutionTime
@GetMapping(OPENCTI_URI + "/exercises/latest/{externalReferenceId}")
public ExerciseSimple latestExerciseByExternalReference(@PathVariable @NotBlank final String externalReferenceId) {
return scenarioService.latestExerciseByExternalReference(externalReferenceId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.openbas.rest.exercise;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.openbas.aop.LogExecutionTime;
import io.openbas.database.model.*;
import io.openbas.database.raw.*;
import io.openbas.database.repository.*;
Expand Down Expand Up @@ -622,11 +623,13 @@ public Exercise changeExerciseStatus(
return exerciseRepository.save(exercise);
}

@LogExecutionTime
@GetMapping(EXERCISE_URI)
public List<ExerciseSimple> exercises() {
return exerciseService.exercises();
}

@LogExecutionTime
@PostMapping(EXERCISE_URI + "/search")
public Page<ExerciseSimple> exercises(@RequestBody @Valid final SearchPaginationInput searchPaginationInput) {
if (currentUser().isAdmin()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.openbas.rest.scenario;

import io.openbas.aop.LogExecutionTime;
import io.openbas.database.model.Exercise;
import io.openbas.rest.exercise.ExerciseService;
import io.openbas.rest.exercise.form.ExerciseSimple;
Expand All @@ -25,12 +26,14 @@ public class ScenarioExerciseApi {

private final ExerciseService exerciseService;

@LogExecutionTime
@GetMapping(SCENARIO_URI + "/{scenarioId}/exercises")
@PreAuthorize("isScenarioObserver(#scenarioId)")
public Iterable<ExerciseSimple> scenarioExercises(@PathVariable @NotBlank final String scenarioId) {
return exerciseService.scenarioExercises(scenarioId);
}

@LogExecutionTime
@PostMapping(SCENARIO_URI + "/{scenarioId}/exercises/search")
@PreAuthorize("isScenarioObserver(#scenarioId)")
public Iterable<ExerciseSimple> scenarioExercises(
Expand Down

0 comments on commit 6bb204f

Please sign in to comment.