* interaction lists referred by msisdn/keyword for message queue SMSSERVICES and interaction lists referred by serviceId/authenticationKey are editable
*
* @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public ActionForward list(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
InteractionListForm interactionListForm = (InteractionListForm) form;
String idParam = req.getParameter("id");
if (idParam != null) {
req.getSession().setAttribute("interactionListId", new Long(idParam)); // required for command entries
}
InteractionList interactionList = interactionListFromSession(req);
// page title and information according to actual type; must be extended for additional types!
MessageResources resources = getResources(req);
if (interactionList instanceof Invocation) {
Invocation invocation = (Invocation) interactionList;
req.setAttribute("title",resources.getMessage(locale,"smssvc.EditServiceInteractions"));
req.setAttribute("information1Title",resources.getMessage(locale,"smssvc.MSISDN") + " / " + resources.getMessage(locale,"smssvc.Keywords"));
req.setAttribute("information1Value",invocation.getMsisdn() == null ? "" : (invocation.getMsisdn() + (invocation.getKeywords() == null ? "" : (" / " + invocation.getKeywords()))));
req.setAttribute("information2Title",resources.getMessage(locale,"smssvc.ServiceId") + " / " + resources.getMessage(locale,"smssvc.Authentication"));
req.setAttribute("information2Value",invocation.getServiceId() == null ? "" : (invocation.getServiceId() + (invocation.getAuthenticationKey() == null ? "" : (" / " + invocation.getAuthenticationKey()))));
req.getSession().setAttribute("interactionListType", "invocation"); // required for cancelling
} else if (interactionList instanceof Fragment){
Fragment fragment = (Fragment)interactionList;
req.setAttribute("title",resources.getMessage(locale,"smssvc.EditFragmentInteractions"));
req.setAttribute("information1Title", resources.getMessage(locale,"smssvc.FragmentName"));
req.setAttribute("information1Value",fragment.getFragmentName());
req.setAttribute("information2Title", null); // second line not used
req.getSession().setAttribute("interactionListType", "fragment"); // required for cancelling
} else {
throw new BugException("can't do anything with list of type: " + interactionList.getClass().getName());
}
req.setAttribute("interactionList", interactionList);
interactionListForm.setGroupId(interactionList.getGroup().getId());
req.getSession().setAttribute("groupId", interactionList.getGroup().getId());
interactionListForm.setInteractionListId(interactionList.getId());
SortedSet<CommandEntry> sortedCommandEntries = sortedCommandEntries(interactionList);
List<DisplayableInteractionContent> displayableInteractions = buildInteractionList(req, interactionList.getGroup(), sortedCommandEntries,interactionList instanceof Fragment, Boolean.TRUE.equals(interactionListForm.getExpandFragments()));
req.setAttribute("interactions",displayableInteractions);
long defaultInsertionPointId = sortedCommandEntries.size() == 0 ? 0L : insertionPointFromRequest(req, sortedCommandEntries.last()).getId();
interactionListForm.setInsertCommandEntryId(defaultInsertionPointId);
interactionListForm.setInsertionType(2);
req.setAttribute("commandEntries", sortedCommandEntries);
return mapping.findForward("list");
}