comparison artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java @ 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 a76de72ad6d1
comparison
equal deleted inserted replaced
153:bf596b83d984 154:1a72f08ce8d7
893 } 893 }
894 } 894 }
895 return null; 895 return null;
896 } 896 }
897 897
898 public void deleteUser(String identifier) { 898 public boolean deleteUser(String identifier) {
899 899
900 Connection conn = null; 900 Connection conn = null;
901 ResultSet result = null; 901 ResultSet result = null;
902 PreparedStatement stmnt = null; 902 PreparedStatement stmnt = null;
903 903
904 if (!StringUtils.checkUUID(identifier)) { 904 if (!StringUtils.checkUUID(identifier)) {
905 return; 905 return false;
906 } 906 }
907 907
908 DataSource dataSource = DBConnection.getDataSource(); 908 DataSource dataSource = DBConnection.getDataSource();
909 try { 909 try {
910 conn = dataSource.getConnection(); 910 conn = dataSource.getConnection();
916 916
917 stmnt.setString(1, identifier); 917 stmnt.setString(1, identifier);
918 result = stmnt.executeQuery(); 918 result = stmnt.executeQuery();
919 919
920 if (!result.next()) { // No such user 920 if (!result.next()) { // No such user
921 return; 921 return false;
922 } 922 }
923 923
924 int id = result.getInt(1); 924 int id = result.getInt(1);
925 925
926 result.close(); result = null; 926 result.close(); result = null;
954 stmnt = conn.prepareStatement(SQL_USERS_DELETE_ID); 954 stmnt = conn.prepareStatement(SQL_USERS_DELETE_ID);
955 stmnt.setInt(1, id); 955 stmnt.setInt(1, id);
956 stmnt.execute(); 956 stmnt.execute();
957 957
958 conn.commit(); 958 conn.commit();
959
960 return true;
959 } 961 }
960 catch (SQLException sqle) { 962 catch (SQLException sqle) {
961 conn.rollback(); 963 conn.rollback();
962 throw sqle; 964 throw sqle;
963 } 965 }
977 if (conn != null) { 979 if (conn != null) {
978 try { conn.close(); } 980 try { conn.close(); }
979 catch (SQLException sqle) {} 981 catch (SQLException sqle) {}
980 } 982 }
981 } 983 }
984
985 return false;
982 } 986 }
983 987
984 public User getUser(String identifier) { 988 public User getUser(String identifier) {
985 989
986 Connection conn = null; 990 Connection conn = null;

http://dive4elements.wald.intevation.org