001/*
002 * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 *
017 * $Id: ActionFilter.java 20637 2007-06-17 12:37:03Z sfermigier $
018 */
019
020package org.nuxeo.ecm.platform.actions;
021
022import java.io.Serializable;
023
024/**
025 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
026 */
027public interface ActionFilter extends Serializable {
028
029    String getId();
030
031    void setId(String id);
032
033    /**
034     * Checks whether this action is valid in the given context.
035     * <p>
036     * The action is considered valid if no denying rule is found and at least one granting rule is found. If no rule is
037     * found at all, it is valid.
038     * <p>
039     * In other words: OR between granting rules, AND between denying rules, denial is favored (also if exceptions
040     * occur), AND inside of rules, OR inside or rule items (type, facet,...).
041     *
042     * @param action the optional action to check against, should be able to be null if filters evaluation only depends
043     *            on given context.
044     * @param context mandatory context holding variables to check against.
045     * @returns true if filters configuration for given action and context. Returns false if an error occurs during one
046     *          of the conditions evaluation.
047     */
048    boolean accept(Action action, ActionContext context);
049
050    /**
051     * Returns a clone, useful for hot reload.
052     *
053     * @since 5.6
054     */
055    ActionFilter clone();
056
057}