RED-5002: Fixed return http error code for testing rules
This commit is contained in:
parent
9b9b0ab271
commit
64bd25a900
@ -17,6 +17,7 @@ import com.iqser.red.service.redaction.v1.resources.RedactionResource;
|
|||||||
import com.iqser.red.service.redaction.v1.server.classification.model.Document;
|
import com.iqser.red.service.redaction.v1.server.classification.model.Document;
|
||||||
import com.iqser.red.service.redaction.v1.server.classification.model.Page;
|
import com.iqser.red.service.redaction.v1.server.classification.model.Page;
|
||||||
import com.iqser.red.service.redaction.v1.server.exception.RedactionException;
|
import com.iqser.red.service.redaction.v1.server.exception.RedactionException;
|
||||||
|
import com.iqser.red.service.redaction.v1.server.exception.RulesValidationException;
|
||||||
import com.iqser.red.service.redaction.v1.server.redaction.service.DroolsExecutionService;
|
import com.iqser.red.service.redaction.v1.server.redaction.service.DroolsExecutionService;
|
||||||
import com.iqser.red.service.redaction.v1.server.redaction.service.ManualRedactionSurroundingTextService;
|
import com.iqser.red.service.redaction.v1.server.redaction.service.ManualRedactionSurroundingTextService;
|
||||||
import com.iqser.red.service.redaction.v1.server.redaction.service.RedactionLogMergeService;
|
import com.iqser.red.service.redaction.v1.server.redaction.service.RedactionLogMergeService;
|
||||||
@ -41,6 +42,7 @@ public class RedactionController implements RedactionResource {
|
|||||||
private final RedactionLogMergeService redactionLogMergeService;
|
private final RedactionLogMergeService redactionLogMergeService;
|
||||||
private final ManualRedactionSurroundingTextService manualRedactionSurroundingTextService;
|
private final ManualRedactionSurroundingTextService manualRedactionSurroundingTextService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RedactionResult classify(@RequestBody RedactionRequest redactionRequest) {
|
public RedactionResult classify(@RequestBody RedactionRequest redactionRequest) {
|
||||||
|
|
||||||
@ -122,14 +124,17 @@ public class RedactionController implements RedactionResource {
|
|||||||
@Override
|
@Override
|
||||||
public void testRules(@RequestBody String rules) {
|
public void testRules(@RequestBody String rules) {
|
||||||
|
|
||||||
droolsExecutionService.testRules(rules);
|
try {
|
||||||
|
droolsExecutionService.testRules(rules);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RulesValidationException("Could not test rules: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RedactionLog getRedactionLog(RedactionRequest redactionRequest) {
|
public RedactionLog getRedactionLog(RedactionRequest redactionRequest) {
|
||||||
|
|
||||||
|
|
||||||
return redactionLogMergeService.provideRedactionLog(redactionRequest);
|
return redactionLogMergeService.provideRedactionLog(redactionRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,19 +143,14 @@ public class RedactionController implements RedactionResource {
|
|||||||
|
|
||||||
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
|
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
|
||||||
document.save(byteArrayOutputStream);
|
document.save(byteArrayOutputStream);
|
||||||
return RedactionResult.builder()
|
return RedactionResult.builder().document(byteArrayOutputStream.toByteArray()).numberOfPages(numberOfPages).build();
|
||||||
.document(byteArrayOutputStream.toByteArray())
|
|
||||||
.numberOfPages(numberOfPages)
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ManualRedactions addSurroundingText(@PathVariable("dossierId") String dossierId,
|
public ManualRedactions addSurroundingText(@PathVariable("dossierId") String dossierId, @PathVariable("fileId") String fileId, @RequestBody ManualRedactions manualRedactions) {
|
||||||
@PathVariable("fileId") String fileId,
|
|
||||||
@RequestBody ManualRedactions manualRedactions) {
|
|
||||||
|
|
||||||
var result = manualRedactionSurroundingTextService.addSurroundingText(dossierId, fileId, manualRedactions);
|
var result = manualRedactionSurroundingTextService.addSurroundingText(dossierId, fileId, manualRedactions);
|
||||||
log.info("Added surrounding text for manual redaction in dossierId {} and fileId {} took: {}", dossierId, fileId, result.getDuration());
|
log.info("Added surrounding text for manual redaction in dossierId {} and fileId {} took: {}", dossierId, fileId, result.getDuration());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user