summaryrefslogtreecommitdiffstats
path: root/dozentenmodulserver/src/main/java/sql
diff options
context:
space:
mode:
authorNino Breuer2014-11-18 15:33:53 +0100
committerNino Breuer2014-11-18 15:33:53 +0100
commit423e985696f29982c41076d64618bf157ddedbaa (patch)
tree405cf77cabe7909f868f652c10a902a645204970 /dozentenmodulserver/src/main/java/sql
parent• fixed bug, where there could only be one image and one lecture with the s... (diff)
parent- (diff)
downloadtutor-module-423e985696f29982c41076d64618bf157ddedbaa.tar.gz
tutor-module-423e985696f29982c41076d64618bf157ddedbaa.tar.xz
tutor-module-423e985696f29982c41076d64618bf157ddedbaa.zip
Merge branch 'master' of ssh://git.openslx.org/openslx-ng/tutor-module
Conflicts: dozentenmodulserver/src/main/java/server/ServerHandler.java dozentenmodulserver/src/main/java/sql/SQL.java
Diffstat (limited to 'dozentenmodulserver/src/main/java/sql')
-rw-r--r--dozentenmodulserver/src/main/java/sql/SQL.java222
1 files changed, 157 insertions, 65 deletions
diff --git a/dozentenmodulserver/src/main/java/sql/SQL.java b/dozentenmodulserver/src/main/java/sql/SQL.java
index 19148516..fa79e2ed 100644
--- a/dozentenmodulserver/src/main/java/sql/SQL.java
+++ b/dozentenmodulserver/src/main/java/sql/SQL.java
@@ -36,7 +36,7 @@ public class SQL {
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (InstantiationException | IllegalAccessException
| ClassNotFoundException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
}
try {
@@ -48,7 +48,7 @@ public class SQL {
return con;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to return connection to Client.");
e.printStackTrace();
}
@@ -78,7 +78,7 @@ public class SQL {
+ ".");
return ret;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to writeFTPUser.");
e.printStackTrace();
}
@@ -113,8 +113,8 @@ public class SQL {
log.info("FTPUser " + user + " deleted.");
return ret;
} catch (SQLException e) {
- // TODO Auto-generated catch block
- log.info("Failed to DeleteUser.");
+
+ log.info("Failed to DeleteUser "+user+".");
e.printStackTrace();
}
return -1;
@@ -136,7 +136,7 @@ public class SQL {
return rs;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to getImage.");
e.printStackTrace();
}
@@ -177,7 +177,7 @@ public class SQL {
return path;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to getPathOfImage.");
e.printStackTrace();
}
@@ -251,7 +251,7 @@ public class SQL {
}
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to setInstitution.");
e.printStackTrace();
}
@@ -378,7 +378,7 @@ public class SQL {
}
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to setPerson.");
e.printStackTrace();
}
@@ -507,7 +507,7 @@ public class SQL {
//con.commit();
con.close();
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to setImageData.");
e.printStackTrace();
}
@@ -563,7 +563,7 @@ public class SQL {
}
con.close();
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
}
return list;
@@ -618,7 +618,7 @@ public class SQL {
}
con.close();
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
}
return list;
@@ -661,7 +661,7 @@ public class SQL {
}
con.close();
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
}
return list;
@@ -722,7 +722,7 @@ public class SQL {
}
con.close();
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
}
return list;
@@ -779,7 +779,7 @@ public class SQL {
}
con.close();
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
}
return list;
@@ -824,7 +824,7 @@ public class SQL {
}
con.close();
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
}
return list;
@@ -870,7 +870,7 @@ public class SQL {
con.close();
return list;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to getLectureListPermissionRead.");
e.printStackTrace();
}
@@ -920,7 +920,7 @@ public class SQL {
con.close();
return list;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to getLectureListPermissionWrite.");
e.printStackTrace();
}
@@ -969,7 +969,7 @@ public class SQL {
con.close();
return list;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to getLectureListPermissionAdmin.");
e.printStackTrace();
}
@@ -1005,7 +1005,7 @@ public class SQL {
con.close();
return list;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to getLectureList.");
e.printStackTrace();
}
@@ -1030,7 +1030,7 @@ public class SQL {
return list;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to getAllOS.");
e.printStackTrace();
}
@@ -1081,15 +1081,104 @@ public class SQL {
con.close();
return map;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to getPersonData.");
e.printStackTrace();
}
return null;
- }
+ }//end getPersonData
+
+
+
+
+ public Map<String, String> getPersonData(String userID) {
+ Map<String, String> map = new HashMap<String, String>();
+ try {
+ Connection con = getConnection();
+ String sql = "SELECT userID, loginName, Nachname, Vorname, mail, m_institution.name as institution FROM bwLehrpool.m_user, m_institution WHERE userID=? AND m_user.institution=m_institution.institutionID;";
+
+ PreparedStatement prest = con.prepareStatement(sql);
+ prest.setString(1, userID);
+
+ ResultSet rs = prest.executeQuery();
+ con.commit();
+ while (rs.next())
+ {
+ map.put("userID", rs.getString("userID"));
+ map.put("loginName", rs.getString("loginName"));
+ map.put("Nachname", rs.getString("Nachname"));
+ map.put("Vorname", rs.getString("Vorname"));
+ map.put("mail", rs.getString("mail"));
+ map.put("institution", rs.getString("institution"));
+
+ }
+ con.close();
+ return map;
+ } catch (SQLException e) {
+ log.info("Failed to getPersonData with userID='"+userID+"'.");
+ e.printStackTrace();
+ }
+ return null;
+ }//end getPersonData
+
+
+
+ public Map<String, String> getItemOwner(String itemID) {
+
+ Map<String, String> map = new HashMap<String, String>();
+ Connection con = getConnection();
+ PreparedStatement prest;
+ String userID;
+
+ try {
+ //find out if the itemID belongs to an image
+ String sql = "SELECT image_owner FROM bwLehrpool.m_VLData_imageInfo WHERE GUID_imageID=?;";
+ prest = con.prepareStatement(sql);
+ prest.setString(1, itemID);
+
+ ResultSet rs = prest.executeQuery();
+ while (rs.next()){
+ map.put("userID",rs.getString("image_owner"));
+ }
+
+ //if map is empty, then itemID does not belong to an image -> must be a lecture
+ if(map.isEmpty()==true){
+ //check if itemID belongs to a lecture
+ sql = "SELECT admin_owner FROM bwLehrpool.m_VLData_lecture WHERE lectureID=?;";
+ prest = con.prepareStatement(sql);
+ prest.setString(1, itemID);
+
+ rs = prest.executeQuery();
+ while(rs.next()){
+ map.put("userID", rs.getString("admin_owner"));
+ }
+ }
+
+ //if map is still empty, then the itemID could not be found
+ if(map.isEmpty()==true){
+ log.error("Failed to getItemOwner for item '"+itemID+"'.");
+ } else {
+
+ //now that we have the userID for this item, get the user information and put it in the map
+ userID = map.get("userID"); //extract the userID
+ map = getPersonData(userID); //get all the rest of his information
+
+ //return this map with all the infos
+ return map;
+
+ }
+
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ //something went horribly wrong...
+ return null;
+ }//end getItemOwner
+
@@ -1192,7 +1281,7 @@ public class SQL {
//con.commit();
con.close();
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to setLectureData.");
e.printStackTrace();
}
@@ -1230,7 +1319,7 @@ public class SQL {
con.close();
return map;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to getImageIDandVersion.");
e.printStackTrace();
}
@@ -1285,7 +1374,7 @@ public class SQL {
con.close();
return map;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to getImageData.");
e.printStackTrace();
}
@@ -1438,7 +1527,7 @@ public class SQL {
con.close();
return 0;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to UpdateImageData.");
e.printStackTrace();
}
@@ -1476,7 +1565,7 @@ public class SQL {
return true;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to deleteImage and permissions.");
e.printStackTrace();
}
@@ -1554,10 +1643,10 @@ public class SQL {
prest.executeUpdate();
con.commit();
con.close();
- log.info("Succeeded to updateLectureData.");
+ //log.info("Succeeded to updateLectureData.");
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to updateLectureData.");
e.printStackTrace();
}
@@ -1587,7 +1676,7 @@ public class SQL {
return ret;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to execute method connectedToLecture.");
e.printStackTrace();
}
@@ -1620,7 +1709,7 @@ public class SQL {
con.close();
return true;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to deleteLecture and permissions.");
e.printStackTrace();
}
@@ -1664,7 +1753,7 @@ public class SQL {
return path;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to getFile.");
e.printStackTrace();
}
@@ -1699,7 +1788,7 @@ public class SQL {
return map;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to getDeleteXMLData.");
e.printStackTrace();
}
@@ -1731,10 +1820,10 @@ public class SQL {
con.commit();
con.close();
- log.info("Succesfully updated image path");
+ //log.info("Succesfully updated image path");
return 0;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to UpdateImagePath.");
e.printStackTrace();
}
@@ -1756,7 +1845,7 @@ public class SQL {
return list;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to getAllUniversities.");
e.printStackTrace();
}
@@ -1789,7 +1878,7 @@ public class SQL {
return pkos;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to getOSpk.");
e.printStackTrace();
}
@@ -1822,7 +1911,7 @@ public class SQL {
return os;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to getOS.");
e.printStackTrace();
}
@@ -1860,7 +1949,7 @@ public class SQL {
con.close();
return map;
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to getLectureData.");
e.printStackTrace();
}
@@ -1897,7 +1986,7 @@ public class SQL {
con.close();
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
}
@@ -1929,7 +2018,7 @@ public class SQL {
return rs.getInt("roleID");
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to getRoleID.");
e.printStackTrace();
}
@@ -1959,8 +2048,8 @@ public class SQL {
con.close();
return id;
} catch (SQLException e) {
- // TODO Auto-generated catch block
- log.info("Failed to LectureID.");
+
+ log.info("Failed to getLectureID.");
e.printStackTrace();
}
return id;
@@ -1981,7 +2070,7 @@ public class SQL {
try {
stm = con.createStatement();
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
}
String query = "SELECT userID, Nachname, Vorname, mail FROM m_user WHERE userID NOT IN ('"
@@ -1995,7 +2084,7 @@ public class SQL {
try {
res = stm.executeQuery(query);
} catch (SQLException e1) {
- // TODO Auto-generated catch block
+
e1.printStackTrace();
}
@@ -2009,7 +2098,7 @@ public class SQL {
false, false));
}
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
}
return list;
@@ -2035,7 +2124,7 @@ public class SQL {
try {
stm = con.createStatement();
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
}
try {
@@ -2068,7 +2157,7 @@ public class SQL {
+ imageID
+ "' AND pmi.userID=u.userID ORDER BY u.Nachname ASC;");*/
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
}
try {
@@ -2109,7 +2198,7 @@ public class SQL {
// System.out.println(res.getString("Nachname")+" "+Boolean.parseBoolean(res.getString("image_read"))+" "+Boolean.parseBoolean(res.getString("image_write"))+" "+Boolean.parseBoolean(res.getString("image_admin")));
}
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
}
return list;
@@ -2151,7 +2240,7 @@ public class SQL {
"FROM bwLehrpool.pm_VLData_lecture pml, bwLehrpool.m_user u WHERE pml.userID!='"+userID+"' AND pml.lectureID='"+lectureID+"' AND pml.userID=u.userID ORDER BY u.Nachname ASC;");
*/
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
}
try {
@@ -2196,7 +2285,7 @@ public class SQL {
// System.out.println(res.getString("Nachname")+" "+Boolean.parseBoolean(res.getString("image_read"))+" "+Boolean.parseBoolean(res.getString("image_write"))+" "+Boolean.parseBoolean(res.getString("image_admin")));
}
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
}
return list;
@@ -2252,7 +2341,7 @@ public class SQL {
con.close();
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to setImageRights.");
e.printStackTrace();
}
@@ -2302,10 +2391,10 @@ public class SQL {
con.commit();
con.close();
- log.info("Written additional image rights.");
+ //log.info("Written additional image rights.");
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
log.info("Failed to write additional image rights.");
}
@@ -2347,10 +2436,10 @@ public class SQL {
+ read + "','" + write + "','" + admin + "');");
*/
con.commit();
- log.info("Written lecture rights for " + pk_lecture);
+ log.info("Written lecture rights for lecture '" + pk_lecture+"'.");
con.close();
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
log.info("Failed to setLectureRights.");
e.printStackTrace();
}
@@ -2395,10 +2484,9 @@ public class SQL {
con.commit();
con.close();
- log.info("Written additional lecture rights for '"
- + userID + "'.");
+ //log.info("Written additional lecture rights for '"+ userID + "'.");
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
log.info("Failed to write additional lecture rights.");
}
@@ -2426,7 +2514,7 @@ public class SQL {
prest.executeUpdate();
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
}
@@ -2438,7 +2526,7 @@ public class SQL {
con.commit();
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
}
}// end deleteAllAdditionalImagePermissions
@@ -2472,7 +2560,7 @@ public class SQL {
con.commit();
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
}
}// end deleteAllAdditionalImagePermissions
@@ -2505,7 +2593,7 @@ public class SQL {
}
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
}
@@ -2535,7 +2623,7 @@ public class SQL {
return rs.getString("name") + " " + rs.getString("architecture") + " bit";
} catch (SQLException e) {
- // TODO Auto-generated catch block
+
e.printStackTrace();
}
@@ -2544,10 +2632,14 @@ public class SQL {
}
+
public String createRandomUUID()
{
return UUID.randomUUID().toString();
}
+
+
+
}// end class