View Javadoc
1   /*
2    * The Kuali Financial System, a comprehensive financial management system for higher education.
3    * 
4    * Copyright 2005-2014 The Kuali Foundation
5    * 
6    * This program is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU Affero General Public License as
8    * published by the Free Software Foundation, either version 3 of the
9    * License, or (at your option) any later version.
10   * 
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU Affero General Public License for more details.
15   * 
16   * You should have received a copy of the GNU Affero General Public License
17   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  package org.kuali.kfs.sys.document.authorization;
20  
21  import java.util.List;
22  import java.util.Set;
23  
24  import org.kuali.kfs.sys.businessobject.AccountingLine;
25  import org.kuali.kfs.sys.document.AccountingDocument;
26  import org.kuali.kfs.sys.document.web.AccountingLineRenderingContext;
27  import org.kuali.kfs.sys.document.web.AccountingLineViewAction;
28  import org.kuali.rice.kim.api.identity.Person;
29  
30  /**
31   * Methods used to determine certain permissions associated with an accounting line.
32   */
33  public interface AccountingLineAuthorizer {
34  
35      /**
36       * Determines which, if any, blocks whose children elements should not in any fashion be rendered
37       * 
38       * @param accountingDocument the accounting document the line to authorize is owned by
39       * @param accountingLine the accounting line that is being authorized against
40       * @param newLine whether the line is a new line or not
41       * @return a Set of the names of blocks that should not being in any way rendered
42       */
43      public abstract Set<String> getUnviewableBlocks(AccountingDocument accountingDocument, AccountingLine accountingLine, boolean newLine, Person currentUser);
44  
45      /**
46       * Determines what actions are available to act upon the given accounting line
47       * 
48       * @param accountingDocument the accounting document the line to authorize is owned by
49       * @param accountingLineRenderingContext a renderable context wrapping the accounting line that is being authorized against
50       * @param accountingLinePropertyName the name of the property that represents the accounting line
51       * @param lineIndex value, as Integer, of the index of the given accounting line within the group's collection of accounting
52       *        lines; if null, then it is assumed that this is a new line
53       * @param groupTitle title of the group from the data dictionary
54       * @return a List of the Actions that are available for this line
55       */
56      public abstract List<AccountingLineViewAction> getActions(AccountingDocument accountingDocument, AccountingLineRenderingContext accountingLineRenderingContext, String accountingLinePropertyName, Integer lineIndex, Person currentUser, String groupTitle);
57  
58      /**
59       * Determines if new lines should be rendered for the given accounting line group (identified by its property name)
60       * 
61       * @param accountingDocument the document that has accounting lines being authorized
62       * @param accountingGroupProperty the property of this accounting group
63       * @return true if new lines should be displayed, false otherwise
64       */
65      public abstract boolean renderNewLine(AccountingDocument accountingDocument, String accountingGroupProperty);
66  
67      /**
68       * Determines if any entire group is rendered as editable, which means that a new line will appear
69       * 
70       * @param accountingDocument the accounting document which the collection of line are on
71       * @param accountingLineRenderingContexts the accounting lines of the group, wrapped in AccountingLineRenderingContext implementations
72       * @param currentUser the current user
73       * @return true if the group can be edited, false otherwise
74       */
75      public abstract boolean isGroupEditable(AccountingDocument accountingDocument, List<? extends AccountingLineRenderingContext> accountingLineRenderingContexts, Person currentUser);
76  
77      /**
78       * determine whether the current user has permission to edit the given field in the given accounting line
79       * 
80       * @param accountingDocument the given accounting document
81       * @param accountingLine the given accounting line in the document
82       * @param accountingLineCollectionProperty the property of the collection the given accounting line is in
83       * @param fieldName the name of a field in the given accounting line
84       * @param editableLine whether the parent line of this field is editable
85       * @param editablePage whether the parent page of this field is editable
86       * @param currentUser the current user
87       * @return true if the the current user has permission to edit the given field in the given accounting line; otherwsie, false
88       */
89      public abstract boolean hasEditPermissionOnField(AccountingDocument accountingDocument, AccountingLine accountingLine, String accountingLineCollectionProperty, String fieldName, boolean editableLine, boolean editablePage, Person currentUser);
90      
91      /**
92       * determine whether the current user has permission to edit the given accounting line as a whole
93       * 
94       * @param accountingDocument the given accounting document
95       * @param accountingLine the given accounting line in the document
96       * @param accountingLineCollectionProperty the property of the group that holds these accounting lines
97       * @param currentUser the current user
98       * @param pageIsEditable whether the current page is editable by the current user or not
99       * @return true if the the current user has permission to edit the given accounting line; otherwsie, false
100      */
101     public abstract boolean hasEditPermissionOnAccountingLine(AccountingDocument accountingDocument, AccountingLine accountingLine, String accountingLineCollectionProperty, Person currentUser, boolean pageIsEditable);
102 }