* javax.servlet.http.HttpServletResponse)
*/
public ActionForward edit(ActionMapping mapping, ActionForm form,HttpServletRequest req, HttpServletResponse resp) {
SmsInteractionEnterOrEditForm smsInteractionEnterOrEditForm = (SmsInteractionEnterOrEditForm) form;
SmsCommandEntry smsCommandEntry = (SmsCommandEntry)commandEntryFromRequest(req);
Group group = smsCommandEntry.getGroup();
checkAccessRights(req, group);
if (smsCommandEntry.getUseAsTemplate() == 1){
req.getSession().setAttribute("attributeId", null); // application-independent selection lists in case of template editing
}
smsInteractionEnterOrEditForm.setCommandEntryId(smsCommandEntry.getId()); // not to be used when editing
smsInteractionEnterOrEditForm.setSortLabel(smsCommandEntry.getSortLabel());
smsInteractionEnterOrEditForm.setMessage(smsCommandEntry.getTextContent());
smsInteractionEnterOrEditForm.setDelayInSeconds(smsCommandEntry.getDelayInSeconds());
prepareUserSets(req, smsInteractionEnterOrEditForm, group);
// destination users (no users selectable because refresh does not work; already selected user may be inserted below)
Set<User> users = new HashSet<User>();
if(smsCommandEntry.getDestinationContact() == 1){
smsInteractionEnterOrEditForm.setDestinationSelection(2);
smsInteractionEnterOrEditForm.setCountryCode("43");
} else if(smsCommandEntry.getDestinationUserSet() != null || smsCommandEntry.getCurrentUserSetAsDestination() == 1){
smsInteractionEnterOrEditForm.setDestinationSelection(4);
smsInteractionEnterOrEditForm.setUserSetId(smsCommandEntry.getDestinationUserSet() != null ? smsCommandEntry.getDestinationUserSet().getId() : -2);
smsInteractionEnterOrEditForm.setCountryCode("43");
} else if(smsCommandEntry.getDestinationUser() != null){
smsInteractionEnterOrEditForm.setDestinationSelection(5);
smsInteractionEnterOrEditForm.setUserId(smsCommandEntry.getDestinationUser().getId());
users.add(smsCommandEntry.getDestinationUser());
smsInteractionEnterOrEditForm.setCountryCode("43");
} else if (smsCommandEntry.getDestinationMsisdn() != null){
smsInteractionEnterOrEditForm.setDestinationSelection(6);
smsInteractionEnterOrEditForm.setUserSetId(-1L);
smsInteractionEnterOrEditForm.setCountryCode(UserManager.countryCode(smsCommandEntry.getDestinationMsisdn()));
smsInteractionEnterOrEditForm.setMobileNumber(UserManager.mobileNumber(smsCommandEntry.getDestinationMsisdn()));
} else { // the sender of the request is also the receiver
smsInteractionEnterOrEditForm.setCountryCode("43");
smsInteractionEnterOrEditForm.setDestinationSelection(1);
}
SortedSet<SmsDestinationAddress> userAddresses = SmsDestinationAddress.smsDestinationAddresses(users);
prepareUser(req, smsInteractionEnterOrEditForm, userAddresses);
String[] senderList = configuredSenderMsisdns(req, group,smsCommandEntry.getSender());
smsInteractionEnterOrEditForm.setSendingMsisdn((smsCommandEntry.getSender() == null || senderList[0].startsWith("(")) ? senderList[0] :smsCommandEntry.getSender().getMsisdn() + "");
req.getSession().setAttribute("msisdnList",senderList);
req.getSession().setAttribute("interactionGroupName",group.getGroupname());
CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
Set<SmsCommandEntry> commandEntries = commandEntryManager.getTemplateCommandEntries(group, new SmsCommandEntry());
req.getSession().setAttribute("templates",commandEntries);