[pal-cvs 3917] [1652] renamed date on delete, and checked existing data.

svnno****@sourc***** svnno****@sourc*****
2009年 1月 1日 (木) 06:31:32 JST


Revision: 1652
          http://svn.sourceforge.jp/view?root=pal&view=rev&rev=1652
Author:   shinsuke
Date:     2009-01-01 06:31:23 +0900 (Thu, 01 Jan 2009)

Log Message:
-----------
renamed date on delete, and checked existing data.

Modified Paths:
--------------
    userinfo/trunk/src/main/java/jp/sf/pal/userinfo/UserInfoConstants.java
    userinfo/trunk/src/main/java/jp/sf/pal/userinfo/action/GroupInfoAction.java
    userinfo/trunk/src/main/java/jp/sf/pal/userinfo/action/RoleInfoAction.java
    userinfo/trunk/src/main/java/jp/sf/pal/userinfo/action/UserInfoAction.java
    userinfo/trunk/src/main/java/jp/sf/pal/userinfo/service/GroupInfoService.java
    userinfo/trunk/src/main/java/jp/sf/pal/userinfo/service/RoleInfoService.java
    userinfo/trunk/src/main/java/jp/sf/pal/userinfo/service/UserInfoService.java
    userinfo/trunk/src/main/resources/application.properties
    userinfo/trunk/src/main/resources/application_ja.properties


-------------- next part --------------
Modified: userinfo/trunk/src/main/java/jp/sf/pal/userinfo/UserInfoConstants.java
===================================================================
--- userinfo/trunk/src/main/java/jp/sf/pal/userinfo/UserInfoConstants.java	2008-12-31 21:26:10 UTC (rev 1651)
+++ userinfo/trunk/src/main/java/jp/sf/pal/userinfo/UserInfoConstants.java	2008-12-31 21:31:23 UTC (rev 1652)
@@ -14,4 +14,6 @@
 
     public static final String USER_PASSWORD = "jp.sf.pal.userinfo.PASSWORD";
 
+    public static final String DELETED_PREFIX = "_DEL_";
+
 }

Modified: userinfo/trunk/src/main/java/jp/sf/pal/userinfo/action/GroupInfoAction.java
===================================================================
--- userinfo/trunk/src/main/java/jp/sf/pal/userinfo/action/GroupInfoAction.java	2008-12-31 21:26:10 UTC (rev 1651)
+++ userinfo/trunk/src/main/java/jp/sf/pal/userinfo/action/GroupInfoAction.java	2008-12-31 21:31:23 UTC (rev 1652)
@@ -157,6 +157,17 @@
 
     @Execute(validator = true, input = "edit.jsp")
     public String confirm() {
+        if (groupInfoForm.mode == CommonConstants.CREATE_MODE) {
+            GroupInfo groupInfo = groupInfoService
+                    .getGroupInfo(groupInfoForm.groupId);
+            if (groupInfo != null) {
+                // throw an exception
+                throw new ActionMessagesException(
+                        "errors.group_already_exists",
+                        new Object[] { groupInfoForm.groupId });
+            }
+        }
+
         return "confirm.jsp";
     }
 
@@ -286,6 +297,13 @@
             }
             groupInfo.setUpdatedBy(request.getRemoteUser());
         } else {
+            groupInfo = groupInfoService.getGroupInfo(groupInfoForm.groupId);
+            if (groupInfo != null) {
+                // throw an exception
+                throw new ActionMessagesException(
+                        "errors.group_already_exists",
+                        new Object[] { groupInfoForm.groupId });
+            }
             groupInfo = new GroupInfo();
             String remoteGroupInfo = request.getRemoteUser();
             groupInfo.setUpdatedBy(remoteGroupInfo);

Modified: userinfo/trunk/src/main/java/jp/sf/pal/userinfo/action/RoleInfoAction.java
===================================================================
--- userinfo/trunk/src/main/java/jp/sf/pal/userinfo/action/RoleInfoAction.java	2008-12-31 21:26:10 UTC (rev 1651)
+++ userinfo/trunk/src/main/java/jp/sf/pal/userinfo/action/RoleInfoAction.java	2008-12-31 21:31:23 UTC (rev 1652)
@@ -157,6 +157,16 @@
 
     @Execute(validator = true, input = "edit.jsp")
     public String confirm() {
+        if (roleInfoForm.mode == CommonConstants.CREATE_MODE) {
+            RoleInfo roleInfo = roleInfoService
+                    .getRoleInfo(roleInfoForm.roleId);
+            if (roleInfo != null) {
+                // throw an exception
+                throw new ActionMessagesException("errors.role_already_exists",
+                        new Object[] { roleInfoForm.roleId });
+            }
+        }
+
         return "confirm.jsp";
     }
 
@@ -284,6 +294,12 @@
             }
             roleInfo.setUpdatedBy(request.getRemoteUser());
         } else {
+            roleInfo = roleInfoService.getRoleInfo(roleInfoForm.roleId);
+            if (roleInfo != null) {
+                // throw an exception
+                throw new ActionMessagesException("errors.role_already_exists",
+                        new Object[] { roleInfoForm.roleId });
+            }
             roleInfo = new RoleInfo();
             String remoteRoleInfo = request.getRemoteUser();
             roleInfo.setUpdatedBy(remoteRoleInfo);

Modified: userinfo/trunk/src/main/java/jp/sf/pal/userinfo/action/UserInfoAction.java
===================================================================
--- userinfo/trunk/src/main/java/jp/sf/pal/userinfo/action/UserInfoAction.java	2008-12-31 21:26:10 UTC (rev 1651)
+++ userinfo/trunk/src/main/java/jp/sf/pal/userinfo/action/UserInfoAction.java	2008-12-31 21:31:23 UTC (rev 1652)
@@ -172,6 +172,16 @@
 
     @Execute(validator = true, input = "edit.jsp")
     public String confirm() {
+        if (userInfoForm.mode == CommonConstants.CREATE_MODE) {
+            UserInfo userInfo = userInfoService
+                    .getUserInfo(userInfoForm.userId);
+            if (userInfo != null) {
+                // throw an exception
+                throw new ActionMessagesException("errors.user_already_exists",
+                        new Object[] { userInfoForm.userId });
+            }
+        }
+
         if (userInfoService.isPasswordEnabled()
                 && !StringUtils.isEmpty(userInfoForm.password)) {
             if (!userInfoForm.password.equals(userInfoForm.passwordConfirm)) {
@@ -442,6 +452,12 @@
             }
             userInfo.setUpdatedBy(request.getRemoteUser());
         } else {
+            userInfo = userInfoService.getUserInfo(userInfoForm.userId);
+            if (userInfo != null) {
+                // throw an exception
+                throw new ActionMessagesException("errors.user_already_exists",
+                        new Object[] { userInfoForm.userId });
+            }
             userInfo = new UserInfo();
             String remoteUserInfo = request.getRemoteUser();
             userInfo.setUpdatedBy(remoteUserInfo);

Modified: userinfo/trunk/src/main/java/jp/sf/pal/userinfo/service/GroupInfoService.java
===================================================================
--- userinfo/trunk/src/main/java/jp/sf/pal/userinfo/service/GroupInfoService.java	2008-12-31 21:26:10 UTC (rev 1651)
+++ userinfo/trunk/src/main/java/jp/sf/pal/userinfo/service/GroupInfoService.java	2008-12-31 21:31:23 UTC (rev 1652)
@@ -6,12 +6,15 @@
 import java.util.Date;
 import java.util.List;
 
+import jp.sf.pal.userinfo.UserInfoConstants;
 import jp.sf.pal.userinfo.common.CommonException;
 import jp.sf.pal.userinfo.common.dxo.PagerDxo;
 import jp.sf.pal.userinfo.common.util.PagingResultBeanWrapper;
 import jp.sf.pal.userinfo.db.allcommon.cbean.PagingResultBean;
 import jp.sf.pal.userinfo.db.cbean.GroupInfoCB;
+import jp.sf.pal.userinfo.db.cbean.GroupMappingCB;
 import jp.sf.pal.userinfo.db.exbhv.GroupInfoBhv;
+import jp.sf.pal.userinfo.db.exbhv.GroupMappingBhv;
 import jp.sf.pal.userinfo.db.exentity.GroupInfo;
 import jp.sf.pal.userinfo.pager.GroupInfoPager;
 import jp.sf.pal.userinfo.plugin.PortalPlugin;
@@ -24,6 +27,8 @@
 
     private transient GroupInfoBhv groupInfoBhv;
 
+    private transient GroupMappingBhv groupMappingBhv;
+
     private PagerDxo pagerDxo;
 
     private PortalPlugin portalPlugin;
@@ -107,15 +112,35 @@
         cb.query().setGroupId_Equal(groupId);
         GroupInfo groupInfo = groupInfoBhv.selectEntity(cb);
 
-        // TODO throw an exception
+        // throw an exception
+        if (groupInfo == null) {
+            throw new CommonException("errors.could_not_find_groupInfo",
+                    new Object[] {});
+        }
 
-        groupInfo.setDeletedBy(name);
-        groupInfo.setDeletedTime(new Timestamp(new Date().getTime()));
-        groupInfoBhv.update(groupInfo);
+        // delete mapping
+        GroupMappingCB cb3 = new GroupMappingCB();
+        cb3.query().setGroupId_Equal(groupId);
+        groupMappingBhv.queryDelete(cb3);
 
+        // delete
+        groupInfoBhv.delete(groupInfo);
+
         if (portalPlugin.isAvailable()) {
             portalPlugin.delete(groupInfo);
         }
+
+        // backup
+        long now = new Date().getTime();
+        StringBuilder buf = new StringBuilder(UserInfoConstants.DELETED_PREFIX);
+        buf.append(now);
+        buf.append("_");
+        buf.append(groupId);
+        groupInfo.setGroupId(buf.length() > 255 ? buf.substring(0, 255) : buf
+                .toString());
+        groupInfo.setDeletedBy(name);
+        groupInfo.setDeletedTime(new Timestamp(now));
+        groupInfoBhv.insert(groupInfo);
     }
 
     public List<GroupInfo> getAvailableGroupList(String[] selectedGroups,
@@ -182,4 +207,12 @@
         this.portalPlugin = portalPlugin;
     }
 
+    public GroupMappingBhv getGroupMappingBhv() {
+        return groupMappingBhv;
+    }
+
+    public void setGroupMappingBhv(GroupMappingBhv groupMappingBhv) {
+        this.groupMappingBhv = groupMappingBhv;
+    }
+
 }

Modified: userinfo/trunk/src/main/java/jp/sf/pal/userinfo/service/RoleInfoService.java
===================================================================
--- userinfo/trunk/src/main/java/jp/sf/pal/userinfo/service/RoleInfoService.java	2008-12-31 21:26:10 UTC (rev 1651)
+++ userinfo/trunk/src/main/java/jp/sf/pal/userinfo/service/RoleInfoService.java	2008-12-31 21:31:23 UTC (rev 1652)
@@ -6,12 +6,15 @@
 import java.util.Date;
 import java.util.List;
 
+import jp.sf.pal.userinfo.UserInfoConstants;
 import jp.sf.pal.userinfo.common.CommonException;
 import jp.sf.pal.userinfo.common.dxo.PagerDxo;
 import jp.sf.pal.userinfo.common.util.PagingResultBeanWrapper;
 import jp.sf.pal.userinfo.db.allcommon.cbean.PagingResultBean;
 import jp.sf.pal.userinfo.db.cbean.RoleInfoCB;
+import jp.sf.pal.userinfo.db.cbean.RoleMappingCB;
 import jp.sf.pal.userinfo.db.exbhv.RoleInfoBhv;
+import jp.sf.pal.userinfo.db.exbhv.RoleMappingBhv;
 import jp.sf.pal.userinfo.db.exentity.RoleInfo;
 import jp.sf.pal.userinfo.pager.RoleInfoPager;
 import jp.sf.pal.userinfo.plugin.PortalPlugin;
@@ -24,6 +27,8 @@
 
     private transient RoleInfoBhv roleInfoBhv;
 
+    private transient RoleMappingBhv roleMappingBhv;
+
     private PagerDxo pagerDxo;
 
     private PortalPlugin portalPlugin;
@@ -106,15 +111,35 @@
         cb.query().setRoleId_Equal(roleId);
         RoleInfo roleInfo = roleInfoBhv.selectEntity(cb);
 
-        // TODO throw an exception
+        // throw an exception
+        if (roleInfo == null) {
+            throw new CommonException("errors.could_not_find_roleInfo",
+                    new Object[] {});
+        }
 
-        roleInfo.setDeletedBy(name);
-        roleInfo.setDeletedTime(new Timestamp(new Date().getTime()));
-        roleInfoBhv.update(roleInfo);
+        // delete mapping
+        RoleMappingCB cb3 = new RoleMappingCB();
+        cb3.query().setRoleId_Equal(roleId);
+        roleMappingBhv.queryDelete(cb3);
 
+        // delete
+        roleInfoBhv.delete(roleInfo);
+
         if (portalPlugin.isAvailable()) {
             portalPlugin.delete(roleInfo);
         }
+
+        // backup
+        long now = new Date().getTime();
+        StringBuilder buf = new StringBuilder(UserInfoConstants.DELETED_PREFIX);
+        buf.append(now);
+        buf.append("_");
+        buf.append(roleId);
+        roleInfo.setRoleId(buf.length() > 255 ? buf.substring(0, 255) : buf
+                .toString());
+        roleInfo.setDeletedBy(name);
+        roleInfo.setDeletedTime(new Timestamp(now));
+        roleInfoBhv.insert(roleInfo);
     }
 
     public List<RoleInfo> getAvailableRoleList(String[] selectedRoles,
@@ -181,4 +206,12 @@
         this.portalPlugin = portalPlugin;
     }
 
+    public RoleMappingBhv getRoleMappingBhv() {
+        return roleMappingBhv;
+    }
+
+    public void setRoleMappingBhv(RoleMappingBhv roleMappingBhv) {
+        this.roleMappingBhv = roleMappingBhv;
+    }
+
 }

Modified: userinfo/trunk/src/main/java/jp/sf/pal/userinfo/service/UserInfoService.java
===================================================================
--- userinfo/trunk/src/main/java/jp/sf/pal/userinfo/service/UserInfoService.java	2008-12-31 21:26:10 UTC (rev 1651)
+++ userinfo/trunk/src/main/java/jp/sf/pal/userinfo/service/UserInfoService.java	2008-12-31 21:31:23 UTC (rev 1652)
@@ -5,6 +5,7 @@
 import java.util.Date;
 import java.util.List;
 
+import jp.sf.pal.userinfo.UserInfoConstants;
 import jp.sf.pal.userinfo.common.CommonException;
 import jp.sf.pal.userinfo.common.dxo.PagerDxo;
 import jp.sf.pal.userinfo.common.util.PagingResultBeanWrapper;
@@ -158,15 +159,40 @@
         cb.query().setUserId_Equal(userId);
         UserInfo userInfo = userInfoBhv.selectEntity(cb);
 
-        // TODO throw an exception
+        // throw an exception
+        if (userInfo == null) {
+            throw new CommonException("errors.could_not_find_userInfo",
+                    new Object[] {});
+        }
 
-        userInfo.setDeletedBy(name);
-        userInfo.setDeletedTime(new Timestamp(new Date().getTime()));
-        userInfoBhv.update(userInfo);
+        // delete mapping
+        RoleMappingCB cb2 = new RoleMappingCB();
+        cb2.query().setUserId_Equal(userId);
+        roleMappingBhv.queryDelete(cb2);
 
+        GroupMappingCB cb3 = new GroupMappingCB();
+        cb3.query().setUserId_Equal(userId);
+        groupMappingBhv.queryDelete(cb3);
+
+        // delete
+        userInfoBhv.delete(userInfo);
+
         if (portalPlugin.isAvailable()) {
             portalPlugin.delete(userInfo);
         }
+
+        // backup
+        long now = new Date().getTime();
+        StringBuilder buf = new StringBuilder(UserInfoConstants.DELETED_PREFIX);
+        buf.append(now);
+        buf.append("_");
+        buf.append(userId);
+        userInfo.setUserId(buf.length() > 255 ? buf.substring(0, 255) : buf
+                .toString());
+        userInfo.setDeletedBy(name);
+        userInfo.setDeletedTime(new Timestamp(now));
+        userInfoBhv.insert(userInfo);
+
     }
 
     public boolean isPasswordEnabled() {

Modified: userinfo/trunk/src/main/resources/application.properties
===================================================================
--- userinfo/trunk/src/main/resources/application.properties	2008-12-31 21:26:10 UTC (rev 1651)
+++ userinfo/trunk/src/main/resources/application.properties	2008-12-31 21:31:23 UTC (rev 1652)
@@ -58,13 +58,16 @@
 errors.could_not_find_groupInfo=Could not find the group information({0}).
 errors.could_not_access_portal_info=Could not access Portal information.
 errors.system_error_occurred_on_portal=System error occurred on Portal.
-errors.role_already_exists=Role already exists on Portal.
-errors.group_already_exists=Group already exists on Portal.
-errors.role_does_not_exist=Role does not exist on Portal.
-errors.group_does_not_exist=Group does not exist on Portal.
-errors.user_already_exists=User already exists on Portal.
-errors.user_does_not_exist=User does not exist on Portal.
+errors.role_already_exists_on_portal=Role already exists on Portal.
+errors.group_already_exists_on_portal=Group already exists on Portal.
+errors.user_already_exists_on_portal=User already exists on Portal.
+errors.role_does_not_exist_on_portal=Role does not exist on Portal.
+errors.group_does_not_exist_on_portal=Group does not exist on Portal.
+errors.user_does_not_exist_on_portal=User does not exist on Portal.
 errors.invalid_password_confirm=Password(Confirm) is different from Password.
+errors.role_already_exists=Role already exists.
+errors.group_already_exists=Group already exists.
+errors.user_already_exists=User already exists.
 
 labels.detail=Detail
 labels.create=Create

Modified: userinfo/trunk/src/main/resources/application_ja.properties
===================================================================
--- userinfo/trunk/src/main/resources/application_ja.properties	2008-12-31 21:26:10 UTC (rev 1651)
+++ userinfo/trunk/src/main/resources/application_ja.properties	2008-12-31 21:31:23 UTC (rev 1652)
@@ -51,13 +51,16 @@
 errors.could_not_find_groupInfo=\u30b0\u30eb\u30fc\u30d7\u60c5\u5831 {0} \u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002
 errors.could_not_access_portal_info=\u30dd\u30fc\u30bf\u30eb\u306e\u60c5\u5831\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002
 errors.system_error_occurred_on_portal=\u30dd\u30fc\u30bf\u30eb\u4e0a\u3067\u30b7\u30b9\u30c6\u30e0\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002
-errors.role_already_exists=\u65e2\u306b\u30dd\u30fc\u30bf\u30eb\u4e0a\u306b\u305d\u306e\u30ed\u30fc\u30eb\u304c\u5b58\u5728\u3057\u307e\u3059\u3002
-errors.group_already_exists=\u65e2\u306b\u30dd\u30fc\u30bf\u30eb\u4e0a\u306b\u305d\u306e\u30b0\u30eb\u30fc\u30d7\u304c\u5b58\u5728\u3057\u307e\u3059\u3002
-errors.role_does_not_exist=\u30dd\u30fc\u30bf\u30eb\u4e0a\u306b\u305d\u306e\u30ed\u30fc\u30eb\u304c\u5b58\u5728\u3057\u307e\u305b\u3093\u3002
-errors.group_does_not_exist=\u30dd\u30fc\u30bf\u30eb\u4e0a\u306b\u305d\u306e\u30b0\u30eb\u30fc\u30d7\u304c\u5b58\u5728\u3057\u307e\u305b\u3093\u3002
-errors.user_already_exists=\u65e2\u306b\u30dd\u30fc\u30bf\u30eb\u4e0a\u306b\u305d\u306e\u30e6\u30fc\u30b6\u30fc\u304c\u5b58\u5728\u3057\u307e\u3059\u3002
-errors.user_does_not_exist=\u30dd\u30fc\u30bf\u30eb\u4e0a\u306b\u305d\u306e\u30e6\u30fc\u30b6\u30fc\u304c\u5b58\u5728\u3057\u307e\u305b\u3093\u3002
+errors.role_already_exists_on_portal=\u65e2\u306b\u30dd\u30fc\u30bf\u30eb\u4e0a\u306b\u305d\u306e\u30ed\u30fc\u30eb\u304c\u5b58\u5728\u3057\u307e\u3059\u3002
+errors.group_already_exists_on_portal=\u65e2\u306b\u30dd\u30fc\u30bf\u30eb\u4e0a\u306b\u305d\u306e\u30b0\u30eb\u30fc\u30d7\u304c\u5b58\u5728\u3057\u307e\u3059\u3002
+errors.user_already_exists_on_portal=\u65e2\u306b\u30dd\u30fc\u30bf\u30eb\u4e0a\u306b\u305d\u306e\u30e6\u30fc\u30b6\u30fc\u304c\u5b58\u5728\u3057\u307e\u3059\u3002
+errors.role_does_not_exist_on_portal=\u30dd\u30fc\u30bf\u30eb\u4e0a\u306b\u305d\u306e\u30ed\u30fc\u30eb\u304c\u5b58\u5728\u3057\u307e\u305b\u3093\u3002
+errors.group_does_not_exist_on_portal=\u30dd\u30fc\u30bf\u30eb\u4e0a\u306b\u305d\u306e\u30b0\u30eb\u30fc\u30d7\u304c\u5b58\u5728\u3057\u307e\u305b\u3093\u3002
+errors.user_does_not_exist_on_portal=\u30dd\u30fc\u30bf\u30eb\u4e0a\u306b\u305d\u306e\u30e6\u30fc\u30b6\u30fc\u304c\u5b58\u5728\u3057\u307e\u305b\u3093\u3002
 errors.invalid_password_confirm=\u300c\u30d1\u30b9\u30ef\u30fc\u30c9(\u78ba\u8a8d)\u300d\u304c\u300c\u30d1\u30b9\u30ef\u30fc\u30c9\u300d\u3068\u7570\u306a\u308a\u307e\u3059\u3002
+errors.role_already_exists=\u65e2\u306b\u305d\u306e\u30ed\u30fc\u30eb\u304c\u5b58\u5728\u3057\u307e\u3059\u3002
+errors.group_already_exists=\u65e2\u306b\u305d\u306e\u30b0\u30eb\u30fc\u30d7\u304c\u5b58\u5728\u3057\u307e\u3059\u3002
+errors.user_already_exists=\u65e2\u306b\u305d\u306e\u30e6\u30fc\u30b6\u30fc\u304c\u5b58\u5728\u3057\u307e\u3059\u3002
 
 labels.detail=\u8a73\u7d30
 labels.create=\u4f5c\u6210


pal-cvs メーリングリストの案内