[pal-cvs 3226] [963] rollback of creating user.

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2008年 6月 5日 (木) 11:36:19 JST


Revision: 963
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=pal&view=rev&rev=963
Author:   shinsuke
Date:     2008-06-05 11:36:18 +0900 (Thu, 05 Jun 2008)

Log Message:
-----------
rollback of creating user.

Modified Paths:
--------------
    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/web/user/UserConfirmPage.java
    pal-admin/trunk/src/main/resources/appMessages.properties
    pal-admin/trunk/src/main/resources/appMessages_ja.properties


-------------- next part --------------
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	2008-06-05 01:41:31 UTC (rev 962)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SecurityProviderLogic.java	2008-06-05 02:36:18 UTC (rev 963)
@@ -333,7 +333,7 @@
 
     }
 
-    public void insertUser(User user) throws PALAdminException {
+    public void insertUser(User user) throws CommonException {
         //Debug
         if (PALAdminConstants.DEBUG) {
             return;
@@ -341,12 +341,14 @@
 
         if (PALAdminUtil.isEmpty(user.getName())
                 || PALAdminUtil.isEmpty(user.getPassword())) {
-            throw new PALAdminException(
-                    "Invalid user name or password. username=" + user.getName()
-                            + ", password=" + user.getPassword());
+            throw new CommonException("username.or.password.is.null");
         }
 
-        //TODO check duplicate name
+        // check duplicate name
+        if (getUserManager().userExists(user.getName())) {
+            throw new CommonException("username.already.exists");
+        }
+
         try {
             // Add user
             getUserManager().addUser(user.getName(), user.getPassword());
@@ -429,20 +431,29 @@
                     getPageManager().updateFolder(userFolder);
                     getPageManager().reset();
                 } catch (FolderNotUpdatedException e) {
-                    //TODO remove user
                     throw new CommonException("could.not.update.folder",
                             "Could not update a folder: "
                                     + userFolder.getPath(), e);
                 } catch (NodeException e) {
-                    //TODO remove user
                     throw new CommonException("could.not.update.folder",
                             "Could not update a folder: "
                                     + userFolder.getPath(), e);
                 }
             }
+        } catch (CommonException e) {
+            try {
+                // remove user
+                deleteUser(user);
+            } catch (PALAdminException e1) {
+            }
+            throw e;
         } catch (Exception e) {
-            logger.error("Could not create user: " + user, e);
-            throw new PALAdminException(e);
+            try {
+                // remove user
+                deleteUser(user);
+            } catch (PALAdminException e1) {
+            }
+            throw new CommonException("failed.to.add.new.user", e);
         }
     }
 

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	2008-06-05 01:41:31 UTC (rev 962)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/service/UserManagementService.java	2008-06-05 02:36:18 UTC (rev 963)
@@ -44,6 +44,7 @@
 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 jp.sf.pal.common.CommonException;
 
 import org.seasar.teeda.extension.util.LabelHelper;
 
@@ -150,7 +151,7 @@
 
     }
 
-    public void insert(AbstractUserPage page) throws PALAdminException {
+    public void insert(AbstractUserPage page) throws CommonException {
         User entity = new User();
         userDxo.convert(page, entity);
         securityProviderLogic.insertUser(entity);

Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/user/UserConfirmPage.java
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/user/UserConfirmPage.java	2008-06-05 01:41:31 UTC (rev 962)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/user/UserConfirmPage.java	2008-06-05 02:36:18 UTC (rev 963)
@@ -22,6 +22,7 @@
 import jp.sf.pal.admin.PALAdminException;
 import jp.sf.pal.admin.util.PALAdminUtil;
 import jp.sf.pal.admin.web.CrudType;
+import jp.sf.pal.common.CommonException;
 import jp.sf.pal.common.util.FacesMessageUtil;
 
 import org.seasar.framework.log.Logger;
@@ -79,7 +80,11 @@
             getUserManagementService().insert(this);
             FacesMessageUtil.addInfoMessage("added.new.user",
                     new Object[] { getName() });
-        } catch (PALAdminException e) {
+        } catch (CommonException e) {
+            FacesMessageUtil.addErrorMessage(e.getMessageId(),
+                    new Object[] { getName() });
+            logger.error("Failed to add a new user: " + getName(), e);
+        } catch (Exception e) {
             FacesMessageUtil.addErrorMessage("failed.to.add.new.user",
                     new Object[] { getName() });
             logger.error("Failed to add a new user: " + getName(), e);

Modified: pal-admin/trunk/src/main/resources/appMessages.properties
===================================================================
--- pal-admin/trunk/src/main/resources/appMessages.properties	2008-06-05 01:41:31 UTC (rev 962)
+++ pal-admin/trunk/src/main/resources/appMessages.properties	2008-06-05 02:36:18 UTC (rev 963)
@@ -103,6 +103,8 @@
 could.not.update.password=Could not update a password. Please contact a site administrator.
 updated.user.info=Updated user information
 
+username.already.exists=Username already exists.
+username.or.password.is.null=Username or Password are null.
 could.not.access.folder=Could not access the target folder. Please contact a site administrator.
 could.not.access.page=Could not access the target page. Please contact a site administrator.
 could.not.find.page=Could not find the target page. Please contact a site administrator.

Modified: pal-admin/trunk/src/main/resources/appMessages_ja.properties
===================================================================
--- pal-admin/trunk/src/main/resources/appMessages_ja.properties	2008-06-05 01:41:31 UTC (rev 962)
+++ pal-admin/trunk/src/main/resources/appMessages_ja.properties	2008-06-05 02:36:18 UTC (rev 963)
@@ -103,6 +103,8 @@
 could.not.update.password=\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u66f4\u65b0\u3067\u304d\u307e\u305b\u3093\u3002\u7ba1\u7406\u8005\u306b\u304a\u554f\u3044\u5408\u308f\u305b\u304f\u3060\u3055\u3044\u3002
 updated.user.info=\u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u3092\u66f4\u65b0\u3057\u307e\u3057\u305f\u3002
 
+username.already.exists=\u305d\u306e\u30e6\u30fc\u30b6\u30fc\u540d\u306f\u65e2\u306b\u5b58\u5728\u3057\u307e\u3059\u3002
+username.or.password.is.null=\u30e6\u30fc\u30b6\u30fc\u540d\u307e\u305f\u306f\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u7a7a\u3067\u3059\u3002
 could.not.access.folder=\u6307\u5b9a\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u307e\u305b\u3093\u3002\u7ba1\u7406\u8005\u306b\u304a\u554f\u3044\u5408\u308f\u305b\u304f\u3060\u3055\u3044\u3002
 could.not.access.page=\u6307\u5b9a\u3057\u305f\u30da\u30fc\u30b8\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u307e\u305b\u3093\u3002\u7ba1\u7406\u8005\u306b\u304a\u554f\u3044\u5408\u308f\u305b\u304f\u3060\u3055\u3044\u3002
 could.not.find.page=\u6307\u5b9a\u3057\u305f\u30da\u30fc\u30b8\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002\u7ba1\u7406\u8005\u306b\u304a\u554f\u3044\u5408\u308f\u305b\u304f\u3060\u3055\u3044\u3002


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