use of com.odysseusinc.arachne.portal.exception.NotExistException in project ArachneCentralAPI by OHDSI.
the class StudyTypeController method delete.
@ApiOperation(value = "Delete study type.", hidden = true)
@RequestMapping(value = "/api/v1/admin/study-types/{studyTypeId}", method = RequestMethod.DELETE)
public JsonResult delete(@PathVariable("studyTypeId") Long id) {
JsonResult result = null;
if (id == null) {
result = new JsonResult<>(JsonResult.ErrorCode.VALIDATION_ERROR);
result.getValidatorErrors().put("studyTypeId", "cannot be null");
} else {
try {
studyTypeService.delete(id);
result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
result.setResult(Boolean.TRUE);
} catch (NotExistException ex) {
log.error(ex.getMessage(), ex);
result = new JsonResult<>(JsonResult.ErrorCode.VALIDATION_ERROR);
result.getValidatorErrors().put("studyTypeId", "Status with id=" + id + " not found");
result.setErrorMessage(ex.getMessage());
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
result = new JsonResult<>(JsonResult.ErrorCode.SYSTEM_ERROR);
result.setErrorMessage(ex.getMessage());
}
}
return result;
}
use of com.odysseusinc.arachne.portal.exception.NotExistException in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionController method deleteSubmissionResultsByUuid.
@ApiOperation("Delete manually uploaded submission result file")
@RequestMapping(value = "/api/v1/analysis-management/submissions/{submissionId}/result/{fileUuid}", method = DELETE)
public JsonResult<Boolean> deleteSubmissionResultsByUuid(@PathVariable("submissionId") Long id, @PathVariable("fileUuid") String fileUuid) {
LOGGER.info("deleting result file for submission with id={} having uuid={}", id, fileUuid);
JsonResult.ErrorCode errorCode;
Boolean hasResult;
try {
ResultFile resultFile = submissionService.getResultFileByPath(contentStorageService.getFileByIdentifier(fileUuid).getPath());
hasResult = submissionService.deleteSubmissionResultFile(id, resultFile);
errorCode = JsonResult.ErrorCode.NO_ERROR;
} catch (NotExistException e) {
LOGGER.warn("Submission was not found, id: {}", id);
errorCode = JsonResult.ErrorCode.VALIDATION_ERROR;
hasResult = false;
} catch (ValidationException e) {
LOGGER.warn("Result file was not deleted", e);
errorCode = JsonResult.ErrorCode.VALIDATION_ERROR;
hasResult = false;
}
JsonResult<Boolean> result = new JsonResult<>(errorCode);
result.setResult(hasResult);
return result;
}
use of com.odysseusinc.arachne.portal.exception.NotExistException in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionController method createSubmission.
@ApiOperation("Create and send submission.")
@RequestMapping(value = "/api/v1/analysis-management/{analysisId}/submissions", method = POST)
public JsonResult<List<DTO>> createSubmission(Principal principal, @RequestBody @Validated CreateSubmissionsDTO createSubmissionsDTO, @PathVariable("analysisId") Long analysisId) throws PermissionDeniedException, NotExistException, IOException, NoExecutableFileException, ValidationException {
final JsonResult<List<DTO>> result;
if (principal == null) {
throw new PermissionDeniedException();
}
IUser user = userService.getByEmail(principal.getName());
if (user == null) {
throw new PermissionDeniedException();
}
Analysis analysis = analysisService.getById(analysisId);
final List<Submission> submissions = AnalysisHelper.createSubmission(submissionService, createSubmissionsDTO.getDataSources(), user, analysis);
final List<DTO> submissionDTOs = submissions.stream().map(s -> conversionService.convert(s, getSubmissionDTOClass())).collect(Collectors.toList());
result = new JsonResult<>(NO_ERROR);
result.setResult(submissionDTOs);
return result;
}
use of com.odysseusinc.arachne.portal.exception.NotExistException in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisServiceImpl method processAnalysisUnlockRequest.
@Override
public void processAnalysisUnlockRequest(IUser user, Long invitationId, Boolean invitationAccepted) throws NotExistException {
final Long userId = user.getId();
final AnalysisUnlockRequest exist = analysisUnlockRequestRepository.findOneByIdAndLeadId(invitationId, userId).orElseThrow(() -> {
final String message = String.format(UNLOCK_REQUEST_NOT_EXIST_EXCEPTION, invitationId, userId);
return new NotExistException(message, AnalysisUnlockRequest.class);
});
if (invitationAccepted != null && invitationAccepted) {
exist.setStatus(AnalysisUnlockRequestStatus.APPROVED);
final A analysis = (A) exist.getAnalysis();
analysis.setLocked(false);
analysisRepository.save(analysis);
} else {
exist.setStatus(AnalysisUnlockRequestStatus.DECLINED);
}
analysisUnlockRequestRepository.save(exist);
}
use of com.odysseusinc.arachne.portal.exception.NotExistException in project ArachneCentralAPI by OHDSI.
the class BasePaperServiceImpl method deleteFile.
@PreAuthorize("hasPermission(#paperId, 'Paper', " + "T(com.odysseusinc.arachne.portal.security.ArachnePermission).LIMITED_EDIT_PAPER)")
// @Transactional not usable for this method.
@Override
public void deleteFile(Long paperId, String fileUuid, PaperFileType fileType) throws FileNotFoundException {
AbstractPaperFile paperFile;
switch(fileType) {
case PAPER:
{
paperFile = paperPaperFileRepository.findByPaperIdAndUuid(paperId, fileUuid).orElseThrow(() -> new NotExistException(AbstractPaperFile.class));
paperPaperFileRepository.delete(paperFile.getId());
break;
}
case PROTOCOL:
{
paperFile = paperProtocolFileRepository.findByPaperIdAndUuid(paperId, fileUuid).orElseThrow(() -> new NotExistException(AbstractPaperFile.class));
paperProtocolFileRepository.delete(paperFile.getId());
break;
}
default:
{
throw new IllegalArgumentException("Illegal filetype: " + fileType);
}
}
fileService.delete(paperFile);
}
Aggregations