001    /*
002     * Copyright 2011 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     */
016    package org.kuali.kfs.sec.businessobject.lookup;
017    
018    import java.util.List;
019    import java.util.Map;
020    
021    import org.kuali.kfs.coa.identity.OrgReviewRoleLookupableHelperServiceImpl;
022    import org.kuali.kfs.sec.SecKeyConstants;
023    import org.kuali.kfs.sec.service.AccessSecurityService;
024    import org.kuali.kfs.sec.util.SecUtil;
025    import org.kuali.rice.kns.util.GlobalVariables;
026    
027    /**
028     * Lookupable helper that provides Access Security integration
029     */
030    public class AccountSecurityOrgReviewRoleLookupableHelperServiceImpl extends OrgReviewRoleLookupableHelperServiceImpl {
031        protected AccessSecurityService accessSecurityService;
032        
033        /**
034         * Gets search results and passes to access security service to apply access restrictions
035         * 
036         * @see org.kuali.rice.kns.lookup.LookupableHelperService#getSearchResults(java.util.Map)
037         */
038        public List getSearchResults(Map<String, String> fieldValues) {
039            List results = super.getSearchResults(fieldValues);
040    
041            int resultSizeBeforeRestrictions = results.size();
042            accessSecurityService.applySecurityRestrictionsForLookup(results, GlobalVariables.getUserSession().getPerson());
043    
044            SecUtil.compareListSizeAndAddMessageIfChanged(resultSizeBeforeRestrictions, results, SecKeyConstants.MESSAGE_LOOKUP_RESULTS_RESTRICTED);
045    
046            return results;
047        }
048    
049        /**
050         * Gets search results and passes to access security service to apply access restrictions
051         * 
052         * @see org.kuali.rice.kns.lookup.LookupableHelperService#getSearchResultsUnbounded(java.util.Map)
053         */
054        public List getSearchResultsUnbounded(Map<String, String> fieldValues) {
055            List results = super.getSearchResultsUnbounded(fieldValues);
056    
057            int resultSizeBeforeRestrictions = results.size();
058            accessSecurityService.applySecurityRestrictionsForLookup(results, GlobalVariables.getUserSession().getPerson());
059            
060            SecUtil.compareListSizeAndAddMessageIfChanged(resultSizeBeforeRestrictions, results, SecKeyConstants.MESSAGE_LOOKUP_RESULTS_RESTRICTED);
061    
062            return results;
063        }
064    
065        /**
066         * Sets the accessSecurityService attribute value.
067         * 
068         * @param accessSecurityService The accessSecurityService to set.
069         */
070        public void setAccessSecurityService(AccessSecurityService accessSecurityService) {
071            this.accessSecurityService = accessSecurityService;
072        }
073    }