DM-285: make component rules version default to -1
* fix 500 when invalid rules file * fix AnalysisLogResource documentation
This commit is contained in:
parent
78d3a772da
commit
f3d148a631
@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestPart;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
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.exception.FileUploadException;
|
||||||
import com.iqser.red.service.persistence.management.v1.processor.service.RulesValidationService;
|
import com.iqser.red.service.persistence.management.v1.processor.service.RulesValidationService;
|
||||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.AuditPersistenceService;
|
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.iqser.red.service.redaction.v1.model.DroolsSyntaxValidation;
|
||||||
import com.knecon.fforesight.keycloakcommons.security.KeycloakSecurity;
|
import com.knecon.fforesight.keycloakcommons.security.KeycloakSecurity;
|
||||||
|
|
||||||
|
import feign.FeignException;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@ -55,14 +57,24 @@ public class RulesController implements RulesResource {
|
|||||||
public ResponseEntity<?> upload(@RequestBody RulesUploadRequestModel rules) {
|
public ResponseEntity<?> upload(@RequestBody RulesUploadRequestModel rules) {
|
||||||
|
|
||||||
RulesUploadRequest rulesUploadRequest = RulesUploadRequest.fromModel(rules);
|
RulesUploadRequest rulesUploadRequest = RulesUploadRequest.fromModel(rules);
|
||||||
|
try {
|
||||||
DroolsSyntaxValidation droolsSyntaxValidation = rulesValidationService.validateRules(rulesUploadRequest.getRuleFileType(), rulesUploadRequest.getRules());
|
DroolsSyntaxValidation droolsSyntaxValidation = rulesValidationService.validateRules(rulesUploadRequest.getRuleFileType(), rulesUploadRequest.getRules());
|
||||||
if (!droolsSyntaxValidation.isCompiled()) {
|
if (!droolsSyntaxValidation.isCompiled()) {
|
||||||
var rulesSyntaxErrorMessages = droolsSyntaxValidation.getDroolsSyntaxErrorMessages()
|
var rulesSyntaxErrorMessages = droolsSyntaxValidation.getDroolsSyntaxErrorMessages()
|
||||||
.stream()
|
.stream()
|
||||||
.map(errorMessage -> RuleSyntaxErrorMessage.builder().line(errorMessage.getLine()).column(errorMessage.getColumn()).message(errorMessage.getMessage()).build())
|
.map(errorMessage -> RuleSyntaxErrorMessage.builder()
|
||||||
|
.line(errorMessage.getLine())
|
||||||
|
.column(errorMessage.getColumn())
|
||||||
|
.message(errorMessage.getMessage())
|
||||||
|
.build())
|
||||||
.toList();
|
.toList();
|
||||||
return new ResponseEntity<>(rulesSyntaxErrorMessages, HttpStatus.BAD_REQUEST);
|
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());
|
rulesPersistenceService.setRules(rulesUploadRequest.getRules(), rulesUploadRequest.getDossierTemplateId(), rulesUploadRequest.getRuleFileType());
|
||||||
|
|
||||||
auditPersistenceService.audit(AuditRequest.builder()
|
auditPersistenceService.audit(AuditRequest.builder()
|
||||||
|
|||||||
@ -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)
|
@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")
|
@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,
|
EntityLog getEntityLog(@PathVariable(DOSSIER_ID) String dossierId,
|
||||||
@PathVariable(FILE_ID) String fileId,
|
@PathVariable(FILE_ID) String fileId,
|
||||||
@RequestParam(value = "excludedType", required = false) List<String> excludedTypes,
|
@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)
|
@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")
|
@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,
|
EntityLog getFilteredEntityLog(@PathVariable(DOSSIER_ID) String dossierId,
|
||||||
@PathVariable(FILE_ID) String fileId,
|
@PathVariable(FILE_ID) String fileId,
|
||||||
@RequestBody FilteredEntityLogRequest filteredEntityLogRequest);
|
@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)
|
@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")
|
@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);
|
ComponentLog getComponentLog(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,5 +30,6 @@ databaseChangeLog:
|
|||||||
- column:
|
- column:
|
||||||
name: component_rules_version
|
name: component_rules_version
|
||||||
type: BIGINT
|
type: BIGINT
|
||||||
|
defaultValue: -1
|
||||||
tableName: file
|
tableName: file
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user