001/* 002 * (C) Copyright 2006-2016 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 */ 019package org.nuxeo.ecm.platform.actions.ejb; 020 021import java.io.Serializable; 022import java.util.List; 023 024import org.nuxeo.ecm.platform.actions.Action; 025import org.nuxeo.ecm.platform.actions.ActionContext; 026import org.nuxeo.ecm.platform.actions.ActionFilter; 027import org.nuxeo.ecm.platform.actions.ActionFilterRegistry; 028import org.nuxeo.ecm.platform.actions.ActionRegistry; 029 030/** 031 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 032 */ 033public interface ActionManager extends Serializable { 034 035 boolean isEnabled(String actionId, ActionContext context); 036 037 boolean isRegistered(String actionId); 038 039 /** 040 * Gets actions for a category (filters are evaluated). 041 * <p> 042 * Only actions available in the given context are returned 043 */ 044 List<Action> getActions(String category, ActionContext context); 045 046 /** 047 * Gets actions for a category (filters are evaluated). 048 * <p> 049 * If hideUnavailableActions, all actions of the category are returned but actions are flagged with an available 050 * flag depending on filters evaluation. 051 */ 052 List<Action> getActions(String category, ActionContext context, boolean hideUnavailableActions); 053 054 Action getAction(String actionId); 055 056 /** 057 * Returns action with given id, evaluating its filters in given context, and returning null if filters evaluation 058 * denies access or if action is not found. 059 * <p> 060 * If hideUnavailableActions is false, the action is always returned but it is flagged with an available flag 061 * depending on filters evaluation. 062 * 063 * @since 5.6 064 */ 065 Action getAction(String actionId, ActionContext context, boolean hideUnavailableActions); 066 067 ActionFilter[] getFilters(String actionId); 068 069 /** 070 * @see ActionFilterRegistry#getFilter(String) 071 * @since 9.1 072 */ 073 ActionFilter getFilter(String filterId); 074 075 /** 076 * Returns false if given filter evaluation is supposed to deny access when checking for this filter. 077 * 078 * @since 5.6 079 */ 080 boolean checkFilter(String filterId, ActionContext context); 081 082 /** 083 * Returns false if given filters evaluation is supposed to deny access when checking for this filter. 084 * 085 * @since 7.1 086 */ 087 boolean checkFilters(List<String> filterIds, ActionContext context); 088 089 /** 090 * @since 8.2 091 */ 092 boolean checkFilters(Action action, ActionContext context); 093 094 /** 095 * Gets all actions in a category (filters are NOT evaluated). 096 */ 097 List<Action> getAllActions(String category); 098 099 /** 100 * @see ActionRegistry#addAction(Action) 101 * @since 9.1 102 */ 103 void addAction(Action action); 104 105 /** 106 * @see ActionRegistry#removeAction(String) 107 * @since 9.1 108 */ 109 Action removeAction(String actionId); 110 111 /** 112 * Cleanup method. 113 */ 114 void remove(); 115 116}