/**
 * Copyright (c) 2005-2008 Intalio inc.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Intalio inc. - initial API and implementation
 */

package org.intalio.tempo.uiframework.actions;

import java.util.Map;

import javax.servlet.http.HttpServletRequestWrapper;

import org.intalio.tempo.uiframework.Configuration;
import org.intalio.tempo.uiframework.Constants;
import org.intalio.tempo.uiframework.UIFWApplicationState;
import org.intalio.tempo.versions.BpmsDescriptorParser;
import org.intalio.tempo.web.ApplicationState;
import org.intalio.tempo.web.controller.Action;
import org.intalio.tempo.web.controller.ActionError;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.ModelAndView;

@SuppressWarnings("unchecked")
public class TasksAction extends Action {
    private static final BpmsDescriptorParser BPMS_DESCRIPTOR_PARSER = new BpmsDescriptorParser();
    private static final Logger _log = LoggerFactory.getLogger(TasksAction.class);

    @Override
    public ModelAndView execute() {
        if (Boolean.valueOf(_request.getParameter("update"))) {
            return new ModelAndView(Constants.TASKS_UPDATE_VIEW, createModel());
        } else {
            return new ModelAndView(Constants.TASKS_VIEW, createModel());
        }
    }

    public ModelAndView getErrorView() {
        return new ModelAndView(Constants.TASKS_VIEW, createModel());
    }

    protected TasksCollector getTaskCollector(String user, String token){
    	return new TasksCollector(new HttpServletRequestWrapper(_request), user, token);
    }
    
    protected void fillModel(Map model) {
        final UIFWApplicationState state = ApplicationState.getCurrentInstance(new HttpServletRequestWrapper(_request));
        final String token = state.getCurrentUser().getToken();
        final String user = state.getCurrentUser().getName();
        try {
        	TasksCollector collector = getTaskCollector(user, token);
            model.put("tasks", collector.retrieveTasks());
        } catch (Exception ex) {
            _errors.add(new ActionError(-1, null, "com_intalio_bpms_workflow_tasks_retrieve_error", null, ActionError.getStackTrace(ex), null, null));
            _log.error("Error while retrieving task list", ex);
        }

        model.put("participantToken", token);
        model.put("currentUser", user);
        model.put("refreshTime", Configuration.getInstance().getRefreshTime());
        model.put("sessionTimeout", Configuration.getInstance().getSessionTimeout());
        BPMS_DESCRIPTOR_PARSER.addBpmsBuildVersionsPropertiesToMap(model);
    }
}

@@ -1325,16 +1325,31 @@
 pdate%22))
+.booleanValue()
 ) %7B%0A    
@@ -2115,22 +2115,97 @@
 ();%0A
- 
+%09%09if (Boolean.valueOf(_request.getParameter(%22update%22)).booleanValue()) %7B%0A%09
        
+ 
 try %7B%0A
+%09
     
@@ -2259,32 +2259,33 @@
 r(user, token);%0A
+%09
             mode
@@ -2323,24 +2323,25 @@
 veTasks());%0A
+%09
         %7D ca
@@ -2357,24 +2357,25 @@
 ption ex) %7B%0A
+%09
             
@@ -2509,24 +2509,25 @@
 ll, null));%0A
+%09
             
@@ -2578,16 +2578,17 @@
 %22, ex);%0A
+%09
         
@@ -2585,24 +2585,27 @@
 %0A%09        %7D%0A
+%09%09%7D
 %0A        mod

fix duplicate init task retrieve request prob