DM-285: make component rules version default to -1 #120
@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.BadRequestException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.FileUploadException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.RulesValidationService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.AuditPersistenceService;
|
||||
@ -35,6 +36,7 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemp
|
||||
import com.iqser.red.service.redaction.v1.model.DroolsSyntaxValidation;
|
||||
import com.knecon.fforesight.keycloakcommons.security.KeycloakSecurity;
|
||||
|
||||
import feign.FeignException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@ -55,13 +57,23 @@ public class RulesController implements RulesResource {
|
||||
public ResponseEntity<?> upload(@RequestBody RulesUploadRequestModel rules) {
|
||||
|
||||
RulesUploadRequest rulesUploadRequest = RulesUploadRequest.fromModel(rules);
|
||||
DroolsSyntaxValidation droolsSyntaxValidation = rulesValidationService.validateRules(rulesUploadRequest.getRuleFileType(), rulesUploadRequest.getRules());
|
||||
if (!droolsSyntaxValidation.isCompiled()) {
|
||||
var rulesSyntaxErrorMessages = droolsSyntaxValidation.getDroolsSyntaxErrorMessages()
|
||||
.stream()
|
||||
.map(errorMessage -> RuleSyntaxErrorMessage.builder().line(errorMessage.getLine()).column(errorMessage.getColumn()).message(errorMessage.getMessage()).build())
|
||||
.toList();
|
||||
return new ResponseEntity<>(rulesSyntaxErrorMessages, HttpStatus.BAD_REQUEST);
|
||||
try {
|
||||
DroolsSyntaxValidation droolsSyntaxValidation = rulesValidationService.validateRules(rulesUploadRequest.getRuleFileType(), rulesUploadRequest.getRules());
|
||||
if (!droolsSyntaxValidation.isCompiled()) {
|
||||
var rulesSyntaxErrorMessages = droolsSyntaxValidation.getDroolsSyntaxErrorMessages()
|
||||
.stream()
|
||||
.map(errorMessage -> RuleSyntaxErrorMessage.builder()
|
||||
.line(errorMessage.getLine())
|
||||
.column(errorMessage.getColumn())
|
||||
.message(errorMessage.getMessage())
|
||||
.build())
|
||||
.toList();
|
||||
return new ResponseEntity<>(rulesSyntaxErrorMessages, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
} catch (FeignException e) {
|
||||
if (e.status() == HttpStatus.BAD_REQUEST.value()) {
|
||||
throw new BadRequestException("The provided rule string is not a valid drools rule file!");
|
||||
}
|
||||
}
|
||||
rulesPersistenceService.setRules(rulesUploadRequest.getRules(), rulesUploadRequest.getDossierTemplateId(), rulesUploadRequest.getRuleFileType());
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ public interface AnalysisLogResource {
|
||||
|
||||
@GetMapping(value = ENTITY_LOG_PATH + DOSSIER_ID_PATH_VARIABLE + FILE_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "Gets the entity log for a fileId", description = "None")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Request contains error."), @ApiResponse(responseCode = "404", description = "The redaction log is not found.")})
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Request contains error."), @ApiResponse(responseCode = "404", description = "The entity log is not found.")})
|
||||
EntityLog getEntityLog(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@RequestParam(value = "excludedType", required = false) List<String> excludedTypes,
|
||||
@ -44,7 +44,7 @@ public interface AnalysisLogResource {
|
||||
|
||||
@PostMapping(value = ENTITY_LOG_PATH + DOSSIER_ID_PATH_VARIABLE + FILE_ID_PATH_VARIABLE + "/filtered", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "Gets the entity log for a fileId grater than the specified date", description = "None")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Request contains error."), @ApiResponse(responseCode = "404", description = "The redaction log is not found.")})
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Request contains error."), @ApiResponse(responseCode = "404", description = "The entity log is not found.")})
|
||||
EntityLog getFilteredEntityLog(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@RequestBody FilteredEntityLogRequest filteredEntityLogRequest);
|
||||
@ -52,7 +52,7 @@ public interface AnalysisLogResource {
|
||||
|
||||
@GetMapping(value = COMPONENT_LOG_PATH + DOSSIER_ID_PATH_VARIABLE + FILE_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "Gets the component log for a fileId", description = "None")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Request contains error."), @ApiResponse(responseCode = "404", description = "The redaction log is not found.")})
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Request contains error."), @ApiResponse(responseCode = "404", description = "The component log is not found.")})
|
||||
ComponentLog getComponentLog(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId);
|
||||
|
||||
}
|
||||
|
||||
@ -30,5 +30,6 @@ databaseChangeLog:
|
||||
- column:
|
||||
name: component_rules_version
|
||||
type: BIGINT
|
||||
defaultValue: -1
|
||||
tableName: file
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user