Skip to content

Commit

Permalink
remove redundant null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-christl committed Oct 28, 2023
1 parent 4bf9968 commit 2c85bc7
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions src/main/java/de/tum/in/www1/artemis/web/rest/FileResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,6 @@ public ResponseEntity<byte[]> getFileUploadSubmission(@PathVariable Long exercis
throw new AccessForbiddenException();
}

if (submission.getFilePath() == null) {
throw new EntityNotFoundException("Submission " + submissionId + " has no file");
}

return buildFileResponse(getActualPathFromPublicPathString(submission.getFilePath()), false);
}

Expand Down Expand Up @@ -301,10 +297,6 @@ public ResponseEntity<byte[]> getUserSignature(@PathVariable Long examUserId) {
ExamUser examUser = examUserRepository.findWithExamById(examUserId).orElseThrow();
authorizationCheckService.checkHasAtLeastRoleInCourseElseThrow(Role.INSTRUCTOR, examUser.getExam().getCourse(), null);

if (examUser.getSigningImagePath() == null) {
throw new EntityNotFoundException("Exam user " + examUserId + " has no signature file");
}

return buildFileResponse(getActualPathFromPublicPathString(examUser.getSigningImagePath()), false);
}

Expand All @@ -321,10 +313,6 @@ public ResponseEntity<byte[]> getExamUserImage(@PathVariable Long examUserId) {
ExamUser examUser = examUserRepository.findWithExamById(examUserId).orElseThrow();
authorizationCheckService.checkHasAtLeastRoleInCourseElseThrow(Role.INSTRUCTOR, examUser.getExam().getCourse(), null);

if (examUser.getStudentImagePath() == null) {
throw new EntityNotFoundException("Exam user " + examUserId + " has no image file");
}

return buildFileResponse(getActualPathFromPublicPathString(examUser.getStudentImagePath()), true);
}

Expand Down Expand Up @@ -352,10 +340,6 @@ public ResponseEntity<byte[]> getLectureAttachment(@PathVariable Long lectureId,
// check if the user is authorized to access the requested attachment unit
checkAttachmentAuthorizationOrThrow(course, attachment);

if (attachment.getLink() == null) {
throw new EntityNotFoundException("Attachment " + filename + " has no file");
}

return buildFileResponse(getActualPathFromPublicPathString(attachment.getLink()), false);
}

Expand Down Expand Up @@ -413,10 +397,6 @@ public ResponseEntity<byte[]> getAttachmentUnitAttachment(@PathVariable Long att
// check if the user is authorized to access the requested attachment unit
checkAttachmentAuthorizationOrThrow(course, attachment);

if (attachment.getLink() == null) {
throw new EntityNotFoundException("Attachment " + attachmentUnitId + " has no file");
}

return buildFileResponse(getActualPathFromPublicPathString(attachment.getLink()), false);
}

Expand Down

0 comments on commit 2c85bc7

Please sign in to comment.