* Creates invocation 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)
*/
@Override
protected ActionForward duplicateBasedOnMappingSet(ActionMapping mapping, ActionForm form,HttpServletRequest req, HttpServletResponse resp){
InvocationEnterOrEditForm f = (InvocationEnterOrEditForm)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 oldInvocationId = req.getSession().getAttribute("oldInteractionListId");
if (oldInvocationId == null || !(oldInvocationId instanceof Long)){
throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"),"old invocation entry not found in session",null,null);
}
Invocation oldInvocation = new SmsDbManager(locale,session).getInvocation((Long)oldInvocationId);
if (oldInvocation == null){
throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"),"old invocation entry #" + oldInvocationId + " not found",null,null);
}
checkAccessRights(req,oldInvocation.getGroup(),null);
Object newEntry = req.getSession().getAttribute("newInteractionList");
if (newEntry == null || !(newEntry instanceof Invocation)){
throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"),"new invocation entry not found in session",null,null);
}
// reload references in current session
Invocation newInvocation = (Invocation)newEntry;
f.initialize(newInvocation,locale,session,getResources(req));
newInvocation = new Invocation();
f.toEntry(newInvocation, locale, session, getResources(req));
checkAccessRights(req, newInvocation.getGroup(),null);
// group assignment is not editable => perform source to destination automatically
mappingSet.add(new Entry(oldInvocation.getGroup()), new Entry(newInvocation.getGroup()));