// reset also confirmation pending because enter will not be called
emailSendForm.setSendConfirmationPending(false);
return mapping.findForward("invalidToken");
}
EmailAddress fromAddress = new EmailAddress(webUser,emailSendForm.getFromEmail(),emailSendForm.getFromPersonalName() == null ? null : emailSendForm.getFromPersonalName());
Long userSetId = emailSendForm.getUserSetId();
Long userId = emailSendForm.getUserId();
Set<User> users=null;
Integer destinationSelection = emailSendForm.getDestinationSelection();
switch (destinationSelection==null?0:destinationSelection){
case 1: // user set
UserSetManager userSetManager = new UserSetManager(locale,session);
if (userSetId.longValue() == -1){
String noUserSetSelectedString = getResources(req).getMessage(locale,"smssvc.MessageNotSentBecauseNoUserSetSelected");
req.setAttribute("generalError",noUserSetSelectedString);
return mapping.findForward("notSent");
}
UserSet userSet = userSetManager.getUserSet(userSetId);
if (userSet == null){
throw new ConfigurationException("illegal user set id: " + userSetId);
}
users = userSet.getUsers();
break;
case 2: // user
if (userId.longValue() == -1){
String noUserSelectedString = getResources(req).getMessage(locale,"smssvc.MessageNotSentBecauseNoUserSelected");
req.setAttribute("generalError",noUserSelectedString);
return mapping.findForward("notSent");
}
UserManager userManager = new UserManager(locale,session);
User user = userManager.getUserDetails(userId);
if (user == null){
throw new ConfigurationException("illegal user id: " + user);
}
Set<User> oneManSet = new HashSet<User>();
oneManSet.add(user);
users = oneManSet;
break;
case 3: // e-mail address
EmailAddress toAddress = new EmailAddress(emailSendForm.getToEmail(), emailSendForm.getToPersonalName());
SortedSet<EmailAddress> receivers = new TreeSet<EmailAddress>();
receivers.add(toAddress);
MessagingManager msgMgr = new MessagingManager(locale, session);
msgMgr.sendEmail(fromAddress, receivers, getCurrentGroup(req), emailSendForm.getSubject(), emailSendForm.getMessage(), emailSendForm.getMimeType() == null ? MailSender.MIME_TYPE_PLAIN_TEXT : emailSendForm.getMimeType().intValue(), sendAt);
Date date = new Date(System.currentTimeMillis());