RED-7158: Rosario wants more verbose error messages #90
@ -26,7 +26,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.client.pdftronredactionservice.PDFTronClient;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.BadRequestException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.NotAllowedException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.AccessControlService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.FileManagementStorageService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.FileService;
|
||||
@ -141,14 +140,15 @@ public class FileManagementController implements FileManagementResource {
|
||||
}
|
||||
|
||||
|
||||
private ResponseEntity<?> getResponseEntityForPDFDocument(String fileId, String dossierId, FileType viewerDocument, boolean inline) {
|
||||
private ResponseEntity<?> getResponseEntityForPDFDocument(String fileId, String dossierId, FileType fileType, boolean inline) {
|
||||
|
||||
String storageId = StorageIdUtils.getStorageId(dossierId, fileId, fileType);
|
||||
try {
|
||||
var file = fileStatusManagementService.getFileStatus(fileId);
|
||||
var pdfFileStream = fileManagementStorageService.getObject(TenantContext.getTenantId(), StorageIdUtils.getStorageId(dossierId, fileId, viewerDocument));
|
||||
var pdfFileStream = fileManagementStorageService.getObject(TenantContext.getTenantId(), storageId);
|
||||
return getResponseEntity(inline, pdfFileStream, file.getFilename());
|
||||
} catch (StorageObjectDoesNotExist e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.NOT_FOUND);
|
||||
return new ResponseEntity<>(String.format("File \"%s\" not found!, the dossier with ID \"%s\" probably does not exist.", storageId, dossierId), HttpStatus.NOT_FOUND);
|
||||
} catch (StorageException e) {
|
||||
log.debug(e.getMessage(), e);
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
|
||||
@ -8,8 +8,6 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -26,6 +24,7 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemp
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.ProcessingStatus;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.WorkflowStatus;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@ -263,7 +262,7 @@ public class FileStatusPersistenceService {
|
||||
|
||||
file.setLastFileAttributeChange(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
throw new NotFoundException(String.format("File with ID \"%s\" not found!", fileId));
|
||||
});
|
||||
|
||||
}
|
||||
@ -312,15 +311,14 @@ public class FileStatusPersistenceService {
|
||||
fileRepository.updateLastAttributeChangeDate(fileId, file.getLastProcessed());
|
||||
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
throw new NotFoundException(String.format("File with ID \"%s\" not found!", fileId));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public FileEntity getStatus(String fileId) {
|
||||
|
||||
return fileRepository.findById(fileId).orElseThrow(() -> new NotFoundException("Unknown file=" + fileId));
|
||||
|
||||
return fileRepository.findById(fileId).orElseThrow(() -> new NotFoundException(String.format("File with ID \"%s\" not found!", fileId)));
|
||||
}
|
||||
|
||||
|
||||
@ -335,7 +333,7 @@ public class FileStatusPersistenceService {
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setExcludedPages(excludedPages);
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
throw new NotFoundException(String.format("File with ID \"%s\" not found!", fileId));
|
||||
});
|
||||
|
||||
}
|
||||
@ -378,7 +376,7 @@ public class FileStatusPersistenceService {
|
||||
|
||||
int countUpdate = fileRepository.setHardDelete(fileId, ProcessingStatus.PROCESSED, now, now, now);
|
||||
if (countUpdate == 0) {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
throw new NotFoundException(String.format("File with ID \"%s\" not found!", fileId));
|
||||
}
|
||||
fileAttributesRepository.deleteByFileId(fileId);
|
||||
}
|
||||
@ -389,7 +387,7 @@ public class FileStatusPersistenceService {
|
||||
|
||||
int countUpdate = fileRepository.setSoftDelete(fileId, ProcessingStatus.PROCESSED, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS), softDeletedTime);
|
||||
if (countUpdate == 0) {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
throw new NotFoundException(String.format("File with ID \"%s\" not found!", fileId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -402,7 +400,7 @@ public class FileStatusPersistenceService {
|
||||
throw new BadRequestException("Cannot undelete a hard-deleted dossier file!");
|
||||
}
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
throw new NotFoundException(String.format("File with ID \"%s\" not found!", fileId));
|
||||
});
|
||||
fileRepository.setSoftDelete(fileId, ProcessingStatus.PROCESSED, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS), null);
|
||||
}
|
||||
@ -416,7 +414,7 @@ public class FileStatusPersistenceService {
|
||||
}
|
||||
int updateCount = fileRepository.setAssignee(fileId, currentAssignee, lastReviewer, lastApprover, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
if (updateCount == 0) {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
throw new NotFoundException(String.format("File with ID \"%s\" not found!", fileId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -429,7 +427,7 @@ public class FileStatusPersistenceService {
|
||||
}
|
||||
int countUpdate = fileRepository.toggleExclusion(fileId, excluded, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
if (countUpdate == 0) {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
throw new NotFoundException(String.format("File with ID \"%s\" not found!", fileId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -442,7 +440,7 @@ public class FileStatusPersistenceService {
|
||||
}
|
||||
int countUpdate = fileRepository.toggleAutomaticAnalysis(fileId, excludedFromAutomaticAnalysis, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
if (countUpdate == 0) {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
throw new NotFoundException(String.format("File with ID \"%s\" not found!", fileId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -474,7 +472,7 @@ public class FileStatusPersistenceService {
|
||||
}
|
||||
|
||||
if (countUpdate == 0) {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
throw new NotFoundException(String.format("File with ID \"%s\" not found!", fileId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user