Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
11 changes: 11 additions & 0 deletions src/main/java/org/gridsuite/study/server/StudyController.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
* @author Franck Lecuyer <franck.lecuyer at rte-france.com>
*/

@SuppressWarnings("checkstyle:RegexpSingleline")
@RestController
@RequestMapping(value = "/" + StudyApi.API_VERSION)
@Tag(name = "Study server")
Expand Down Expand Up @@ -1325,6 +1326,16 @@ public ResponseEntity<Void> reindexStudy(@Parameter(description = "study uuid")
return ResponseEntity.ok().build();
}

@PostMapping(value = "/studies/{studyUuid}/reindex-if-needed")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be better to keep the endpoint reindex-all to force reindexation ?
/studies/{studyUuid}/reindex-all?if-needed=true/false

@Operation(summary = "reindex the study if needed")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Study reindexed"),
@ApiResponse(responseCode = "404", description = "The study or network doesn't exist")})
public ResponseEntity<Void> reindexStudyIfNeeded(@Parameter(description = "study uuid") @PathVariable("studyUuid") UUID studyUuid) {
studyService.reindexStudyIfNeeded(studyUuid);
return ResponseEntity.ok().build();
}

@PostMapping(value = "/studies/{studyUuid}/notification")
@Operation(summary = "Create study related notification")
@ApiResponses(value = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1674,6 +1674,14 @@ public void reindexStudy(UUID studyUuid) {
reindexStudy(studyRepository.findById(studyUuid).orElseThrow(() -> new StudyException(STUDY_NOT_FOUND)));
}

@Transactional
public void reindexStudyIfNeeded(UUID studyUuid) {
StudyIndexationStatus status = getStudyIndexationStatus(studyUuid);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make private getStudyIndexationStatus

if (status == StudyIndexationStatus.NOT_INDEXED) {
reindexStudy(studyUuid);
}
}

@Transactional
public StudyIndexationStatus getStudyIndexationStatus(UUID studyUuid) {
StudyEntity study = studyRepository.findById(studyUuid).orElseThrow(() -> new StudyException(STUDY_NOT_FOUND));
Expand Down