001/*
002 * (C) Copyright 2006-2007 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Nuxeo - initial API and implementation
018 *
019 * $Id: ActionFilter.java 20637 2007-06-17 12:37:03Z sfermigier $
020 */
021
022package org.nuxeo.ecm.platform.actions;
023
024/**
025 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
026 */
027public interface ActionFilter {
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     * @return 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}