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:
Corina Olariu 2022-02-04 10:07:49 +01:00 committed by Timo Bejan
commit 84a2e00f02
4 changed files with 24 additions and 6 deletions

View File

@ -9,6 +9,8 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import java.util.List;
@ResponseStatus(value = HttpStatus.OK)
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)
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);
@GetMapping(value = SECTION_GRID_PATH + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)

View File

@ -9,6 +9,8 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequiredArgsConstructor
public class RedactionLogController implements RedactionLogResource {
@ -18,9 +20,10 @@ public class RedactionLogController implements RedactionLogResource {
public 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) {
return redactionLogService.getRedactionLog(dossierId, fileId, withManualRedactions);
return redactionLogService.getRedactionLog(dossierId, fileId, excludedTypes, withManualRedactions);
}

View File

@ -13,6 +13,8 @@ import com.iqser.red.service.redaction.v1.model.SectionGrid;
import feign.FeignException;
import lombok.RequiredArgsConstructor;
import java.util.List;
@Service
@RequiredArgsConstructor
public class RedactionLogService {
@ -23,21 +25,25 @@ public class RedactionLogService {
private final DossierPersistenceService dossierPersistenceService;
private final FileStatusService fileStatusService;
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);
if (fileStatus.isExcluded()) {
throw new NotFoundException("Excluded files have no redactionLog");
}
RedactionLog redactionLog;
if (withManualRedactions) {
var dossier = dossierPersistenceService.getAndValidateDossier(dossierId);
var manualRedactions = manualRedactionService.getManualRedactions(fileId);
try {
return redactionClient.getRedactionLog(RedactionRequest.builder()
redactionLog = redactionClient.getRedactionLog(RedactionRequest.builder()
.dossierId(dossierId)
.fileId(fileId)
.manualRedactions(manualRedactions)
@ -51,8 +57,14 @@ public class RedactionLogService {
throw e;
}
} else {
return fileManagementStorageService.getRedactionLog(dossierId, fileId);
redactionLog = fileManagementStorageService.getRedactionLog(dossierId, fileId);
}
if (excludedTypes != null) {
redactionLog.getRedactionLogEntry().removeIf(nextEntry -> excludedTypes.contains(nextEntry.getType()));
}
return redactionLog;
}

View File

@ -27,8 +27,8 @@ public class RedactionLogTest extends AbstractPersistenceServerServiceTest {
var file = fileTesterAndProvider.testAndProvideFile(dossier);
assertThat(redactionLogClient.getSectionGrid(dossier.getId(), file.getId())).isNotNull();
assertThat(redactionLogClient.getRedactionLog(dossier.getId(), file.getId(), true)).isNotNull();
assertThat(redactionLogClient.getRedactionLog(dossier.getId(), file.getId(), false)).isNotNull();
assertThat(redactionLogClient.getRedactionLog(dossier.getId(), file.getId(), null,true)).isNotNull();
assertThat(redactionLogClient.getRedactionLog(dossier.getId(), file.getId(), null,false)).isNotNull();
}
}