diff options
Diffstat (limited to 'dozentenmodulserver/src/main/java')
| -rw-r--r-- | dozentenmodulserver/src/main/java/server/ServerHandler.java | 81 | ||||
| -rw-r--r-- | dozentenmodulserver/src/main/java/sql/SQL.java | 156 |
2 files changed, 138 insertions, 99 deletions
diff --git a/dozentenmodulserver/src/main/java/server/ServerHandler.java b/dozentenmodulserver/src/main/java/server/ServerHandler.java index d4b763cb..a6412e24 100644 --- a/dozentenmodulserver/src/main/java/server/ServerHandler.java +++ b/dozentenmodulserver/src/main/java/server/ServerHandler.java @@ -38,7 +38,7 @@ public class ServerHandler implements Server.Iface { @Override public User getFtpUser() throws TException { - log.info(new Date() + " - returning FTPUser..."); + log.info("returning FTPUser..."); User user = new User(); user.setUserName(UUID.randomUUID().toString().substring(0, 8)); user.setPassword(getEncodedSha1Sum(UUID.randomUUID().toString() @@ -54,7 +54,7 @@ public class ServerHandler implements Server.Iface { sql.writeFTPUser(user.getUserName(), user.getPassword()); return user; } else { - log.info(new Date() + " - returning null user"); + log.info("Error: returning null user"); return null; } } @@ -69,15 +69,14 @@ public class ServerHandler implements Server.Iface { } if (Files.exists(path) == true) { - log.info(new Date() + " - folder '" + path - + "' exists, no further action"); + log.info("folder '" + path + "' exists, no further action"); return true; } else { // create directory and set permissions boolean success = (new File(path + "")).mkdirs(); if (!success) { - log.info(new Date() + " - failed to create folder '" + path + log.info("failed to create folder '" + path + "'"); return false; } else { @@ -88,8 +87,7 @@ public class ServerHandler implements Server.Iface { // TODO Auto-generated catch block e.printStackTrace(); } - log.info(new Date() + " - folder '" + path - + "' successfully created"); + log.info("folder '" + path + "' successfully created"); return true; } } @@ -106,15 +104,14 @@ public class ServerHandler implements Server.Iface { } if (Files.exists(path) == true) { - log.info(new Date() + " - folder '" + path - + "' exists, no further action"); + log.info("folder '" + path + "' exists, no further action"); return true; } else { // create directory and set permissions boolean success = (new File(path + "")).mkdirs(); if (!success) { - log.info(new Date() + " - failed to create folder '" + path + log.info("failed to create folder '" + path + "'"); return false; } else { @@ -125,7 +122,7 @@ public class ServerHandler implements Server.Iface { // TODO Auto-generated catch block e.printStackTrace(); } - log.info(new Date() + " - folder '" + path + log.info("folder '" + path + "' successfully created"); return true; } @@ -137,7 +134,7 @@ public class ServerHandler implements Server.Iface { try { MessageDigest md = MessageDigest.getInstance("SHA1"); md.update(key.getBytes()); - log.info(new Date() + " - successfully returned EncodedSha1Sum"); + log.info("successfully returned EncodedSha1Sum"); return new BigInteger(1, md.digest()).toString(16); } catch (NoSuchAlgorithmException e) { // handle error case to taste @@ -153,7 +150,7 @@ public class ServerHandler implements Server.Iface { @Override public String getPathOfImage(String image_id, String version) throws TException { - log.info(new Date() + " - successfully returned PathOfImage: " + log.info("successfully returned PathOfImage: " + sql.getPathOfImage(image_id, version)); return sql.getPathOfImage(image_id, version); @@ -196,7 +193,7 @@ public class ServerHandler implements Server.Iface { sql.setImageData(login, license, internet, cpu, ram, imagename, desc, imagePath, filesize, mode, pk_os); - log.info(new Date() + " - written VLdata"); + log.info("written VLdata"); // TODO Auto-generated method stub return true; } @@ -266,7 +263,7 @@ public class ServerHandler implements Server.Iface { XMLCreator xml = new XMLCreator(sql.getConnection(), name); try { xml.create(name); - log.info(new Date() + " - XML created."); + log.info("XML created."); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -288,8 +285,7 @@ public class ServerHandler implements Server.Iface { + filename; File tmpFile = new File(file); - log.info(new Date() - + " - Trying to move file to '/srv/openslx/nfs/prod/" + log.info("Trying to move file to '/srv/openslx/nfs/prod/" + tmpFile.getName() + "'"); try { FileUtils.moveFile(tmpFile, @@ -297,12 +293,12 @@ public class ServerHandler implements Server.Iface { + filename)); // int ret = sql.UpdateImagePath(filename); if (sql.UpdateImagePath(filename) == 0) { - log.info(new Date() + " - file moved and database updated."); + log.info("file moved and database updated."); } } catch (IOException e) { // TODO Auto-generated catch block - log.info(new Date() + " - Failed to move file."); + log.info("Failed to move file."); e.printStackTrace(); } return true; @@ -311,7 +307,7 @@ public class ServerHandler implements Server.Iface { @Override public Map<String, String> getImageData(String imageid, String imageversion) throws TException { - log.info(new Date() + " - returning ImageData: " + log.info("returning ImageData: " + sql.getImageData(imageid, imageversion).size() + "items."); return sql.getImageData(imageid, imageversion); } @@ -339,33 +335,26 @@ public class ServerHandler implements Server.Iface { @Override public List<Lecture> getLectureList() throws TException { - log.info(new Date().toString() + " - returning LectureList: " - + sql.getLectureList().size() + " items."); + log.info("returning LectureList"); return sql.getLectureList(); } @Override public List<Lecture> getLectureListPermissionRead(String userID) { - log.info(new Date().toString() + " - returning LectureListRead: " - + sql.getLectureListPermissionRead(userID).size() - + " items for user " + userID); + log.info("returning LectureListRead"); return sql.getLectureListPermissionRead(userID); }// end getLectureListPermissionRead @Override public List<Lecture> getLectureListPermissionWrite(String userID) { - log.info(new Date().toString() + " - returning LectureListWrite: " - + sql.getLectureListPermissionWrite(userID).size() - + " items for user " + userID); + log.info("returning LectureListWrite"); return sql.getLectureListPermissionWrite(userID); }// end getLectureListPermissionRead @Override public List<Lecture> getLectureListPermissionAdmin(String userID) { - log.info(new Date().toString() + " - returning LectureListAdmin: " - + sql.getLectureListPermissionAdmin(userID).size() - + " items for user " + userID); + log.info("returning LectureListAdmin"); return sql.getLectureListPermissionAdmin(userID); }// end getLectureListPermissionRead @@ -429,8 +418,13 @@ public class ServerHandler implements Server.Iface { @Override public boolean deleteImageData(String id, String version) throws TException { - - return sql.deleteImage(id, version); + boolean success=false; + + if(sql.deleteImage(id, version)==true){ + success=true; + log.info("Image '"+id+"' and permissions successfully deleted."); + } + return success; } @Override @@ -441,6 +435,7 @@ public class ServerHandler implements Server.Iface { } public boolean deleteLecture(String id, String hs, String user) { + boolean success = false; Map<String, String> map = new HashMap<String, String>(); map = sql.getDeleteXMLData(id); try { @@ -456,8 +451,12 @@ public class ServerHandler implements Server.Iface { log.info(new Date() + " - Failed to execute deleteLecture"); e.printStackTrace(); } - return sql.deleteLecture(id); - + + if(sql.deleteLecture(id) == true){ + success = true; + log.info("Lecture '"+id+"' and permissions successfully deleted."); + } + return success; } @Override @@ -469,8 +468,7 @@ public class ServerHandler implements Server.Iface { @Override public Map<String, String> getLectureData(String lectureid) throws TException { - log.info(new Date() + " - returning LectureData: " - + sql.getLectureData(lectureid).size() + "items."); + log.info("returning LectureData"); return sql.getLectureData(lectureid); } @@ -549,7 +547,7 @@ public class ServerHandler implements Server.Iface { linkallowed); } - log.info(new Date() + " - written image rights"); + log.info("written image rights"); return true; } @@ -604,6 +602,7 @@ public class ServerHandler implements Server.Iface { // return null; } + //set permissions for users which are !=userID public boolean writeAdditionalImageRights(String imageName, String userID, boolean isRead, boolean isWrite, boolean isLinkAllowed, boolean isAdmin) { @@ -614,8 +613,7 @@ public class ServerHandler implements Server.Iface { sql.writeAdditionalImageRights(imageID, userID, isRead, isWrite, isLinkAllowed, isAdmin); - log.info(new Date() + " - written additional image rights for " - + userID); + log.info("written additional image rights for " + userID); return success; } @@ -627,8 +625,7 @@ public class ServerHandler implements Server.Iface { sql.writeAdditionalLectureRights(lectureID, userID, isRead, isWrite, isAdmin); - log.info(new Date() + " - written additional lecture rights for " - + userID); + log.info("written additional lecture rights for "+ userID); return true; } diff --git a/dozentenmodulserver/src/main/java/sql/SQL.java b/dozentenmodulserver/src/main/java/sql/SQL.java index 9b3495e2..8fc5d8f3 100644 --- a/dozentenmodulserver/src/main/java/sql/SQL.java +++ b/dozentenmodulserver/src/main/java/sql/SQL.java @@ -46,7 +46,7 @@ public class SQL { return con;
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to return connection to Client.");
+ log.info("Failed to return connection to Client.");
e.printStackTrace();
}
return null;
@@ -68,12 +68,12 @@ public class SQL { + "temp/');");
con.commit();
con.close();
- log.info(new Date() + " - created FTPUser " + user + " : " + pass
+ log.info("Created FTPUser " + user + " : " + pass
+ ".");
return ret;
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to writeFTPUser.");
+ log.info("Failed to writeFTPUser.");
e.printStackTrace();
}
return -1;
@@ -90,11 +90,11 @@ public class SQL { + user + "';");
con.commit();
con.close();
- log.info(new Date() + " - FTPUser " + user + " deleted.");
+ log.info("FTPUser " + user + " deleted.");
return ret;
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to DeleteUser.");
+ log.info("Failed to DeleteUser.");
e.printStackTrace();
}
return -1;
@@ -111,7 +111,7 @@ public class SQL { } catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to getImage.");
+ log.info("Failed to getImage.");
e.printStackTrace();
}
@@ -135,7 +135,7 @@ public class SQL { } catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to getPathOfImage.");
+ log.info("Failed to getPathOfImage.");
e.printStackTrace();
}
@@ -173,7 +173,7 @@ public class SQL { } catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to setInstitution.");
+ log.info("Failed to setInstitution.");
e.printStackTrace();
}
return "-1";
@@ -231,7 +231,7 @@ public class SQL { } catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to setPerson.");
+ log.info("Failed to setPerson.");
e.printStackTrace();
}
return "-1";
@@ -260,6 +260,7 @@ public class SQL { // create a UUID
String uid = UUID.randomUUID().toString();
+ /*
log.info(" - Query is: "
+ "INSERT INTO `bwLehrpool`.`m_VLData_imageInfo`(`GUID_imageID`,`imageVersion`,`image_name`,`image_description`,`image_path`,`image_lastCall`,`image_create_time`,`image_update_time`,`image_owner`,`image_change_by`,`rec_create_time`,`rec_change_time`,`rec_owner`,`rec_change_by`,`content_operatingSystem`,`status_isCompressed`,`status_isSecure`,`status_isOptimzed`,`status_isValid`,`status_isReady`,`status_isDeleted`,`status_isLastOfficialVersion`,`cond_hasLicenseRestriction`,`cond_hasInternetRestriction`,`cond_minRAM`,`cond_minCPUs`,`image_isTemplate`,`image_filesize`,`image_syncMode`)VALUES('"
+ uid // GUID_imageID
@@ -294,6 +295,7 @@ public class SQL { + ",'" + filesize // image_filesize
+ "','" + shareMode // shareMode
+ "');");
+ */
stm.executeUpdate("INSERT INTO `bwLehrpool`.`m_VLData_imageInfo`(`GUID_imageID`,`imageVersion`,`image_name`,`image_description`,`image_path`,`image_lastCall`,`image_create_time`,`image_update_time`,`image_owner`,`image_change_by`,`rec_create_time`,`rec_change_time`,`rec_owner`,`rec_change_by`,`content_operatingSystem`,`status_isCompressed`,`status_isSecure`,`status_isOptimzed`,`status_isValid`,`status_isReady`,`status_isDeleted`,`status_isLastOfficialVersion`,`cond_hasLicenseRestriction`,`cond_hasInternetRestriction`,`cond_minRAM`,`cond_minCPUs`,`image_isTemplate`,`image_filesize`,`image_syncMode`)VALUES('"
+ uid // GUID_imageID
@@ -332,7 +334,7 @@ public class SQL { con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to setImageData.");
+ log.info("Failed to setImageData.");
e.printStackTrace();
}
return true;
@@ -389,7 +391,6 @@ public class SQL { stm = con.createStatement();
// ResultSet
- // res=stm.executeQuery("SELECT vl.GUID_imageID, vl.imageVersion,vl.image_name, vl.cond_hasLicenseRestriction, os.name,os.architecture, '' as lecture,vl.image_update_time, Concat(u.Nachname,' ',u.Vorname) as user, vl.image_isTemplate FROM bwLehrpool.pm_VLData_image as pmi, bwLehrpool.m_VLData_imageInfo vl, bwLehrpool.m_operatingSystem os, bwLehrpool.m_user u Where vl.content_operatingSystem=os.operatingSystemID and vl.image_owner=u.userID and vl.image_name not in (SELECT vl.image_name FROM bwLehrpool.m_VLData_imageInfo vl, bwLehrpool.m_operatingSystem os, bwLehrpool.m_VLData_lecture lect, bwLehrpool.m_user u Where vl.content_operatingSystem=os.operatingSystemID and lect.imageID=vl.GUID_imageID and vl.image_owner=u.userID) union SELECT vl.GUID_imageID, vl.imageVersion,vl.image_name, vl.cond_hasLicenseRestriction, os.name,os.architecture, lect.name as lecture, vl.image_update_time, Concat(u.Nachname,' ',u.Vorname) as user, vl.image_isTemplate FROM bwLehrpool.m_VLData_imageInfo vl, bwLehrpool.m_operatingSystem os, bwLehrpool.m_VLData_lecture lect, bwLehrpool.m_user u Where vl.content_operatingSystem=os.operatingSystemID and lect.imageID=vl.GUID_imageID and vl.image_owner=u.userID;");
ResultSet res = stm
.executeQuery("SELECT DISTINCT vl.GUID_imageID, vl.imageVersion, vl.image_name, vl.cond_hasLicenseRestriction, os.name, os.architecture, '' as lecture, vl.image_update_time, Concat(u.Nachname,' ',u.Vorname) as user, vl.image_isTemplate, vl.image_description FROM bwLehrpool.pm_VLData_image pmi, bwLehrpool.m_VLData_imageInfo vl, bwLehrpool.m_operatingSystem os, bwLehrpool.m_user u WHERE pmi.userID='"
+ userID
@@ -428,7 +429,6 @@ public class SQL { stm = con.createStatement();
// ResultSet
- // res=stm.executeQuery("SELECT vl.GUID_imageID, vl.imageVersion,vl.image_name, vl.cond_hasLicenseRestriction, os.name,os.architecture, '' as lecture,vl.image_update_time, Concat(u.Nachname,' ',u.Vorname) as user, vl.image_isTemplate FROM bwLehrpool.pm_VLData_image as pmi, bwLehrpool.m_VLData_imageInfo vl, bwLehrpool.m_operatingSystem os, bwLehrpool.m_user u Where vl.content_operatingSystem=os.operatingSystemID and vl.image_owner=u.userID and vl.image_name not in (SELECT vl.image_name FROM bwLehrpool.m_VLData_imageInfo vl, bwLehrpool.m_operatingSystem os, bwLehrpool.m_VLData_lecture lect, bwLehrpool.m_user u Where vl.content_operatingSystem=os.operatingSystemID and lect.imageID=vl.GUID_imageID and vl.image_owner=u.userID) union SELECT vl.GUID_imageID, vl.imageVersion,vl.image_name, vl.cond_hasLicenseRestriction, os.name,os.architecture, lect.name as lecture, vl.image_update_time, Concat(u.Nachname,' ',u.Vorname) as user, vl.image_isTemplate FROM bwLehrpool.m_VLData_imageInfo vl, bwLehrpool.m_operatingSystem os, bwLehrpool.m_VLData_lecture lect, bwLehrpool.m_user u Where vl.content_operatingSystem=os.operatingSystemID and lect.imageID=vl.GUID_imageID and vl.image_owner=u.userID;");
ResultSet res = stm
.executeQuery("SELECT DISTINCT vl.GUID_imageID, vl.imageVersion, vl.image_name, vl.cond_hasLicenseRestriction, os.name, os.architecture, '' as lecture, vl.image_update_time, Concat(u.Nachname,' ',u.Vorname) as user, vl.image_isTemplate FROM bwLehrpool.pm_VLData_image pmi, bwLehrpool.m_VLData_imageInfo vl, bwLehrpool.m_operatingSystem os, bwLehrpool.m_user u WHERE pmi.userID='"
+ userID
@@ -458,8 +458,39 @@ public class SQL { public List<Image> getImageListPermissionAdmin(String userID){
- //fill me
- return null;
+ Connection con = getConnection();
+ Statement stm;
+
+ List<Image> list = new ArrayList<Image>();
+ try {
+
+ stm = con.createStatement();
+
+ // ResultSet
+ ResultSet res = stm
+ .executeQuery("SELECT DISTINCT vl.GUID_imageID, vl.imageVersion, vl.image_name, vl.cond_hasLicenseRestriction, os.name, os.architecture, '' as lecture, vl.image_update_time, Concat(u.Nachname,' ',u.Vorname) as user, vl.image_isTemplate FROM bwLehrpool.pm_VLData_image pmi, bwLehrpool.m_VLData_imageInfo vl, bwLehrpool.m_operatingSystem os, bwLehrpool.m_user u WHERE pmi.userID='"
+ + userID
+ + "' AND u.userID = pmi.userID AND pmi.image_admin = 1 AND pmi.GUID_imageID = vl.GUID_imageID AND vl.content_operatingSystem=os.operatingSystemID;");
+
+ while (res.next()) {
+ list.add(new Image(res.getString("GUID_imageID"), res
+ .getString("imageVersion"),
+ res.getString("image_name"), res
+ .getString("cond_hasLicenseRestriction"), res
+ .getString("name")
+ + " "
+ + res.getString("architecture") + " bit", res
+ .getString("lecture"), res
+ .getString("image_update_time"), res
+ .getString("user"), res
+ .getString("image_isTemplate")));
+ }
+ con.close();
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return list;
}
@@ -488,7 +519,7 @@ public class SQL { return list;
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to getLectureListPermissionRead.");
+ log.info("Failed to getLectureListPermissionRead.");
e.printStackTrace();
}
return list;
@@ -519,7 +550,7 @@ public class SQL { return list;
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to getLectureListPermissionWrite.");
+ log.info("Failed to getLectureListPermissionWrite.");
e.printStackTrace();
}
return list;
@@ -549,7 +580,7 @@ public class SQL { return list;
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to getLectureListPermissionAdmin.");
+ log.info("Failed to getLectureListPermissionAdmin.");
e.printStackTrace();
}
return list;
@@ -575,7 +606,7 @@ public class SQL { return list;
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to getLectureList.");
+ log.info("Failed to getLectureList.");
e.printStackTrace();
}
return null;
@@ -596,7 +627,7 @@ public class SQL { } catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to getAllOS.");
+ log.info("Failed to getAllOS.");
e.printStackTrace();
}
@@ -627,7 +658,7 @@ public class SQL { return map;
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to getPersonData.");
+ log.info("Failed to getPersonData.");
e.printStackTrace();
}
return null;
@@ -680,7 +711,7 @@ public class SQL { con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to setLectureData.");
+ log.info("Failed to setLectureData.");
e.printStackTrace();
}
return 0;
@@ -705,7 +736,7 @@ public class SQL { return map;
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to getImageIDandVersion.");
+ log.info("Failed to getImageIDandVersion.");
e.printStackTrace();
}
return null;
@@ -743,7 +774,7 @@ public class SQL { return map;
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to getImageData.");
+ log.info("Failed to getImageData.");
e.printStackTrace();
}
return null;
@@ -767,6 +798,7 @@ public class SQL { if (license == true) {
license_bol = 1;
}
+ /*
log.info(new Date() + " - 'image_name` = '" + newName
+ "\n length of name=" + newName.length());
@@ -790,6 +822,7 @@ public class SQL { + ",`image_syncMode` = '" + shareMode
+ "' WHERE GUID_imageID = '" + id + "' AND imageVersion = "
+ version + ";");
+ */
stm.executeUpdate("UPDATE bwLehrpool.m_VLData_imageInfo SET imageVersion = "
+ newVersion
@@ -830,7 +863,7 @@ public class SQL { return 0;
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to UpdateImageData.");
+ log.info("Failed to UpdateImageData.");
e.printStackTrace();
}
return -1;
@@ -842,16 +875,20 @@ public class SQL { Connection con = getConnection();
Statement stm = con.createStatement();
- stm.executeUpdate("DELETE FROM bwLehrpool.m_VLData_imageInfo where GUID_imageID = '"
- + id + "' " + "AND imageVersion = '" + version + "';");
+ //delete the image record
+ stm.executeUpdate("DELETE FROM bwLehrpool.m_VLData_imageInfo WHERE GUID_imageID = '"+ id + "' " + "AND imageVersion = '" + version + "';");
+ //delete all permission records for this image
+ stm.executeUpdate("DELETE FROM bwLehrpool.pm_VLData_image WHERE GUID_imageID = '"+id+"';");
+
+
con.commit();
con.close();
return true;
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to deleteImage.");
+ log.info("Failed to deleteImage and permissions.");
e.printStackTrace();
}
@@ -890,11 +927,11 @@ public class SQL { + "'WHERE `lectureID` = '" + id + "';");
con.commit();
con.close();
- log.info(new Date() + " - Succeeded to updateLectureData.");
+ log.info("Succeeded to updateLectureData.");
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to updateLectureData.");
+ log.info("Failed to updateLectureData.");
e.printStackTrace();
}
@@ -917,8 +954,7 @@ public class SQL { } catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date()
- + " - Failed to execute method connectedToLecture.");
+ log.info("Failed to execute method connectedToLecture.");
e.printStackTrace();
}
@@ -931,15 +967,19 @@ public class SQL { try {
Connection con = getConnection();
Statement stm = con.createStatement();
- stm.executeUpdate("DELETE FROM bwLehrpool.m_VLData_lecture WHERE lectureID = '"
- + id + "';");
+
+ //delete the lecture record
+ stm.executeUpdate("DELETE FROM bwLehrpool.m_VLData_lecture WHERE lectureID = '" + id + "';");
+ //delete all permission records for this lecture
+ stm.executeUpdate("DELETE FROM bwLehrpool.pm_VLData_lecture WHERE lectureID = '" + id + "';");
+
con.commit();
con.close();
return true;
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to deleteLecture.");
+ log.info("Failed to deleteLecture and permissions.");
e.printStackTrace();
}
@@ -965,7 +1005,7 @@ public class SQL { } catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to getFile.");
+ log.info("Failed to getFile.");
e.printStackTrace();
}
@@ -991,7 +1031,7 @@ public class SQL { } catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to getDeleteXMLData.");
+ log.info("Failed to getDeleteXMLData.");
e.printStackTrace();
}
@@ -1004,11 +1044,12 @@ public class SQL { Statement stm = con.createStatement();
String image_path = "prod/" + name;
+ /*
log.info(new Date()
+ " - Updating ImagePath with: UPDATE `bwLehrpool`.`m_VLData_imageInfo` SET `image_path` = '"
+ image_path + "' WHERE `image_path` = '" + "temp/" + name
+ "';");
-
+ */
stm.executeUpdate("UPDATE `bwLehrpool`.`m_VLData_imageInfo` SET `image_path` = '"
+ image_path
+ "' WHERE `image_path` = '"
@@ -1017,10 +1058,11 @@ public class SQL { + "';");
con.commit();
con.close();
+ log.info("Succesfully updated image path");
return 0;
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to UpdateImagePath.");
+ log.info("Failed to UpdateImagePath.");
e.printStackTrace();
}
return -1;
@@ -1040,7 +1082,7 @@ public class SQL { } catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to getAllUniversities.");
+ log.info("Failed to getAllUniversities.");
e.printStackTrace();
}
@@ -1052,8 +1094,7 @@ public class SQL { try {
Connection con = getConnection();
Statement stm = con.createStatement();
- log.info(new Date() + " - Getting PrimaryKey for OS: " + os
- + " architecture: " + architecture);
+ //log.info(new Date() + " - Getting PrimaryKey for OS: " + os + " architecture: " + architecture);
ResultSet rs = stm
.executeQuery("SELECT operatingSystemID FROM bwLehrpool.m_operatingSystem where name like '"
+ os
@@ -1062,13 +1103,13 @@ public class SQL { + "';");
rs.first();
String pkos = rs.getString("operatingSystemID");
- log.info(new Date() + " - Key is " + pkos);
+ //log.info(" - Key is " + pkos);
con.close();
return pkos;
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to getOSpk.");
+ log.info("Failed to getOSpk.");
e.printStackTrace();
}
@@ -1092,7 +1133,7 @@ public class SQL { } catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to getOS.");
+ log.info("Failed to getOS.");
e.printStackTrace();
}
@@ -1123,7 +1164,7 @@ public class SQL { return map;
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to getLectureData.");
+ log.info("Failed to getLectureData.");
e.printStackTrace();
}
return null;
@@ -1140,12 +1181,12 @@ public class SQL { + username + "'");
if (rs.next()) {
ret = true;
- log.info(new Date() + " - User " + rs.getString("loginName")
- + " exist.");
+ log.info("Checking user: " + rs.getString("loginName")
+ + " exists.");
} else {
ret = false;
- log.info(new Date() + " - User " + rs.getString("loginName")
- + " not exist.");
+ log.info("Checking user: " + rs.getString("loginName")
+ + " does not exist.");
}
con.close();
@@ -1172,7 +1213,7 @@ public class SQL { } catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to getRoleID.");
+ log.info("Failed to getRoleID.");
e.printStackTrace();
}
return -1;
@@ -1194,7 +1235,7 @@ public class SQL { return id;
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to LectureID.");
+ log.info("Failed to LectureID.");
e.printStackTrace();
}
return id;
@@ -1469,7 +1510,7 @@ public class SQL { con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
- log.info(new Date() + " - Failed to setImageRights.");
+ log.info("Failed to setImageRights.");
e.printStackTrace();
}
return 0;
@@ -1487,20 +1528,21 @@ public class SQL { try {
stm = con.createStatement();
- log.info(new Date() + " - INSERT INTO pm_VLData_image (" + "GUID, "
+ /*
+ log.info("INSERT INTO pm_VLData_image (" + "GUID, "
+ "GUID_imageID, " + "roleID, " + "userID, "
+ "image_read, " + "image_write, " + "Image_admin, "
+ "link_allowed)" + "VALUES(" + "'" + uid + "'," + "'"
+ imageID + "'," + "1," + "'" + userID + "'," + isRead
- + "," + isWrite + "," + isLinkAllowed + "," + isAdmin + ""
- + ")");
-
+ + "," + isWrite + "," + isAdmin + "," + isLinkAllowed + ""
+ + ");");
+ */
stm.executeUpdate("INSERT INTO pm_VLData_image (" + "GUID, "
+ "GUID_imageID, " + "roleID, " + "userID, "
+ "image_read, " + "image_write, " + "Image_admin, "
+ "link_allowed)" + "VALUES(" + "'" + uid + "'," + "'"
+ imageID + "'," + "1," + "'" + userID + "'," + isRead
- + "," + isWrite + "," + isLinkAllowed + "," + isAdmin + ""
+ + "," + isWrite + "," + isAdmin + "," + isLinkAllowed + ""
+ ");");
con.commit();
con.close();
|
