コード例 #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 Message sendTutorShipConfirmedMessage(User sender, User receiver) {
   Message acceptanceMessage = new Message();
   String messageText =
       new StringBuilder()
           .append("Your Tutorship for " + sender.getFirstName() + " was accepted by him!\n")
           .append("This message is auto generated. Do not answer")
           .toString();
   acceptanceMessage.setMessageText(messageText);
   acceptanceMessage.setMessageSubject("Tutorship accepted!");
   acceptanceMessage.setReceiver(receiver);
   acceptanceMessage.setSender(sender);
   return send(acceptanceMessage);
 }
コード例 #3
0
 public void sendRatingReminder(Tutor tutor, User student) {
   Message reminder = new Message();
   reminder.setMessageText(
       "Don't forget to rate your tutor:"
           + "<br>"
           + "<a href=\"/tutoris_baernae/rate?tutorId="
           + tutor.getId()
           + "\"><u> Click here to rate your tutor </u></a>");
   reminder.setMessageSubject("Rate " + tutor.getStudent().getFirstName());
   reminder.setSender(tutor.getStudent());
   reminder.setReceiver(student);
   send(reminder);
 }
コード例 #4
0
  public Message sendContactDetails(User sender, User receiver) {
    assert (!sender.equals(receiver));
    Message contactDetails = new Message();

    String allContactInformations =
        new StringBuilder()
            .append("You can contact me as follows: \n")
            .append("<br>Full name: " + sender.getFirstName() + " " + sender.getLastName() + " \n")
            .append("<br>Email: " + sender.getEmail() + " \n")
            .append("<br>This message is auto generated. Do not answer")
            .toString();
    contactDetails.setMessageSubject("Contact Details");
    contactDetails.setMessageText(allContactInformations);
    contactDetails.setReceiver(receiver);
    contactDetails.setSender(sender);
    return send(contactDetails);
  }