Pull request #217: RED-3333 - Optional false_positives in redaction log
Merge in RED/persistence-service from feature/RED-3333 to master * commit '7f1b924b5c78ae72ab8234f05fa47bc354e14857': RED-3333 - Optional false_positives in redaction log
This commit is contained in:
commit
84a2e00f02
@ -9,6 +9,8 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@ResponseStatus(value = HttpStatus.OK)
|
@ResponseStatus(value = HttpStatus.OK)
|
||||||
public interface RedactionLogResource {
|
public interface RedactionLogResource {
|
||||||
|
|
||||||
@ -23,6 +25,7 @@ public interface RedactionLogResource {
|
|||||||
|
|
||||||
@GetMapping(value = REDACTION_LOG_PATH + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
@GetMapping(value = REDACTION_LOG_PATH + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
RedactionLog getRedactionLog(@PathVariable(DOSSIER_ID_PARAM) String dossierId, @PathVariable(FILE_ID) String fileId,
|
RedactionLog getRedactionLog(@PathVariable(DOSSIER_ID_PARAM) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||||
|
@RequestParam(value = "excludedType", required = false) List<String> excludedTypes,
|
||||||
@RequestParam(value = "withManualRedactions", required = false, defaultValue = "true") boolean withManualRedactions);
|
@RequestParam(value = "withManualRedactions", required = false, defaultValue = "true") boolean withManualRedactions);
|
||||||
|
|
||||||
@GetMapping(value = SECTION_GRID_PATH + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
@GetMapping(value = SECTION_GRID_PATH + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
|||||||
@ -9,6 +9,8 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class RedactionLogController implements RedactionLogResource {
|
public class RedactionLogController implements RedactionLogResource {
|
||||||
@ -18,9 +20,10 @@ public class RedactionLogController implements RedactionLogResource {
|
|||||||
|
|
||||||
public RedactionLog getRedactionLog(@PathVariable(DOSSIER_ID_PARAM) String dossierId,
|
public RedactionLog getRedactionLog(@PathVariable(DOSSIER_ID_PARAM) String dossierId,
|
||||||
@PathVariable(FILE_ID) String fileId,
|
@PathVariable(FILE_ID) String fileId,
|
||||||
|
@RequestParam(value = "excludedType", required = false) List<String> excludedTypes,
|
||||||
@RequestParam(value = "withManualRedactions", required = false, defaultValue = "true") boolean withManualRedactions) {
|
@RequestParam(value = "withManualRedactions", required = false, defaultValue = "true") boolean withManualRedactions) {
|
||||||
|
|
||||||
return redactionLogService.getRedactionLog(dossierId, fileId, withManualRedactions);
|
return redactionLogService.getRedactionLog(dossierId, fileId, excludedTypes, withManualRedactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,8 @@ import com.iqser.red.service.redaction.v1.model.SectionGrid;
|
|||||||
import feign.FeignException;
|
import feign.FeignException;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class RedactionLogService {
|
public class RedactionLogService {
|
||||||
@ -23,21 +25,25 @@ public class RedactionLogService {
|
|||||||
private final DossierPersistenceService dossierPersistenceService;
|
private final DossierPersistenceService dossierPersistenceService;
|
||||||
private final FileStatusService fileStatusService;
|
private final FileStatusService fileStatusService;
|
||||||
|
|
||||||
|
|
||||||
public RedactionLog getRedactionLog(String dossierId, String fileId, boolean withManualRedactions) {
|
public RedactionLog getRedactionLog(String dossierId, String fileId, boolean withManualRedactions) {
|
||||||
|
return getRedactionLog(dossierId, fileId, null, withManualRedactions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RedactionLog getRedactionLog(String dossierId, String fileId, List<String> excludedTypes, boolean withManualRedactions) {
|
||||||
|
|
||||||
var fileStatus = fileStatusService.getStatus(fileId);
|
var fileStatus = fileStatusService.getStatus(fileId);
|
||||||
|
|
||||||
if (fileStatus.isExcluded()) {
|
if (fileStatus.isExcluded()) {
|
||||||
throw new NotFoundException("Excluded files have no redactionLog");
|
throw new NotFoundException("Excluded files have no redactionLog");
|
||||||
}
|
}
|
||||||
|
RedactionLog redactionLog;
|
||||||
|
|
||||||
if (withManualRedactions) {
|
if (withManualRedactions) {
|
||||||
var dossier = dossierPersistenceService.getAndValidateDossier(dossierId);
|
var dossier = dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||||
var manualRedactions = manualRedactionService.getManualRedactions(fileId);
|
var manualRedactions = manualRedactionService.getManualRedactions(fileId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return redactionClient.getRedactionLog(RedactionRequest.builder()
|
redactionLog = redactionClient.getRedactionLog(RedactionRequest.builder()
|
||||||
.dossierId(dossierId)
|
.dossierId(dossierId)
|
||||||
.fileId(fileId)
|
.fileId(fileId)
|
||||||
.manualRedactions(manualRedactions)
|
.manualRedactions(manualRedactions)
|
||||||
@ -51,8 +57,14 @@ public class RedactionLogService {
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return fileManagementStorageService.getRedactionLog(dossierId, fileId);
|
redactionLog = fileManagementStorageService.getRedactionLog(dossierId, fileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (excludedTypes != null) {
|
||||||
|
redactionLog.getRedactionLogEntry().removeIf(nextEntry -> excludedTypes.contains(nextEntry.getType()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return redactionLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -27,8 +27,8 @@ public class RedactionLogTest extends AbstractPersistenceServerServiceTest {
|
|||||||
var file = fileTesterAndProvider.testAndProvideFile(dossier);
|
var file = fileTesterAndProvider.testAndProvideFile(dossier);
|
||||||
|
|
||||||
assertThat(redactionLogClient.getSectionGrid(dossier.getId(), file.getId())).isNotNull();
|
assertThat(redactionLogClient.getSectionGrid(dossier.getId(), file.getId())).isNotNull();
|
||||||
assertThat(redactionLogClient.getRedactionLog(dossier.getId(), file.getId(), true)).isNotNull();
|
assertThat(redactionLogClient.getRedactionLog(dossier.getId(), file.getId(), null,true)).isNotNull();
|
||||||
assertThat(redactionLogClient.getRedactionLog(dossier.getId(), file.getId(), false)).isNotNull();
|
assertThat(redactionLogClient.getRedactionLog(dossier.getId(), file.getId(), null,false)).isNotNull();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user