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.xml;
 import static org.kuali.rice.core.api.impex.xml.XmlConstants.*;

Parsing routines for XML structures shared across parsers.

Kuali Rice Team (
 public class CommonXmlParser {
     private static final Logger LOG = Logger.getLogger(CommonXmlParser.class);

Parses, but does not save, a RuleResponsibility from responsibility identifier elements nested in the specified element

element parent element of responsibility identifier elements
a parsed RuleResponsibility
     public static RuleResponsibilityBo parseResponsibilityNameAndType(Element elementthrows XmlException {
         RuleResponsibilityBo responsibility = new RuleResponsibilityBo();
         String principalId = element.getChildText(element.getNamespace());
         String principalName = element.getChildText(element.getNamespace());
         String groupId = element.getChildText(element.getNamespace());
         Element groupNameElement = element.getChild(element.getNamespace());
         String role = element.getChildText(element.getNamespace());
         Element roleNameElement = element.getChild(element.getNamespace());
         String user = element.getChildText(element.getNamespace());
         String workgroup = element.getChildText(element.getNamespace());
         if (!StringUtils.isEmpty(user)) {
             principalName = user;
             .warn("Rule XML is using deprecated element 'user', please use 'principalName' instead.");
         // in code below, we allow core config parameter replacement in responsibilities
         if (!StringUtils.isBlank(principalId)) {
             principalId = Utilities.substituteConfigParameters(principalId);
             Principal principal = KimApiServiceLocator.getIdentityService().getPrincipal(principalId);
             if (principal == null) {
                 throw new XmlException("Could not locate principal with the given id: " + principalId);
         } else if (!StringUtils.isBlank(principalName)) {
             principalName = Utilities.substituteConfigParameters(principalName);
             Principal principal = KimApiServiceLocator.getIdentityService().getPrincipalByPrincipalName(principalName);
             if (principal == null) {
                 throw new XmlException("Could not locate principal with the given name: " + principalName);
         } else if (!StringUtils.isBlank(groupId)) {
             groupId = Utilities.substituteConfigParameters(groupId);
             Group group = KimApiServiceLocator.getGroupService().getGroup(groupId);
             if (group == null) {
                 throw new XmlException("Could not locate group with the given id: " + groupId);
         } else if (groupNameElement != null) {
             String groupName = groupNameElement.getText();
             String groupNamespace = groupNameElement.getAttributeValue();
             if (StringUtils.isBlank(groupName)) {
                 throw new XmlException("Group name element has no value");
             if (StringUtils.isBlank(groupNamespace)) {
                 throw new XmlException("namespace attribute must be specified");
            groupName = Utilities.substituteConfigParameters(groupName);
            groupNamespace = Utilities.substituteConfigParameters(groupNamespace);
            Group group = KimApiServiceLocator.getGroupService().getGroupByNamespaceCodeAndName(groupNamespace,
            if (group == null) {
                throw new XmlException("Could not locate group with the given namespace: " + groupNamespace + " and name: " + groupName);
        } else if (!StringUtils.isBlank(role)) {
            role = Utilities.substituteConfigParameters(role);
        } else if (roleNameElement != null) {
            String roleName = roleNameElement.getText();
            String attributeClassName = roleNameElement.getAttributeValue();
            if (StringUtils.isBlank(roleName)) {
                throw new XmlException("Role name element has no value");
            if (StringUtils.isBlank(attributeClassName)) {
                throw new XmlException("attributeClassName attribute must be specified");
            roleName = Utilities.substituteConfigParameters(roleName);
            attributeClassName = Utilities.substituteConfigParameters(attributeClassName);
        } else if (!StringUtils.isBlank(workgroup)) {
            .warn("Rule XML is using deprecated element 'workgroup', please use 'groupName' instead.");
            workgroup = Utilities.substituteConfigParameters(workgroup);
            String workgroupNamespace = Utilities.parseGroupNamespaceCode(workgroup);
            String workgroupName = Utilities.parseGroupName(workgroup);
            Group workgroupObject = KimApiServiceLocator.getGroupService().getGroupByNamespaceCodeAndName(
            if (workgroupObject == null) {
                throw new XmlException("Could not locate workgroup: " + workgroup);
        } else {
            return null;
        return responsibility;
New to GrepCode? Check out our FAQ X