DM-285: fully deprecated RedactionLog, added component rule file
* return 404, when component rule file hasn't been created yet* deprecate RSSResponse * enter clean redaction-service version * fixed some messages * used correct RuleFileType
This commit is contained in:
parent
2e142f12e9
commit
56baa7db07
@ -16,7 +16,7 @@ import com.iqser.red.service.persistence.management.v1.processor.service.EntityL
|
||||
import com.iqser.red.service.persistence.service.v1.api.external.resource.AnalysisLogResource;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.componentlog.ComponentLog;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLog;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.FilteredRedactionLogRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.FilteredEntityLogRequest;
|
||||
|
||||
import feign.FeignException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -25,7 +25,7 @@ import lombok.RequiredArgsConstructor;
|
||||
@RequiredArgsConstructor
|
||||
public class AnalysisLogController implements AnalysisLogResource {
|
||||
|
||||
private final EntityLogService redactionLogService;
|
||||
private final EntityLogService entityLogService;
|
||||
private final ComponentLogService componentLogService;
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ public class AnalysisLogController implements AnalysisLogResource {
|
||||
@RequestParam(value = "includeFalsePositives", required = false, defaultValue = "false") boolean includeFalsePositives) {
|
||||
|
||||
try {
|
||||
return redactionLogService.getEntityLog(dossierId, fileId, excludedTypes);
|
||||
return entityLogService.getEntityLog(dossierId, fileId, excludedTypes);
|
||||
} catch (FeignException e) {
|
||||
throw processFeignException(e);
|
||||
}
|
||||
@ -47,10 +47,10 @@ public class AnalysisLogController implements AnalysisLogResource {
|
||||
@PreAuthorize("hasAuthority('" + READ_REDACTION_LOG + "')")
|
||||
public EntityLog getFilteredEntityLog(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@RequestBody FilteredRedactionLogRequest filteredRedactionLogRequest) {
|
||||
@RequestBody FilteredEntityLogRequest filteredEntityLogRequest) {
|
||||
|
||||
try {
|
||||
return redactionLogService.getFilteredEntityLog(dossierId, fileId, filteredRedactionLogRequest);
|
||||
return entityLogService.getFilteredEntityLog(dossierId, fileId, filteredEntityLogRequest);
|
||||
} catch (FeignException e) {
|
||||
throw processFeignException(e);
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.componentlog.ComponentLog;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLog;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.FilteredRedactionLogRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.FilteredEntityLogRequest;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
@ -33,7 +33,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 redaction 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.")})
|
||||
EntityLog getEntityLog(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@ -43,15 +43,15 @@ 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 redaction 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.")})
|
||||
EntityLog getFilteredEntityLog(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@RequestBody FilteredRedactionLogRequest filteredRedactionLogRequest);
|
||||
@RequestBody FilteredEntityLogRequest filteredEntityLogRequest);
|
||||
|
||||
|
||||
@GetMapping(value = COMPONENT_LOG_PATH + DOSSIER_ID_PATH_VARIABLE + FILE_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "Gets the redaction 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.")})
|
||||
ComponentLog getComponentLog(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId);
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLog;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLogEntry;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.FilteredRedactionLogRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.FilteredEntityLogRequest;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@ -48,14 +48,13 @@ public class EntityLogService {
|
||||
}
|
||||
|
||||
|
||||
public EntityLog getFilteredEntityLog(String dossierId, String fileId, FilteredEntityLogRequest filteredEntityLogRequest) {
|
||||
|
||||
public EntityLog getFilteredEntityLog(String dossierId, String fileId, FilteredRedactionLogRequest filteredRedactionLogRequest) {
|
||||
|
||||
if (filteredRedactionLogRequest.getSpecifiedDate() == null) {
|
||||
filteredRedactionLogRequest.setSpecifiedDate(OffsetDateTime.MIN);
|
||||
if (filteredEntityLogRequest.getSpecifiedDate() == null) {
|
||||
filteredEntityLogRequest.setSpecifiedDate(OffsetDateTime.MIN);
|
||||
}
|
||||
|
||||
var entityLog = getEntityLog(dossierId, fileId, filteredRedactionLogRequest.getExcludedTypes());
|
||||
var entityLog = getEntityLog(dossierId, fileId, filteredEntityLogRequest.getExcludedTypes());
|
||||
var entityLogEntry = entityLog.getEntityLogEntry();
|
||||
|
||||
Iterator<EntityLogEntry> it = entityLogEntry.iterator();
|
||||
@ -63,15 +62,17 @@ public class EntityLogService {
|
||||
var redactionLogEntry = it.next();
|
||||
boolean isAfterSpecifiedDate = false;
|
||||
for (var change : redactionLogEntry.getChanges()) {
|
||||
if (change.getDateTime() != null && change.getDateTime().isAfter(filteredRedactionLogRequest.getSpecifiedDate())) {
|
||||
if (change.getDateTime() != null && change.getDateTime().isAfter(filteredEntityLogRequest.getSpecifiedDate())) {
|
||||
isAfterSpecifiedDate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (var manualChange : redactionLogEntry.getManualChanges()) {
|
||||
if (manualChange.getProcessedDate() != null && manualChange.getProcessedDate()
|
||||
.isAfter(filteredRedactionLogRequest.getSpecifiedDate()) || manualChange.getRequestedDate() != null && manualChange.getRequestedDate()
|
||||
.isAfter(filteredRedactionLogRequest.getSpecifiedDate())) {
|
||||
.isAfter(filteredEntityLogRequest.getSpecifiedDate()) || manualChange.getRequestedDate() != null && manualChange.getRequestedDate()
|
||||
.isAfter(filteredEntityLogRequest.getSpecifiedDate())) {
|
||||
isAfterSpecifiedDate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -100,8 +100,8 @@ public class FileManagementStorageService {
|
||||
try {
|
||||
return storageService.readJSONObject(TenantContext.getTenantId(), StorageIdUtils.getStorageId(dossierId, fileId, FileType.ENTITY_LOG), EntityLog.class);
|
||||
} catch (StorageObjectDoesNotExist e) {
|
||||
log.debug("RedactionLog does not exist");
|
||||
throw new NotFoundException(String.format("RedactionLog does not exist for Dossier ID \"%s\" and File ID \"%s\"!", dossierId, fileId));
|
||||
log.debug("EntityLog does not exist");
|
||||
throw new NotFoundException(String.format("EntityLog does not exist for Dossier ID \"%s\" and File ID \"%s\"!", dossierId, fileId));
|
||||
} catch (StorageException e) {
|
||||
throw new InternalServerErrorException(e.getMessage());
|
||||
}
|
||||
@ -171,8 +171,8 @@ public class FileManagementStorageService {
|
||||
try {
|
||||
return storageService.readJSONObject(TenantContext.getTenantId(), StorageIdUtils.getStorageId(dossierId, fileId, FileType.COMPONENT_LOG), ComponentLog.class);
|
||||
} catch (StorageObjectDoesNotExist e) {
|
||||
log.debug("RedactionLog does not exist");
|
||||
throw new NotFoundException(String.format("RedactionLog does not exist for Dossier ID \"%s\" and File ID \"%s\"!", dossierId, fileId));
|
||||
log.debug("ComponentLog does not exist");
|
||||
throw new NotFoundException(String.format("ComponentLog does not exist for Dossier ID \"%s\" and File ID \"%s\"!", dossierId, fileId));
|
||||
} catch (StorageException e) {
|
||||
throw new InternalServerErrorException(e.getMessage());
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@ public class DossierTemplateExportService {
|
||||
objectMapper.writeValueAsBytes(ruleSet.getValue())));
|
||||
|
||||
// add component rule set
|
||||
var componentRuleSet = rulesPersistenceService.getRules(dossierTemplateId, RuleFileType.ENTITY);
|
||||
var componentRuleSet = rulesPersistenceService.getRules(dossierTemplateId, RuleFileType.COMPONENT);
|
||||
fileSystemBackedArchiver.addEntries(new FileSystemBackedArchiver.ArchiveModel(null,
|
||||
getFilename(ExportFilename.COMPONENT_RULES, TXT_EXT),
|
||||
objectMapper.writeValueAsBytes(componentRuleSet.getValue())));
|
||||
|
||||
@ -12,7 +12,7 @@ import lombok.NoArgsConstructor;
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FilteredRedactionLogRequest {
|
||||
public class FilteredEntityLogRequest {
|
||||
|
||||
private List<String> excludedTypes;
|
||||
private boolean withManualRedactions;
|
||||
Loading…
x
Reference in New Issue
Block a user