View Javadoc

1   /**
2    * Copyright 2005-2015 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.rice.kim.rules.ui;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.rice.core.api.util.RiceKeyConstants;
20  import org.kuali.rice.kim.bo.ui.RoleDocumentDelegation;
21  import org.kuali.rice.kim.rule.event.ui.AddDelegationEvent;
22  import org.kuali.rice.kim.rule.ui.AddDelegationRule;
23  import org.kuali.rice.kns.rules.DocumentRuleBase;
24  import org.kuali.rice.krad.util.GlobalVariables;
25  
26  /**
27   * This is a description of what this class does - shyu don't forget to fill this in. 
28   * 
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   *
31   */
32  public class RoleDocumentDelegationRule extends DocumentRuleBase implements AddDelegationRule {
33  
34  	protected static final String ERROR_PATH = "permission.permissionId";
35  	
36  	public boolean processAddDelegation(AddDelegationEvent addDelegationEvent) {
37  		RoleDocumentDelegation newDelegation = addDelegationEvent.getDelegation();
38  		boolean rulePassed = true;
39  		if (newDelegation == null || StringUtils.isBlank(newDelegation.getDelegationTypeCode())) {
40              rulePassed = false;
41              GlobalVariables.getMessageMap().putError(ERROR_PATH, RiceKeyConstants.ERROR_EMPTY_ENTRY, new String[] {"Permission"});
42          }
43  		return rulePassed;
44  	} 
45  
46  }