use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class FeedbackSessionsDb method updateInstructorRespondent.
public void updateInstructorRespondent(String oldEmail, String newEmail, FeedbackSessionAttributes feedbackSession) throws InvalidParametersException, EntityDoesNotExistException {
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, oldEmail);
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, newEmail);
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, feedbackSession);
feedbackSession.sanitizeForSaving();
if (!feedbackSession.isValid()) {
throw new InvalidParametersException(feedbackSession.getInvalidityInfo());
}
FeedbackSession fs = getEntity(feedbackSession);
if (fs == null) {
throw new EntityDoesNotExistException(ERROR_UPDATE_NON_EXISTENT + feedbackSession.toString());
}
if (fs.getRespondingInstructorList().contains(oldEmail)) {
fs.getRespondingInstructorList().remove(oldEmail);
fs.getRespondingInstructorList().add(newEmail);
}
saveEntity(fs, feedbackSession);
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class FeedbackSessionsDb method updateFeedbackSession.
/**
* Updates the feedback session identified by {@code newAttributes.feedbackSesionName}
* and {@code newAttributes.courseId}.
* For the remaining parameters, the existing value is preserved
* if the parameter is null (due to 'keep existing' policy).<br>
* Preconditions: <br>
* * {@code newAttributes.feedbackSesionName} and {@code newAttributes.courseId}
* are non-null and correspond to an existing feedback session. <br>
*/
public void updateFeedbackSession(FeedbackSessionAttributes newAttributes) throws InvalidParametersException, EntityDoesNotExistException {
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, newAttributes);
newAttributes.sanitizeForSaving();
if (!newAttributes.isValid()) {
throw new InvalidParametersException(newAttributes.getInvalidityInfo());
}
FeedbackSession fs = getEntity(newAttributes);
if (fs == null) {
throw new EntityDoesNotExistException(ERROR_UPDATE_NON_EXISTENT + newAttributes.toString());
}
fs.setInstructions(newAttributes.getInstructions());
fs.setStartTime(newAttributes.getStartTime());
fs.setEndTime(newAttributes.getEndTime());
fs.setSessionVisibleFromTime(newAttributes.getSessionVisibleFromTime());
fs.setResultsVisibleFromTime(newAttributes.getResultsVisibleFromTime());
fs.setTimeZone(newAttributes.getTimeZone().getId());
fs.setGracePeriod(newAttributes.getGracePeriodMinutes());
fs.setFeedbackSessionType(newAttributes.getFeedbackSessionType());
fs.setSentOpenEmail(newAttributes.isSentOpenEmail());
fs.setSentClosingEmail(newAttributes.isSentClosingEmail());
fs.setSentClosedEmail(newAttributes.isSentClosedEmail());
fs.setSentPublishedEmail(newAttributes.isSentPublishedEmail());
fs.setIsOpeningEmailEnabled(newAttributes.isOpeningEmailEnabled());
fs.setSendClosingEmail(newAttributes.isClosingEmailEnabled());
fs.setSendPublishedEmail(newAttributes.isPublishedEmailEnabled());
saveEntity(fs, newAttributes);
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class FeedbackSessionsDb method updateStudentRespondent.
public void updateStudentRespondent(String oldEmail, String newEmail, FeedbackSessionAttributes feedbackSession) throws InvalidParametersException, EntityDoesNotExistException {
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, oldEmail);
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, newEmail);
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, feedbackSession);
feedbackSession.sanitizeForSaving();
if (!feedbackSession.isValid()) {
throw new InvalidParametersException(feedbackSession.getInvalidityInfo());
}
FeedbackSession fs = getEntity(feedbackSession);
if (fs == null) {
throw new EntityDoesNotExistException(ERROR_UPDATE_NON_EXISTENT + feedbackSession.toString());
}
if (fs.getRespondingStudentList().contains(oldEmail)) {
fs.getRespondingStudentList().remove(oldEmail);
fs.getRespondingStudentList().add(newEmail);
}
saveEntity(fs, feedbackSession);
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class FeedbackSessionsDb method deleteStudentRespondent.
// The objectify library does not support throwing checked exceptions inside transactions
@SuppressWarnings("PMD.AvoidThrowingRawExceptionTypes")
public void deleteStudentRespondent(String email, FeedbackSessionAttributes feedbackSession) throws EntityDoesNotExistException, InvalidParametersException {
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, email);
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, feedbackSession);
feedbackSession.sanitizeForSaving();
if (!feedbackSession.isValid()) {
throw new InvalidParametersException(feedbackSession.getInvalidityInfo());
}
try {
ofy().transact(new VoidWork() {
@Override
public void vrun() {
FeedbackSession fs = getEntity(feedbackSession);
if (fs == null) {
throw new RuntimeException(new EntityDoesNotExistException(ERROR_UPDATE_NON_EXISTENT + feedbackSession.toString()));
}
fs.getRespondingStudentList().remove(email);
saveEntity(fs, feedbackSession);
}
});
} catch (RuntimeException e) {
if (e.getCause() instanceof EntityDoesNotExistException) {
throw (EntityDoesNotExistException) e.getCause();
}
throw e;
}
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class InstructorsDb method updateInstructorByEmail.
/**
* Updates the instructor. Cannot modify Course ID or email.
*/
public void updateInstructorByEmail(InstructorAttributes instructorAttributesToUpdate) throws InvalidParametersException, EntityDoesNotExistException {
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, instructorAttributesToUpdate);
if (!instructorAttributesToUpdate.isValid()) {
throw new InvalidParametersException(instructorAttributesToUpdate.getInvalidityInfo());
}
instructorAttributesToUpdate.sanitizeForSaving();
Instructor instructorToUpdate = getInstructorEntityForEmail(instructorAttributesToUpdate.courseId, instructorAttributesToUpdate.email);
if (instructorToUpdate == null) {
throw new EntityDoesNotExistException(ERROR_UPDATE_NON_EXISTENT_ACCOUNT + instructorAttributesToUpdate.email + ThreadHelper.getCurrentThreadStack());
}
instructorToUpdate.setGoogleId(instructorAttributesToUpdate.googleId);
instructorToUpdate.setName(instructorAttributesToUpdate.name);
instructorToUpdate.setIsArchived(instructorAttributesToUpdate.isArchived);
instructorToUpdate.setRole(instructorAttributesToUpdate.role);
instructorToUpdate.setIsDisplayedToStudents(instructorAttributesToUpdate.isDisplayedToStudents);
instructorToUpdate.setDisplayedName(instructorAttributesToUpdate.displayedName);
instructorToUpdate.setInstructorPrivilegeAsText(instructorAttributesToUpdate.getTextFromInstructorPrivileges());
// TODO: make courseId+email the non-modifiable values
putDocument(makeAttributes(instructorToUpdate));
saveEntity(instructorToUpdate, instructorAttributesToUpdate);
}
Aggregations