[pal-cvs 2223] [32] added profiling rule admin page.

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2007年 4月 9日 (月) 12:49:00 JST


Revision: 32
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=pal&view=rev&rev=32
Author:   shinsuke
Date:     2007-04-09 12:48:59 +0900 (Mon, 09 Apr 2007)

Log Message:
-----------
added profiling rule admin page.

Modified Paths:
--------------
    pal-admin/trunk/src/main/java/jp/sf/pal/admin/PALAdminConstants.java
    pal-admin/trunk/src/main/java/jp/sf/pal/admin/entity/User.java
    pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SecurityProviderLogic.java
    pal-admin/trunk/src/main/java/jp/sf/pal/admin/service/UserManagementService.java
    pal-admin/trunk/src/main/java/jp/sf/pal/admin/util/PALAdminUtil.java
    pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/user/AbstractUserPage.java
    pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/user/UserCreatePage.java
    pal-admin/trunk/src/main/resources/appMessages.properties
    pal-admin/trunk/src/main/resources/jp/sf/pal/admin/web/user/label.properties
    pal-admin/trunk/src/main/webapp/view/user/userConfirm.html
    pal-admin/trunk/src/main/webapp/view/user/userCreate.html
    pal-admin/trunk/src/main/webapp/view/user/userEdit.html
    pal-admin/trunk/src/main/webapp/view/user/userGroupEdit.html
    pal-admin/trunk/src/main/webapp/view/user/userRoleEdit.html

Added Paths:
-----------
    pal-admin/trunk/src/main/java/jp/sf/pal/admin/entity/PrincipalRule.java
    pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/user/UserProfilingRuleEditPage.java
    pal-admin/trunk/src/main/webapp/view/user/userProfilingRuleEdit.html

Removed Paths:
-------------
    pal-admin/trunk/src/main/java/jp/sf/pal/admin/entity/ProfilingRule.java


-------------- next part --------------
Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/PALAdminConstants.java
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/PALAdminConstants.java	2007-04-09 02:41:11 UTC (rev 31)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/PALAdminConstants.java	2007-04-09 03:48:59 UTC (rev 32)
@@ -38,4 +38,11 @@
 
     public static final String USER_CREDENTIAL_EXTEND_UNLIMITED = PREFIX
             + "ExtendUnlimited";
+
+    //TODO move to properties file
+    public static final String PAGE_LOCATOR = "page";
+
+    //TODO move to properties file
+    public static final String MENU_LOCATOR = "menu";
+
 }

Copied: pal-admin/trunk/src/main/java/jp/sf/pal/admin/entity/PrincipalRule.java (from rev 30, pal-admin/trunk/src/main/java/jp/sf/pal/admin/entity/ProfilingRule.java)
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/entity/ProfilingRule.java	2007-04-08 23:55:51 UTC (rev 30)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/entity/PrincipalRule.java	2007-04-09 03:48:59 UTC (rev 32)
@@ -0,0 +1,87 @@
+package jp.sf.pal.admin.entity;
+
+import java.io.Serializable;
+
+import jp.sf.pal.admin.PALAdminConstants;
+
+public class PrincipalRule implements Serializable
+{
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 2527117448954090837L;
+
+    private String profilingRuleName;
+
+    private String locatorName;
+
+    public static final String SEPARATOR = PALAdminConstants.PREFIX
+            + "PrincipalRule.SEPARATOR";
+
+    /**
+     * @return the locatorName
+     */
+    public String getLocatorName()
+    {
+        return locatorName;
+    }
+
+    /**
+     * @param locatorName the locatorName to set
+     */
+    public void setLocatorName(String locatorName)
+    {
+        this.locatorName = locatorName;
+    }
+
+    /**
+     * @return the profilingRuleName
+     */
+    public String getProfilingRuleName()
+    {
+        return profilingRuleName;
+    }
+
+    /**
+     * @param profilingRuleName the profilingRuleName to set
+     */
+    public void setProfilingRuleName(String id)
+    {
+        this.profilingRuleName = id;
+    }
+
+    public String getLabel()
+    {
+        return getLocatorName() + "/" + getProfilingRuleName();
+    }
+
+    public String getValue()
+    {
+        return getLocatorName() + SEPARATOR + getProfilingRuleName();
+    }
+
+    public String toString()
+    {
+        return getLabel();
+    }
+
+    public static PrincipalRule getInstance(String value)
+    {
+        if (value == null)
+        {
+            return null;
+        }
+        int index = value.indexOf(SEPARATOR);
+        if (index < 0)
+        {
+            return null;
+        }
+
+        PrincipalRule principalRule = new PrincipalRule();
+        principalRule.setLocatorName(value.substring(0, index));
+        principalRule.setProfilingRuleName(value.substring(index
+                + SEPARATOR.length()));
+        return principalRule;
+    }
+}

Deleted: pal-admin/trunk/src/main/java/jp/sf/pal/admin/entity/ProfilingRule.java
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/entity/ProfilingRule.java	2007-04-09 02:41:11 UTC (rev 31)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/entity/ProfilingRule.java	2007-04-09 03:48:59 UTC (rev 32)
@@ -1,22 +0,0 @@
-package jp.sf.pal.admin.entity;
-
-public class ProfilingRule
-{
-    private String id;
-
-    /**
-     * @return the id
-     */
-    public String getId()
-    {
-        return id;
-    }
-
-    /**
-     * @param id the id to set
-     */
-    public void setId(String id)
-    {
-        this.id = id;
-    }
-}

Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/entity/User.java
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/entity/User.java	2007-04-09 02:41:11 UTC (rev 31)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/entity/User.java	2007-04-09 03:48:59 UTC (rev 32)
@@ -1,16 +1,20 @@
 package jp.sf.pal.admin.entity;
 
+import java.io.Serializable;
 import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
-import org.apache.jetspeed.profiler.ProfileLocator;
+import jp.sf.pal.admin.PALAdminConstants;
 
-public class User
+public class User implements Serializable
 {
+    /**
+     * 
+     */
+    private static final long serialVersionUID = -8545253440267174975L;
+
     private String name;
 
     private String password;
@@ -21,7 +25,7 @@
 
     private List<Group> groups;
 
-    private Map<String, ProfilingRule> profilingRules;
+    private List<PrincipalRule> principalRules;
 
     private String expires;
 
@@ -35,7 +39,7 @@
     {
         roles = new ArrayList<Role>();
         groups = new ArrayList<Group>();
-        profilingRules = new HashMap<String, ProfilingRule>();
+        principalRules = new ArrayList<PrincipalRule>();
     }
 
     /**
@@ -73,17 +77,17 @@
     /**
      * @return the profileRules
      */
-    public Map<String, ProfilingRule> getProfilingRules()
+    public List<PrincipalRule> getPrincipalRules()
     {
-        return profilingRules;
+        return principalRules;
     }
 
     /**
      * @param profileRules the profileRules to set
      */
-    public void setProfilingRules(Map<String, ProfilingRule> profileRules)
+    public void setPrincipalRules(List<PrincipalRule> profileRules)
     {
-        this.profilingRules = profileRules;
+        this.principalRules = profileRules;
     }
 
     /**
@@ -168,18 +172,19 @@
         return null;
     }
 
-    public void setProfilingRuleName(String profilingRulename)
+    public void setPrincipalRuleName(String principalRulename)
     {
-        ProfilingRule profilingRule = new ProfilingRule();
-        profilingRule.setId(profilingRulename);
-        profilingRules.put(ProfileLocator.PAGE_LOCATOR, profilingRule);
+        PrincipalRule principalRule = new PrincipalRule();
+        principalRule.setProfilingRuleName(principalRulename);
+        principalRule.setLocatorName(PALAdminConstants.PAGE_LOCATOR);
+        principalRules.add(principalRule);
     }
 
-    public String getProfilingRuleName()
+    public String getPrincipalRuleName()
     {
-        if (!profilingRules.isEmpty())
+        if (!principalRules.isEmpty())
         {
-            return profilingRules.get(ProfileLocator.PAGE_LOCATOR).getId();
+            return principalRules.get(0).getProfilingRuleName();
         }
         return null;
     }

Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SecurityProviderLogic.java
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SecurityProviderLogic.java	2007-04-09 02:41:11 UTC (rev 31)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SecurityProviderLogic.java	2007-04-09 03:48:59 UTC (rev 32)
@@ -5,7 +5,6 @@
 import java.util.Calendar;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 
 import javax.faces.context.FacesContext;
@@ -14,7 +13,7 @@
 import jp.sf.pal.admin.PALAdminConstants;
 import jp.sf.pal.admin.PALAdminException;
 import jp.sf.pal.admin.entity.Group;
-import jp.sf.pal.admin.entity.ProfilingRule;
+import jp.sf.pal.admin.entity.PrincipalRule;
 import jp.sf.pal.admin.entity.Role;
 import jp.sf.pal.admin.entity.User;
 import jp.sf.pal.admin.pager.GroupPager;
@@ -361,19 +360,22 @@
                 }
             }
 
-            // Add profiling rule
-            Principal principal = PALAdminUtil.getPrincipal(getUserSubject(user
-                    .getName()), UserPrincipal.class);
-            for (Iterator<Map.Entry<String, ProfilingRule>> ite = user
-                    .getProfilingRules().entrySet().iterator(); ite.hasNext();)
+            // Add principal rule
+            Principal principal = getUserPrincipal(user.getName());
+            for (Iterator<PrincipalRule> ite = user.getPrincipalRules()
+                    .iterator(); ite.hasNext();)
+
             {
-                Map.Entry<String, ProfilingRule> e = ite.next();
-                if (!PALAdminUtil.isEmpty(e.getKey()) && e.getValue() != null
-                        && e.getValue().getId() != null)
+                PrincipalRule principalRule = ite.next();
+                if (!PALAdminUtil.isEmpty(principalRule.getLocatorName())
+                        && !PALAdminUtil.isEmpty(principalRule
+                                .getProfilingRuleName()))
                 {
-                    getProfiler().setRuleForPrincipal(principal,
-                            getProfiler().getRule(e.getValue().getId()),
-                            e.getKey());
+                    getProfiler().setRuleForPrincipal(
+                            principal,
+                            getProfiler().getRule(
+                                    principalRule.getProfilingRuleName()),
+                            principalRule.getLocatorName());
                 }
             }
 
@@ -482,7 +484,7 @@
 
             //TODO groups
             //TODO roles
-            //TODO profilingrules
+            //TODO principal rules
             return user;
         }
         catch (SecurityException e)
@@ -680,6 +682,39 @@
         return getRoleManager().roleExists(role.getName());
     }
 
+    public void removePrincipalRuleFromUser(User user,
+            PrincipalRule principalRule) throws PALAdminException
+    {
+        try
+        {
+            Iterator<org.apache.jetspeed.profiler.rules.PrincipalRule> it = getProfiler()
+                    .getRulesForPrincipal(getUserPrincipal(user.getName()))
+                    .iterator();
+            while (it.hasNext())
+            {
+                org.apache.jetspeed.profiler.rules.PrincipalRule rule = it
+                        .next();
+                if (rule.getLocatorName()
+                        .equals(principalRule.getLocatorName()))
+                {
+                    //TODO does not work??
+                    getProfiler().deletePrincipalRule(rule);
+                }
+            }
+
+        }
+        catch (Exception e)
+        {
+            logger.error(
+                    "Could not remove the principalRule from the user. user="
+                            + user + ", principalRule=" + principalRule, e);
+            throw new PALAdminException(
+                    "Could not remove the principalRule from the user. user="
+                            + user + ", principalRule=" + principalRule, e);
+        }
+
+    }
+
     //
     // Role
     //
@@ -784,6 +819,28 @@
 
     }
 
+    public void addPrincipalRuleToUser(User user, PrincipalRule principalRule)
+            throws PALAdminException
+    {
+        try
+        {
+            getProfiler()
+                    .setRuleForPrincipal(
+                            getUserPrincipal(user.getName()),
+                            getProfiler().getRule(
+                                    principalRule.getProfilingRuleName()),
+                            principalRule.getLocatorName());
+        }
+        catch (SecurityException e)
+        {
+            logger.error("Could not add the principal rule to user. user="
+                    + user + ", principalRule=" + principalRule, e);
+            throw new PALAdminException(
+                    "Could not add the principal rule to user. user=" + user
+                            + ", principalRule=" + principalRule, e);
+        }
+    }
+
     //
     // Group
     //
@@ -888,6 +945,7 @@
 
     }
 
+    //TODO String to User
     public List<String> getGroupNamesForUsername(String username)
     {
         //Debug
@@ -947,4 +1005,38 @@
         }
         return list;
     }
+
+    public List<PrincipalRule> getPrincipalRuleForUser(User user)
+    {
+        ArrayList<PrincipalRule> list = new ArrayList<PrincipalRule>();
+        try
+        {
+            Principal userPrincipal = getUserPrincipal(user.getName());
+            for (Iterator<org.apache.jetspeed.profiler.rules.PrincipalRule> ite = getProfiler()
+                    .getRulesForPrincipal(userPrincipal).iterator(); ite
+                    .hasNext();)
+            {
+                org.apache.jetspeed.profiler.rules.PrincipalRule rule = ite
+                        .next();
+                PrincipalRule principalRule = new PrincipalRule();
+                principalRule.setLocatorName(rule.getLocatorName());
+                principalRule.setProfilingRuleName(rule.getProfilingRule()
+                        .getId());
+                list.add(principalRule);
+            }
+        }
+        catch (SecurityException e)
+        {
+            logger.error("Could not get principal rules.", e);
+        }
+        return list;
+    }
+
+    private Principal getUserPrincipal(String username)
+            throws SecurityException
+    {
+        return PALAdminUtil.getPrincipal(getUserSubject(username),
+                UserPrincipal.class);
+    }
+
 }

Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/service/UserManagementService.java
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/service/UserManagementService.java	2007-04-09 02:41:11 UTC (rev 31)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/service/UserManagementService.java	2007-04-09 03:48:59 UTC (rev 32)
@@ -1,7 +1,6 @@
 package jp.sf.pal.admin.service;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -12,6 +11,7 @@
 import jp.sf.pal.admin.PALAdminException;
 import jp.sf.pal.admin.dxo.UserDxo;
 import jp.sf.pal.admin.entity.Group;
+import jp.sf.pal.admin.entity.PrincipalRule;
 import jp.sf.pal.admin.entity.Role;
 import jp.sf.pal.admin.entity.User;
 import jp.sf.pal.admin.logic.SecurityProviderLogic;
@@ -21,6 +21,7 @@
 import jp.sf.pal.admin.web.user.UserEditPage;
 import jp.sf.pal.admin.web.user.UserGroupEditPage;
 import jp.sf.pal.admin.web.user.UserListPage;
+import jp.sf.pal.admin.web.user.UserProfilingRuleEditPage;
 import jp.sf.pal.admin.web.user.UserRoleEditPage;
 
 import org.seasar.teeda.extension.util.LabelHelper;
@@ -152,17 +153,8 @@
 
     public List<Map<String, String>> getProfilingRuleNames()
     {
-        ArrayList<Map<String, String>> list = new ArrayList<Map<String, String>>();
-        for (Iterator<String> ite = securityProviderLogic
-                .getProfilingRuleNames().iterator(); ite.hasNext();)
-        {
-            Map<String, String> map = new HashMap<String, String>();
-            String value = ite.next();
-            map.put("label", value);
-            map.put("value", value);
-            list.add(map);
-        }
-        return list;
+        return PALAdminUtil.createItems(securityProviderLogic
+                .getProfilingRuleNames().iterator());
     }
 
     public boolean isUserExists(String username)
@@ -365,4 +357,60 @@
 
         return false;
     }
+
+    public void loadPage(UserProfilingRuleEditPage page)
+    {
+        List<Map<String, String>> locatorList = new ArrayList<Map<String, String>>();
+        locatorList.add(PALAdminUtil.createItem(PALAdminConstants.PAGE_LOCATOR,
+                PALAdminConstants.PAGE_LOCATOR));
+        locatorList.add(PALAdminUtil.createItem(PALAdminConstants.MENU_LOCATOR,
+                PALAdminConstants.MENU_LOCATOR));
+        page.setNewLocatorNameItems(locatorList);
+
+        page.setNewProfilingRuleNameItems(getProfilingRuleNames());
+
+        User user = new User();
+        user.setName(page.getName());
+        page.setPrincipalRulesItems(getSecurityProviderLogic()
+                .getPrincipalRuleForUser(user));
+    }
+
+    public void addPrincipalRuleToUser(UserProfilingRuleEditPage page)
+            throws PALAdminException
+    {
+        User user = new User();
+        user.setName(page.getName());
+        PrincipalRule principalRule = new PrincipalRule();
+        principalRule.setLocatorName(page.getNewLocatorName());
+        principalRule.setProfilingRuleName(page.getNewProfilingRuleName());
+        getSecurityProviderLogic().addPrincipalRuleToUser(user, principalRule);
+    }
+
+    public void removePrincipalRulesFromUser(UserProfilingRuleEditPage page)
+            throws PALAdminException
+    {
+        List<String> failedPrincipalRules = new ArrayList<String>();
+        User user = new User();
+        user.setName(page.getName());
+        String[] principalRules = page.getPrincipalRules();
+        for (int i = 0; i < principalRules.length; i++)
+        {
+            try
+            {
+                PrincipalRule principalRule = PrincipalRule
+                        .getInstance(principalRules[i]);
+                getSecurityProviderLogic().removePrincipalRuleFromUser(user,
+                        principalRule);
+            }
+            catch (PALAdminException e)
+            {
+                failedPrincipalRules.add(principalRules[i]);
+            }
+        }
+        if (failedPrincipalRules.size() > 0)
+        {
+            throw new PALAdminException("Could not remove principalRules: "
+                    + failedPrincipalRules);
+        }
+    }
 }

Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/util/PALAdminUtil.java
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/util/PALAdminUtil.java	2007-04-09 02:41:11 UTC (rev 31)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/util/PALAdminUtil.java	2007-04-09 03:48:59 UTC (rev 32)
@@ -71,12 +71,12 @@
         return buf.toString();
     }
 
-    public static String toStringFromArray(String[] strs)
+    public static String toStringFromArray(Object[] strs)
     {
         StringBuffer buf = new StringBuffer();
         for (int i = 0; i < strs.length; i++)
         {
-            buf.append(strs[i]);
+            buf.append(strs[i].toString());
             if (i + 1 < strs.length)
             {
                 buf.append(", ");

Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/user/AbstractUserPage.java
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/user/AbstractUserPage.java	2007-04-09 02:41:11 UTC (rev 31)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/user/AbstractUserPage.java	2007-04-09 03:48:59 UTC (rev 32)
@@ -16,8 +16,6 @@
 
     private String roleName;
 
-    private String profilingRuleName;
-
     private UserManagementService userManagementService;
 
     public AbstractUserPage()
@@ -54,22 +52,6 @@
     }
 
     /**
-     * @return the profilingRule
-     */
-    public String getProfilingRuleName()
-    {
-        return profilingRuleName;
-    }
-
-    /**
-     * @param profilingRule the profilingRule to set
-     */
-    public void setProfilingRuleName(String profilingRule)
-    {
-        this.profilingRuleName = profilingRule;
-    }
-
-    /**
      * @return the role
      */
     public String getRoleName()

Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/user/UserCreatePage.java
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/user/UserCreatePage.java	2007-04-09 02:41:11 UTC (rev 31)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/user/UserCreatePage.java	2007-04-09 03:48:59 UTC (rev 32)
@@ -7,26 +7,7 @@
 {
     private List<Map<String, String>> roleNameItems;
 
-    private List<Map<String, String>> profilingRuleNameItems;
-
     /**
-     * @return the profilingRuleItems
-     */
-    public List<Map<String, String>> getProfilingRuleNameItems()
-    {
-        return profilingRuleNameItems;
-    }
-
-    /**
-     * @param profilingRuleItems the profilingRuleItems to set
-     */
-    public void setProfilingRuleNameItems(
-            List<Map<String, String>> profilingRuleItems)
-    {
-        this.profilingRuleNameItems = profilingRuleItems;
-    }
-
-    /**
      * @return the roleItems
      */
     public List<Map<String, String>> getRoleNameItems()
@@ -51,8 +32,6 @@
     {
         // set pull-down
         setRoleNameItems(getUserManagementService().getRoleNames());
-        setProfilingRuleNameItems(getUserManagementService()
-                .getProfilingRuleNames());
 
         // update?
         return null;

Added: pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/user/UserProfilingRuleEditPage.java
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/user/UserProfilingRuleEditPage.java	2007-04-09 02:41:11 UTC (rev 31)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/user/UserProfilingRuleEditPage.java	2007-04-09 03:48:59 UTC (rev 32)
@@ -0,0 +1,277 @@
+package jp.sf.pal.admin.web.user;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.internal.FacesMessageUtil;
+
+import org.seasar.framework.log.Logger;
+
+import jp.sf.pal.admin.PALAdminException;
+import jp.sf.pal.admin.entity.PrincipalRule;
+import jp.sf.pal.admin.service.UserManagementService;
+import jp.sf.pal.admin.util.PALAdminUtil;
+import jp.sf.pal.admin.web.AbstractCrudPage;
+
+public class UserProfilingRuleEditPage extends AbstractCrudPage
+{
+    /**
+     * Logger for this class
+     */
+    private static final Logger logger = Logger
+            .getLogger(UserProfilingRuleEditPage.class);
+
+    private String name;
+
+    private List<Map<String, String>> newProfilingRuleNameItems;
+
+    private int newProfilingRuleNameIndex;
+
+    private String newProfilingRuleName;
+
+    private List<Map<String, String>> newLocatorNameItems;
+
+    private int newLocatorNameIndex;
+
+    private String newLocatorName;
+
+    private List<PrincipalRule> principalRulesItems;
+
+    private String[] principalRules;
+
+    private UserManagementService userManagementService;
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    public List<Map<String, String>> getNewProfilingRuleNameItems()
+    {
+        return newProfilingRuleNameItems;
+    }
+
+    public void setNewProfilingRuleNameItems(
+            List<Map<String, String>> newProfilingRuleItems)
+    {
+        this.newProfilingRuleNameItems = newProfilingRuleItems;
+    }
+
+    public List<Map<String, String>> getNewLocatorNameItems()
+    {
+        return newLocatorNameItems;
+    }
+
+    public void setNewLocatorNameItems(
+            List<Map<String, String>> newProfilingRuleTypeItems)
+    {
+        this.newLocatorNameItems = newProfilingRuleTypeItems;
+    }
+
+    public List<PrincipalRule> getPrincipalRulesItems()
+    {
+        return principalRulesItems;
+    }
+
+    public void setPrincipalRulesItems(List<PrincipalRule> profilingRulesItems)
+    {
+        this.principalRulesItems = profilingRulesItems;
+    }
+
+    /**
+     * @return the newProfilingRuleName
+     */
+    public String getNewProfilingRuleName()
+    {
+        return newProfilingRuleName;
+    }
+
+    /**
+     * @param newProfilingRuleName the newProfilingRuleName to set
+     */
+    public void setNewProfilingRuleName(String newProfilingRule)
+    {
+        this.newProfilingRuleName = newProfilingRule;
+    }
+
+    /**
+     * @return the newProfilingRuleNameIndex
+     */
+    public int getNewProfilingRuleNameIndex()
+    {
+        return newProfilingRuleNameIndex;
+    }
+
+    /**
+     * @param newProfilingRuleNameIndex the newProfilingRuleNameIndex to set
+     */
+    public void setNewProfilingRuleNameIndex(int newProfilingRuleIndex)
+    {
+        this.newProfilingRuleNameIndex = newProfilingRuleIndex;
+    }
+
+    /**
+     * @return the newLocatorName
+     */
+    public String getNewLocatorName()
+    {
+        return newLocatorName;
+    }
+
+    /**
+     * @param newLocatorName the newLocatorName to set
+     */
+    public void setNewLocatorName(String newProfilingRuleType)
+    {
+        this.newLocatorName = newProfilingRuleType;
+    }
+
+    /**
+     * @return the newLocatorNameIndex
+     */
+    public int getNewLocatorNameIndex()
+    {
+        return newLocatorNameIndex;
+    }
+
+    /**
+     * @param newLocatorNameIndex the newLocatorNameIndex to set
+     */
+    public void setNewLocatorNameIndex(int newProfilingRuleTypeIndex)
+    {
+        this.newLocatorNameIndex = newProfilingRuleTypeIndex;
+    }
+
+    /**
+     * @return the profilingRules
+     */
+    public String[] getPrincipalRules()
+    {
+        return principalRules;
+    }
+
+    /**
+     * @param profilingRules the profilingRules to set
+     */
+    public void setPrincipalRules(String[] profilingRules)
+    {
+        this.principalRules = profilingRules;
+    }
+
+    /**
+     * @return the userManagementService
+     */
+    public UserManagementService getUserManagementService()
+    {
+        return userManagementService;
+    }
+
+    /**
+     * @param userManagementService the userManagementService to set
+     */
+    public void setUserManagementService(
+            UserManagementService userManagementService)
+    {
+        this.userManagementService = userManagementService;
+    }
+
+    public String initialize()
+    {
+        return null;
+    }
+
+    public String prerender()
+    {
+        // load page
+        getUserManagementService().loadPage(this);
+
+        return null;
+    }
+
+    public String doAddProfilingRule()
+    {
+        if (getName() == null || getNewLocatorName() == null
+                || getNewProfilingRuleName() == null)
+        {
+            FacesMessageUtil
+                    .addWarnMessage("invalid.profilingRule.or.user.name");
+            return null;
+        }
+
+        try
+        {
+            getUserManagementService().addPrincipalRuleToUser(this);
+            FacesMessageUtil.addInfoMessage("added.principalRule.to.user",
+                    new Object[] { getName(), getNewLocatorName(),
+                            getNewProfilingRuleName() });
+
+            // clear
+            setNewLocatorName(null);
+            setNewProfilingRuleName(null);
+        }
+        catch (PALAdminException e)
+        {
+            FacesMessageUtil.addErrorMessage(
+                    "failed.to.add.principalRule.to.user", new Object[] {
+                            getName(), getNewLocatorName(),
+                            getNewProfilingRuleName() });
+            logger.error("Failed to add principalRule to user. user="
+                    + getName() + ", principalRule=" + getNewLocatorName()
+                    + "/" + getNewProfilingRuleName(), e);
+        }
+        return null;
+    }
+
+    public String doRemoveProfilingRule()
+    {
+        try
+        {
+            getUserManagementService().removePrincipalRulesFromUser(this);
+            FacesMessageUtil
+                    .addInfoMessage(
+                            "removed.principalRules.from.user",
+                            new Object[] {
+                                    getName(),
+                                    PALAdminUtil
+                                            .toStringFromArray(parsePrincipalRules(getPrincipalRules())) });
+
+            // clear
+            setPrincipalRules(null);
+        }
+        catch (PALAdminException e)
+        {
+            FacesMessageUtil
+                    .addErrorMessage(
+                            "failed.to.remove.principalRules.from.user",
+                            new Object[] {
+                                    getName(),
+                                    PALAdminUtil
+                                            .toStringFromArray(parsePrincipalRules(getPrincipalRules())) });
+            logger.error("Failed to remove principalRules from user. user="
+                    + getName() + ", principalRules=" + getPrincipalRules(), e);
+        }
+        return null;
+    }
+
+    private Object[] parsePrincipalRules(String[] rules)
+    {
+        List<PrincipalRule> list = new ArrayList<PrincipalRule>();
+        for (int i = 0; i < rules.length; i++)
+        {
+            list.add(PrincipalRule.getInstance(rules[i]));
+        }
+        return list.toArray();
+    }
+
+    public boolean isProfilingRulesForUser()
+    {
+        return getPrincipalRulesItems().size() > 0;
+    }
+
+}


Property changes on: pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/user/UserProfilingRuleEditPage.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: pal-admin/trunk/src/main/resources/appMessages.properties
===================================================================
--- pal-admin/trunk/src/main/resources/appMessages.properties	2007-04-09 02:41:11 UTC (rev 31)
+++ pal-admin/trunk/src/main/resources/appMessages.properties	2007-04-09 03:48:59 UTC (rev 32)
@@ -31,3 +31,9 @@
 invalid.role.or.user.name=Invalid role or user name.
 role.exists.in.user=The role({1}) exists in the user({0}).
 
+added.principalRule.to.user= Added the profiling rule({1}/{2}) to the user({0}).
+failed.to.add.principalRule.to.user=Failed to add the profiling rule({1}/{2}) to the user({0}).
+removed.principalRules.from.user=Removed profiling rules({1}) from the user({0}).
+failed.to.remove.principalRules.from.user=Failed to remove profiling rules({1}) from the user({0}).
+invalid.principalRule.or.user.name=Invalid profiling rule or user name.
+principalRule.exists.in.user=The profiling rule({1}/{2}) exists in the user({0}).

Modified: pal-admin/trunk/src/main/resources/jp/sf/pal/admin/web/user/label.properties
===================================================================
--- pal-admin/trunk/src/main/resources/jp/sf/pal/admin/web/user/label.properties	2007-04-09 02:41:11 UTC (rev 31)
+++ pal-admin/trunk/src/main/resources/jp/sf/pal/admin/web/user/label.properties	2007-04-09 03:48:59 UTC (rev 32)
@@ -7,6 +7,7 @@
 userList=User List
 userInformation=User Information
 basicTab=Basic
+profilingRuleTab=Rule
 
 # userList
 userList.delete=Delete
@@ -33,5 +34,8 @@
 userRoleEdit.role=Role
 userRoleEdit.notFound=Not found.
 
+# userProfilingRuleEdit
+userProfilingRuleEdit.newProfilingRule=New Profiling Rule
+userProfilingRuleEdit.profilingrule=Profiling Rule
+userProfilingRuleEdit.notFound=Not found.
 
-

Modified: pal-admin/trunk/src/main/webapp/view/user/userConfirm.html
===================================================================
--- pal-admin/trunk/src/main/webapp/view/user/userConfirm.html	2007-04-09 02:41:11 UTC (rev 31)
+++ pal-admin/trunk/src/main/webapp/view/user/userConfirm.html	2007-04-09 03:48:59 UTC (rev 32)
@@ -51,11 +51,6 @@
 	        <td class="portlet-section-body"><span id="roleName">ROLE</span><input type="hidden" id="roleName-hidden" /></td>
 	        <td class="portlet-section-body"><span id="roleNameMessage"></span></td>
         </tr>
-        <tr>
-            <td class="portlet-section-subheader"><label id="profilingRuleLabel">Profiling Rule</label></td>
-	        <td class="portlet-section-body"><span id="profilingRuleName">RULE</span><input type="hidden" id="profilingRuleName-hidden" /></td>
-	        <td class="portlet-section-body"><span id="profilingRuleNameMessage"></span></td>
-        </tr>
       </div>
     </table>
     

Modified: pal-admin/trunk/src/main/webapp/view/user/userCreate.html
===================================================================
--- pal-admin/trunk/src/main/webapp/view/user/userCreate.html	2007-04-09 02:41:11 UTC (rev 31)
+++ pal-admin/trunk/src/main/webapp/view/user/userCreate.html	2007-04-09 03:48:59 UTC (rev 32)
@@ -54,15 +54,6 @@
 	        </td>
 	        <td class="portlet-section-body"><span id="roleMessage"></span></td>
         </tr>
-        <tr>
-            <td class="portlet-section-subheader"><label id="profilingRuleLabel">Profiling Rule</label></td>
-	        <td class="portlet-section-body">
-	            <select id="profilingRuleNameItems">
-	                <option>RULE</option>
-	            </select>
-	        </td>
-	        <td class="portlet-section-body"><span id="profilingRuleMessage"></span></td>
-        </tr>
     </table>
     
     <div>

Modified: pal-admin/trunk/src/main/webapp/view/user/userEdit.html
===================================================================
--- pal-admin/trunk/src/main/webapp/view/user/userEdit.html	2007-04-09 02:41:11 UTC (rev 31)
+++ pal-admin/trunk/src/main/webapp/view/user/userEdit.html	2007-04-09 03:48:59 UTC (rev 32)
@@ -39,6 +39,10 @@
         <a id="jumpUserGroupEdit" href="userGroupEdit.html?fixed_crudType=3&name=name" style="text-decoration: none;">
             <span id="groupTabLabel">Group</span>
         </a>
+        |
+        <a id="jumpUserProfilingRuleEdit" href="userProfilingRuleEdit.html?fixed_crudType=3&name=name" style="text-decoration: none;">
+            <span id="profilingRuleTabLabel">Profiling Rule</span>
+        </a>
     </div>
 
     <table class="tablebg">
@@ -48,31 +52,26 @@
 	        <td class="portlet-section-body"><span id="nameMessage"></span></td>
         </tr>
         <tr>
+            <td class="portlet-section-subheader"><label id="passwordLabel">Password</label></td>
+	        <td class="portlet-section-body"><input type="password" id="password"/></td>
+	        <td class="portlet-section-body"><span id="passwordMessage"></span></td>
+        </tr>
+        <tr>
             <td class="portlet-section-subheader"><label id="lastLogonLabel">Last Logon</label></td>
 	        <td class="portlet-section-body"><span id="lastLogon">April 7, 2007 6:44:43 AM JST</span></td>
 	        <td class="portlet-section-body"></td>
         </tr>
         <tr>
-            <td class="portlet-section-subheader"><label id="expirationDateLabel">Expiration Date</label></td>
-	        <td class="portlet-section-body"><span id="expirationDate">April 7, 2007 6:44:43 AM JST</span></td>
-	        <td class="portlet-section-body"></td>
+            <td class="portlet-section-subheader"><label id="userEnabledLabel">User Enabled</label></td>
+	        <td class="portlet-section-body"><input type="checkbox" id="userEnabled"/></td>
+	        <td class="portlet-section-body"><span id="userEnabledMessage"></span></td>
         </tr>
         <tr>
-            <td class="portlet-section-subheader"><label id="passwordLabel">Password</label></td>
-	        <td class="portlet-section-body"><input type="password" id="password"/></td>
-	        <td class="portlet-section-body"><span id="passwordMessage"></span></td>
-        </tr>
-        <tr>
             <td class="portlet-section-subheader"><label id="changePasswordLabel">Change Password on Next Login</label></td>
 	        <td class="portlet-section-body"><input type="checkbox" id="updateRequired"/></td>
 	        <td class="portlet-section-body"><span id="updateRequiredMessage"></span></td>
         </tr>
         <tr>
-            <td class="portlet-section-subheader"><label id="userEnabledLabel">User Enabled</label></td>
-	        <td class="portlet-section-body"><input type="checkbox" id="userEnabled"/></td>
-	        <td class="portlet-section-body"><span id="userEnabledMessage"></span></td>
-        </tr>
-        <tr>
             <td class="portlet-section-subheader"><label id="expiresLabel">Expires</label></td>
 	        <td class="portlet-section-body">
 	            <select id="expiresItems">
@@ -81,6 +80,11 @@
 	        </td>
 	        <td class="portlet-section-body"><span id="expiresMessage"></span></td>
         </tr>
+        <tr>
+            <td class="portlet-section-subheader"><label id="expirationDateLabel">Expiration Date</label></td>
+	        <td class="portlet-section-body"><span id="expirationDate">April 7, 2007 6:44:43 AM JST</span></td>
+	        <td class="portlet-section-body"></td>
+        </tr>
     </table>
     
     <div>

Modified: pal-admin/trunk/src/main/webapp/view/user/userGroupEdit.html
===================================================================
--- pal-admin/trunk/src/main/webapp/view/user/userGroupEdit.html	2007-04-09 02:41:11 UTC (rev 31)
+++ pal-admin/trunk/src/main/webapp/view/user/userGroupEdit.html	2007-04-09 03:48:59 UTC (rev 32)
@@ -39,6 +39,10 @@
         </a>
         |
         <span id="groupTabLabel">Group</span>
+        |
+        <a id="jumpUserProfilingRuleEdit" href="userProfilingRuleEdit.html?fixed_crudType=3&name=name" style="text-decoration: none;">
+            <span id="profilingRuleTabLabel">Profiling Rule</span>
+        </a>
     </div>
 
     <table class="tablebg">

Added: pal-admin/trunk/src/main/webapp/view/user/userProfilingRuleEdit.html
===================================================================
--- pal-admin/trunk/src/main/webapp/view/user/userProfilingRuleEdit.html	2007-04-09 02:41:11 UTC (rev 31)
+++ pal-admin/trunk/src/main/webapp/view/user/userProfilingRuleEdit.html	2007-04-09 03:48:59 UTC (rev 32)
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="stylesheet" type="text/css" href="../../css/global.css"/>
+</head>
+<body>
+<form id="UserProfilingRuleEditForm"><input type="hidden" id="crudType" />
+<!-- tab: BEGIN -->
+<div style="padding: 0px 0px 3px 10px; margin:5px 0px;border-bottom:1px solid #000000;">
+  <span id="userTabLabel" style="border-top:1px solid #000000;border-right:1px solid #000000;border-bottom:1px solid #ffffff;border-left:1px solid #000000;padding: 3px 5px 3px 5px; margin: 0px 0px;">User</span>
+  <a id="jumpRoleList" href="../role/roleList.html" style="text-decoration: none;">
+    <span id="roleTabLabel" style="font-weight: bold;color:#ffffff;background-color:#999999;border:1px solid #000000; padding: 3px 5px 3px 5px; margin: 0px 0px;">Role</span>
+  </a>
+  <a id="jumpGroupList" href="../group/groupList.html" style="text-decoration: none;">
+    <span id="groupTabLabel" style="font-weight: bold;color:#ffffff;background-color:#999999;border:1px solid #000000; padding: 3px 5px 3px 5px; margin: 0px 0px;">Group</span>
+  </a>
+</div>
+<!-- tab: END -->
+
+<div>
+    <span id="allMessages" fatalClass="portlet-msg-error" errorClass="portlet-msg-error" warnClass="portlet-msg-alert" infoClass="portlet-msg-info"></span>
+</div>
+
+<!-- content: BEGIN -->
+<div style="padding:5px 0px;">
+    <div class="portlet-section-header">
+      <label id="userInformationLabel">User Information</label>
+    </div>
+
+    <div>
+        <a id="jumpUserEdit" href="userEdit.html?fixed_crudType=3&name=name" style="text-decoration: none;">
+            <span id="basicTabLabel">Basic</span>
+        </a>
+        |
+        <a id="jumpUserRoleEdit" href="userRoleEdit.html?fixed_crudType=3&name=name" style="text-decoration: none;">
+            <span id="roleTabLabel">Role</span>
+        </a>
+        |
+        <a id="jumpUserGroupEdit" href="userGroupEdit.html?fixed_crudType=3&name=name" style="text-decoration: none;">
+            <span id="groupTabLabel">Group</span>
+        </a>
+        |
+        <span id="profilingRuleTabLabel">Profiling Rule</span>
+    </div>
+
+    <table class="tablebg">
+        <tr>
+            <td class="portlet-section-subheader"><label id="newProfilingRuleLabel">New Profiling Rule</label></td>
+	        <td class="portlet-section-body">
+	            <select id="newLocatorNameItems" style="width:60px;">
+	                <option>NEW LOCATOR</option>
+	            </select>
+	            <select id="newProfilingRuleNameItems" style="width:140px;">
+	                <option>NEW RULE</option>
+	            </select>
+	            <input type="button" id="doAddProfilingRule" value="Add" class="portlet-form-button" onclick="location.href='userProfilingRuleEdit.html'"/>
+	        </td>
+	        <td><span id="newProfilingRuleMessage"></span></td>
+        </tr>
+        <tr>
+            <td class="portlet-section-subheader"><label id="profilingRuleLabel">Profiling Rule</label></td>
+	        <td class="portlet-section-body">
+	          <div id="isProfilingRulesForUser">
+	            <select id="principalRulesItems" multiple="multiple" size="10" style="width:200px;">
+	                <option>RULE</option>
+	            </select>
+                <input type="button" id="doRemoveProfilingRule" value="Remove"
+                    onclick="location.href='userProfilingRuleEdit.html'" class="portlet-form-button"/>
+              </div>
+	          <div id="isNotProfilingRulesForUser">
+	            <label id="notFoundLabel">Not found.</label>
+	          </div>
+	        </td>
+            <td><span id="profilingRulesMessage"></span></td>
+        </tr>
+    </table>
+    
+    <div>
+      <input type="button" id="jumpUserList" value="Back"
+	    onclick="location.href='userList.html'" class="portlet-form-button"/>
+      <div id="isNotRead" style="display:inline;">
+	    <input type="hidden" id="name-hidden"/>
+      </div>
+    </div>
+</div>
+<!-- content: BEGIN -->
+</form>
+</body></html>


Property changes on: pal-admin/trunk/src/main/webapp/view/user/userProfilingRuleEdit.html
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: pal-admin/trunk/src/main/webapp/view/user/userRoleEdit.html
===================================================================
--- pal-admin/trunk/src/main/webapp/view/user/userRoleEdit.html	2007-04-09 02:41:11 UTC (rev 31)
+++ pal-admin/trunk/src/main/webapp/view/user/userRoleEdit.html	2007-04-09 03:48:59 UTC (rev 32)
@@ -39,6 +39,10 @@
         <a id="jumpUserGroupEdit" href="userGroupEdit.html?fixed_crudType=3&name=name" style="text-decoration: none;">
             <span id="groupTabLabel">Group</span>
         </a>
+        |
+        <a id="jumpUserProfilingRuleEdit" href="userProfilingRuleEdit.html?fixed_crudType=3&name=name" style="text-decoration: none;">
+            <span id="profilingRuleTabLabel">Profiling Rule</span>
+        </a>
     </div>
 
     <table class="tablebg">


pal-cvs メーリングリストの案内
Back to archive index