# HG changeset patch # User Sascha L. Teichmann # Date 1299144963 0 # Node ID 1a72f08ce8d76e4473075eb7d99fb79333835df2 # Parent bf596b83d984a15cfe1d286d58f058220e7844d5 Propagate delete user errors correctly. artifacts/trunk@1379 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r bf596b83d984 -r 1a72f08ce8d7 ChangeLog --- 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 + + * 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 * artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultUserFactory.java, diff -r bf596b83d984 -r 1a72f08ce8d7 artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.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; } diff -r bf596b83d984 -r 1a72f08ce8d7 artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java --- 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) { diff -r bf596b83d984 -r 1a72f08ce8d7 artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultUserFactory.java --- 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); } diff -r bf596b83d984 -r 1a72f08ce8d7 artifacts/src/main/java/de/intevation/artifacts/UserFactory.java --- 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);