diff options
Diffstat (limited to 'dozentenmodulserver/src/main/java/server/ServerHandler.java')
| -rw-r--r-- | dozentenmodulserver/src/main/java/server/ServerHandler.java | 81 |
1 files changed, 39 insertions, 42 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; } |
