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