use of teammates.common.exception.InvalidParametersException in project teammates by TEAMMATES.
the class InstructorCourseInstructorEditSaveAction method execute.
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
String instructorId = getRequestParamValue(Const.ParamsNames.INSTRUCTOR_ID);
String instructorName = getRequestParamValue(Const.ParamsNames.INSTRUCTOR_NAME);
Assumption.assertPostParamNotNull(Const.ParamsNames.INSTRUCTOR_NAME, instructorName);
String instructorEmail = getRequestParamValue(Const.ParamsNames.INSTRUCTOR_EMAIL);
Assumption.assertPostParamNotNull(Const.ParamsNames.INSTRUCTOR_EMAIL, instructorEmail);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId), Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR);
InstructorAttributes instructorToEdit = extractUpdatedInstructor(courseId, instructorId, instructorName, instructorEmail);
updateToEnsureValidityOfInstructorsForTheCourse(courseId, instructorToEdit);
try {
if (instructorId == null) {
logic.updateInstructorByEmail(instructorEmail, instructorToEdit);
} else {
logic.updateInstructorByGoogleId(instructorId, instructorToEdit);
}
statusToUser.add(new StatusMessage(String.format(Const.StatusMessages.COURSE_INSTRUCTOR_EDITED, instructorName), StatusMessageColor.SUCCESS));
statusToAdmin = "Instructor <span class=\"bold\"> " + instructorName + "</span>" + " for Course <span class=\"bold\">[" + courseId + "]</span> edited.<br>" + "New Name: " + instructorName + "<br>New Email: " + instructorEmail;
} catch (InvalidParametersException e) {
setStatusForException(e);
}
/* Create redirection to 'Edit' page with corresponding course id */
RedirectResult result = createRedirectResult(Const.ActionURIs.INSTRUCTOR_COURSE_EDIT_PAGE);
result.addResponseParam(Const.ParamsNames.COURSE_ID, courseId);
return result;
}
use of teammates.common.exception.InvalidParametersException in project teammates by TEAMMATES.
the class InstructorFeedbackUnpublishAction method execute.
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
String nextUrl = getRequestParamValue(Const.ParamsNames.NEXT_URL);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
FeedbackSessionAttributes session = logic.getFeedbackSession(feedbackSessionName, courseId);
boolean isCreatorOnly = false;
gateKeeper.verifyAccessible(instructor, session, isCreatorOnly, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
try {
logic.unpublishFeedbackSession(session);
if (session.isPublishedEmailEnabled()) {
taskQueuer.scheduleFeedbackSessionUnpublishedEmail(session.getCourseId(), session.getFeedbackSessionName());
}
statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_SESSION_UNPUBLISHED, StatusMessageColor.SUCCESS));
statusToAdmin = "Feedback Session <span class=\"bold\">(" + feedbackSessionName + ")</span> " + "for Course <span class=\"bold\">[" + courseId + "]</span> unpublished.";
} catch (InvalidParametersException e) {
setStatusForException(e);
}
if (nextUrl == null) {
nextUrl = Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE;
}
return createRedirectResult(nextUrl);
}
use of teammates.common.exception.InvalidParametersException in project teammates by TEAMMATES.
the class AdminEmailComposeSendAction method checkAddressReceiverString.
private void checkAddressReceiverString(String addressReceiverString) throws InvalidParametersException {
FieldValidator validator = new FieldValidator();
String[] emails = addressReceiverString.split(",");
for (String email : emails) {
String error = validator.getInvalidityInfoForEmail(email);
if (!error.isEmpty()) {
isError = true;
statusToUser.add(new StatusMessage(error, StatusMessageColor.DANGER));
throw new InvalidParametersException("<strong>Email Format Error</strong>");
}
}
}
use of teammates.common.exception.InvalidParametersException in project teammates by TEAMMATES.
the class InstructorCourseEnrollSaveAction method execute.
@Override
public ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
String studentsInfo = getRequestParamValue(Const.ParamsNames.STUDENTS_ENROLLMENT_INFO);
String sanitizedStudentsInfo = SanitizationHelper.sanitizeForHtml(studentsInfo);
Assumption.assertPostParamNotNull(Const.ParamsNames.STUDENTS_ENROLLMENT_INFO, studentsInfo);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId), Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
/* Process enrollment list and setup data for page result */
try {
List<StudentAttributes>[] students = enrollAndProcessResultForDisplay(studentsInfo, courseId);
boolean hasSection = hasSections(students);
InstructorCourseEnrollResultPageData pageData = new InstructorCourseEnrollResultPageData(account, sessionToken, courseId, students, hasSection, studentsInfo);
statusToAdmin = "Students Enrolled in Course <span class=\"bold\">[" + courseId + "]:</span><br>" + sanitizedStudentsInfo.replace("\n", "<br>");
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_COURSE_ENROLL_RESULT, pageData);
} catch (EnrollException | InvalidParametersException e) {
setStatusForException(e);
statusToAdmin += "<br>Enrollment string entered by user:<br>" + sanitizedStudentsInfo.replace("\n", "<br>");
InstructorCourseEnrollPageData pageData = new InstructorCourseEnrollPageData(account, sessionToken, courseId, studentsInfo);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_COURSE_ENROLL, pageData);
} catch (EntityAlreadyExistsException e) {
setStatusForException(e);
statusToUser.add(new StatusMessage("The enrollment failed, possibly because some students were re-enrolled before " + "the previous enrollment action was still being processed by TEAMMATES database " + "servers. Please try again after about 10 minutes. If the problem persists, " + "please contact TEAMMATES support", StatusMessageColor.DANGER));
InstructorCourseEnrollPageData pageData = new InstructorCourseEnrollPageData(account, sessionToken, courseId, studentsInfo);
log.severe("Entity already exists exception occurred when updating student: " + e.getMessage());
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_COURSE_ENROLL, pageData);
}
}
use of teammates.common.exception.InvalidParametersException in project teammates by TEAMMATES.
the class InstructorCourseInstructorAddAction method execute.
@Override
protected ActionResult execute() {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
String instructorName = getRequestParamValue(Const.ParamsNames.INSTRUCTOR_NAME);
Assumption.assertPostParamNotNull(Const.ParamsNames.INSTRUCTOR_NAME, instructorName);
String instructorEmail = getRequestParamValue(Const.ParamsNames.INSTRUCTOR_EMAIL);
Assumption.assertPostParamNotNull(Const.ParamsNames.INSTRUCTOR_EMAIL, instructorEmail);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId), Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR);
InstructorAttributes instructorToAdd = extractCompleteInstructor(courseId, instructorName, instructorEmail);
/* Process adding the instructor and setup status to be shown to user and admin */
try {
logic.createInstructor(instructorToAdd);
taskQueuer.scheduleCourseRegistrationInviteToInstructor(loggedInUser.googleId, instructorEmail, courseId);
statusToUser.add(new StatusMessage(String.format(Const.StatusMessages.COURSE_INSTRUCTOR_ADDED, instructorName, instructorEmail), StatusMessageColor.SUCCESS));
statusToAdmin = "New instructor (<span class=\"bold\"> " + instructorEmail + "</span>)" + " for Course <span class=\"bold\">[" + courseId + "]</span> created.<br>";
} catch (EntityAlreadyExistsException e) {
setStatusForException(e, Const.StatusMessages.COURSE_INSTRUCTOR_EXISTS);
} catch (InvalidParametersException e) {
setStatusForException(e);
}
RedirectResult redirectResult = createRedirectResult(Const.ActionURIs.INSTRUCTOR_COURSE_EDIT_PAGE);
redirectResult.addResponseParam(Const.ParamsNames.COURSE_ID, courseId);
return redirectResult;
}
Aggregations