Search in sources :

Example 31 with UnauthorizedAccessException

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);
}
Also used : NullPostParameterException(teammates.common.exception.NullPostParameterException) UnauthorizedAccessException(teammates.common.exception.UnauthorizedAccessException) DeadlineExceededException(com.google.apphosting.api.DeadlineExceededException) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 32 with UnauthorizedAccessException

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");
    }
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) UnauthorizedAccessException(teammates.common.exception.UnauthorizedAccessException) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Aggregations

UnauthorizedAccessException (teammates.common.exception.UnauthorizedAccessException)32 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)18 Test (org.testng.annotations.Test)13 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)8 ShowPageResult (teammates.ui.controller.ShowPageResult)8 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)6 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)6 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)5 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)4 EntityNotFoundException (teammates.common.exception.EntityNotFoundException)4 FeedbackQuestionsDb (teammates.storage.api.FeedbackQuestionsDb)4 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)4 RedirectResult (teammates.ui.controller.RedirectResult)4 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)3 StatusMessage (teammates.common.util.StatusMessage)3 Action (teammates.ui.controller.Action)3 DeadlineExceededException (com.google.apphosting.api.DeadlineExceededException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 UserType (teammates.common.datatransfer.UserType)2