RED-8339: Fixes
This commit is contained in:
parent
f3a7d40ff9
commit
1fda16b6ca
@ -1,10 +1,8 @@
|
||||
package com.iqser.red.service.persistence.v1.internal.api.controller;
|
||||
|
||||
import com.iqser.red.commons.spring.ErrorMessage;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.*;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import java.sql.SQLException;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@ -14,9 +12,17 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.stream.Collectors;
|
||||
import com.iqser.red.commons.spring.ErrorMessage;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.BadRequestException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.ConflictException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.DossierNotFoundException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.InvalidRulesException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.RulesTimeoutDetectedException;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.mongo.exception.ComponentLogDocumentNotFoundException;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@RestControllerAdvice
|
||||
@ -129,4 +135,14 @@ public class InternalControllerAdvice {
|
||||
return new ErrorMessage(OffsetDateTime.now(), e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
@Hidden
|
||||
@ResponseBody
|
||||
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
|
||||
@ExceptionHandler(ComponentLogDocumentNotFoundException.class)
|
||||
public ErrorMessage handleCustomException(ComponentLogDocumentNotFoundException e) {
|
||||
|
||||
return new ErrorMessage(OffsetDateTime.now(), e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -72,16 +72,7 @@ public class ComponentLogService {
|
||||
|
||||
public ComponentLog getComponentLog(String dossierId, String fileId, boolean includeOverrides) {
|
||||
|
||||
ComponentLog componentLog;
|
||||
try {
|
||||
componentLog = fileManagementStorageService.getComponentLog(dossierId, fileId);
|
||||
} catch (NotFoundException e) {
|
||||
var componentLogOptional = componentLogMongoService.findComponentLogByDossierIdAndFileId(dossierId, fileId);
|
||||
if (componentLogOptional.isEmpty()) {
|
||||
throw new NotFoundException(e.getMessage());
|
||||
}
|
||||
componentLog = componentLogOptional.get();
|
||||
}
|
||||
ComponentLog componentLog = fileManagementStorageService.getComponentLog(dossierId, fileId);
|
||||
|
||||
if (!includeOverrides) {
|
||||
componentLog = sortComponentLogEntriesByOrderList(componentLog, ORDER);
|
||||
@ -153,7 +144,9 @@ public class ComponentLogService {
|
||||
|
||||
private void insertOverride(String dossierId, String fileId, ComponentLogEntry componentToAdd) {
|
||||
|
||||
componentLogMongoService.insertComponentLogEntries(dossierId, fileId, List.of(componentToAdd));
|
||||
ComponentLog componentLog = fileManagementStorageService.getComponentLog(dossierId, fileId);
|
||||
|
||||
componentLogMongoService.insertComponentLogEntries(dossierId, fileId, componentLog, List.of(componentToAdd));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -97,11 +97,11 @@ public class ComponentLogMongoService {
|
||||
}
|
||||
|
||||
|
||||
public void insertComponentLogEntries(String dossierId, String fileId, List<ComponentLogEntry> componentLogEntries) {
|
||||
public void insertComponentLogEntries(String dossierId, String fileId, ComponentLog componentLog, List<ComponentLogEntry> componentLogEntries) {
|
||||
|
||||
String componentLogId = mapper.getComponentLogId(dossierId, fileId);
|
||||
|
||||
ComponentLogDocument componentLogDocument = getComponentLogDocument(componentLogId);
|
||||
ComponentLogDocument componentLogDocument = mapper.toComponentLogDocument(dossierId, fileId, componentLog);
|
||||
|
||||
List<ComponentDocument> componentDocuments = componentLogEntries.stream()
|
||||
.map(componentLogEntry -> mapper.toComponentDocument(componentLogId, componentLogEntry))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user