You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by dl...@apache.org on 2004/12/23 17:55:23 UTC

cvs commit: jakarta-jetspeed-2/applications/security/src/webapp/WEB-INF/security/rolemgt role-add.jsp

dlestrat    2004/12/23 08:55:23

  Modified:    applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt
                        RoleMgtRenderUtil.java RoleMgtPortlet.java
                        RoleActionForm.java RoleTreeTable.java
               applications/security/src/java/org/apache/jetspeed/portlets/security
                        ChangePasswordPortlet.java
               applications/security/src/java/org/apache/jetspeed/portlets/security/resources
                        RoleMgtResources.properties
               applications/security/src/webapp/WEB-INF/security/rolemgt
                        role-add.jsp
  Added:       applications/security/src/test/org/apache/jetspeed/portlets/security
                        TestSecurityApplicationUtils.java
               applications/security/src/java/org/apache/jetspeed/portlets/security
                        SecurityApplicationUtils.java
                        SecurityApplicationResources.java
  Log:
  http://nagoya.apache.org/jira/browse/JS2-23#action_57015
  
  Revision  Changes    Path
  1.2       +26 -0     jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt/RoleMgtRenderUtil.java
  
  Index: RoleMgtRenderUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt/RoleMgtRenderUtil.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RoleMgtRenderUtil.java	29 Nov 2004 21:11:57 -0000	1.1
  +++ RoleMgtRenderUtil.java	23 Dec 2004 16:55:23 -0000	1.2
  @@ -24,6 +24,7 @@
   import javax.faces.component.UIComponent;
   
   import org.apache.myfaces.custom.tabbedpane.HtmlPanelTabbedPane;
  +import org.apache.myfaces.custom.tree.HtmlTree;
   
   /**
    * <p>
  @@ -59,6 +60,31 @@
           }
   
           return tabbedPane;
  +    }
  +    
  +    /**
  +     * <p>
  +     * Utility method used to locate the tree table component.
  +     * </p>
  +     * 
  +     * @param component The component.
  +     * @return The {@link HtmlTree}.
  +     */
  +    public static HtmlTree findTree(UIComponent component)
  +    {
  +        HtmlTree tree = null;
  +
  +        UIComponent parent = component.getParent();
  +        if (parent instanceof HtmlTree)
  +        {
  +            tree = (HtmlTree) parent;
  +        }
  +        else
  +        {
  +            tree = findTree(parent);
  +        }
  +
  +        return tree;
       }
   
       /**
  
  
  
  1.2       +12 -60    jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt/RoleMgtPortlet.java
  
  Index: RoleMgtPortlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt/RoleMgtPortlet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RoleMgtPortlet.java	29 Nov 2004 21:11:57 -0000	1.1
  +++ RoleMgtPortlet.java	23 Dec 2004 16:55:23 -0000	1.2
  @@ -15,19 +15,15 @@
    */
   package org.apache.jetspeed.portlets.security.rolemgt;
   
  -import java.util.prefs.BackingStoreException;
  -import java.util.prefs.Preferences;
  -
   import javax.faces.context.FacesContext;
   import javax.portlet.PortletConfig;
   import javax.portlet.PortletException;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  -import org.apache.jetspeed.security.BasePrincipal;
  -import org.apache.myfaces.custom.tree.DefaultMutableTreeNode;
  -import org.apache.myfaces.custom.tree.model.DefaultTreeModel;
  -import org.apache.myfaces.custom.tree.model.TreeModel;
  +import org.apache.jetspeed.portlets.security.SecurityApplicationResources;
  +import org.apache.jetspeed.portlets.security.SecurityApplicationUtils;
  +import org.apache.jetspeed.security.RoleManager;
   import org.apache.portals.bridges.myfaces.FacesPortlet;
   
   /**
  @@ -35,15 +31,9 @@
    */
   public class RoleMgtPortlet extends FacesPortlet
   {
  -
  +    /** The logger. */
       private static final Log log = LogFactory.getLog(RoleMgtPortlet.class);
  -
  -    /** Role tree table binding variable. */
  -    private static final String ROLE_TREE_TABLE = "roleTreeTable";
       
  -    /** The role tree model. */
  -    TreeModel roleTreeModel = new DefaultTreeModel();
  -
       /**
        * @see javax.portlet.Portlet#init(javax.portlet.PortletConfig)
        */
  @@ -51,10 +41,11 @@
       {
           super.init(config);
   
  -        Preferences prefs = Preferences.userRoot().node(
  -                (BasePrincipal.PREFS_ROLE_ROOT).substring(0, (BasePrincipal.PREFS_ROLE_ROOT).length() - 1));
  -
  -        roleTreeModel = buildTreeModel(prefs);
  +        RoleManager roleMgr = (RoleManager) getPortletContext().getAttribute(SecurityApplicationResources.CPS_ROLE_MANAGER_COMPONENT);
  +        if (null == roleMgr)
  +        {
  +            throw new PortletException("Failed to find the role manager on portlet initialization.");
  +        }
       }
      
       /**
  @@ -62,49 +53,10 @@
        */
       protected void preProcessFaces(FacesContext context)
       {
  -        context.getExternalContext().getSessionMap().put(ROLE_TREE_TABLE, new RoleTreeTable(roleTreeModel));
  -    }
  -    
  -    /**
  -     * <p>
  -     * Build the tree model.
  -     * </p>
  -     * 
  -     * @param prefs The preferences.
  -     * @return The tree model.
  -     */
  -    private TreeModel buildTreeModel(Preferences prefs)
  -    {
  -        DefaultMutableTreeNode root = new DefaultMutableTreeNode(new RoleTreeItem(prefs.absolutePath(), prefs.name()));
  -        processPreferences(prefs, root);
  -
  -        return new DefaultTreeModel(root);
  -    }
  -
  -    /**
  -     * <p>
  -     * Recursively processes the preferences to build the role tree model.
  -     * </p>
  -     * 
  -     * @param prefs The preferences.
  -     * @param parent The parent to add the role item to.
  -     */
  -    protected void processPreferences(Preferences prefs, DefaultMutableTreeNode parent)
  -    {
  -        try
  -        {
  -            String[] names = prefs.childrenNames();
  -            for (int i = 0; i < names.length; i++)
  -            {
  -                Preferences childPrefs = prefs.node(names[i]);
  -                DefaultMutableTreeNode child = new DefaultMutableTreeNode(new RoleTreeItem(childPrefs.absolutePath(), names[i]));
  -                parent.insert(child);
  -                processPreferences(childPrefs, child);
  -            }
  -        }
  -        catch (BackingStoreException bse)
  +        if (null == context.getExternalContext().getSessionMap().get(SecurityApplicationResources.ROLE_TREE_TABLE))
           {
  -            log.warn("can't find children of " + prefs.absolutePath(), bse);
  +            context.getExternalContext().getSessionMap().put(SecurityApplicationResources.ROLE_TREE_TABLE, 
  +                    new RoleTreeTable(SecurityApplicationUtils.buildRoleTreeModel()));
           }
       }
   
  
  
  
  1.2       +69 -4     jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt/RoleActionForm.java
  
  Index: RoleActionForm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt/RoleActionForm.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RoleActionForm.java	29 Nov 2004 21:11:57 -0000	1.1
  +++ RoleActionForm.java	23 Dec 2004 16:55:23 -0000	1.2
  @@ -16,14 +16,40 @@
   package org.apache.jetspeed.portlets.security.rolemgt;
   
   import java.io.Serializable;
  +import java.util.Collection;
  +import java.util.Map;
  +
  +import javax.faces.context.ExternalContext;
  +import javax.faces.context.FacesContext;
  +import javax.faces.el.VariableResolver;
  +
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
  +import org.apache.jetspeed.portlets.security.SecurityApplicationResources;
  +import org.apache.jetspeed.portlets.security.SecurityApplicationUtils;
  +import org.apache.jetspeed.security.Role;
  +import org.apache.jetspeed.security.RoleManager;
  +import org.apache.jetspeed.security.SecurityException;
  +import org.apache.myfaces.custom.tree.TreeNode;
  +import org.apache.myfaces.custom.tree.model.DefaultTreeModel;
   
   /**
    * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
    */
   public class RoleActionForm implements Serializable
   {
  +    
  +    /** The logger. */
  +    private static final Log log = LogFactory.getLog(RoleActionForm.class);
  +    
       /** The role action form bean. */
       public final static String ROLE_ACTION_FORM = "roleActionForm";
  +    
  +    /** The default parent role path. */
  +    private final static String DEFAULT_PARENT_ROLE_PATH = "/role";
  +    
  +    /** The default parent role name. */
  +    private final static String DEFAULT_PARENT_ROLE_NAME = "role";
   
       /** The parent role. */
       private RoleTreeItem parentRole;
  @@ -44,7 +70,7 @@
        */
       public RoleActionForm()
       {
  -        this.parentRole = new RoleTreeItem("/role", "role");
  +        this.parentRole = new RoleTreeItem(DEFAULT_PARENT_ROLE_PATH, DEFAULT_PARENT_ROLE_NAME);
       }
   
       /**
  @@ -118,9 +144,48 @@
        */
       public void addRole()
       {
  -        // Call the role manager. Add the role.
  -        String newRoleFullPath = getParentRole().getFullPath() + "/" + getRoleName();
  -        System.out.println("******* New Full Path: " + newRoleFullPath);
  +        ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
  +        Map appMap = (Map) externalContext.getApplicationMap();
  +        RoleManager roleMgr = (RoleManager) appMap.get(SecurityApplicationResources.CPS_ROLE_MANAGER_COMPONENT);  
  +        try
  +        {
  +            String roleToAddPath = getRoleName();
  +            // If the role to add is relative to a selected parent.
  +            if (!getParentRole().getRoleName().equals(DEFAULT_PARENT_ROLE_NAME))
  +            {
  +                roleToAddPath = getParentRole().getRoleName() + "." + roleToAddPath;
  +            }
  +            if (log.isDebugEnabled())
  +            {
  +                log.debug("Adding role: " + roleToAddPath);
  +            }
  +            // Add role.
  +            roleMgr.addRole(roleToAddPath);
  +            // Get the newly added role.
  +            Role addedRole = roleMgr.getRole(roleToAddPath);
  +            // Resolve the tree table.
  +            FacesContext facesContext = FacesContext.getCurrentInstance();
  +            VariableResolver vr = facesContext.getApplication().getVariableResolver();
  +            RoleTreeTable roleTree = (RoleTreeTable) vr.resolveVariable(facesContext, RoleTreeTable.ROLE_TREE_TABLE);
  +            // Get the listeners registered.
  +            Collection listeners = roleTree.getTreeModel().getTreeModelListeners();
  +            // TODO We could be more sophisticated and not rebuild the old tree.  For now this will do.
  +            roleTree.setTreeModel(SecurityApplicationUtils.buildRoleTreeModel());
  +            // Get the new tree model.
  +            DefaultTreeModel treeModel = roleTree.getTreeModel();
  +            // Add the old listeners back...
  +            treeModel.getTreeModelListeners().addAll(listeners);
  +            // Get the index of the new node.
  +            TreeNode parentNode = SecurityApplicationUtils.findTreeNode(roleTree, getParentRole().getFullPath());
  +            TreeNode childNode = SecurityApplicationUtils.findTreeNode(roleTree, addedRole.getPreferences().absolutePath());
  +            int [] childIndices = {treeModel.getIndexOfChild(parentNode, childNode)};
  +            // Send the node inserted event.
  +            treeModel.nodesWereInserted(parentNode, childIndices);
  +        }
  +        catch (SecurityException se)
  +        {
  +            log.error("Error adding role " + getRoleName() + ". " + se);
  +        }
       }   
   
   }
  
  
  
  1.2       +9 -4      jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt/RoleTreeTable.java
  
  Index: RoleTreeTable.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt/RoleTreeTable.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RoleTreeTable.java	29 Nov 2004 21:11:57 -0000	1.1
  +++ RoleTreeTable.java	23 Dec 2004 16:55:23 -0000	1.2
  @@ -30,6 +30,9 @@
    */
   public class RoleTreeTable implements Serializable
   {
  +    /** The role tree table bean. */
  +    public final static String ROLE_TREE_TABLE = "roleTreeTable";
  +    
       private DefaultTreeModel treeModel;
   
       /**
  @@ -47,13 +50,15 @@
        */
       public RoleTreeTable()
       {
  -        DefaultMutableTreeNode root = new DefaultMutableTreeNode(new RoleTreeItem("/role/XY", "XY"));
  +        DefaultMutableTreeNode root = new DefaultMutableTreeNode(new RoleTreeItem("/role", "role"));
  +        DefaultMutableTreeNode xy = new DefaultMutableTreeNode(new RoleTreeItem("/role/XY", "XY"));
  +        root.insert(xy);
           DefaultMutableTreeNode a = new DefaultMutableTreeNode(new RoleTreeItem("/role/XY/A", "A"));
  -        root.insert(a);
  +        xy.insert(a);
           DefaultMutableTreeNode b = new DefaultMutableTreeNode(new RoleTreeItem("/role/XY/B", "B"));
  -        root.insert(b);
  +        xy.insert(b);
           DefaultMutableTreeNode c = new DefaultMutableTreeNode(new RoleTreeItem("/role/XY/C", "C"));
  -        root.insert(c);
  +        xy.insert(c);
   
           DefaultMutableTreeNode node = new DefaultMutableTreeNode(new RoleTreeItem("/role/XY/A/a1", "a1"));
           a.insert(node);
  
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/test/org/apache/jetspeed/portlets/security/TestSecurityApplicationUtils.java
  
  Index: TestSecurityApplicationUtils.java
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache 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
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * 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.apache.jetspeed.portlets.security;
  
  import org.apache.jetspeed.portlets.security.rolemgt.RoleTreeItem;
  import org.apache.jetspeed.portlets.security.rolemgt.RoleTreeTable;
  import org.apache.myfaces.custom.tree.DefaultMutableTreeNode;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  /**
   * <p>
   * Test case for the {@link SecurityApplicationUtils}.
   * 
   * @author <a href="dlestrat@apache.org">David Le Strat</a>
   */
  public class TestSecurityApplicationUtils extends TestCase
  {
          
      /**
       * @param name The test name.
       */
      public TestSecurityApplicationUtils(String name)
      {
          super(name);
      }
      
      /**
       * <p>
       * Start the tests.
       * </p>
       *
       * @param args the arguments. Not used
       */
      public static void main(String args[]) 
      {
          junit.awtui.TestRunner.main( new String[] { TestSecurityApplicationUtils.class.getName() } );
      }
   
      /**
       * <p>
       * Creates the test suite.
       * </p>
       *
       * @return a test suite (<code>TestSuite</code>) that includes all methods
       *         starting with "test"
       */
      public static Test suite() 
      {
          // All methods starting with "test" will be executed in the test suite.
          return new TestSuite(TestSecurityApplicationUtils.class);
      }
      
      /**
       * @see junit.framework.TestCase#setUp()
       */
      protected void setUp() throws Exception
      {
          super.setUp();
      }
      
      /**
       * @see junit.framework.TestCase#tearDown()
       */
      protected void tearDown() throws Exception
      {
      }
      
      /**
       * <p>
       * Test getNodePathDepth.
       * </p>
       */
      public void testGetNodePathDepth()
      {
          String nodePath = "/role/manager/sales";
          int depth = SecurityApplicationUtils.getNodePathDepth(nodePath);
          assertEquals(3, depth);
      }
      
      /**
       * <p>
       * Test getNodePathAtDepth(String nodePath, int depth).
       * </p>
       */
      public void testGetNodePathAtDepth()
      {
          String nodePath = "/role/manager/sales";
          String depthNodePath = SecurityApplicationUtils.getNodePathAtDepth(nodePath, 0);
          assertEquals("/role", depthNodePath);
          
          depthNodePath = SecurityApplicationUtils.getNodePathAtDepth(nodePath, 1);
          assertEquals("/role/manager", depthNodePath);
          
          depthNodePath = SecurityApplicationUtils.getNodePathAtDepth(nodePath, 2);
          assertEquals("/role/manager/sales", depthNodePath);
      }
      
      public void testFindTreeNode()
      {
          DefaultMutableTreeNode treeNode = SecurityApplicationUtils.findTreeNode(new RoleTreeTable(), "/role/XY/A/a1");
          assertNotNull(treeNode);
          assertEquals("/role/XY/A/a1", ((RoleTreeItem) treeNode.getUserObject()).getFullPath());
      }
  }
  
  
  
  1.4       +2 -3      jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/ChangePasswordPortlet.java
  
  Index: ChangePasswordPortlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/ChangePasswordPortlet.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ChangePasswordPortlet.java	25 Nov 2004 02:25:58 -0000	1.3
  +++ ChangePasswordPortlet.java	23 Dec 2004 16:55:23 -0000	1.4
  @@ -57,13 +57,12 @@
       public static final String WHY = "why";
       public static final String REQUIRED = "required";
       public static final String CANCELLED = "cancelled";
  -    public static final String CPS_USER_MANAGER_COMPONENT = "cps:UserManager";
       
       public void init(PortletConfig config)
       throws PortletException 
       {
           super.init(config);
  -        manager = (UserManager) getPortletContext().getAttribute(CPS_USER_MANAGER_COMPONENT);
  +        manager = (UserManager) getPortletContext().getAttribute(SecurityApplicationResources.CPS_USER_MANAGER_COMPONENT);
           if (null == manager)
           {
               throw new PortletException("Failed to find the User Manager on portlet initialization");
  
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/SecurityApplicationUtils.java
  
  Index: SecurityApplicationUtils.java
  ===================================================================
  /*
   * Copyright 2000-2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache 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
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * 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.apache.jetspeed.portlets.security;
  
  import java.util.Iterator;
  import java.util.StringTokenizer;
  import java.util.prefs.BackingStoreException;
  import java.util.prefs.Preferences;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.apache.jetspeed.portlets.security.rolemgt.RoleTreeItem;
  import org.apache.jetspeed.portlets.security.rolemgt.RoleTreeTable;
  import org.apache.jetspeed.security.BasePrincipal;
  import org.apache.myfaces.custom.tree.DefaultMutableTreeNode;
  import org.apache.myfaces.custom.tree.model.DefaultTreeModel;
  
  /**
   * <p>
   * Utility class for the security application.
   * </p>
   * 
   * @author <a href="dlestrat@apache.org">David Le Strat</a>
   */
  public class SecurityApplicationUtils
  {
      /** The logger. */
      private static final Log log = LogFactory.getLog(SecurityApplicationUtils.class);
      
      /** Node path delimiter. */
      private static final String PATH_DELIMITER = "/";
     
      /**
       * <p>
       * Build the role tree model.
       * </p>
       * 
       * @return The tree model.
       */
      public static DefaultTreeModel buildRoleTreeModel()
      {
          DefaultTreeModel roleTreeModel = buildTreeModel(BasePrincipal.PREFS_ROLE_ROOT);
          
          return roleTreeModel;
      }
      
      /**
       * <p>
       * Build the tree model.
       * </p>
       * 
       * @param prefs The preferences.
       * @return The tree model.
       */
      private static DefaultTreeModel buildTreeModel(String prefsRoot)
      {
          Preferences prefs = Preferences.userRoot().node(prefsRoot.substring(0, prefsRoot.length() - 1));
          
          DefaultMutableTreeNode root = new DefaultMutableTreeNode(new RoleTreeItem(prefs.absolutePath(), prefs.name()));
          processPreferences(prefs, root);
  
          return new DefaultTreeModel(root);
      }
  
      /**
       * <p>
       * Recursively processes the preferences to build the role tree model.
       * </p>
       * 
       * @param prefs The preferences.
       * @param parent The parent to add the role item to.
       */
      private static void processPreferences(Preferences prefs, DefaultMutableTreeNode parent)
      {
          try
          {
              String[] names = prefs.childrenNames();
              for (int i = 0; i < names.length; i++)
              {
                  Preferences childPrefs = prefs.node(names[i]);
                  DefaultMutableTreeNode child = new DefaultMutableTreeNode(new RoleTreeItem(childPrefs.absolutePath(), names[i]));
                  System.out.println("++++++ Rebuilding tree - Adding to tree: " + childPrefs.absolutePath());
                  parent.insert(child);
                  processPreferences(childPrefs, child);
              }
          }
          catch (BackingStoreException bse)
          {
              log.warn("can't find children of " + prefs.absolutePath(), bse);
          }
      }
      
      /**
       * <p>
       * Finds a tree node in the tree model given the nodePath of the node to find.
       * </p>
       * 
       * @param treeModel The tree model.
       * @param nodePath The path of the node to find.
       * @return The {@link DefaultMutableTreeNode}.
       */
      public static DefaultMutableTreeNode findTreeNode(RoleTreeTable treeModel, String nodePath)
      {
          DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) treeModel.getTreeModel().getRoot();
          int nodePathDepth = getNodePathDepth(nodePath);
          for (int i = 1; i < nodePathDepth; i++)
          {
              if (null != treeNode)
              {
                  treeNode = findTreeNodeAtDepth(getNodePathAtDepth(nodePath, i), treeNode.children());
              }
          }
          return treeNode;
      }
      
      /**
       * <p>
       * Finds the current child matching the sub node path where the node path is the path
       * matching the level of the children.
       * </p>
       * 
       * @param nodePath The node path to find the child at.
       * @param children The children at the given level.
       * @return
       */
      protected static DefaultMutableTreeNode findTreeNodeAtDepth(String nodePath, Iterator children)
      {
          DefaultMutableTreeNode nodeAtDepth = null;
          while (children.hasNext())
          {
              DefaultMutableTreeNode currNode = (DefaultMutableTreeNode) children.next();
              RoleTreeItem currItem = (RoleTreeItem) currNode.getUserObject();
              if (currItem.getFullPath().equals(nodePath))
              {
                  nodeAtDepth = currNode;
                  break;
              }
          }
          return nodeAtDepth;
      }
      
      /**
       * <p>
       * Gets a subset of the node path at the given depth.
       * </p>
       * 
       * @param nodePath The node path.
       * @param depth The depth where depth starts at 0;
       * @return The subset of the node path.
       */
      protected static String getNodePathAtDepth(String nodePath, int depth)
      {
          StringTokenizer tokens = new StringTokenizer(nodePath, PATH_DELIMITER);
          int nodeDepth = tokens.countTokens();
          String nodePathAtDepth = nodePath;
          if (depth < nodeDepth)
          {
              nodePathAtDepth = PATH_DELIMITER;
              for (int i = 0; i <= depth; i ++)
              {
                  nodePathAtDepth += tokens.nextToken();
                  if ((depth > 0) && (i <= depth - 1))
                  {
                      nodePathAtDepth += PATH_DELIMITER;
                  }
              }
          }
          return nodePathAtDepth;
      }
      
      /**
       * <p>
       * The depth represented in the node path.
       * </p>
       * 
       * @param nodePath The node path.
       * @return The depth.
       */
      protected static int getNodePathDepth(String nodePath)
      {
          StringTokenizer tokens = new StringTokenizer(nodePath, PATH_DELIMITER);
          return tokens.countTokens();
      }
  
  }
  
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/SecurityApplicationResources.java
  
  Index: SecurityApplicationResources.java
  ===================================================================
  /*
   * Copyright 2000-2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache 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
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * 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.apache.jetspeed.portlets.security;
  
  /**
   * <p>
   * Common resources used by the security applications.
   * </p>
   * 
   * @author <a href="dlestrat@apache.org">David Le Strat</a>
   */
  public class SecurityApplicationResources
  {
      /** The role manager component. */
      public final static String CPS_ROLE_MANAGER_COMPONENT = "cps:RoleManager";
      
      /** The user manager component. */
      public static final String CPS_USER_MANAGER_COMPONENT = "cps:UserManager";
      
      /** Role tree table binding variable. */
      public static final String ROLE_TREE_TABLE = "roleTreeTable";
  
  }
  
  
  
  1.2       +2 -0      jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/resources/RoleMgtResources.properties
  
  Index: RoleMgtResources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/resources/RoleMgtResources.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RoleMgtResources.properties	29 Nov 2004 21:11:11 -0000	1.1
  +++ RoleMgtResources.properties	23 Dec 2004 16:55:23 -0000	1.2
  @@ -16,6 +16,8 @@
   currentRolePath = Current Role Path:
   currentRoleName = Current Role Name:
   
  +addRoleInfo=To add more than 1 role in the role hierarchy, use "." as a separator. E.g. manager.sales will create the role hierarchy /manager/sales.
  +
   availableUsersHeader = Available Users
   selectedUsersHeader = Selected Users
   
  
  
  
  1.2       +2 -0      jakarta-jetspeed-2/applications/security/src/webapp/WEB-INF/security/rolemgt/role-add.jsp
  
  Index: role-add.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/applications/security/src/webapp/WEB-INF/security/rolemgt/role-add.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- role-add.jsp	29 Nov 2004 21:12:45 -0000	1.1
  +++ role-add.jsp	23 Dec 2004 16:55:23 -0000	1.2
  @@ -28,6 +28,8 @@
   <f:verbatim>&nbsp;</f:verbatim>
   <h:outputText value="#{roleActionForm.parentRole.roleName}" />
   <f:verbatim><br><br></f:verbatim>
  +<h:outputText value="#{roleMgtMessages['addRoleInfo']}" styleClass="portlet-msg-info" />
  +<f:verbatim><br><br></f:verbatim>
   
   <h:form id="addRoleForm" name="addRoleForm">
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org