View Javadoc
1   /*
2    * Copyright 2009 The Kuali Foundation.
3    * 
4    * Licensed under the Educational Community License, Version 1.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl1.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.sec.businessobject.lookup;
17  
18  import java.util.List;
19  import java.util.Map;
20  
21  import org.kuali.ole.sec.SecKeyConstants;
22  import org.kuali.ole.sec.service.AccessSecurityService;
23  import org.kuali.ole.sec.util.SecUtil;
24  import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
25  import org.kuali.rice.krad.util.GlobalVariables;
26  
27  
28  /**
29   * Lookupable helper that provides Access Security integration
30   */
31  public class AccessSecurityLookupableHelperServiceImpl extends KualiLookupableHelperServiceImpl {
32      protected AccessSecurityService accessSecurityService;
33  
34      /**
35       * Gets search results and passes to access security service to apply access restrictions
36       * 
37       * @see org.kuali.rice.kns.lookup.LookupableHelperService#getSearchResults(java.util.Map)
38       */
39      public List getSearchResults(Map<String, String> fieldValues) {
40          List results = super.getSearchResults(fieldValues);
41  
42          int resultSizeBeforeRestrictions = results.size();
43          accessSecurityService.applySecurityRestrictionsForLookup(results, GlobalVariables.getUserSession().getPerson());
44          
45          accessSecurityService.compareListSizeAndAddMessageIfChanged(resultSizeBeforeRestrictions, results, SecKeyConstants.MESSAGE_LOOKUP_RESULTS_RESTRICTED);
46          
47          return results;
48      }
49  
50      /**
51       * Gets search results and passes to access security service to apply access restrictions
52       * 
53       * @see org.kuali.rice.kns.lookup.LookupableHelperService#getSearchResultsUnbounded(java.util.Map)
54       */
55      public List getSearchResultsUnbounded(Map<String, String> fieldValues) {
56          List results = super.getSearchResultsUnbounded(fieldValues);
57  
58          int resultSizeBeforeRestrictions = results.size();
59          accessSecurityService.applySecurityRestrictionsForLookup(results, GlobalVariables.getUserSession().getPerson());
60          
61          accessSecurityService.compareListSizeAndAddMessageIfChanged(resultSizeBeforeRestrictions, results, SecKeyConstants.MESSAGE_LOOKUP_RESULTS_RESTRICTED);
62  
63          return results;
64      }
65  
66      /**
67       * Sets the accessSecurityService attribute value.
68       * 
69       * @param accessSecurityService The accessSecurityService to set.
70       */
71      public void setAccessSecurityService(AccessSecurityService accessSecurityService) {
72          this.accessSecurityService = accessSecurityService;
73      }
74  
75  }