Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2013 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 package org.kuali.rice.kew.rule;
 import java.util.List;
A simple base RoleAttribute implementation for roles that do not need to be qualified prior to resolution.

Kuali Rice Team (
 public abstract class UnqualifiedRoleAttribute extends AbstractRoleAttribute {
     private static final long serialVersionUID = -356582375961050905L;
 	protected List<RoleNameroles;

No-arg constructor for subclasses that will override getRoleNames() to provide their own roles list
     public UnqualifiedRoleAttribute() {
          = Collections.emptyList();

Constructor for subclasses that can provide a role list at construction time
     public UnqualifiedRoleAttribute(List<RoleNameroles) {
         this. = roles;
     public List<RoleNamegetRoleNames() {
         return ;

Returns a List<String> containing only the roleName parameter; i.e. no qualification occurs
     public List<StringgetQualifiedRoleNames(String roleNameDocumentContent documentContent) {
         List<StringqualifiedRoleName = new ArrayList<String>(1);
         return qualifiedRoleName;

Helper method for parsing the actual role name out from the class/rolename combination as Role class combines the two and does expose the original role name

classAndRole the class and role string (e.g. org.blah.MyRoleAttribute!SOME_ROLE_NAME)
the role name portion of the class and role string (e.g. SOME_ROLE_NAME);
     protected String parseRoleNameFromClassAndRole(String classAndRole) {
         return classAndRole.substring(classAndRole.indexOf("!") + 1);


roleName roleName to test
whether the roleName specifies a role that this attribute can resolve
     protected boolean isValidRoleName(String roleName) {
         // this attribute should never be called to resolve any roles other than those it advertised as supporting!
         boolean valid = false;
         for (RoleName rolegetRoleNames()) {
             if (parseRoleNameFromClassAndRole(role.getName()).equals(roleName)) {
                 valid = true;
         return valid;
     public ResolvedQualifiedRole resolveQualifiedRole(RouteContext routeContextString roleNameString qualifiedRole) {
         // some sanity checking
         if (!roleName.equals(qualifiedRole)) {
             throw new IllegalArgumentException("UnqualifiedRoleAttribute resolveQualifiedRole invoked with differing role and qualified role (they should be the same)");
         if (!isValidRoleName(roleName)) {
             throw new IllegalArgumentException("This attribute does not support the role: '" + roleName + "'");
         return resolveRole(routeContextroleName);

Template method for subclasses to implement

routeContext the RouteContext
roleName the role name
a ResolvedQualifiedRole
    protected abstract ResolvedQualifiedRole resolveRole(RouteContext routeContextString roleName);
New to GrepCode? Check out our FAQ X