/*
 * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 2.1 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl.html
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * Contributors:
 *     Nuxeo - initial API and implementation
 *
 * $Id: PageFlowActionFilter.java 21461 2007-06-26 20:42:26Z sfermigier $
 */

package org.nuxeo.ecm.platform.actions;

import java.util.HashMap;
import java.util.Map;

import org.jboss.seam.core.Pageflow;

/**
 * @author  <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
 *
 */
public class PageFlowActionFilter extends AbstractActionFilter {

    public static final Map EMPTY_TRANSITION_MAP = new HashMap();

    private static final long serialVersionUID = 3003327715065315406L;

    private Map pageFlowTransitions;

    public PageFlowActionFilter() {
        super("PAGE_FLOW_FILTER", Action.EMPTY_CATEGORIES);
    }

    public Map getPageflowTransitions() {
        if (pageFlowTransitions == null) {
            try {
                pageFlowTransitions = Pageflow.instance()
                    .getPage().getLeavingTransitionsMap();
            } catch (IllegalStateException e) {
                // no seam context found
                pageFlowTransitions = EMPTY_TRANSITION_MAP;
            }
        }
        return pageFlowTransitions;
    }

    public boolean accept(Action action, ActionContext context) {
        Map leavingTransitions = getPageflowTransitions();
        return leavingTransitions.containsKey(action.getId());
    }

}

@@ -802,23 +802,27 @@
 va.util.
-HashMap
+Collections
 ;%0Aimport
@@ -874,16 +874,54 @@
 ageflow;
+%0Aimport org.jbpm.graph.def.Transition;
 %0A%0A/**%0A *
@@ -1082,16 +1082,36 @@
 inal Map
+%3CString, Transition%3E
  EMPTY_T
@@ -1130,16 +1130,25 @@
 P = 
-new Hash
+Collections.empty
 Map(
@@ -1238,16 +1238,36 @@
 vate Map
+%3CString, Transition%3E
  pageFlo
@@ -1392,18 +1392,73 @@
     
-public Map
+@SuppressWarnings(%22unchecked%22)%0A    public Map%3CString, Transition%3E
  get
@@ -1937,24 +1937,24 @@
  context) %7B%0A
-
         Map 
@@ -1952,16 +1952,36 @@
      Map
+%3CString, Transition%3E
  leaving

Use generics.