changeset 154:1a72f08ce8d7

Propagate delete user errors correctly. artifacts/trunk@1379 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 03 Mar 2011 09:36:03 +0000
parents bf596b83d984
children f797093c60bd
files ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultUserFactory.java artifacts/src/main/java/de/intevation/artifacts/UserFactory.java
diffstat 5 files changed, 21 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Mar 03 08:51:02 2011 +0000
+++ b/ChangeLog	Thu Mar 03 09:36:03 2011 +0000
@@ -1,3 +1,11 @@
+2011-03-03	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java,
+	  artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultUserFactory.java,
+	  artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java,
+	  artifacts/src/main/java/de/intevation/artifacts/UserFactory.java:
+	  Propagate delete user errors correctly.
+
 2011-03-03  Ingo Weinzierl <ingo@intevation.de>
 
 	* artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultUserFactory.java,
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java	Thu Mar 03 08:51:02 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java	Thu Mar 03 09:36:03 2011 +0000
@@ -1055,14 +1055,9 @@
         Element root = ec.create("result");
         result.appendChild(root);
 
-        try {
-            factory.deleteUser(userId, context);
-            root.setTextContent(OPERATION_SUCCESSFUL);
-        }
-        catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            root.setTextContent(OPERATION_FAILURE);
-        }
+        boolean success = factory.deleteUser(userId, context);
+
+        root.setTextContent(success ? OPERATION_SUCCESSFUL: OPERATION_FAILURE);
 
         return result;
     }
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Thu Mar 03 08:51:02 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Thu Mar 03 09:36:03 2011 +0000
@@ -895,14 +895,14 @@
         return null;
     }
 
-    public void deleteUser(String identifier) {
+    public boolean deleteUser(String identifier) {
 
         Connection        conn   = null;
         ResultSet         result = null;
         PreparedStatement stmnt  = null;
 
         if (!StringUtils.checkUUID(identifier)) {
-            return;
+            return false;
         }
 
         DataSource dataSource = DBConnection.getDataSource();
@@ -918,7 +918,7 @@
                 result = stmnt.executeQuery();
 
                 if (!result.next()) { // No such user
-                    return;
+                    return false;
                 }
 
                 int id = result.getInt(1);
@@ -956,6 +956,8 @@
                 stmnt.execute();
 
                 conn.commit();
+
+                return true;
             }
             catch (SQLException sqle) {
                 conn.rollback();
@@ -979,6 +981,8 @@
                 catch (SQLException sqle) {}
             }
         }
+
+        return false;
     }
 
     public User getUser(String identifier) {
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultUserFactory.java	Thu Mar 03 08:51:02 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultUserFactory.java	Thu Mar 03 09:36:03 2011 +0000
@@ -67,10 +67,10 @@
      * @param user The user to be deleted.
      * @param context The CallContext.
      */
-    public void deleteUser(String identifier, Object context) {
+    public boolean deleteUser(String identifier, Object context) {
         logger.debug("DefaultUserFactory.deleteUser: " + identifier);
 
-        Backend.getInstance().deleteUser(identifier);
+        return Backend.getInstance().deleteUser(identifier);
     }
 
 
--- a/artifacts/src/main/java/de/intevation/artifacts/UserFactory.java	Thu Mar 03 08:51:02 2011 +0000
+++ b/artifacts/src/main/java/de/intevation/artifacts/UserFactory.java	Thu Mar 03 09:36:03 2011 +0000
@@ -16,7 +16,7 @@
 
     User createUser(String name, Document role, Object context);
 
-    void deleteUser(String identifier, Object context);
+    boolean deleteUser(String identifier, Object context);
 
     User getUser(String identifier, Object context);
 

http://dive4elements.wald.intevation.org