/**
* Creates timer event entry with interactions based on mapping set in session
* @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)
*/
protected ActionForward duplicateBasedOnMappingSet(ActionMapping mapping, ActionForm form,HttpServletRequest req, HttpServletResponse resp){
TimerEventEnterOrEditForm f = (TimerEventEnterOrEditForm)form;
// get mappings from session
Object mappingSetFromSession = req.getSession().getAttribute("mappingSet");
if (!(mappingSetFromSession instanceof MappingSet)) {
throw new BugException("invalid mappingSet parameter: " + mappingSetFromSession);
}
MappingSet mappingSet = (MappingSet) mappingSetFromSession;
mappingSet.reload(locale, session);
Object oldTimerEventId = req.getSession().getAttribute("oldInteractionListId");
if (oldTimerEventId == null || !(oldTimerEventId instanceof Long)){
throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"),"old timer event entry not found in session",null,null);
}
TimerEvent oldTimerEvent = new SmsServiceDbManager(locale,session).getTimerEvent((Long)oldTimerEventId);
if (oldTimerEvent == null){
throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"),"old timer event entry #" + oldTimerEventId + " not found",null,null);
}
checkAccessRights(req,oldTimerEvent.getGroup(),null);
Object newEntry = req.getSession().getAttribute("newTimerEvent");
if (newEntry == null || !(newEntry instanceof TimerEvent)){
throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"),"new timer event entry not found in session",null,null);
}
// reload references in current session
TimerEvent newTimerEvent = (TimerEvent)newEntry;
f.initialize(newTimerEvent,locale,session,getResources(req));
newTimerEvent = new TimerEvent();
f.toEntry(newTimerEvent, locale, session, getResources(req));
checkAccessRights(req, newTimerEvent.getGroup(),null);
// group assignment is not editable => perform source to destination automatically
mappingSet.add(new Entry(oldTimerEvent.getGroup()), new Entry(newTimerEvent.getGroup()));