001/**
002 * Copyright 2005-2016 The Kuali Foundation
003 *
004 * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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 */
016package org.kuali.rice.kew.doctype.service;
017
018import org.kuali.rice.kew.engine.node.RouteNodeInstance;
019import org.kuali.rice.kew.doctype.bo.DocumentType;
020import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
021
022import java.util.List;
023
024/**
025 * Implements permission checks related to Document Type.  In general,
026 * these permission checks are invoked from the various actions
027 * which require authorization.
028 * 
029 * @author Kuali Rice Team (rice.collab@kuali.org)
030 */
031public interface DocumentTypePermissionService {
032
033        /**
034         * Determines if the given principal is authorized to receive ad hoc requests
035         * for the given DocumentType and action request type.
036         */
037        boolean canReceiveAdHocRequest(String principalId, DocumentRouteHeaderValue document, String actionRequestCode);
038
039        /**
040         * Determines if the given group is authorized to receive ad hoc requests of the
041         * specified action request code for the given DocumentType and action request type.  
042         * A group is considered to be authorized to receive an ad hoc request if all
043         * of it's members can receive the request.
044         */
045        boolean canGroupReceiveAdHocRequest(String groupId, DocumentRouteHeaderValue document, String actionRequestCode);
046        
047        /**
048         * Determines if the given principal can administer routing for the given
049         * DocumentType.  Having this permission gives them "super user" capabilities.
050         */
051        boolean canAdministerRouting(String principalId, DocumentType documentType);
052
053    /**
054     * Determines if the given principal can super user approve a single action
055     * request for a given DocumentType, route node, and routeStatusCode
056     */
057    boolean canSuperUserApproveSingleActionRequest(String principalId, DocumentType documentType,
058            List<RouteNodeInstance> routeNodeInstances, String routeStatusCode);
059
060    /**
061     * Determines if the given principal can super user approve a document
062     * for a given DocumentType, route node, and routeStatusCode
063     */
064    boolean canSuperUserApproveDocument(String principalId, DocumentType documentType,
065            List<RouteNodeInstance> routeNodeInstances, String routeStatusCode);
066
067    /**
068     * Determines if the given principal can super user disapprove a document
069     * for a given DocumentType, route node, and routeStatusCode
070     */
071    boolean canSuperUserDisapproveDocument(String principalId, DocumentType documentType,
072            List<RouteNodeInstance> routeNodeInstances, String routeStatusCode);
073
074    /**
075         * Determines if the given principal can initiate documents of the given DocumentType.
076         */
077        boolean canInitiate(String principalId, DocumentType documentType);
078        
079        /**
080         * Determines if the given principal can route documents of the given DocumentRouteHeaderValue.  The permission check
081         * also considers the document status and initiator of the document.
082         */
083        boolean canRoute(String principalId, DocumentRouteHeaderValue documentRouteHeaderValue);
084        
085        /**
086         * Determines if the given principal can save documents of the given DocumentType.  The permission check
087         * also considers the document's current route nodes, document status, and initiator of the document.
088         * 
089         * <p>It is intended the only one of the given route nodes will need to satisfy the permission check.
090         * For example, if the save permission is defined for node 1 but not for node 2, then a document which
091         * is at both node 1 and node 2 should satisfy the permission check.
092         */
093        boolean canSave(String principalId, DocumentRouteHeaderValue document);
094
095        /**
096         * Determines if the given principal can blanket approve documents of the given DocumentType.  The permission check
097         * also considers the document status and the initiator of the document.
098         */
099        boolean canBlanketApprove(String principalId, DocumentRouteHeaderValue document);
100
101        /**
102         * Determines if the given principal can cancel documents of the given DocumentType.  The permission check
103         * also considers the document's current route nodes, document status, and initiator of the document.
104         * 
105         * <p>It is intended the only one of the given route nodes will need to satisfy the permission check.
106         * For example, if the cancel permission is defined for node 1 but not for node 2, then a document which
107         * is at both node 1 and node 2 should satisfy the permission check.
108         */
109        boolean canCancel(String principalId, DocumentRouteHeaderValue document);
110        
111        /**
112         * Determines if the given principal can add route log messages for documents of the given DocumentRouteHeaderValue.  The permission check
113         * also considers the document status and initiator of the document.
114         */
115        boolean canAddRouteLogMessage(String principalId, DocumentRouteHeaderValue documentRouteHeaderValue);
116
117    /**
118     * Determines if the given principal can recall the specified document given the permission details.
119     * @since 2.1
120     */
121    boolean canRecall(String principalId, DocumentRouteHeaderValue document);
122
123}