From e3c94b5d842c937d7a5f3284b3ff0f91bb51eec4 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 27 May 2015 20:27:58 +0200 Subject: [server] Added some TODOs --- dozentenmodulserver/src/main/java/sql/SQL.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'dozentenmodulserver/src/main/java/sql') diff --git a/dozentenmodulserver/src/main/java/sql/SQL.java b/dozentenmodulserver/src/main/java/sql/SQL.java index c953de34..890e6e39 100644 --- a/dozentenmodulserver/src/main/java/sql/SQL.java +++ b/dozentenmodulserver/src/main/java/sql/SQL.java @@ -27,6 +27,7 @@ public class SQL { private static final Logger log = Logger.getLogger(SQL.class); public Connection getConnection() { + // TODO: Connection pooling, better yet some abstraction layer for mysql, eg. like dalesbred in master-server try { Class.forName("com.mysql.jdbc.Driver").newInstance(); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { @@ -140,6 +141,13 @@ public class SQL { } public String setInstitution(String university) { + // TODO: WTF!? + // 1) This method is called set* and has a return value (other than boolean) + // 2) This method generates a random ID for an institution name (which is called university in the + // parameter), so every satellite server has a different ID for the same institution + // 3) If an institution is renamed, it gets a new id, and the old one remains in the db + // 4) In case it inserts a new institution with an ID, it queries the DB for the ID right + // after doing so. So it's expected to be different from what was just inserted!?? try { Connection con = getConnection(); @@ -242,6 +250,9 @@ public class SQL { con.commit(); + // TODO: why... WHY!? We had the user id from the beginning! We just inserted it! + // Also if there are two users with same first and last name we might get + // the wrong id! JUST WHY!!!!!? sql = "SELECT userID FROM bwLehrpool.m_user where Nachname like " + "?" + " and Vorname like " + "?" + ";"; @@ -352,6 +363,7 @@ public class SQL { log.info("Failed to setImageData."); e.printStackTrace(); + // TODO: Yeah great - it failed, we log it, but we still return true.... } return true; @@ -385,6 +397,8 @@ public class SQL { } catch (SQLException e) { e.printStackTrace(); + // TODO: Shouldn't we return null or something that gives the client a chance + // to detect the failure and notify the user? } return list; } @@ -484,6 +498,7 @@ public class SQL { return list; } + // TODO: OK this method is pretty much the tenth copy&paste version of the stuff above. Maybe refactor something here? public List getImageListPermissionAdmin(String userID) { Connection con = getConnection(); @@ -783,6 +798,7 @@ public class SQL { // if map is empty, then itemID does not belong to an image -> must // be a lecture + // TODO: Errr what? Why? Trial and error until we find the right table? if (map.isEmpty() == true) { // check if itemID belongs to a lecture sql = "SELECT admin_owner FROM bwLehrpool.m_VLData_lecture WHERE lectureID=?;"; @@ -928,6 +944,8 @@ public class SQL { ResultSet data = prest.executeQuery(); con.commit(); while (data.next()) { + // TODO: This is just a horrible idea. Make a typo anywhere for the key, it still compiles but doesn't work. + // Somebody was too lazy to create a proper struct/class here.... map.put("name", data.getString("image_name")); map.put("internet", data.getString("cond_hasInternetRestriction")); map.put("license", data.getString("cond_hasLicenseRestriction")); @@ -1516,6 +1534,7 @@ public class SQL { link_allowed = false; image_admin = false; + // TODO: Are those really non-numeric columns? If yes, keep in mind parseInt can throw an exception... if (Integer.parseInt(res.getString("image_read")) != 0) { image_read = true; } -- cgit v1.2.3-55-g7522