diff options
| author | unknown | 2014-04-25 11:00:22 +0200 |
|---|---|---|
| committer | unknown | 2014-04-25 11:00:22 +0200 |
| commit | ff6fca0ea5478fd8d4f58783773cee217bc407dd (patch) | |
| tree | d16e69e9c7bd42e3ea1485deda5d971b15fa6642 /Dozentenmodulserver/src | |
| parent | Merge branch 'master' of git.openslx.org:openslx-ng/tutor-module (diff) | |
| download | tutor-module-ff6fca0ea5478fd8d4f58783773cee217bc407dd.tar.gz tutor-module-ff6fca0ea5478fd8d4f58783773cee217bc407dd.tar.xz tutor-module-ff6fca0ea5478fd8d4f58783773cee217bc407dd.zip | |
Die XML Datei wird beim Löschen der Lecture nun auch gelöscht
Diffstat (limited to 'Dozentenmodulserver/src')
| -rw-r--r-- | Dozentenmodulserver/src/server/Server.java | 236 | ||||
| -rw-r--r-- | Dozentenmodulserver/src/server/ServerHandler.java | 24 | ||||
| -rw-r--r-- | Dozentenmodulserver/src/sql/SQL.java | 18 |
3 files changed, 263 insertions, 15 deletions
diff --git a/Dozentenmodulserver/src/server/Server.java b/Dozentenmodulserver/src/server/Server.java index 88003fa2..91afb099 100644 --- a/Dozentenmodulserver/src/server/Server.java +++ b/Dozentenmodulserver/src/server/Server.java @@ -70,7 +70,7 @@ public class Server { public boolean connectedToLecture(String id, String version) throws org.apache.thrift.TException; - public boolean deleteLecture(String id) throws org.apache.thrift.TException; + public boolean deleteLecture(String id, String hs, String user) throws org.apache.thrift.TException; } @@ -110,7 +110,7 @@ public class Server { public void connectedToLecture(String id, String version, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; - public void deleteLecture(String id, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void deleteLecture(String id, String hs, String user, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; } @@ -573,16 +573,18 @@ public class Server { throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "connectedToLecture failed: unknown result"); } - public boolean deleteLecture(String id) throws org.apache.thrift.TException + public boolean deleteLecture(String id, String hs, String user) throws org.apache.thrift.TException { - send_deleteLecture(id); + send_deleteLecture(id, hs, user); return recv_deleteLecture(); } - public void send_deleteLecture(String id) throws org.apache.thrift.TException + public void send_deleteLecture(String id, String hs, String user) throws org.apache.thrift.TException { deleteLecture_args args = new deleteLecture_args(); args.setId(id); + args.setHs(hs); + args.setUser(user); sendBase("deleteLecture", args); } @@ -1302,24 +1304,30 @@ public class Server { } } - public void deleteLecture(String id, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + public void deleteLecture(String id, String hs, String user, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); - deleteLecture_call method_call = new deleteLecture_call(id, resultHandler, this, ___protocolFactory, ___transport); + deleteLecture_call method_call = new deleteLecture_call(id, hs, user, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class deleteLecture_call extends org.apache.thrift.async.TAsyncMethodCall { private String id; - public deleteLecture_call(String id, 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 { + private String hs; + private String user; + public deleteLecture_call(String id, String hs, String user, 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.id = id; + this.hs = hs; + this.user = user; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("deleteLecture", org.apache.thrift.protocol.TMessageType.CALL, 0)); deleteLecture_args args = new deleteLecture_args(); args.setId(id); + args.setHs(hs); + args.setUser(user); args.write(prot); prot.writeMessageEnd(); } @@ -1732,7 +1740,7 @@ public class Server { public deleteLecture_result getResult(I iface, deleteLecture_args args) throws org.apache.thrift.TException { deleteLecture_result result = new deleteLecture_result(); - result.success = iface.deleteLecture(args.id); + result.success = iface.deleteLecture(args.id, args.hs, args.user); result.setSuccessIsSet(true); return result; } @@ -2696,7 +2704,7 @@ public class Server { } public void start(I iface, deleteLecture_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws TException { - iface.deleteLecture(args.id,resultHandler); + iface.deleteLecture(args.id, args.hs, args.user,resultHandler); } } @@ -19784,6 +19792,8 @@ public class Server { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("deleteLecture_args"); private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.STRING, (short)-1); + private static final org.apache.thrift.protocol.TField HS_FIELD_DESC = new org.apache.thrift.protocol.TField("hs", org.apache.thrift.protocol.TType.STRING, (short)-2); + private static final org.apache.thrift.protocol.TField USER_FIELD_DESC = new org.apache.thrift.protocol.TField("user", org.apache.thrift.protocol.TType.STRING, (short)-3); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { @@ -19792,10 +19802,14 @@ public class Server { } public String id; // required + public String hs; // required + public String user; // 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 { - ID((short)-1, "id"); + ID((short)-1, "id"), + HS((short)-2, "hs"), + USER((short)-3, "user"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); @@ -19812,6 +19826,10 @@ public class Server { switch(fieldId) { case -1: // ID return ID; + case -2: // HS + return HS; + case -3: // USER + return USER; default: return null; } @@ -19857,6 +19875,10 @@ public class Server { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.HS, new org.apache.thrift.meta_data.FieldMetaData("hs", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.USER, new org.apache.thrift.meta_data.FieldMetaData("user", 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(deleteLecture_args.class, metaDataMap); } @@ -19865,10 +19887,14 @@ public class Server { } public deleteLecture_args( - String id) + String id, + String hs, + String user) { this(); this.id = id; + this.hs = hs; + this.user = user; } /** @@ -19878,6 +19904,12 @@ public class Server { if (other.isSetId()) { this.id = other.id; } + if (other.isSetHs()) { + this.hs = other.hs; + } + if (other.isSetUser()) { + this.user = other.user; + } } public deleteLecture_args deepCopy() { @@ -19887,6 +19919,8 @@ public class Server { @Override public void clear() { this.id = null; + this.hs = null; + this.user = null; } public String getId() { @@ -19913,6 +19947,54 @@ public class Server { } } + public String getHs() { + return this.hs; + } + + public deleteLecture_args setHs(String hs) { + this.hs = hs; + return this; + } + + public void unsetHs() { + this.hs = null; + } + + /** Returns true if field hs is set (has been assigned a value) and false otherwise */ + public boolean isSetHs() { + return this.hs != null; + } + + public void setHsIsSet(boolean value) { + if (!value) { + this.hs = null; + } + } + + public String getUser() { + return this.user; + } + + public deleteLecture_args setUser(String user) { + this.user = user; + return this; + } + + public void unsetUser() { + this.user = null; + } + + /** Returns true if field user is set (has been assigned a value) and false otherwise */ + public boolean isSetUser() { + return this.user != null; + } + + public void setUserIsSet(boolean value) { + if (!value) { + this.user = null; + } + } + public void setFieldValue(_Fields field, Object value) { switch (field) { case ID: @@ -19923,6 +20005,22 @@ public class Server { } break; + case HS: + if (value == null) { + unsetHs(); + } else { + setHs((String)value); + } + break; + + case USER: + if (value == null) { + unsetUser(); + } else { + setUser((String)value); + } + break; + } } @@ -19931,6 +20029,12 @@ public class Server { case ID: return getId(); + case HS: + return getHs(); + + case USER: + return getUser(); + } throw new IllegalStateException(); } @@ -19944,6 +20048,10 @@ public class Server { switch (field) { case ID: return isSetId(); + case HS: + return isSetHs(); + case USER: + return isSetUser(); } throw new IllegalStateException(); } @@ -19970,6 +20078,24 @@ public class Server { return false; } + boolean this_present_hs = true && this.isSetHs(); + boolean that_present_hs = true && that.isSetHs(); + if (this_present_hs || that_present_hs) { + if (!(this_present_hs && that_present_hs)) + return false; + if (!this.hs.equals(that.hs)) + return false; + } + + boolean this_present_user = true && this.isSetUser(); + boolean that_present_user = true && that.isSetUser(); + if (this_present_user || that_present_user) { + if (!(this_present_user && that_present_user)) + return false; + if (!this.user.equals(that.user)) + return false; + } + return true; } @@ -19996,6 +20122,26 @@ public class Server { return lastComparison; } } + lastComparison = Boolean.valueOf(isSetHs()).compareTo(other.isSetHs()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetHs()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.hs, other.hs); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetUser()).compareTo(other.isSetUser()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetUser()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.user, other.user); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -20023,6 +20169,22 @@ public class Server { sb.append(this.id); } first = false; + if (!first) sb.append(", "); + sb.append("hs:"); + if (this.hs == null) { + sb.append("null"); + } else { + sb.append(this.hs); + } + first = false; + if (!first) sb.append(", "); + sb.append("user:"); + if (this.user == null) { + sb.append("null"); + } else { + sb.append(this.user); + } + first = false; sb.append(")"); return sb.toString(); } @@ -20074,6 +20236,22 @@ public class Server { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case -2: // HS + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.hs = iprot.readString(); + struct.setHsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case -3: // USER + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.user = iprot.readString(); + struct.setUserIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -20089,6 +20267,16 @@ public class Server { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); + if (struct.user != null) { + oprot.writeFieldBegin(USER_FIELD_DESC); + oprot.writeString(struct.user); + oprot.writeFieldEnd(); + } + if (struct.hs != null) { + oprot.writeFieldBegin(HS_FIELD_DESC); + oprot.writeString(struct.hs); + oprot.writeFieldEnd(); + } if (struct.id != null) { oprot.writeFieldBegin(ID_FIELD_DESC); oprot.writeString(struct.id); @@ -20115,20 +20303,40 @@ public class Server { if (struct.isSetId()) { optionals.set(0); } - oprot.writeBitSet(optionals, 1); + if (struct.isSetHs()) { + optionals.set(1); + } + if (struct.isSetUser()) { + optionals.set(2); + } + oprot.writeBitSet(optionals, 3); if (struct.isSetId()) { oprot.writeString(struct.id); } + if (struct.isSetHs()) { + oprot.writeString(struct.hs); + } + if (struct.isSetUser()) { + oprot.writeString(struct.user); + } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, deleteLecture_args struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(1); + BitSet incoming = iprot.readBitSet(3); if (incoming.get(0)) { struct.id = iprot.readString(); struct.setIdIsSet(true); } + if (incoming.get(1)) { + struct.hs = iprot.readString(); + struct.setHsIsSet(true); + } + if (incoming.get(2)) { + struct.user = iprot.readString(); + struct.setUserIsSet(true); + } } } diff --git a/Dozentenmodulserver/src/server/ServerHandler.java b/Dozentenmodulserver/src/server/ServerHandler.java index f9450107..9529ec22 100644 --- a/Dozentenmodulserver/src/server/ServerHandler.java +++ b/Dozentenmodulserver/src/server/ServerHandler.java @@ -383,11 +383,13 @@ public class ServerHandler implements Server.Iface { String stringFile = sql.getFile(con, imageid, imageversion); log.info(new Date()+" - File to Delete: "+stringFile); + File tmpFile = new File(stringFile); try { //File wird von Server gelöscht FileUtils.forceDelete(tmpFile); + log.info(new Date()+" - Delete Successful"); return true; @@ -413,8 +415,28 @@ public class ServerHandler implements Server.Iface { return sql.connectedToLecture(con, id, version); } - public boolean deleteLecture(String id){ + public boolean deleteLecture(String id, String hs, String user){ + ResultSet rs=sql.getDeleteXMLData(con, id); + try { + rs.next(); + String date=rs.getString("admin_createTime").replace(" ", "").replace("-", "").replace(":", ""); + String name=rs.getString("name"); + String path="/srv/openslx/nfs/temp/"+date.substring(0, date.length()-2)+"_"+hs+"_"+user+"_"+name+".xml"; + log.info(new Date()+" - File to Delete: "+path); + File xmlFile=new File(path); + FileUtils.forceDelete(xmlFile); + log.info(new Date()+" - Delete Successful"); + } catch (SQLException e) { + log.info(new Date()+" - Delete Failed"); + e.printStackTrace(); + } catch (IOException e) { + log.info(new Date()+" - Delete Failed"); + e.printStackTrace(); + } return sql.deleteLecture(con, id); + } + + } diff --git a/Dozentenmodulserver/src/sql/SQL.java b/Dozentenmodulserver/src/sql/SQL.java index 143efb78..ab5f28aa 100644 --- a/Dozentenmodulserver/src/sql/SQL.java +++ b/Dozentenmodulserver/src/sql/SQL.java @@ -556,4 +556,22 @@ public class SQL { return null;
}
+
+ public ResultSet getDeleteXMLData(Connection con, String id)
+ {
+ try {
+ Statement stm = con.createStatement();
+
+ ResultSet rs=stm.executeQuery("SELECT name, admin_createTime FROM bwLehrpool.m_VLData_lecture where lectureID='"+id+"';");
+
+
+ return rs;
+
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return null;
+ }
}
|
