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.service.impl;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.ole.coa.service.OrganizationService;
20  import org.kuali.ole.sys.OLEPropertyConstants;
21  import org.kuali.ole.sys.context.SpringContext;
22  
23  /**
24   * Custom access permission evaluator that looks at the organization hierarchy when matching values
25   */
26  public class DescendOrganizationAccessPermissionEvaluatorImpl extends AccessPermissionEvaluatorImpl {
27  
28      /**
29       * Matches org values based on org hierarchy
30       * 
31       * @see org.kuali.ole.sec.service.impl.AccessPermissionEvaluatorImpl#isMatch(java.lang.String, java.lang.String)
32       */
33      @Override
34      protected boolean isMatch(String matchValue, String value) {
35          boolean match = false;
36  
37          if (StringUtils.equalsIgnoreCase(value, matchValue)) {
38              match = true;
39          }
40          else {
41              String chartCode = (String) otherKeyFieldValues.get(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE);
42              match = SpringContext.getBean(OrganizationService.class).isParentOrganization(chartCode, value, chartCode, matchValue);
43          }
44  
45          return match;
46      }
47  
48  }