use of teammates.common.exception.UnauthorizedAccessException in project teammates by TEAMMATES.
the class AdminExceptionTestAction method execute.
@Override
// deliberately done for testing
@SuppressWarnings("PMD.AvoidThrowingNullPointerException")
protected ActionResult execute() throws EntityDoesNotExistException {
gateKeeper.verifyAdminPrivileges(account);
String error = getRequestParamValue(Const.ParamsNames.ERROR);
if (error.equals(AssertionError.class.getSimpleName())) {
throw new AssertionError("AssertionError Testing");
} else if (error.equals(EntityDoesNotExistException.class.getSimpleName())) {
throw new EntityDoesNotExistException("EntityDoesNotExistException Testing");
} else if (error.equals(UnauthorizedAccessException.class.getSimpleName())) {
throw new UnauthorizedAccessException();
} else if (error.equals(NullPointerException.class.getSimpleName())) {
throw new NullPointerException();
} else if (error.equals(DeadlineExceededException.class.getSimpleName())) {
throw new DeadlineExceededException();
} else if (error.equals(NullPostParameterException.class.getSimpleName())) {
throw new NullPostParameterException("test null post param exception");
}
statusToAdmin = "adminExceptionTest";
return createRedirectResult(Const.ActionURIs.ADMIN_HOME_PAGE);
}
use of teammates.common.exception.UnauthorizedAccessException in project teammates by TEAMMATES.
the class InstructorFeedbackSubmissionEditSaveAction method verifyAccessibleForSpecificUser.
@Override
protected void verifyAccessibleForSpecificUser() {
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
FeedbackSessionAttributes session = logic.getFeedbackSession(feedbackSessionName, courseId);
boolean isCreatorOnly = false;
gateKeeper.verifyAccessible(instructor, session, isCreatorOnly);
boolean shouldEnableSubmit = instructor.isAllowedForPrivilege(Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS);
if (!shouldEnableSubmit && instructor.isAllowedForPrivilegeAnySection(session.getFeedbackSessionName(), Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS)) {
shouldEnableSubmit = true;
}
if (!shouldEnableSubmit) {
throw new UnauthorizedAccessException("Feedback session [" + session.getFeedbackSessionName() + "] is not accessible to instructor [" + instructor.email + "] for this purpose");
}
}
Aggregations