Search in sources :

Example 81 with InvalidParametersException

use of teammates.common.exception.InvalidParametersException in project teammates by TEAMMATES.

the class CoursesDb method updateCourse.

/**
 * Updates the course.<br>
 * Updates only name and course archive status.<br>
 * Preconditions: <br>
 * * {@code courseToUpdate} is non-null.<br>
 */
public void updateCourse(CourseAttributes courseToUpdate) throws InvalidParametersException, EntityDoesNotExistException {
    Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, courseToUpdate);
    courseToUpdate.sanitizeForSaving();
    if (!courseToUpdate.isValid()) {
        throw new InvalidParametersException(courseToUpdate.getInvalidityInfo());
    }
    Course courseEntityToUpdate = getCourseEntity(courseToUpdate.getId());
    if (courseEntityToUpdate == null) {
        throw new EntityDoesNotExistException(ERROR_UPDATE_NON_EXISTENT_COURSE);
    }
    courseEntityToUpdate.setName(courseToUpdate.getName());
    courseEntityToUpdate.setTimeZone(courseToUpdate.getTimeZone().getId());
    saveEntity(courseEntityToUpdate, courseToUpdate);
}
Also used : InvalidParametersException(teammates.common.exception.InvalidParametersException) Course(teammates.storage.entity.Course) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 82 with InvalidParametersException

use of teammates.common.exception.InvalidParametersException in project teammates by TEAMMATES.

the class StudentProfileEditSaveAction method execute.

@Override
protected ActionResult execute() throws EntityDoesNotExistException {
    try {
        account.studentProfile = extractProfileData();
        logic.updateStudentProfile(account.studentProfile);
        statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_PROFILE_EDITED, StatusMessageColor.SUCCESS));
        statusToAdmin = "Student Profile for <span class=\"bold\">(" + account.googleId + ")</span> edited.<br>" + SanitizationHelper.sanitizeForHtmlTag(account.studentProfile.toString());
    } catch (InvalidParametersException ipe) {
        setStatusForException(ipe);
    }
    return createRedirectResult(Const.ActionURIs.STUDENT_PROFILE_PAGE);
}
Also used : InvalidParametersException(teammates.common.exception.InvalidParametersException) StatusMessage(teammates.common.util.StatusMessage)

Example 83 with InvalidParametersException

use of teammates.common.exception.InvalidParametersException in project teammates by TEAMMATES.

the class StudentProfilePictureAction method handleRequestWithEmailAndCourse.

private ActionResult handleRequestWithEmailAndCourse() throws EntityDoesNotExistException {
    String email;
    String courseId;
    try {
        email = getStudentEmailFromRequest();
        courseId = getCourseIdFromRequest();
    } catch (InvalidParametersException e) {
        log.warning("Attempting to decrypt malformed ciphertext when retrieving email or course id from request.");
        throw new EntityDoesNotExistException(e);
    }
    log.info("email: " + email + ", course: " + courseId);
    StudentAttributes student = getStudentForGivenParameters(courseId, email);
    gateKeeper.verifyAccessibleForCurrentUserAsInstructorOrTeamMemberOrAdmin(account, courseId, student.section, email);
    return createImageResult(getPictureKeyForStudent(student));
}
Also used : InvalidParametersException(teammates.common.exception.InvalidParametersException) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Aggregations

InvalidParametersException (teammates.common.exception.InvalidParametersException)83 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)37 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)24 StatusMessage (teammates.common.util.StatusMessage)21 Test (org.testng.annotations.Test)19 EntityAlreadyExistsException (teammates.common.exception.EntityAlreadyExistsException)19 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)13 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)12 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)9 FeedbackSession (teammates.storage.entity.FeedbackSession)9 Text (com.google.appengine.api.datastore.Text)8 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)8 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)6 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)6 ArrayList (java.util.ArrayList)5 InstructorPrivileges (teammates.common.datatransfer.InstructorPrivileges)5 VoidWork (com.googlecode.objectify.VoidWork)4 StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)4 PageData (teammates.ui.pagedata.PageData)4 FeedbackResponseCommentAttributes (teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes)3