예제 #1
0
 private Message getMessageFromForm(MessageForm messageForm, User sender) {
   Message message = new Message();
   User receiver = userDao.findByEmailLike(messageForm.getReceiver());
   if (receiver == null)
     throw new InvalidUserException("The user you want to send a message does not exist");
   message.setSender(sender);
   message.setReceiver(receiver);
   message.setMessageSubject(messageForm.getMessageSubject());
   message.setMessageText(messageForm.getMessageText());
   return message;
 }
예제 #2
0
 public MessageForm sendTutorShipOffer(MessageForm messageForm, User sender) {
   Message offerMessage = getMessageFromForm(messageForm, sender);
   tutorShipService.addOfferedTutorShip(offerMessage);
   offerMessage.setMessageSubject("Tutorship Offer");
   offerMessage = send(offerMessage);
   messageForm.setId(offerMessage.getId());
   return messageForm;
 }
예제 #3
0
 /**
  * Sends the message by saving it to the database.
  *
  * @param messageForm a valid messageForm, not null
  * @param User the sender of the message, not null
  * @throws InvalidUserException if the receiver doesn't exist/couldn't be found by the string
  *     receiver given in the messageForm
  */
 @Transactional
 public MessageForm sendMessageFromForm(MessageForm messageForm, User sender)
     throws InvalidUserException {
   assert (messageForm != null);
   assert (sender != null);
   Message message = send(getMessageFromForm(messageForm, sender));
   messageForm.setId(message.getId());
   return messageForm;
 }