[pal-cvs 3919] [1654] set delete flag on user delete process.

svnno****@sourc***** svnno****@sourc*****
2009年 1月 1日 (木) 07:27:21 JST


Revision: 1654
          http://svn.sourceforge.jp/view?root=pal&view=rev&rev=1654
Author:   shinsuke
Date:     2009-01-01 07:27:20 +0900 (Thu, 01 Jan 2009)

Log Message:
-----------
set delete flag on user delete process.

Modified Paths:
--------------
    userinfo/trunk/src/main/java/jp/sf/pal/userinfo/action/UserInfoAction.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/action/UserInfoAction.java
===================================================================
--- userinfo/trunk/src/main/java/jp/sf/pal/userinfo/action/UserInfoAction.java	2008-12-31 21:49:19 UTC (rev 1653)
+++ userinfo/trunk/src/main/java/jp/sf/pal/userinfo/action/UserInfoAction.java	2008-12-31 22:27:20 UTC (rev 1654)
@@ -174,10 +174,11 @@
     public String confirm() {
         if (userInfoForm.mode == CommonConstants.CREATE_MODE) {
             UserInfo userInfo = userInfoService
-                    .getUserInfo(userInfoForm.userId);
+                    .getUserInfoWithDeleted(userInfoForm.userId);
             if (userInfo != null) {
                 // throw an exception
-                throw new ActionMessagesException("errors.user_already_exists",
+                throw new ActionMessagesException(
+                        "errors.cannot_use_this_user",
                         new Object[] { userInfoForm.userId });
             }
         }
@@ -452,10 +453,12 @@
             }
             userInfo.setUpdatedBy(request.getRemoteUser());
         } else {
-            userInfo = userInfoService.getUserInfo(userInfoForm.userId);
+            userInfo = userInfoService
+                    .getUserInfoWithDeleted(userInfoForm.userId);
             if (userInfo != null) {
                 // throw an exception
-                throw new ActionMessagesException("errors.user_already_exists",
+                throw new ActionMessagesException(
+                        "errors.cannot_use_this_user",
                         new Object[] { userInfoForm.userId });
             }
             userInfo = new UserInfo();

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:49:19 UTC (rev 1653)
+++ userinfo/trunk/src/main/java/jp/sf/pal/userinfo/service/UserInfoService.java	2008-12-31 22:27:20 UTC (rev 1654)
@@ -5,7 +5,6 @@
 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;
@@ -94,6 +93,28 @@
         return userInfo;
     }
 
+    public UserInfo getUserInfoWithDeleted(String userId) {
+        UserInfoCB cb = new UserInfoCB();
+
+        // setup
+
+        cb.query().setUserId_Equal(userId);
+        UserInfo userInfo = userInfoBhv.selectEntity(cb);
+        if (userInfo == null) {
+            return null;
+        }
+
+        // RoleMappingCB cb2 = new RoleMappingCB();
+        // cb2.query().setUserId_Equal(userId);
+        // userInfo.setRoleMappingList(roleMappingBhv.selectList(cb2));
+        //
+        // GroupMappingCB cb3 = new GroupMappingCB();
+        // cb3.query().setUserId_Equal(userId);
+        // userInfo.setGroupMappingList(groupMappingBhv.selectList(cb3));
+
+        return userInfo;
+    }
+
     public void store(UserInfo userInfo) throws CommonException {
         Timestamp now = new Timestamp(System.currentTimeMillis());
         userInfo.setUpdatedTime(now);
@@ -174,25 +195,16 @@
         cb3.query().setUserId_Equal(userId);
         groupMappingBhv.queryDelete(cb3);
 
-        // delete
-        userInfoBhv.delete(userInfo);
+        // set delete
+        long now = new Date().getTime();
+        userInfo.setDeletedBy(name);
+        userInfo.setDeletedTime(new Timestamp(now));
+        userInfoBhv.update(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:49:19 UTC (rev 1653)
+++ userinfo/trunk/src/main/resources/application.properties	2008-12-31 22:27:20 UTC (rev 1654)
@@ -68,6 +68,7 @@
 errors.role_already_exists=Role already exists.
 errors.group_already_exists=Group already exists.
 errors.user_already_exists=User already exists.
+errors.cannot_use_this_user=Cannot use this user id. The user id was used now/before.
 
 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:49:19 UTC (rev 1653)
+++ userinfo/trunk/src/main/resources/application_ja.properties	2008-12-31 22:27:20 UTC (rev 1654)
@@ -61,6 +61,7 @@
 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
+errors.cannot_use_this_user=\u3053\u306e\u30e6\u30fc\u30b6\u30fcID\u306f\u5229\u7528\u3067\u304d\u307e\u305b\u3093\u3002\u73fe\u5728\u307e\u305f\u306f\u4ee5\u524d\u306b\u305d\u306e\u30e6\u30fc\u30b6\u30fcID\u306f\u5229\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002
 
 labels.detail=\u8a73\u7d30
 labels.create=\u4f5c\u6210


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