View Javadoc
1   /*
2    * Copyright 2011 The Kuali Foundation.
3    *
4    * Licensed under the Educational Community License, Version 2.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/ecl2.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.coa.identity.OrgReviewRoleLookupableHelperServiceImpl;
22  import org.kuali.ole.sec.SecKeyConstants;
23  import org.kuali.ole.sec.service.AccessSecurityService;
24  import org.kuali.rice.krad.util.GlobalVariables;
25  
26  /**
27   * Lookupable helper that provides Access Security integration
28   */
29  public class AccountSecurityOrgReviewRoleLookupableHelperServiceImpl extends OrgReviewRoleLookupableHelperServiceImpl {
30      protected AccessSecurityService accessSecurityService;
31  
32      /**
33       * Gets search results and passes to access security service to apply access restrictions
34       *
35       * @see org.kuali.rice.kns.lookup.LookupableHelperService#getSearchResults(java.util.Map)
36       */
37      @Override
38      public List getSearchResults(Map<String, String> fieldValues) {
39          List results = super.getSearchResults(fieldValues);
40  
41          int resultSizeBeforeRestrictions = results.size();
42          accessSecurityService.applySecurityRestrictionsForLookup(results, GlobalVariables.getUserSession().getPerson());
43  
44          accessSecurityService.compareListSizeAndAddMessageIfChanged(resultSizeBeforeRestrictions, results, SecKeyConstants.MESSAGE_LOOKUP_RESULTS_RESTRICTED);
45  
46          return results;
47      }
48  
49      /**
50       * Gets search results and passes to access security service to apply access restrictions
51       *
52       * @see org.kuali.rice.kns.lookup.LookupableHelperService#getSearchResultsUnbounded(java.util.Map)
53       */
54      @Override
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  }