portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlest...@apache.org
Subject cvs commit: jakarta-jetspeed-2/applications/security/src/webapp/images sw_med_rond.gif
Date Mon, 29 Nov 2004 21:11:59 GMT
dlestrat    2004/11/29 13:11:58

  Added:       applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt
                        RoleMgtPortlet.java RoleActionForm.java
                        RoleMgtUser.java RoleMgtRenderUtil.java
                        RoleActionController.java
                        PanelTabStateListener.java
                        AddRoleCommandLinkActionListener.java
                        RoleTreeItem.java SelectedUsersList.java
                        RoleActionListener.java AvailableUsersList.java
                        RoleTreeTable.java
               applications/security/src/webapp/images/tree
                        node_close_middle.gif node_open.gif node_close.gif
                        folder.png node_open_first.gif folder.gif
                        noline.gif node_open_last.gif line_middle.gif
                        node_close_first.gif line.gif node_close_last.gif
                        node_open_middle.gif line_first.gif line_last.gif
               applications/security/src/webapp/images sw_med_rond.gif
  Log:
  http://nagoya.apache.org/jira/browse/JS2-23#action_55991
  
  Revision  Changes    Path
  1.1                  jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt/RoleMgtPortlet.java
  
  Index: RoleMgtPortlet.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.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.portals.bridges.myfaces.FacesPortlet;
  
  /**
   * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
   */
  public class RoleMgtPortlet extends FacesPortlet
  {
  
      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)
       */
      public void init(PortletConfig config) throws PortletException
      {
          super.init(config);
  
          Preferences prefs = Preferences.userRoot().node(
                  (BasePrincipal.PREFS_ROLE_ROOT).substring(0, (BasePrincipal.PREFS_ROLE_ROOT).length()
- 1));
  
          roleTreeModel = buildTreeModel(prefs);
      }
     
      /**
       * @see org.apache.portals.bridges.myfaces.FacesPortlet#preProcessFaces(javax.faces.context.FacesContext)
       */
      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)
          {
              log.warn("can't find children of " + prefs.absolutePath(), bse);
          }
      }
  
  }
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt/RoleActionForm.java
  
  Index: RoleActionForm.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.rolemgt;
  
  import java.io.Serializable;
  
  /**
   * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
   */
  public class RoleActionForm implements Serializable
  {
      /** The role action form bean. */
      public final static String ROLE_ACTION_FORM = "roleActionForm";
  
      /** The parent role. */
      private RoleTreeItem parentRole;
  
      /** The selected roles. */
      private String[] selectedRoles;
  
      /** The new role name. */
      private String roleName;
  
      /** The new role path. */
      private String rolePath;
  
      /**
       * <p>
       * Default Constructor.
       * </p>
       */
      public RoleActionForm()
      {
          this.parentRole = new RoleTreeItem("/role", "role");
      }
  
      /**
       * @return Returns the parentRole.
       */
      public RoleTreeItem getParentRole()
      {
          return parentRole;
      }
  
      /**
       * @param parentRole The parentRole to set.
       */
      public void setParentRole(RoleTreeItem parentRole)
      {
          this.parentRole = parentRole;
      }
  
      /**
       * @return Returns the selectedRoles.
       */
      public String[] getSelectedRoles()
      {
          return selectedRoles;
      }
  
      /**
       * @param selectedRoles The selectedRoles to set.
       */
      public void setSelectedRoles(String[] selectedRoles)
      {
          this.selectedRoles = selectedRoles;
      }
  
      /**
       * @return Returns the roleName.
       */
      public String getRoleName()
      {
          return roleName;
      }
  
      /**
       * @param roleName The roleName to set.
       */
      public void setRoleName(String roleName)
      {
          this.roleName = roleName;
      }
  
      /**
       * @return Returns the rolePath.
       */
      public String getRolePath()
      {
          return rolePath;
      }
  
      /**
       * @param rolePath The rolePath to set.
       */
      public void setRolePath(String rolePath)
      {
          this.rolePath = rolePath;
      }
  
      /**
       * <p>
       * Add a new role.
       * </p>
       */
      public void addRole()
      {
          // Call the role manager. Add the role.
          String newRoleFullPath = getParentRole().getFullPath() + "/" + getRoleName();
          System.out.println("******* New Full Path: " + newRoleFullPath);
      }   
  
  }
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt/RoleMgtUser.java
  
  Index: RoleMgtUser.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.rolemgt;
  
  /**
   * <p>
   * Light weight user used for the role management portlet.
   * </p>
   * 
   * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
   */
  public class RoleMgtUser
  {
      /** The user name. */
      private String username;
  
      /**
       * @param username The username.
       */
      public RoleMgtUser(String username)
      {
          this.username = username;
      }
  
      /**
       * @return Returns the username.
       */
      public String getUsername()
      {
          return username;
      }
  
      /**
       * @param username The username to set.
       */
      public void setUsername(String username)
      {
          this.username = username;
      }
  }
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt/RoleMgtRenderUtil.java
  
  Index: RoleMgtRenderUtil.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.rolemgt;
  
  import java.text.MessageFormat;
  import java.util.Locale;
  import java.util.MissingResourceException;
  import java.util.ResourceBundle;
  
  import javax.faces.application.FacesMessage;
  import javax.faces.component.UIComponent;
  
  import org.apache.myfaces.custom.tabbedpane.HtmlPanelTabbedPane;
  
  /**
   * <p>
   * Utility class used for rendering.
   * </p>
   * 
   * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
   */
  public class RoleMgtRenderUtil
  {
      private static final String DETAIL_SUFFIX = "Detail";
      
      /**
       * <p>
       * Utility method used to locate the tabbed panel component.
       * </p>
       * 
       * @param component The component.
       * @return The {@link HtmlPanelTabbedPane}.
       */
      public static HtmlPanelTabbedPane findTabbedPane(UIComponent component)
      {
          HtmlPanelTabbedPane tabbedPane = null;
  
          UIComponent parent = component.getParent();
          if (parent instanceof HtmlPanelTabbedPane)
          {
              tabbedPane = (HtmlPanelTabbedPane) parent;
          }
          else
          {
              tabbedPane = findTabbedPane(parent);
          }
  
          return tabbedPane;
      }
  
      /**
       * <p>
       * Utility to get validation messages.
       * </p>
       * 
       * @param locale The locale.
       * @param severity The severity.
       * @param messageId The messageId.
       * @param bundleName The bundleName.
       * @param args The args.
       * @return The {@link FacesMessage}
       */
      public static FacesMessage getMessage(Locale locale, FacesMessage.Severity severity,
              String messageId, String bundleName, Object args[])
      {
          ResourceBundle resourceBundle = ResourceBundle.getBundle(bundleName, locale);
          String detail = null;
  
          String summary = getBundleString(resourceBundle, messageId);
          if (summary != null)
          {
              detail = getBundleString(resourceBundle, messageId + DETAIL_SUFFIX);
          }
  
          if (args != null && args.length > 0)
          {
              MessageFormat format;
  
              if (summary != null)
              {
                  format = new MessageFormat(summary, locale);
                  summary = format.format(args);
              }
  
              if (detail != null)
              {
                  format = new MessageFormat(detail, locale);
                  detail = format.format(args);
              }
          }
  
          return new FacesMessage(severity, summary, detail);
      }
      
      /**
       * <p>
       * Utility to get a bundle string.
       * </p>
       * 
       * @param bundle The bundle.
       * @param key The key.
       * @return The message.
       */
      private static String getBundleString(ResourceBundle bundle, String key)
      {
          try
          {
              return bundle == null ? null : bundle.getString(key);
          }
          catch (MissingResourceException e)
          {
              return null;
          }
      }
  
  }
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt/RoleActionController.java
  
  Index: RoleActionController.java
  ===================================================================
  /*
   * Created on Nov 28, 2004
   *
   * TODO To change the template for this generated file go to
   * Window - Preferences - Java - Code Style - Code Templates
   */
  package org.apache.jetspeed.portlets.security.rolemgt;
  
  /**
   * @author David Le Strat
   *
   * TODO To change the template for this generated type comment go to
   * Window - Preferences - Java - Code Style - Code Templates
   */
  public class RoleActionController
  {
      /** The parent role. */
      private RoleTreeItem parentRole;
      
      
  
  }
  
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt/PanelTabStateListener.java
  
  Index: PanelTabStateListener.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.rolemgt;
  
  import java.io.Serializable;
  import java.util.List;
  
  import javax.faces.component.UIComponent;
  import javax.faces.context.FacesContext;
  import javax.faces.event.AbortProcessingException;
  
  import org.apache.myfaces.custom.tabbedpane.HtmlPanelTab;
  import org.apache.myfaces.custom.tabbedpane.HtmlPanelTabbedPane;
  import org.apache.myfaces.custom.tabbedpane.TabChangeEvent;
  import org.apache.myfaces.custom.tabbedpane.TabChangeListener;
  
  /**
   * <p>
   * Controls the state of the role management tabs.
   * </p>
   * 
   * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
   */
  public class PanelTabStateListener implements Serializable, TabChangeListener
  {
      /** The panel tab state bean. */
      public static final String PANEL_TAB_STATE = "roleMgtPanelTabState";
      
      /** Edit role id. */
      private static final String EDIT_ROLE_TAB_ID = "editRoleTab";
  
      /** Role management panel tab state value binding. */
      private static final String ROLE_MGT_PANEL_TAB_STATE = "roleMgtPanelTabState";
  
      /** Whether to render edit role. */
      private boolean renderEditRole = false;
  
      /** Whether to render view roles. */
      private boolean renderViewRoles = true;
  
      /**
       * @return Returns the renderEditRole.
       */
      public boolean isRenderEditRole()
      {
          return renderEditRole;
      }
  
      /**
       * @param renderEditRole The renderEditRole to set.
       */
      public void setRenderEditRole(boolean renderEditRole)
      {
          this.renderEditRole = renderEditRole;
      }
  
      /**
       * @return Returns the renderViewRoles.
       */
      public boolean isRenderViewRoles()
      {
          return renderViewRoles;
      }
  
      /**
       * @param renderViewRoles The renderViewRoles to set.
       */
      public void setRenderViewRoles(boolean renderViewRoles)
      {
          this.renderViewRoles = renderViewRoles;
      }
  
      /**
       * <p>
       * Render edit role.
       * </p>
       */
      public void renderEditRole()
      {
          this.renderEditRole = true;
          this.renderViewRoles = false;
          FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(ROLE_MGT_PANEL_TAB_STATE,
this);
      }
  
      /**
       * <p>
       * Render view roles.
       * </p>
       */
      public void renderViewRoles()
      {
          this.renderEditRole = false;
          this.renderViewRoles = true;
          FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(ROLE_MGT_PANEL_TAB_STATE,
this);
      }
  
      /**
       * @see org.apache.myfaces.custom.tabbedpane.TabChangeListener#processTabChange(org.apache.myfaces.custom.tabbedpane.TabChangeEvent)
       */
      public void processTabChange(TabChangeEvent tabChangeEvent) throws AbortProcessingException
      {
          HtmlPanelTabbedPane tabbedPane = (HtmlPanelTabbedPane) tabChangeEvent.getComponent();
          List children = tabbedPane.getChildren();
          for (int i = 0, len = children.size(); i < len; i++)
          {
              UIComponent child = (UIComponent) children.get(i);
              if (child instanceof HtmlPanelTab)
              {
                  if (child.getId().equals(EDIT_ROLE_TAB_ID) && child.isRendered())
                  {
                      renderViewRoles();
                  }
              }
          }
      }
  }
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt/AddRoleCommandLinkActionListener.java
  
  Index: AddRoleCommandLinkActionListener.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.rolemgt;
  
  import java.util.prefs.Preferences;
  
  import javax.faces.component.UIComponent;
  import javax.faces.context.FacesContext;
  
  import javax.faces.el.VariableResolver;
  import javax.faces.event.AbortProcessingException;
  import javax.faces.event.ActionEvent;
  import javax.faces.event.ActionListener;
  
  import org.apache.myfaces.custom.tabbedpane.HtmlPanelTabbedPane;
  
  /**
   * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
   */
  public class AddRoleCommandLinkActionListener implements ActionListener
  {
      /** The role action controller bean. */
      private final static String ADD_ROLE_TO_PARAM = "addRoleToParam";
  
      public void processAction(ActionEvent event) throws AbortProcessingException
      {
          UIComponent component = event.getComponent();
          HtmlPanelTabbedPane tabbedPane = RoleMgtRenderUtil.findTabbedPane(component);
  
          // Load add role pane.
          tabbedPane.setSelectedIndex(1);
  
          // Set the current role action.
          FacesContext facesContext = FacesContext.getCurrentInstance();
          VariableResolver vr = facesContext.getApplication().getVariableResolver();
  
          RoleActionForm roleAction = (RoleActionForm) vr.resolveVariable(facesContext, RoleActionForm.ROLE_ACTION_FORM);
  
          String fullPath = (String) facesContext.getExternalContext().getRequestParameterMap().get(ADD_ROLE_TO_PARAM);
          Preferences prefs = Preferences.userRoot().node(fullPath);
  
          roleAction.setParentRole(new RoleTreeItem(fullPath, prefs.name()));
  
          //if (component.getId().equals("addButton") ||
          //    component.getId().equals("href1"))
          //{
          //    form.add();
          //}
          //else
          //{
          //    form.subtract();
          //}
      }
  }
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt/RoleTreeItem.java
  
  Index: RoleTreeItem.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.rolemgt;
  
  import java.io.Serializable;
  
  /**
   * <p>
   * Bean class holding a role tree item.
   * </p>
   * 
   * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
   */
  public class RoleTreeItem implements Serializable
  {
      /** The full path. */
      private String fullPath;
  
      /** The role name. */
      private String roleName;
      
      /**
       * @param fullPath The full path.
       * @param roleName The role name.
       */
      public RoleTreeItem(String fullPath, String roleName)
      {
          this.fullPath = fullPath;
          this.roleName = roleName;
      }
  
      /**
       * @return Returns the fullPath.
       */
      public String getFullPath()
      {
          return fullPath;
      }
  
      /**
       * @param fullPath The fullPath to set.
       */
      public void setFullPath(String fullPath)
      {
          this.fullPath = fullPath;
      }
  
      /**
       * @return Returns the roleName.
       */
      public String getRoleName()
      {
          return roleName;
      }
  
      /**
       * @param roleName The roleName to set.
       */
      public void setRoleName(String roleName)
      {
          this.roleName = roleName;
      }
  
  }
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt/SelectedUsersList.java
  
  Index: SelectedUsersList.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.rolemgt;
  
  import java.util.ArrayList;
  import java.util.List;
  
  /**
   * <p>
   * Selected users list.
   * </p>
   * 
   * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
   */
  public class SelectedUsersList
  {
      private List selectedUsers = new ArrayList();
      
      /**
       * <p>
       * Default constructor.
       * </p>
       */
      public SelectedUsersList()
      {
          for (int i = 1; i < 7; i++)
          {
              selectedUsers.add(new RoleMgtUser("username" + i));
          }
      }
  
      /**
       * @return Returns the selectedUsers.
       */
      public List getSelectedUsers()
      {
          return this.selectedUsers;
      }
      /**
       * @param selectedUsers The selectedUsers to set.
       */
      public void setSelectedUsers(List selectedUsers)
      {
          this.selectedUsers = selectedUsers;
      }
  }
  
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt/RoleActionListener.java
  
  Index: RoleActionListener.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.rolemgt;
  
  import java.util.prefs.Preferences;
  
  import javax.faces.application.FacesMessage;
  import javax.faces.component.UIComponent;
  import javax.faces.context.FacesContext;
  import javax.faces.el.VariableResolver;
  import javax.faces.event.AbortProcessingException;
  import javax.faces.event.ActionEvent;
  import javax.faces.event.ActionListener;
  import javax.faces.event.PhaseId;
  
  import org.apache.myfaces.custom.tabbedpane.HtmlPanelTabbedPane;
  
  /**
   * @author <a href="dlestrat@apache.org">David Le Strat </a>
   */
  public class RoleActionListener implements ActionListener
  {
      /** The role management bundle name. */
      private final static String ROLE_MGT_RESOURCES = "org.apache.jetspeed.portlets.security.resources.RoleMgtResources";
      
      /** The invalid selected roles message id. */
      private final static String INVALID_SELECTED_ROLES_MESSAGE_ID = "invalidSelectedRoles";
      
      /** The add role action. */
      private final static String ADD_ROLE_ACTION = "addRoleAction";
      
      /** The edit role action. */
      private final static String EDIT_ROLE_ACTION = "editRoleAction";
  
      /**
       * @see javax.faces.event.ActionListener#processAction(javax.faces.event.ActionEvent)
       */
      public void processAction(ActionEvent event) throws AbortProcessingException
      {
          if (event.getPhaseId() == PhaseId.INVOKE_APPLICATION)
          {
              FacesContext facesContext = FacesContext.getCurrentInstance();
              UIComponent component = event.getComponent();
  
              VariableResolver vr = facesContext.getApplication().getVariableResolver();
              RoleActionForm roleActionForm = (RoleActionForm) vr.resolveVariable(facesContext,
                      RoleActionForm.ROLE_ACTION_FORM);
              if (component.getId().equals(ADD_ROLE_ACTION))
              {
                  roleActionForm.addRole();
                  HtmlPanelTabbedPane tabbedPane = RoleMgtRenderUtil.findTabbedPane(component);
                  // Load the view roles pane.
                  tabbedPane.setSelectedIndex(0);
              }
              else if (component.getId().equals(EDIT_ROLE_ACTION))
              {
                  String[] selectedRoles = roleActionForm.getSelectedRoles();
                  
                  if ((null == selectedRoles) || (selectedRoles.length == 0) || (selectedRoles.length
> 1))
                  {
                      facesContext.addMessage(component.getClientId(facesContext),
                              RoleMgtRenderUtil.getMessage(facesContext.getViewRoot().getLocale(),
  									   					 FacesMessage.SEVERITY_ERROR,
  									   					 INVALID_SELECTED_ROLES_MESSAGE_ID,
  									   					 ROLE_MGT_RESOURCES,
  									   					 null));
                  }
                  else
                  {
                      Preferences prefs = Preferences.userRoot().node(selectedRoles[0]);
                      roleActionForm.setRolePath(prefs.absolutePath());
                      roleActionForm.setRoleName(prefs.name());
                      
                      PanelTabStateListener panelTabState = (PanelTabStateListener) vr.resolveVariable(facesContext,
                              PanelTabStateListener.PANEL_TAB_STATE);
                      panelTabState.renderEditRole();
                  }
  
              }
          }
      }
  }
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt/AvailableUsersList.java
  
  Index: AvailableUsersList.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.rolemgt;
  
  import java.util.ArrayList;
  import java.util.List;
  
  /**
   * <p>
   * Available users list.
   * </p>
   * 
   * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
   */
  public class AvailableUsersList
  {
      private List availableUsers = new ArrayList();
      
      /**
       * <p>
       * Default constructor.
       * </p>
       */
      public AvailableUsersList()
      {
          for (int i = 1; i < 995; i++)
          {
              availableUsers.add(new RoleMgtUser("username" + i));
          }
      }
  
      /**
       * @return Returns the availableUsers.
       */
      public List getAvailableUsers()
      {
          return availableUsers;
      }
      /**
       * @param availableUsers The availableUsers to set.
       */
      public void setAvailableUsers(List availableUsers)
      {
          this.availableUsers = availableUsers;
      }
  }
  
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/rolemgt/RoleTreeTable.java
  
  Index: RoleTreeTable.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.rolemgt;
  
  import java.io.Serializable;
  
  import org.apache.myfaces.custom.tree.DefaultMutableTreeNode;
  import org.apache.myfaces.custom.tree.model.DefaultTreeModel;
  import org.apache.myfaces.custom.tree.model.TreeModel;
  
  /**
   * <p>
   * Bean holding the tree hierarchy.
   * </p>
   * 
   * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
   */
  public class RoleTreeTable implements Serializable
  {
      private DefaultTreeModel treeModel;
  
      /**
       * @param treeModel The treeModel.
       */
      public RoleTreeTable(TreeModel treeModel)
      {
          this.treeModel = (DefaultTreeModel) treeModel;
      }
  
      /**
       * <p>
       * Default constructor.
       * </p>
       */
      public RoleTreeTable()
      {
          DefaultMutableTreeNode root = new DefaultMutableTreeNode(new RoleTreeItem("/role/XY",
"XY"));
          DefaultMutableTreeNode a = new DefaultMutableTreeNode(new RoleTreeItem("/role/XY/A",
"A"));
          root.insert(a);
          DefaultMutableTreeNode b = new DefaultMutableTreeNode(new RoleTreeItem("/role/XY/B",
"B"));
          root.insert(b);
          DefaultMutableTreeNode c = new DefaultMutableTreeNode(new RoleTreeItem("/role/XY/C",
"C"));
          root.insert(c);
  
          DefaultMutableTreeNode node = new DefaultMutableTreeNode(new RoleTreeItem("/role/XY/A/a1",
"a1"));
          a.insert(node);
          node = new DefaultMutableTreeNode(new RoleTreeItem("/role/XY/A/a2", "a2"));
          a.insert(node);
          node = new DefaultMutableTreeNode(new RoleTreeItem("/role/XY/A/a3", "a3"));
          a.insert(node);
          node = new DefaultMutableTreeNode(new RoleTreeItem("/role/XY/B/b", "b"));
          b.insert(node);
  
          a = node;
          node = new DefaultMutableTreeNode(new RoleTreeItem("/role/XY/B/b/x1", "x1"));
          a.insert(node);
          node = new DefaultMutableTreeNode(new RoleTreeItem("/role/XY/B/b/x2", "x2"));
          a.insert(node);
          
          this.treeModel = new DefaultTreeModel(root);
      }
  
      /**
       * @return Returns the treeModel.
       */
      public DefaultTreeModel getTreeModel()
      {
          return treeModel;
      }
  
      /**
       * @param treeModel The treeModel to set.
       */
      public void setTreeModel(DefaultTreeModel treeModel)
      {
          this.treeModel = treeModel;
      }
  }
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/webapp/images/tree/node_close_middle.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/webapp/images/tree/node_open.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/webapp/images/tree/node_close.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/webapp/images/tree/folder.png
  
  	<<Binary file>>
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/webapp/images/tree/node_open_first.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/webapp/images/tree/folder.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/webapp/images/tree/noline.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/webapp/images/tree/node_open_last.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/webapp/images/tree/line_middle.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/webapp/images/tree/node_close_first.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/webapp/images/tree/line.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/webapp/images/tree/node_close_last.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/webapp/images/tree/node_open_middle.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/webapp/images/tree/line_first.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/webapp/images/tree/line_last.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/webapp/images/sw_med_rond.gif
  
  	<<Binary file>>
  
  

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


Mime
View raw message