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 024import java.io.Serializable; 025 026/** 027 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 028 */ 029public interface ActionFilter extends Serializable { 030 031 String getId(); 032 033 void setId(String id); 034 035 /** 036 * Checks whether this action is valid in the given context. 037 * <p> 038 * The action is considered valid if no denying rule is found and at least one granting rule is found. If no rule is 039 * found at all, it is valid. 040 * <p> 041 * In other words: OR between granting rules, AND between denying rules, denial is favored (also if exceptions 042 * occur), AND inside of rules, OR inside or rule items (type, facet,...). 043 * 044 * @param action the optional action to check against, should be able to be null if filters evaluation only depends 045 * on given context. 046 * @param context mandatory context holding variables to check against. 047 * @returns true if filters configuration for given action and context. Returns false if an error occurs during one 048 * of the conditions evaluation. 049 */ 050 boolean accept(Action action, ActionContext context); 051 052 /** 053 * Returns a clone, useful for hot reload. 054 * 055 * @since 5.6 056 */ 057 ActionFilter clone(); 058 059}