use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class AdminEmailComposeSendAction method updateDraftEmailToSent.
private void updateDraftEmailToSent(String emailId, String subject, List<String> addressReceiver, List<String> groupReceiver, String content) {
AdminEmailAttributes finalisedEmail = AdminEmailAttributes.builder(subject, addressReceiver, groupReceiver, new Text(content)).withSendDate(Instant.now()).build();
try {
logic.updateAdminEmailById(finalisedEmail, emailId);
} catch (InvalidParametersException | EntityDoesNotExistException e) {
isError = true;
setStatusForException(e);
return;
}
moveJobToGroupModeTaskQueue();
moveJobToAddressModeTaskQueue();
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class AdminEmailTrashAction method execute.
@Override
protected ActionResult execute() {
gateKeeper.verifyAdminPrivileges(account);
String emailId = getRequestParamValue(Const.ParamsNames.ADMIN_EMAIL_ID);
String redirect = getRequestParamValue(Const.ParamsNames.ADMIN_EMAIL_TRASH_ACTION_REDIRECT);
if (redirect == null) {
redirect = Const.ActionURIs.ADMIN_EMAIL_TRASH_PAGE;
}
if (redirect.contains("sentpage")) {
redirect = Const.ActionURIs.ADMIN_EMAIL_SENT_PAGE;
} else if (redirect.contains("draftpage")) {
redirect = Const.ActionURIs.ADMIN_EMAIL_DRAFT_PAGE;
} else {
redirect = Const.ActionURIs.ADMIN_EMAIL_TRASH_PAGE;
}
if (emailId == null || emailId.isEmpty()) {
statusToAdmin = "Invalid parameter : email id cannot be null or empty";
statusToUser.add(new StatusMessage("Invalid parameter : email id cannot be null or empty", StatusMessageColor.DANGER));
return createRedirectResult(redirect);
}
if (requestUrl.contains(Const.ActionURIs.ADMIN_EMAIL_MOVE_TO_TRASH)) {
try {
logic.moveAdminEmailToTrashBin(emailId);
statusToAdmin = "Email with id" + emailId + " has been moved to trash bin";
statusToUser.add(new StatusMessage("The item has been moved to trash bin", StatusMessageColor.SUCCESS));
} catch (InvalidParametersException | EntityDoesNotExistException e) {
setStatusForException(e, "An error has occurred when moving email to trash bin");
}
return createRedirectResult(redirect);
} else if (requestUrl.contains(Const.ActionURIs.ADMIN_EMAIL_MOVE_OUT_TRASH)) {
try {
logic.moveAdminEmailOutOfTrashBin(emailId);
statusToAdmin = "Email with id" + emailId + " has been moved out of trash bin";
statusToUser.add(new StatusMessage("The item has been moved out of trash bin", StatusMessageColor.SUCCESS));
} catch (InvalidParametersException | EntityDoesNotExistException e) {
setStatusForException(e, "An error has occurred when moving email out of trash bin");
}
return createRedirectResult(Const.ActionURIs.ADMIN_EMAIL_TRASH_PAGE);
}
return createRedirectResult(redirect);
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class InstructorCourseEnrollSaveAction method enrollAndProcessResultForDisplay.
private List<StudentAttributes>[] enrollAndProcessResultForDisplay(String studentsInfo, String courseId) throws EnrollException, EntityDoesNotExistException, InvalidParametersException, EntityAlreadyExistsException {
CourseEnrollmentResult enrollResult = logic.enrollStudents(studentsInfo, courseId);
List<StudentAttributes> students = enrollResult.studentList;
// Adjust submissions for all feedback responses within the course
List<FeedbackSessionAttributes> feedbackSessions = logic.getFeedbackSessionsForCourse(courseId);
for (FeedbackSessionAttributes session : feedbackSessions) {
// Schedule adjustment of submissions for feedback session in course
taskQueuer.scheduleFeedbackResponseAdjustmentForCourse(courseId, session.getFeedbackSessionName(), enrollResult.enrollmentList);
}
students.sort(Comparator.comparing(obj -> obj.updateStatus.numericRepresentation));
return separateStudents(students);
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class InstructorCourseInstructorAbstractAction method updateInstructorWithSectionLevelPrivileges.
/**
* Updates section and session level privileges for the instructor.
*
* @param courseId Course that the instructor is being added to.
* @param instructor Instructor that will be added.
* This will be modified within the method.
*/
protected void updateInstructorWithSectionLevelPrivileges(String courseId, InstructorAttributes instructor) {
List<String> sectionNames = null;
try {
sectionNames = logic.getSectionNamesForCourse(courseId);
} catch (EntityDoesNotExistException e) {
return;
}
HashMap<String, Boolean> isSectionSpecialMappings = new HashMap<>();
for (String sectionName : sectionNames) {
isSectionSpecialMappings.put(sectionName, false);
}
List<String> feedbackNames = new ArrayList<>();
List<FeedbackSessionAttributes> feedbacks = logic.getFeedbackSessionsForCourse(courseId);
for (FeedbackSessionAttributes feedback : feedbacks) {
feedbackNames.add(feedback.getFeedbackSessionName());
}
Map<String, List<String>> sectionNamesMap = getSectionsWithSpecialPrivilegesFromParameters(instructor, sectionNames, isSectionSpecialMappings);
sectionNamesMap.forEach((sectionGroupName, specialSectionsInSectionGroup) -> {
updateInstructorPrivilegesForSectionInSectionLevel(sectionGroupName, specialSectionsInSectionGroup, instructor);
// check if session-specific permissions are to be used
String setSessionsStr = getRequestParamValue("is" + sectionGroupName + "sessionsset");
boolean isSessionsForSectionGroupSpecial = Boolean.parseBoolean(setSessionsStr);
if (isSessionsForSectionGroupSpecial) {
updateInstructorPrivilegesForSectionInSessionLevel(sectionGroupName, specialSectionsInSectionGroup, feedbackNames, instructor);
} else {
removeSessionLevelPrivileges(instructor, specialSectionsInSectionGroup);
}
});
isSectionSpecialMappings.forEach((sectionNameToBeChecked, isSectionSpecial) -> {
if (!isSectionSpecial) {
instructor.privileges.removeSectionLevelPrivileges(sectionNameToBeChecked);
}
});
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class Action method executeAndPostProcess.
/**
* ------------------------------------------------
*/
/**
* Executes the action (as implemented by a child class). Before passing
* the result to the caller, it does some post processing: <br>
* 1. If the original request contained a URL to redirect after performing
* the action, the result will be replaced with a new 'redirect' type
* result. Note: Redirection is not allowed to third-party destinations. <br>
* 2. User ID, error flag, and the status message will be added to the response,
* to be encoded into the URL. The error flag is also added to the
* {@code isError} flag in the {@link ActionResult} object.
*/
public ActionResult executeAndPostProcess() {
if (!isValidUser()) {
return createRedirectResult(getAuthenticationRedirectUrl());
}
// get the result from the child class.
ActionResult response;
try {
response = execute();
} catch (EntityDoesNotExistException e) {
throw new EntityNotFoundException(e);
}
// set error flag of the result
response.isError = isError;
// Set the common parameters for the response
if (gateKeeper.getCurrentUser() != null) {
response.responseParams.put(Const.ParamsNames.USER_ID, account.googleId);
}
if (regkey != null) {
response.responseParams.put(Const.ParamsNames.REGKEY, getRegkeyFromRequest());
if (student != null) {
response.responseParams.put(Const.ParamsNames.STUDENT_EMAIL, student.email);
response.responseParams.put(Const.ParamsNames.COURSE_ID, student.course);
}
if (getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME) != null) {
response.responseParams.put(Const.ParamsNames.FEEDBACK_SESSION_NAME, getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME));
}
}
response.responseParams.put(Const.ParamsNames.ERROR, Boolean.toString(response.isError));
// Pass status message using session to prevent XSS attack
if (!response.getStatusMessage().isEmpty()) {
putStatusMessageToSession(response);
}
return response;
}
Aggregations