diff options
| author | Nino Breuer | 2014-12-01 16:30:59 +0100 |
|---|---|---|
| committer | Nino Breuer | 2014-12-01 16:30:59 +0100 |
| commit | 6a90495ac046d90a749ec2ec152ffdf4d7d603f0 (patch) | |
| tree | 625e5d14802ad1d3d847ab1895edd85a48167e95 /dozentenmodulserver/src/main/java/server | |
| parent | • changed implementation of user authentication. (diff) | |
| parent | • Admin can download any image (diff) | |
| download | tutor-module-6a90495ac046d90a749ec2ec152ffdf4d7d603f0.tar.gz tutor-module-6a90495ac046d90a749ec2ec152ffdf4d7d603f0.tar.xz tutor-module-6a90495ac046d90a749ec2ec152ffdf4d7d603f0.zip | |
Merge branch 'master' of ssh://git.openslx.org/openslx-ng/tutor-module
Conflicts:
dozentenmodul/src/main/java/gui/image/CreateImageTechnisch_GUI.java
dozentenmodul/src/main/java/gui/image/EditImageTechnisch_GUI.java
dozentenmodul/src/main/java/gui/image/FTPCreateUploader_GUI.java
möp. großes geschrei, fehler bitte an mich.
dozentenmodul/src/main/java/gui/image/FTPEditDownloader_GUI.java
dozentenmodul/src/main/java/gui/image/FTPEditUploader_GUI.java
dozentenmodul/src/main/java/gui/image/SearchImage_GUI.java
dozentenmodul/src/main/java/gui/lecture/DeleteLecture_GUI.java
dozentenmodul/src/main/java/gui/lecture/EditLectureAllgemein_GUI.java
dozentenmodul/src/main/java/gui/lecture/EditLectureLink_GUI.java
dozentenmodulserver/src/main/java/server/ServerHandler.java
dozentenmodulserver/src/main/java/server/generated/Server.java
dozentenmodulserver/thrift/server.thrift
Diffstat (limited to 'dozentenmodulserver/src/main/java/server')
| -rw-r--r-- | dozentenmodulserver/src/main/java/server/ServerHandler.java | 308 | ||||
| -rw-r--r-- | dozentenmodulserver/src/main/java/server/generated/Server.java | 980 |
2 files changed, 1118 insertions, 170 deletions
diff --git a/dozentenmodulserver/src/main/java/server/ServerHandler.java b/dozentenmodulserver/src/main/java/server/ServerHandler.java index d9a663c4..0deb1037 100644 --- a/dozentenmodulserver/src/main/java/server/ServerHandler.java +++ b/dozentenmodulserver/src/main/java/server/ServerHandler.java @@ -34,19 +34,17 @@ import thrift.MasterThriftConnection; //import thrift.SessionData; import sql.SQL; + //import util.XMLCreator; -public class ServerHandler implements Server.Iface -{ - +public class ServerHandler implements Server.Iface { + private static Logger log = Logger.getLogger(ServerHandler.class); static SQL sql = new SQL(); private Map<String,UserInfo> tokenManager = new HashMap<>(); //saves the current tokens and the mapped userdata, returning from the server - - - + public boolean authenticated(String token) throws TException { if(tokenManager.get(token) != null) @@ -97,18 +95,15 @@ public class ServerHandler implements Server.Iface return true; } return false; - } - - - - + } @Override public User getFtpUser(String token) throws TException { if(authenticated(token)) { + log.info("returning FTPUser..."); User user = new User(); user.setUserName(UUID.randomUUID().toString().substring(0, 8)); @@ -119,7 +114,7 @@ public class ServerHandler implements Server.Iface } else { user.setPath(Configuration.config.getAbsolute_path() + "/"); } - + // check if folder temp and folder prod exist if (folderTempExists() == true && folderProdExists() == true) { sql.writeFTPUser(user.getUserName(), user.getPassword()); @@ -130,12 +125,10 @@ public class ServerHandler implements Server.Iface } } return null; - + } - - public boolean folderTempExists() - { + public boolean folderTempExists() { // check if folder temp exists, otherwise create it Path path = null; if (Configuration.config.getAbsolute_path().endsWith("/")) { @@ -145,15 +138,14 @@ public class ServerHandler implements Server.Iface } if (Files.exists(path) == true) { - log.info("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("failed to create folder '" + path - + "'"); + log.info("failed to create folder '" + path + "'"); return false; } else { // set permissions @@ -162,13 +154,12 @@ public class ServerHandler implements Server.Iface } catch (IOException e) { e.printStackTrace(); } - log.info("folder '" + path + "' successfully created"); + log.info("folder '" + path + "' successfully created"); return true; } } }// end folderTempExists() - public boolean folderProdExists() { // check if folder temp exists, otherwise create it @@ -180,15 +171,14 @@ public class ServerHandler implements Server.Iface } if (Files.exists(path) == true) { - log.info("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("failed to create folder '" + path - + "'"); + log.info("failed to create folder '" + path + "'"); return false; } else { // set permissions @@ -197,15 +187,13 @@ public class ServerHandler implements Server.Iface } catch (IOException e) { e.printStackTrace(); } - log.info("folder '" + path - + "' successfully created"); + log.info("folder '" + path + "' successfully created"); return true; } } }// end folderProdExists() - public String getEncodedSha1Sum(String key) { try { MessageDigest md = MessageDigest.getInstance("SHA1"); @@ -220,10 +208,12 @@ public class ServerHandler implements Server.Iface @Override + public long DeleteFtpUser(String user, String token) throws TException { if(authenticated(token)) { + return sql.DeleteUser(user); } return -1; @@ -231,22 +221,24 @@ public class ServerHandler implements Server.Iface @Override + public String getPathOfImage(String image_id, String version, String token) throws TException { if(authenticated(token)) { log.info("successfully returned PathOfImage: " + sql.getPathOfImage(image_id, version)); + return sql.getPathOfImage(image_id, version); } return null; } - @Override public String setInstitution(String university, String token) throws TException { if(authenticated(token)) { + return sql.setInstitution(university); } return null; @@ -269,77 +261,79 @@ public class ServerHandler implements Server.Iface } else { mode = "to_be_published"; } - + // String pk_institution = sql.setInstitution(university); - // String pk_person = sql.setPerson(login, lastname, firstname, Mail, + // String pk_person = sql.setPerson(login, lastname, firstname, + // Mail, // new Date(), pk_institution); - + // OS impl Select and write - // ACHTUNG: Anzahl der Leerzeichen muss eingehalten werden: 'Windows 7 + // ACHTUNG: Anzahl der Leerzeichen muss eingehalten werden: 'Windows + // 7 // 32 bit" - String pk_os = sql.getOSpk(os.substring(0, nthIndexOf(os, " ", 2)), os - .substring(nthIndexOf(os, " ", 2), os.lastIndexOf(" ")) - .replace(" ", "")); - + String pk_os = sql.getOSpk(os.substring(0, nthIndexOf(os, " ", 2)), + os.substring(nthIndexOf(os, " ", 2), os.lastIndexOf(" ")) + .replace(" ", "")); + // sql.setImageData(pk_person, license, internet, cpu, ram, // imagename,desc, imagePath, filesize,mode,pk_os); - - - + sql.setImageData(userID, license, internet, cpu, ram, imagename, desc, imagePath, filesize, mode, pk_os, uid); log.info("userID in serverhandler was: "+userID); + log.info("written VLdata"); return true; } return false; } - @Override + public List<Image> getImageListPermissionWrite(String userID, String token) throws TException { if(authenticated(token)) { + return sql.getImageListPermissionWrite(userID); } return null; } - @Override public List<Image> getImageListPermissionRead(String userID, String token) throws TException { if(authenticated(token)) { + return sql.getImageListPermissionRead(userID); } return null; } - @Override public List<Image> getImageListPermissionLink(String userID, String token) throws TException { if(authenticated(token)) { + return sql.getImageListPermissionLink(userID); } return null; } - - + @Override public List<Image> getImageListPermissionAdmin(String userID, String token) throws TException { if(authenticated(token)) { + return sql.getImageListPermissionAdmin(userID); } return null; } - + @Override public List<Image> getImageListAllTemplates(String token) throws TException { @@ -349,7 +343,6 @@ public class ServerHandler implements Server.Iface } return null; } - @Override public List<String> getAllOS(String token) throws TException @@ -365,14 +358,10 @@ public class ServerHandler implements Server.Iface @Override public Map<String, String> getPersonData(String Vorname, String Nachname, String token) throws TException { - /* + if(authenticated(token)) { - return sql.getPersonData(Vorname, Nachname); - } - return null; - */ - + Map<String, String> map = new HashMap<>(); UserInfo ui = getUserFromToken(token); @@ -387,8 +376,10 @@ public class ServerHandler implements Server.Iface map.put("Hochschule", tempMap.get("Hochschule")); return map; - + } + return null; } + public void setPerson(String userID, String token, String institution) throws TException { @@ -419,19 +410,18 @@ public class ServerHandler implements Server.Iface String pk_institution = sql.setInstitution(university); String pk_person = sql.setPerson(ui.getEMail(), ui.getLastName(), ui.getFirstName(), ui.getEMail(), new Date(), pk_institution); - + map = sql.getImageIDandVersion(imageID); - - //pk_image = map.get("GUID"); + + // pk_image = map.get("GUID"); imageversion = Integer.parseInt(map.get("version")); - + sql.setLectureData(pk_person, imageID, imageversion, name, desc, shortdesc, startDate, endDate, isActive, lectureID); } - return false; - + return false; + } - @Override public boolean startFileCopy(String filename, String token) throws TException @@ -442,18 +432,18 @@ public class ServerHandler implements Server.Iface String file = Configuration.config.getAbsolute_path() + "temp/" + filename; File tmpFile = new File(file); - + log.info("Trying to move file to '/srv/openslx/nfs/prod/" + tmpFile.getName() + "'"); try { FileUtils.moveFile(tmpFile, - new File(Configuration.config.getAbsolute_path() + "prod/" - + filename)); + new File(Configuration.config.getAbsolute_path() + + "prod/" + filename)); // int ret = sql.UpdateImagePath(filename); if (sql.UpdateImagePath(filename) == 0) { log.info("file moved and database updated."); } - + } catch (IOException e) { log.info("Failed to move file."); e.printStackTrace(); @@ -479,20 +469,38 @@ public class ServerHandler implements Server.Iface long cpu, String id, String version, boolean isTemplate, long filesize, long shareMode, String os, String token) throws TException { - if(authenticated(token)) + + if (authenticated(token)) { + + //get old_image_path + String old_image_path = sql.getFile(id, version); + String mode = null; - + if (shareMode == 0) { mode = "only_local"; } else { mode = "to_be_published"; } - String pk_os = sql.getOSpk(os.substring(0, nthIndexOf(os, " ", 2)), os - .substring(nthIndexOf(os, " ", 2), os.lastIndexOf(" ")) - .replace(" ", "")); - sql.UpdateImageData(name, newName, desc, image_path, license, internet, - cpu, ram, id, version, isTemplate, filesize, mode, pk_os); + String pk_os = sql.getOSpk(os.substring(0, nthIndexOf(os, " ", 2)), + os.substring(nthIndexOf(os, " ", 2), os.lastIndexOf(" ")) + .replace(" ", "")); + + // do database update - if successful then delete old file from + // drive + int val = sql.UpdateImageData(name, newName, desc, image_path, + license, internet, cpu, ram, id, version, isTemplate, + filesize, mode, pk_os); + + if (val == 0) { + // update was successful - delete old file + deleteImageByPath(old_image_path); + } else { + // update was not successful - delete new file + // TODO not yet implemented + + } } return false; } @@ -521,7 +529,6 @@ public class ServerHandler implements Server.Iface return null; }// end getLectureListPermissionRead - @Override public List<Lecture> getLectureListPermissionWrite(String token) throws TException { @@ -535,6 +542,7 @@ public class ServerHandler implements Server.Iface }// end getLectureListPermissionRead @Override + public List<Lecture> getLectureListPermissionAdmin(String token) throws TException { if(authenticated(token)) @@ -557,27 +565,13 @@ public class ServerHandler implements Server.Iface { UserInfo ui = getUserFromToken(token); - Map<String, String> map = new HashMap<String, String>(); - map = sql.getDeleteXMLData(id); sql.updateLectureData(imageid, imageversion, ui.getLastName(), newName, desc, shortdesc, startDate, endDate, isActive, id); - - String path = Configuration.config.getAbsolute_path() + "prod/" - + map.get("date").substring(0, map.get("date").length() - 2) - + "_" + university + "_" + ui.getEMail() + "_" + map.get("name") - + ".xml"; - File tmpFile = new File(path); - try { - FileUtils.forceDelete(tmpFile); - } catch (IOException e1) { - e1.printStackTrace(); - } } return false; } - @Override public boolean deleteImageServer(String imageid, String imageversion, String token) throws TException { @@ -585,24 +579,23 @@ public class ServerHandler implements Server.Iface { String stringFile = sql.getFile(imageid, imageversion); log.info("File to Delete: " + stringFile); - + File tmpFile = new File(Configuration.config.getAbsolute_path() + stringFile); - + try { // File wird von Server gelöscht FileUtils.forceDelete(tmpFile); return true; - + } catch (IOException e) { log.info("Failed to execute deleteImageServer."); e.printStackTrace(); - + } } return false; } - @Override public boolean deleteImageData(String id, String version, String token) throws TException @@ -620,6 +613,33 @@ public class ServerHandler implements Server.Iface return success; } +//TODO +public boolean deleteImageByPath(String image_path) throws TException{ + + + + //String stringFile = sql.getFile(imageid, imageversion); + log.info("File to Delete: " + image_path); + + File tmpFile = new File(Configuration.config.getAbsolute_path() + + image_path); + + try { + // File wird von Server gelöscht + FileUtils.forceDelete(tmpFile); + return true; + + } catch (IOException e) { + log.info("Failed to execute deleteImageServer."); + e.printStackTrace(); + + } + + + return false; + +} + @Override public boolean connectedToLecture(String id, String version, String token) throws TException { @@ -640,28 +660,16 @@ public class ServerHandler implements Server.Iface if(authenticated(token)) { - Map<String, String> map = new HashMap<String, String>(); - map = sql.getDeleteXMLData(id); - try { - - String path = Configuration.config.getAbsolute_path() - + "prod/" - + map.get("date") - .substring(0, map.get("date").length() - 2) + "_" - + university + "_" + user + "_" + map.get("name") + ".xml"; - File xmlFile = new File(path); - FileUtils.forceDelete(xmlFile); - } catch (IOException e) { - log.info("Failed to execute deleteLecture."); - e.printStackTrace(); - } - - if(sql.deleteLecture(id) == true){ + if(sql.deleteLecture(id) == true) + { + success = true; - log.info("Lecture '"+id+"' and permissions successfully deleted."); + log.info("Lecture '" + id + + "' and permissions successfully deleted."); } } return success; + } @Override @@ -679,7 +687,6 @@ public class ServerHandler implements Server.Iface { if(authenticated(token)) { - //log.info("returning LectureData"); return sql.getLectureData(lectureid); } return null; @@ -692,6 +699,7 @@ public class ServerHandler implements Server.Iface for (int i = 0; i < index; i++) { j = string.indexOf(searchToken, j + 1); + if (j == -1) break; } @@ -734,13 +742,13 @@ public class ServerHandler implements Server.Iface Map<String, String> map = new HashMap<String, String>(); String pk_institution = sql.setInstitution(university); + String pk_person = sql.setPerson(userID, ui.getLastName(), ui.getFirstName(), ui.getEMail(), new Date(), pk_institution); map = sql.getImageIDandVersion(imageID); - - + pk_image = map.get("GUID"); - + if (role.equals("Dozent")) { int read = 1; int write = 1; @@ -748,10 +756,10 @@ public class ServerHandler implements Server.Iface int admin = 1; int linkallowed = 1; int roleID = sql.getRoleID(role); - - sql.setImageRights(pk_person, pk_image, roleID, read, write, admin, - linkallowed); - + + sql.setImageRights(pk_person, pk_image, roleID, read, write, + admin, linkallowed); + } else if (role.equals("Admin")) { int read = 1; int write = 1; @@ -759,9 +767,9 @@ public class ServerHandler implements Server.Iface int admin = 1; int linkallowed = 1; int roleID = sql.getRoleID(role); - - sql.setImageRights(pk_person, pk_image, roleID, read, write, admin, - linkallowed); + + sql.setImageRights(pk_person, pk_image, roleID, read, write, + admin, linkallowed); } else { int read = 1; int write = 0; @@ -769,11 +777,11 @@ public class ServerHandler implements Server.Iface int admin = 0; int linkallowed = 0; int roleID = sql.getRoleID(role); - - sql.setImageRights(pk_person, pk_image, roleID, read, write, admin, - linkallowed); + + sql.setImageRights(pk_person, pk_image, roleID, read, write, + admin, linkallowed); } - + log.info("Written image rights"); return true; } @@ -797,17 +805,17 @@ public class ServerHandler implements Server.Iface // int changePermission=0; int admin = 1; int roleID = sql.getRoleID(role); - + sql.setLectureRights(pk_person, lectureID, roleID, read, write, admin); - + } else if (role.equals("Admin")) { int read = 1; int write = 1; // int changePermission=1; int admin = 1; int roleID = sql.getRoleID(role); - + sql.setLectureRights(pk_person, lectureID, roleID, read, write, admin); } else { @@ -816,11 +824,11 @@ public class ServerHandler implements Server.Iface // int changePermission=0; int admin = 0; int roleID = sql.getRoleID(role); - + sql.setLectureRights(pk_person, lectureID, roleID, read, write, admin); } - + return true; } return false; @@ -837,7 +845,7 @@ public class ServerHandler implements Server.Iface return null; } - //set permissions for users which are !=userID + // set permissions for users which are !=userID public boolean writeAdditionalImageRights(String imageID, String userID, boolean isRead, boolean isWrite, boolean isLinkAllowed, boolean isAdmin, String token) throws TException @@ -845,31 +853,29 @@ public class ServerHandler implements Server.Iface boolean success = false; if(authenticated(token)) { - Map<String, String> map = new HashMap<String, String>(); map = sql.getImageIDandVersion(imageID); - //String imageID = map.get("GUID"); - + // String imageID = map.get("GUID"); + sql.writeAdditionalImageRights(imageID, userID, isRead, isWrite, isLinkAllowed, isAdmin); - log.info("Written additional image rights for " + userID); + log.info("Written additional image rights for " + userID); } return success; } - public boolean writeAdditionalLectureRights(String lectureID, String userID, boolean isRead, boolean isWrite, boolean isAdmin, String token) throws TException { if(authenticated(token)) { Map<String, String> map = new HashMap<String, String>(); - //String lectureID = sql.getLectureID(lectureID); - - sql.writeAdditionalLectureRights(lectureID, userID, isRead, isWrite, - isAdmin); - log.info("Written additional lecture rights for "+ userID); - + // String lectureID = sql.getLectureID(lectureID); + + sql.writeAdditionalLectureRights(lectureID, userID, isRead, + isWrite, isAdmin); + log.info("Written additional lecture rights for " + userID); + return true; } return false; @@ -886,6 +892,7 @@ public class ServerHandler implements Server.Iface return null; } + public List<Person> getPermissionForUserAndLecture(String token,String lectureID, String userID) throws TException { if(authenticated(token)) @@ -915,17 +922,17 @@ public class ServerHandler implements Server.Iface UserInfo ui = getUserFromToken(token); sql.deleteAllAdditionalLecturePermissions(lectureID, userID); } - + return; } + @Override - public List<Image> getImageList(String token) throws TException + public List<Image> getImageList(String userID, String token) throws TException { - UserInfo ui = getUserFromToken(token); if(authenticated(token)) { - return sql.getImageList(ui.getEMail()); + return sql.getImageList(userID); } return null; } @@ -951,7 +958,6 @@ public class ServerHandler implements Server.Iface } @Override - public String createRandomUUID(String token) throws TException { if(authenticated(token)) @@ -971,8 +977,6 @@ public class ServerHandler implements Server.Iface } - - @Override public boolean userIsImageAdmin(String imageID, String token, String userID) throws TException { @@ -983,17 +987,17 @@ public class ServerHandler implements Server.Iface return sql.userIsImageAdmin(userID,imageID); } return false; - - } - + } @Override public boolean userIsLectureAdmin(String userID, String lectureID, String token) throws TException { + if(authenticated(token)) { return sql.userIsLectureAdmin(userID,lectureID); + } return false; } @@ -1007,6 +1011,4 @@ public class ServerHandler implements Server.Iface - - }// end class diff --git a/dozentenmodulserver/src/main/java/server/generated/Server.java b/dozentenmodulserver/src/main/java/server/generated/Server.java index 831fd8cd..2c2f94df 100644 --- a/dozentenmodulserver/src/main/java/server/generated/Server.java +++ b/dozentenmodulserver/src/main/java/server/generated/Server.java @@ -60,7 +60,7 @@ public class Server { public List<Image> getImageListAllTemplates(String token) throws org.apache.thrift.TException; - public List<Image> getImageList(String token) throws org.apache.thrift.TException; + public List<Image> getImageList(String userID, String token) throws org.apache.thrift.TException; public List<Lecture> getLectureList(String token) throws org.apache.thrift.TException; @@ -96,6 +96,8 @@ public class Server { public boolean deleteImageServer(String id, String version, String token) throws org.apache.thrift.TException; + public boolean deleteImageByPath(String image_path) throws org.apache.thrift.TException; + public boolean connectedToLecture(String id, String version, String token) throws org.apache.thrift.TException; public boolean deleteLecture(String id, String token, String university) throws org.apache.thrift.TException; @@ -162,7 +164,7 @@ public class Server { public void getImageListAllTemplates(String token, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; - public void getImageList(String token, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void getImageList(String userID, String token, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; public void getLectureList(String token, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; @@ -198,6 +200,8 @@ public class Server { public void deleteImageServer(String id, String version, String token, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void deleteImageByPath(String image_path, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void connectedToLecture(String id, String version, String token, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; public void deleteLecture(String id, String token, String university, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; @@ -557,15 +561,16 @@ public class Server { throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getImageListAllTemplates failed: unknown result"); } - public List<Image> getImageList(String token) throws org.apache.thrift.TException + public List<Image> getImageList(String userID, String token) throws org.apache.thrift.TException { - send_getImageList(token); + send_getImageList(userID, token); return recv_getImageList(); } - public void send_getImageList(String token) throws org.apache.thrift.TException + public void send_getImageList(String userID, String token) throws org.apache.thrift.TException { getImageList_args args = new getImageList_args(); + args.setUserID(userID); args.setToken(token); sendBase("getImageList", args); } @@ -1019,6 +1024,29 @@ public class Server { throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "deleteImageServer failed: unknown result"); } + public boolean deleteImageByPath(String image_path) throws org.apache.thrift.TException + { + send_deleteImageByPath(image_path); + return recv_deleteImageByPath(); + } + + public void send_deleteImageByPath(String image_path) throws org.apache.thrift.TException + { + deleteImageByPath_args args = new deleteImageByPath_args(); + args.setImage_path(image_path); + sendBase("deleteImageByPath", args); + } + + public boolean recv_deleteImageByPath() throws org.apache.thrift.TException + { + deleteImageByPath_result result = new deleteImageByPath_result(); + receiveBase(result, "deleteImageByPath"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "deleteImageByPath failed: unknown result"); + } + public boolean connectedToLecture(String id, String version, String token) throws org.apache.thrift.TException { send_connectedToLecture(id, version, token); @@ -1961,23 +1989,26 @@ public class Server { } } - public void getImageList(String token, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + public void getImageList(String userID, String token, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); - getImageList_call method_call = new getImageList_call(token, resultHandler, this, ___protocolFactory, ___transport); + getImageList_call method_call = new getImageList_call(userID, token, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class getImageList_call extends org.apache.thrift.async.TAsyncMethodCall { + private String userID; private String token; - public getImageList_call(String token, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + public getImageList_call(String userID, String token, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); + this.userID = userID; this.token = token; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getImageList", org.apache.thrift.protocol.TMessageType.CALL, 0)); getImageList_args args = new getImageList_args(); + args.setUserID(userID); args.setToken(token); args.write(prot); prot.writeMessageEnd(); @@ -2690,6 +2721,38 @@ public class Server { } } + public void deleteImageByPath(String image_path, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + deleteImageByPath_call method_call = new deleteImageByPath_call(image_path, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class deleteImageByPath_call extends org.apache.thrift.async.TAsyncMethodCall { + private String image_path; + public deleteImageByPath_call(String image_path, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.image_path = image_path; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("deleteImageByPath", org.apache.thrift.protocol.TMessageType.CALL, 0)); + deleteImageByPath_args args = new deleteImageByPath_args(); + args.setImage_path(image_path); + args.write(prot); + prot.writeMessageEnd(); + } + + public boolean getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_deleteImageByPath(); + } + } + public void connectedToLecture(String id, String version, String token, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); connectedToLecture_call method_call = new connectedToLecture_call(id, version, token, resultHandler, this, ___protocolFactory, ___transport); @@ -3461,6 +3524,7 @@ public class Server { processMap.put("deleteImageData", new deleteImageData()); processMap.put("updateLecturedata", new updateLecturedata()); processMap.put("deleteImageServer", new deleteImageServer()); + processMap.put("deleteImageByPath", new deleteImageByPath()); processMap.put("connectedToLecture", new connectedToLecture()); processMap.put("deleteLecture", new deleteLecture()); processMap.put("checkUser", new checkUser()); @@ -3742,7 +3806,7 @@ public class Server { public getImageList_result getResult(I iface, getImageList_args args) throws org.apache.thrift.TException { getImageList_result result = new getImageList_result(); - result.success = iface.getImageList(args.token); + result.success = iface.getImageList(args.userID, args.token); return result; } } @@ -4093,6 +4157,27 @@ public class Server { } } + public static class deleteImageByPath<I extends Iface> extends org.apache.thrift.ProcessFunction<I, deleteImageByPath_args> { + public deleteImageByPath() { + super("deleteImageByPath"); + } + + public deleteImageByPath_args getEmptyArgsInstance() { + return new deleteImageByPath_args(); + } + + protected boolean isOneway() { + return false; + } + + public deleteImageByPath_result getResult(I iface, deleteImageByPath_args args) throws org.apache.thrift.TException { + deleteImageByPath_result result = new deleteImageByPath_result(); + result.success = iface.deleteImageByPath(args.image_path); + result.setSuccessIsSet(true); + return result; + } + } + public static class connectedToLecture<I extends Iface> extends org.apache.thrift.ProcessFunction<I, connectedToLecture_args> { public connectedToLecture() { super("connectedToLecture"); @@ -4526,6 +4611,7 @@ public class Server { processMap.put("deleteImageData", new deleteImageData()); processMap.put("updateLecturedata", new updateLecturedata()); processMap.put("deleteImageServer", new deleteImageServer()); + processMap.put("deleteImageByPath", new deleteImageByPath()); processMap.put("connectedToLecture", new connectedToLecture()); processMap.put("deleteLecture", new deleteLecture()); processMap.put("checkUser", new checkUser()); @@ -5211,7 +5297,7 @@ public class Server { } public void start(I iface, getImageList_args args, org.apache.thrift.async.AsyncMethodCallback<List<Image>> resultHandler) throws TException { - iface.getImageList(args.token,resultHandler); + iface.getImageList(args.userID, args.token,resultHandler); } } @@ -6087,6 +6173,58 @@ public class Server { } } + public static class deleteImageByPath<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, deleteImageByPath_args, Boolean> { + public deleteImageByPath() { + super("deleteImageByPath"); + } + + public deleteImageByPath_args getEmptyArgsInstance() { + return new deleteImageByPath_args(); + } + + public AsyncMethodCallback<Boolean> getResultHandler(final AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new AsyncMethodCallback<Boolean>() { + public void onComplete(Boolean o) { + deleteImageByPath_result result = new deleteImageByPath_result(); + result.success = o; + result.setSuccessIsSet(true); + try { + fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + return; + } catch (Exception e) { + LOGGER.error("Exception writing to internal frame buffer", e); + } + fb.close(); + } + public void onError(Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TBase msg; + deleteImageByPath_result result = new deleteImageByPath_result(); + { + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + return; + } catch (Exception ex) { + LOGGER.error("Exception writing to internal frame buffer", ex); + } + fb.close(); + } + }; + } + + protected boolean isOneway() { + return false; + } + + public void start(I iface, deleteImageByPath_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws TException { + iface.deleteImageByPath(args.image_path,resultHandler); + } + } + public static class connectedToLecture<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, connectedToLecture_args, Boolean> { public connectedToLecture() { super("connectedToLecture"); @@ -18102,7 +18240,8 @@ public class Server { public static class getImageList_args implements org.apache.thrift.TBase<getImageList_args, getImageList_args._Fields>, java.io.Serializable, Cloneable, Comparable<getImageList_args> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getImageList_args"); - private static final org.apache.thrift.protocol.TField TOKEN_FIELD_DESC = new org.apache.thrift.protocol.TField("token", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField USER_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("userID", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField TOKEN_FIELD_DESC = new org.apache.thrift.protocol.TField("token", org.apache.thrift.protocol.TType.STRING, (short)2); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { @@ -18110,11 +18249,13 @@ public class Server { schemes.put(TupleScheme.class, new getImageList_argsTupleSchemeFactory()); } + public String userID; // required public String token; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { - TOKEN((short)1, "token"); + USER_ID((short)1, "userID"), + TOKEN((short)2, "token"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); @@ -18129,7 +18270,9 @@ public class Server { */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { - case 1: // TOKEN + case 1: // USER_ID + return USER_ID; + case 2: // TOKEN return TOKEN; default: return null; @@ -18174,6 +18317,8 @@ public class Server { public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.USER_ID, new org.apache.thrift.meta_data.FieldMetaData("userID", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.TOKEN, new org.apache.thrift.meta_data.FieldMetaData("token", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); metaDataMap = Collections.unmodifiableMap(tmpMap); @@ -18184,9 +18329,11 @@ public class Server { } public getImageList_args( + String userID, String token) { this(); + this.userID = userID; this.token = token; } @@ -18194,6 +18341,9 @@ public class Server { * Performs a deep copy on <i>other</i>. */ public getImageList_args(getImageList_args other) { + if (other.isSetUserID()) { + this.userID = other.userID; + } if (other.isSetToken()) { this.token = other.token; } @@ -18205,9 +18355,34 @@ public class Server { @Override public void clear() { + this.userID = null; this.token = null; } + public String getUserID() { + return this.userID; + } + + public getImageList_args setUserID(String userID) { + this.userID = userID; + return this; + } + + public void unsetUserID() { + this.userID = null; + } + + /** Returns true if field userID is set (has been assigned a value) and false otherwise */ + public boolean isSetUserID() { + return this.userID != null; + } + + public void setUserIDIsSet(boolean value) { + if (!value) { + this.userID = null; + } + } + public String getToken() { return this.token; } @@ -18234,6 +18409,14 @@ public class Server { public void setFieldValue(_Fields field, Object value) { switch (field) { + case USER_ID: + if (value == null) { + unsetUserID(); + } else { + setUserID((String)value); + } + break; + case TOKEN: if (value == null) { unsetToken(); @@ -18247,6 +18430,9 @@ public class Server { public Object getFieldValue(_Fields field) { switch (field) { + case USER_ID: + return getUserID(); + case TOKEN: return getToken(); @@ -18261,6 +18447,8 @@ public class Server { } switch (field) { + case USER_ID: + return isSetUserID(); case TOKEN: return isSetToken(); } @@ -18280,6 +18468,15 @@ public class Server { if (that == null) return false; + boolean this_present_userID = true && this.isSetUserID(); + boolean that_present_userID = true && that.isSetUserID(); + if (this_present_userID || that_present_userID) { + if (!(this_present_userID && that_present_userID)) + return false; + if (!this.userID.equals(that.userID)) + return false; + } + boolean this_present_token = true && this.isSetToken(); boolean that_present_token = true && that.isSetToken(); if (this_present_token || that_present_token) { @@ -18305,6 +18502,16 @@ public class Server { int lastComparison = 0; + lastComparison = Boolean.valueOf(isSetUserID()).compareTo(other.isSetUserID()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetUserID()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.userID, other.userID); + if (lastComparison != 0) { + return lastComparison; + } + } lastComparison = Boolean.valueOf(isSetToken()).compareTo(other.isSetToken()); if (lastComparison != 0) { return lastComparison; @@ -18335,6 +18542,14 @@ public class Server { StringBuilder sb = new StringBuilder("getImageList_args("); boolean first = true; + sb.append("userID:"); + if (this.userID == null) { + sb.append("null"); + } else { + sb.append(this.userID); + } + first = false; + if (!first) sb.append(", "); sb.append("token:"); if (this.token == null) { sb.append("null"); @@ -18385,7 +18600,15 @@ public class Server { break; } switch (schemeField.id) { - case 1: // TOKEN + case 1: // USER_ID + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.userID = iprot.readString(); + struct.setUserIDIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // TOKEN if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.token = iprot.readString(); struct.setTokenIsSet(true); @@ -18408,6 +18631,11 @@ public class Server { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); + if (struct.userID != null) { + oprot.writeFieldBegin(USER_ID_FIELD_DESC); + oprot.writeString(struct.userID); + oprot.writeFieldEnd(); + } if (struct.token != null) { oprot.writeFieldBegin(TOKEN_FIELD_DESC); oprot.writeString(struct.token); @@ -18431,10 +18659,16 @@ public class Server { public void write(org.apache.thrift.protocol.TProtocol prot, getImageList_args struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); - if (struct.isSetToken()) { + if (struct.isSetUserID()) { optionals.set(0); } - oprot.writeBitSet(optionals, 1); + if (struct.isSetToken()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetUserID()) { + oprot.writeString(struct.userID); + } if (struct.isSetToken()) { oprot.writeString(struct.token); } @@ -18443,8 +18677,12 @@ public class Server { @Override public void read(org.apache.thrift.protocol.TProtocol prot, getImageList_args struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(1); + BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { + struct.userID = iprot.readString(); + struct.setUserIDIsSet(true); + } + if (incoming.get(1)) { struct.token = iprot.readString(); struct.setTokenIsSet(true); } @@ -36369,6 +36607,714 @@ public class Server { } + public static class deleteImageByPath_args implements org.apache.thrift.TBase<deleteImageByPath_args, deleteImageByPath_args._Fields>, java.io.Serializable, Cloneable, Comparable<deleteImageByPath_args> { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("deleteImageByPath_args"); + + private static final org.apache.thrift.protocol.TField IMAGE_PATH_FIELD_DESC = new org.apache.thrift.protocol.TField("image_path", org.apache.thrift.protocol.TType.STRING, (short)1); + + private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new deleteImageByPath_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new deleteImageByPath_argsTupleSchemeFactory()); + } + + public String image_path; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + IMAGE_PATH((short)1, "image_path"); + + private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // IMAGE_PATH + return IMAGE_PATH; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.IMAGE_PATH, new org.apache.thrift.meta_data.FieldMetaData("image_path", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(deleteImageByPath_args.class, metaDataMap); + } + + public deleteImageByPath_args() { + } + + public deleteImageByPath_args( + String image_path) + { + this(); + this.image_path = image_path; + } + + /** + * Performs a deep copy on <i>other</i>. + */ + public deleteImageByPath_args(deleteImageByPath_args other) { + if (other.isSetImage_path()) { + this.image_path = other.image_path; + } + } + + public deleteImageByPath_args deepCopy() { + return new deleteImageByPath_args(this); + } + + @Override + public void clear() { + this.image_path = null; + } + + public String getImage_path() { + return this.image_path; + } + + public deleteImageByPath_args setImage_path(String image_path) { + this.image_path = image_path; + return this; + } + + public void unsetImage_path() { + this.image_path = null; + } + + /** Returns true if field image_path is set (has been assigned a value) and false otherwise */ + public boolean isSetImage_path() { + return this.image_path != null; + } + + public void setImage_pathIsSet(boolean value) { + if (!value) { + this.image_path = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case IMAGE_PATH: + if (value == null) { + unsetImage_path(); + } else { + setImage_path((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case IMAGE_PATH: + return getImage_path(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case IMAGE_PATH: + return isSetImage_path(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof deleteImageByPath_args) + return this.equals((deleteImageByPath_args)that); + return false; + } + + public boolean equals(deleteImageByPath_args that) { + if (that == null) + return false; + + boolean this_present_image_path = true && this.isSetImage_path(); + boolean that_present_image_path = true && that.isSetImage_path(); + if (this_present_image_path || that_present_image_path) { + if (!(this_present_image_path && that_present_image_path)) + return false; + if (!this.image_path.equals(that.image_path)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + @Override + public int compareTo(deleteImageByPath_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetImage_path()).compareTo(other.isSetImage_path()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetImage_path()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.image_path, other.image_path); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("deleteImageByPath_args("); + boolean first = true; + + sb.append("image_path:"); + if (this.image_path == null) { + sb.append("null"); + } else { + sb.append(this.image_path); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class deleteImageByPath_argsStandardSchemeFactory implements SchemeFactory { + public deleteImageByPath_argsStandardScheme getScheme() { + return new deleteImageByPath_argsStandardScheme(); + } + } + + private static class deleteImageByPath_argsStandardScheme extends StandardScheme<deleteImageByPath_args> { + + public void read(org.apache.thrift.protocol.TProtocol iprot, deleteImageByPath_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // IMAGE_PATH + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.image_path = iprot.readString(); + struct.setImage_pathIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, deleteImageByPath_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.image_path != null) { + oprot.writeFieldBegin(IMAGE_PATH_FIELD_DESC); + oprot.writeString(struct.image_path); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class deleteImageByPath_argsTupleSchemeFactory implements SchemeFactory { + public deleteImageByPath_argsTupleScheme getScheme() { + return new deleteImageByPath_argsTupleScheme(); + } + } + + private static class deleteImageByPath_argsTupleScheme extends TupleScheme<deleteImageByPath_args> { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, deleteImageByPath_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetImage_path()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetImage_path()) { + oprot.writeString(struct.image_path); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, deleteImageByPath_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.image_path = iprot.readString(); + struct.setImage_pathIsSet(true); + } + } + } + + } + + public static class deleteImageByPath_result implements org.apache.thrift.TBase<deleteImageByPath_result, deleteImageByPath_result._Fields>, java.io.Serializable, Cloneable, Comparable<deleteImageByPath_result> { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("deleteImageByPath_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.BOOL, (short)0); + + private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new deleteImageByPath_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new deleteImageByPath_resultTupleSchemeFactory()); + } + + public boolean success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __SUCCESS_ISSET_ID = 0; + private byte __isset_bitfield = 0; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(deleteImageByPath_result.class, metaDataMap); + } + + public deleteImageByPath_result() { + } + + public deleteImageByPath_result( + boolean success) + { + this(); + this.success = success; + setSuccessIsSet(true); + } + + /** + * Performs a deep copy on <i>other</i>. + */ + public deleteImageByPath_result(deleteImageByPath_result other) { + __isset_bitfield = other.__isset_bitfield; + this.success = other.success; + } + + public deleteImageByPath_result deepCopy() { + return new deleteImageByPath_result(this); + } + + @Override + public void clear() { + setSuccessIsSet(false); + this.success = false; + } + + public boolean isSuccess() { + return this.success; + } + + public deleteImageByPath_result setSuccess(boolean success) { + this.success = success; + setSuccessIsSet(true); + return this; + } + + public void unsetSuccess() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID); + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID); + } + + public void setSuccessIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value); + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((Boolean)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return Boolean.valueOf(isSuccess()); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof deleteImageByPath_result) + return this.equals((deleteImageByPath_result)that); + return false; + } + + public boolean equals(deleteImageByPath_result that) { + if (that == null) + return false; + + boolean this_present_success = true; + boolean that_present_success = true; + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (this.success != that.success) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + @Override + public int compareTo(deleteImageByPath_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("deleteImageByPath_result("); + boolean first = true; + + sb.append("success:"); + sb.append(this.success); + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class deleteImageByPath_resultStandardSchemeFactory implements SchemeFactory { + public deleteImageByPath_resultStandardScheme getScheme() { + return new deleteImageByPath_resultStandardScheme(); + } + } + + private static class deleteImageByPath_resultStandardScheme extends StandardScheme<deleteImageByPath_result> { + + public void read(org.apache.thrift.protocol.TProtocol iprot, deleteImageByPath_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { + struct.success = iprot.readBool(); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, deleteImageByPath_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.isSetSuccess()) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + oprot.writeBool(struct.success); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class deleteImageByPath_resultTupleSchemeFactory implements SchemeFactory { + public deleteImageByPath_resultTupleScheme getScheme() { + return new deleteImageByPath_resultTupleScheme(); + } + } + + private static class deleteImageByPath_resultTupleScheme extends TupleScheme<deleteImageByPath_result> { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, deleteImageByPath_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + oprot.writeBool(struct.success); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, deleteImageByPath_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.success = iprot.readBool(); + struct.setSuccessIsSet(true); + } + } + } + + } + public static class connectedToLecture_args implements org.apache.thrift.TBase<connectedToLecture_args, connectedToLecture_args._Fields>, java.io.Serializable, Cloneable, Comparable<connectedToLecture_args> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("connectedToLecture_args"); |
