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.businessobject.lookup.OrganizationRoutingModelNameLookupableHelperServiceImpl;
22  import org.kuali.ole.sec.SecKeyConstants;
23  import org.kuali.ole.sec.service.AccessSecurityService;
24  import org.kuali.ole.sec.util.SecUtil;
25  import org.kuali.rice.krad.util.GlobalVariables;
26  
27  public class AccessSecurityAccountDelegateModelLookupableHelperServiceImpl extends OrganizationRoutingModelNameLookupableHelperServiceImpl {
28  
29      protected AccessSecurityService accessSecurityService;
30  
31      /**
32       * Gets search results and passes to access security service to apply access restrictions
33       * 
34       * @see org.kuali.rice.kns.lookup.LookupableHelperService#getSearchResults(java.util.Map)
35       */
36      public List getSearchResults(Map<String, String> fieldValues) {
37          List results = super.getSearchResults(fieldValues);
38  
39          int resultSizeBeforeRestrictions = results.size();
40          accessSecurityService.applySecurityRestrictionsForLookup(results, GlobalVariables.getUserSession().getPerson());
41  
42          accessSecurityService.compareListSizeAndAddMessageIfChanged(resultSizeBeforeRestrictions, results, SecKeyConstants.MESSAGE_LOOKUP_RESULTS_RESTRICTED);
43  
44          return results;
45      }
46  
47      /**
48       * Gets search results and passes to access security service to apply access restrictions
49       * 
50       * @see org.kuali.rice.kns.lookup.LookupableHelperService#getSearchResultsUnbounded(java.util.Map)
51       */
52      public List getSearchResultsUnbounded(Map<String, String> fieldValues) {
53          List results = super.getSearchResultsUnbounded(fieldValues);
54  
55          int resultSizeBeforeRestrictions = results.size();
56          accessSecurityService.applySecurityRestrictionsForLookup(results, GlobalVariables.getUserSession().getPerson());
57  
58          accessSecurityService.compareListSizeAndAddMessageIfChanged(resultSizeBeforeRestrictions, results, SecKeyConstants.MESSAGE_LOOKUP_RESULTS_RESTRICTED);
59  
60          return results;
61      }
62  
63      /**
64       * Sets the accessSecurityService attribute value.
65       * 
66       * @param accessSecurityService The accessSecurityService to set.
67       */
68      public void setAccessSecurityService(AccessSecurityService accessSecurityService) {
69          this.accessSecurityService = accessSecurityService;
70      }
71  
72  }