Hi Janaka, This fix has introduced a regression issue, :(. An NPE is thrown if you create a populator for a dropdown, where the populator is not equal to the default lifecycle populator. I fixed this in r118961.
Thanks, Senaka. On Wed, Dec 7, 2011 at 3:38 PM, <jan...@wso2.com> wrote: > Author: janaka > Date: Wed Dec 7 02:08:26 2011 > New Revision: 117080 > URL: http://wso2.org/svn/browse/wso2?view=rev&revision=117080 > > Log: > Adding fix for CARBON-11710 > > > Modified: > > branches/carbon/3.2.0/components/governance/org.wso2.carbon.governance.generic.ui/3.2.3/src/main/resources/web/generic/add_edit.jsp > > branches/carbon/3.2.0/components/governance/org.wso2.carbon.governance.generic.ui/3.2.3/src/main/resources/web/generic/edit_ajaxprocessor.jsp > > branches/carbon/3.2.0/components/governance/org.wso2.carbon.governance.list.ui/3.2.3/src/main/java/org/wso2/carbon/governance/list/ui/internal/GovernanceListUIServiceComponent.java > > Modified: > branches/carbon/3.2.0/components/governance/org.wso2.carbon.governance.generic.ui/3.2.3/src/main/resources/web/generic/add_edit.jsp > URL: > http://wso2.org/svn/browse/wso2/branches/carbon/3.2.0/components/governance/org.wso2.carbon.governance.generic.ui/3.2.3/src/main/resources/web/generic/add_edit.jsp?rev=117080&r1=117079&r2=117080&view=diff > > ============================================================================== > --- > branches/carbon/3.2.0/components/governance/org.wso2.carbon.governance.generic.ui/3.2.3/src/main/resources/web/generic/add_edit.jsp > (original) > +++ > branches/carbon/3.2.0/components/governance/org.wso2.carbon.governance.generic.ui/3.2.3/src/main/resources/web/generic/add_edit.jsp > Wed Dec 7 02:08:26 2011 > @@ -235,6 +235,7 @@ > <input type="hidden" name="region" > value="<%=request.getParameter("region")%>"/> > <input type="hidden" name="item" > value="<%=request.getParameter("item")%>"/> > <input type="hidden" name="key" > value="<%=request.getParameter("key")%>"/> > + <input type="hidden" name="lifecycleAttribute" > value="<%=request.getParameter("lifecycleAttribute")%>"/> > <table class="styledLeft" id="#_addTable"> > <tr><td> > <%=table.toString()%> > > Modified: > branches/carbon/3.2.0/components/governance/org.wso2.carbon.governance.generic.ui/3.2.3/src/main/resources/web/generic/edit_ajaxprocessor.jsp > URL: > http://wso2.org/svn/browse/wso2/branches/carbon/3.2.0/components/governance/org.wso2.carbon.governance.generic.ui/3.2.3/src/main/resources/web/generic/edit_ajaxprocessor.jsp?rev=117080&r1=117079&r2=117080&view=diff > > ============================================================================== > --- > branches/carbon/3.2.0/components/governance/org.wso2.carbon.governance.generic.ui/3.2.3/src/main/resources/web/generic/edit_ajaxprocessor.jsp > (original) > +++ > branches/carbon/3.2.0/components/governance/org.wso2.carbon.governance.generic.ui/3.2.3/src/main/resources/web/generic/edit_ajaxprocessor.jsp > Wed Dec 7 02:08:26 2011 > @@ -213,6 +213,7 @@ > <input type="hidden" name="item" > value="<%=request.getParameter("add_edit_item")%>"/> > <input type="hidden" name="key" > value="<%=request.getParameter("key")%>"/> > <input type="hidden" name="breadcrumb" > value="<%=request.getParameter("add_edit_breadcrumb")%>"/> > + <input type="hidden" name="lifecycleAttribute" > value="<%=request.getParameter("lifecycleAttribute")%>"/> > <table class="styledLeft"> > <tr><td> > <%=table.toString()%> > > Modified: > branches/carbon/3.2.0/components/governance/org.wso2.carbon.governance.list.ui/3.2.3/src/main/java/org/wso2/carbon/governance/list/ui/internal/GovernanceListUIServiceComponent.java > URL: > http://wso2.org/svn/browse/wso2/branches/carbon/3.2.0/components/governance/org.wso2.carbon.governance.list.ui/3.2.3/src/main/java/org/wso2/carbon/governance/list/ui/internal/GovernanceListUIServiceComponent.java?rev=117080&r1=117079&r2=117080&view=diff > > ============================================================================== > --- > branches/carbon/3.2.0/components/governance/org.wso2.carbon.governance.list.ui/3.2.3/src/main/java/org/wso2/carbon/governance/list/ui/internal/GovernanceListUIServiceComponent.java > (original) > +++ > branches/carbon/3.2.0/components/governance/org.wso2.carbon.governance.list.ui/3.2.3/src/main/java/org/wso2/carbon/governance/list/ui/internal/GovernanceListUIServiceComponent.java > Wed Dec 7 02:08:26 2011 > @@ -18,9 +18,12 @@ > */ > package org.wso2.carbon.governance.list.ui.internal; > > +import org.apache.axiom.om.OMAttribute; > import org.apache.axiom.om.OMElement; > +import org.apache.axiom.om.xpath.AXIOMXPath; > import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; > +import org.jaxen.JaxenException; > import org.osgi.framework.ServiceRegistration; > import org.osgi.service.component.ComponentContext; > import > org.wso2.carbon.governance.api.util.GovernanceArtifactConfiguration; > @@ -40,10 +43,8 @@ > > import javax.servlet.http.HttpServletRequest; > import javax.servlet.http.HttpSession; > -import java.util.LinkedHashMap; > -import java.util.LinkedList; > -import java.util.List; > -import java.util.Map; > +import javax.xml.namespace.QName; > +import java.util.*; > > /** > * The List UI Declarative Service Component. > @@ -59,6 +60,8 @@ > > private static Log log = > LogFactory.getLog(GovernanceListUIServiceComponent.class); > private ServiceRegistration serviceRegistration; > + private static final String DEFAULT_LIFECYCLE_GENERATOR_CLASS > + = > "org.wso2.carbon.governance.services.ui.utils.LifecycleListPopulator"; > > protected void activate(ComponentContext context) { > UIAuthenticationExtender authenticationExtender = new > UIAuthenticationExtender() { > @@ -128,23 +131,92 @@ > Map<String, String> viewUIMap, String key) { > String singularLabel = configuration.getSingularLabel(); > String pluralLabel = configuration.getPluralLabel(); > + > + String lifecycleAttribute = key + "Lifecycle_lifecycleName"; > + > + lifecycleAttribute = BuilLifecycleAttribute(configuration, > DEFAULT_LIFECYCLE_GENERATOR_CLASS, lifecycleAttribute); > + > if (singularLabel == null || pluralLabel == null) { > log.error("The singular label and plural label have not " + > "been defined for the artifact type: " + key); > } else { > String path = "../generic/edit_ajaxprocessor.jsp?key=" + key + > "&lifecycleAttribute=" + > - key + "Lifecycle_lifecycleName&add_edit_breadcrumb=" > + singularLabel + > + lifecycleAttribute +"&add_edit_breadcrumb=" + > singularLabel + > > "&add_edit_region=region3&add_edit_item=governance_add_" + key + > "_menu&breadcrumb=" + singularLabel; > viewUIMap.put(configuration.getMediaType(), path); > } > } > > + private String BuilLifecycleAttribute(GovernanceArtifactConfiguration > configuration, > + String > defaultLifecycleGeneratorClass, String lifecycleAttribute) { > + try { > + OMElement configurationElement = > configuration.getContentDefinition(); > + String xpathExpression = "//@class"; > + > + AXIOMXPath xpath = new AXIOMXPath(xpathExpression); > + List resultNodes = xpath.selectNodes(configurationElement); > + > + if (resultNodes != null && resultNodes.size() > 0) { > + String lifecycleParentName = null; > + String lifecycleName = null; > + > + for (Object resultNode : resultNodes) { > + OMElement parentElement = > ((OMAttribute)resultNode).getOwner(); > + if(parentElement.getAttributeValue(new > QName("class")).equals(defaultLifecycleGeneratorClass)){ > + Iterator childrenIterator = > parentElement.getParent().getChildrenWithLocalName("name"); > + while (childrenIterator.hasNext()) { > + OMElement next = (OMElement) > childrenIterator.next(); > + lifecycleName = next.getAttributeValue(new > QName("label")); > + } > + OMElement rootElement = (OMElement) ((OMElement) > parentElement.getParent()).getParent(); > + lifecycleParentName = > rootElement.getAttributeValue(new QName("name")); > + break; > + } > + } > + lifecycleAttribute = > convertName(lifecycleParentName.split(" ")) > + + "_" + convertName(lifecycleName.split(" ")); > + } > + } catch (JaxenException e) { > + e.printStackTrace(); //To change body of catch statement use > File | Settings | File Templates. > + } > + return lifecycleAttribute; > + } > + > + private String convertName(String[] nameParts) { > + String convertedName = null; > + // making widget name camel case > + > + for (String namePart : nameParts) { > + int i; > + for (i = 0; i < namePart.length(); i++) { > + char c = namePart.charAt(i); > + if (!Character.isLetter(c) || Character.isLowerCase(c)) { > + break; > + } > + } > + if (namePart.equals(nameParts[0])) { > + namePart = namePart.substring(0, i).toLowerCase() + > namePart.substring(i); > + } > + if (convertedName == null) { > + convertedName = namePart; > + } else { > + convertedName += namePart; > + } > + } > + return convertedName; > + } > + > private void buildMenuList(HttpServletRequest request, > GovernanceArtifactConfiguration > configuration, List<Menu> menuList, > String key) { > String singularLabel = configuration.getSingularLabel(); > String pluralLabel = configuration.getPluralLabel(); > + > + String lifecycleAttribute = key + "Lifecycle_lifecycleName"; > + > + lifecycleAttribute = BuilLifecycleAttribute(configuration, > DEFAULT_LIFECYCLE_GENERATOR_CLASS, lifecycleAttribute); > + > if (singularLabel == null || pluralLabel == null) { > log.error("The singular label and plural label have not " + > "been defined for the artifact type: " + key); > @@ -161,8 +233,8 @@ > addMenu.setI18nKey(singularLabel); > addMenu.setParentMenu("add_sub_menu"); > addMenu.setLink("../generic/add_edit.jsp"); > - addMenu.setUrlParameters("key=" + key + > "&lifecycleAttribute=" + key + > - "Lifecycle_lifecycleName&breadcrumb=" + > singularLabel); > + addMenu.setUrlParameters("key=" + key + > "&lifecycleAttribute=" + lifecycleAttribute + > + "&breadcrumb=" + singularLabel); > addMenu.setRegion("region3"); > addMenu.setOrder("50"); > addMenu.setStyleClass("manage"); > @@ -213,7 +285,7 @@ > configureMenu.setLink("../generic/configure.jsp"); > configureMenu.setUrlParameters("key=" + key + > "&breadcrumb=" + pluralLabel + > > "&add_edit_region=region3&add_edit_item=governance_add_" + key + "_menu" + > - "&lifecycleAttribute=" + key + > "Lifecycle_lifecycleName" + > + "&lifecycleAttribute=" + lifecycleAttribute + > "&add_edit_breadcrumb=" + singularLabel + > "&singularLabel=" + singularLabel + > "&pluralLabel=" + pluralLabel); > configureMenu.setRegion("region1"); > _______________________________________________ > Carbon-commits mailing list > carbon-comm...@wso2.org > https://wso2.org/cgi-bin/mailman/listinfo/carbon-commits > -- *Senaka Fernando* Product Manager - WSO2 Governance Registry; Associate Technical Lead; WSO2 Inc.; http://wso2.com* Member; Apache Software Foundation; http://apache.org E-mail: senaka AT wso2.com **P: +1 408 754 7388; ext: 51736*; *M: +94 77 322 1818 Linked-In: http://linkedin.com/in/senakafernando *Lean . Enterprise . Middleware
_______________________________________________ Carbon-dev mailing list Carbon-dev@wso2.org http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev