summaryrefslogtreecommitdiffstats
path: root/Dozentenmodulserver/src
diff options
context:
space:
mode:
authorunknown2014-05-25 17:49:07 +0200
committerunknown2014-05-25 17:49:07 +0200
commitb0b65eca6b6600a57d71c5f63f8e5a066e6accd7 (patch)
tree21b55c6f7ff2c60401ede9f369738b2ae2d5f77f /Dozentenmodulserver/src
parent links + encoding (diff)
parentFreigabe Mechanismus implementiert, nun sollte die notwendige Grundlage für d... (diff)
downloadtutor-module-b0b65eca6b6600a57d71c5f63f8e5a066e6accd7.tar.gz
tutor-module-b0b65eca6b6600a57d71c5f63f8e5a066e6accd7.tar.xz
tutor-module-b0b65eca6b6600a57d71c5f63f8e5a066e6accd7.zip
Merge branch 'master' of ssh://git.openslx.org/openslx-ng/tutor-module
Conflicts: ffffDozentenmodul/bin/gui/image/CreateImageTechnisch_GUI.class Dozentenmodul/bin/gui/image/DeleteImage_GUI.class Dozentenmodul/bin/gui/image/EditImageAllgemein_GUI.class Dozentenmodul/bin/gui/image/FTPCreateUploader_GUI$8.class Dozentenmodul/bin/gui/image/FTPCreateUploader_GUI.class Dozentenmodul/bin/gui/image/FTPDownloader_GUI.class Dozentenmodul/bin/gui/image/FTPEditUploader_GUI.class Dozentenmodul/bin/gui/image/SearchEditImage_GUI.class Dozentenmodul/bin/gui/image/SearchImage_GUI.class Dozentenmodul/bin/gui/intro/VmWareLink_GUI.class Dozentenmodul/bin/gui/lecture/CreateLectureAllgemein_GUI.class Dozentenmodul/bin/gui/lecture/EditLectureAllgemein_GUI.class Dozentenmodul/bin/gui/lecture/ExtendedSearchForImages_GUI.class Dozentenmodul/src/gui/lecture/EditLectureLink_GUI.java Dozentenmodul/src/models/Links.java
Diffstat (limited to 'Dozentenmodulserver/src')
-rw-r--r--Dozentenmodulserver/src/server/BinaryListener.java43
-rw-r--r--Dozentenmodulserver/src/server/Server.java252
-rw-r--r--Dozentenmodulserver/src/server/ServerHandler.java293
-rw-r--r--Dozentenmodulserver/src/server/TBinaryProtocolSafe.java123
-rw-r--r--Dozentenmodulserver/src/server/startServer.java35
-rw-r--r--Dozentenmodulserver/src/sql/SQL.java252
-rw-r--r--Dozentenmodulserver/src/util/XMLCreator.java2
7 files changed, 687 insertions, 313 deletions
diff --git a/Dozentenmodulserver/src/server/BinaryListener.java b/Dozentenmodulserver/src/server/BinaryListener.java
index a48b381e..ffeb9bd5 100644
--- a/Dozentenmodulserver/src/server/BinaryListener.java
+++ b/Dozentenmodulserver/src/server/BinaryListener.java
@@ -3,33 +3,46 @@ package server;
import java.util.Date;
import org.apache.log4j.Logger;
+import org.apache.thrift.protocol.TProtocolFactory;
import org.apache.thrift.server.TServer;
-import org.apache.thrift.server.TServer.Args;
-import org.apache.thrift.server.TSimpleServer;
+import org.apache.thrift.server.TThreadPoolServer.Args;
+import org.apache.thrift.server.TThreadPoolServer;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TServerTransport;
import org.apache.thrift.transport.TTransportException;
-public class BinaryListener implements Runnable
-{
- private static Logger log = Logger.getLogger( BinaryListener.class );
+public class BinaryListener implements Runnable {
+ private static Logger log = Logger.getLogger(BinaryListener.class);
+
+ private final int MINWORKERTHREADS = 20; // keine ahnung ob das passt...
+ private final int MAXWORKERTHREADS = 80; // ebenso
@Override
- public void run()
- {
+ public void run() {
final ServerHandler handler = new ServerHandler();
- final Server.Processor<ServerHandler> processor = new Server.Processor<ServerHandler>( handler );
+ final Server.Processor<ServerHandler> processor = new Server.Processor<ServerHandler>(
+ handler);
final TServerTransport transport;
+ final TProtocolFactory protFactory = new TBinaryProtocolSafe.Factory(
+ true, true);
try {
- transport = new TServerSocket( 9090 );
- log.info(new Date()+" - Connected to Port 9090");
- } catch ( TTransportException e ) {
- log.fatal( new Date() +" - Could not listen on port 9090" );
+ transport = new TServerSocket(9090);
+ log.info(new Date() + " - Connected to Port 9090");
+
+ } catch (TTransportException e) {
+ log.fatal(new Date() + " - Could not listen on port 9090");
return;
}
- TServer server = new TSimpleServer( new Args( transport ).processor( processor ) );
- log.info(new Date() +" - Started running BinaryListener");
+ TServer server = new TThreadPoolServer(new Args(transport)
+ .protocolFactory(protFactory).processor(processor)
+ .minWorkerThreads(MINWORKERTHREADS)
+ .maxWorkerThreads(MAXWORKERTHREADS));
+
+ log.info(new Date() + " - Started running BinaryListener");
+ log.info(new Date() + " - MINWORKERTHREADS=" + MINWORKERTHREADS
+ + " and MAXWORKERTHREADS=" + MAXWORKERTHREADS + "\n");
server.serve();
+
}
-
+
}
diff --git a/Dozentenmodulserver/src/server/Server.java b/Dozentenmodulserver/src/server/Server.java
index ef434865..b652bf7a 100644
--- a/Dozentenmodulserver/src/server/Server.java
+++ b/Dozentenmodulserver/src/server/Server.java
@@ -42,7 +42,7 @@ public class Server {
public String getPathOfImage(String image_id, String version) throws org.apache.thrift.TException;
- public boolean writeVLdata(String imagename, String login, String firstname, String lastname, String university, String Mail, String Tel, String Fak, boolean license, boolean internet, long ram, long cpu, String imagePath, boolean isTemplate, long filesize) throws org.apache.thrift.TException;
+ public boolean writeVLdata(String imagename, String login, String firstname, String lastname, String university, String Mail, String Tel, String Fak, boolean license, boolean internet, long ram, long cpu, String imagePath, boolean isTemplate, long filesize, long shareMode) throws org.apache.thrift.TException;
public List<Image> getImageList() throws org.apache.thrift.TException;
@@ -58,7 +58,7 @@ public class Server {
public Map<String,String> getImageData(String imageid, String imageversion) throws org.apache.thrift.TException;
- public boolean updateImageData(String name, String newName, String image_path, boolean license, boolean internet, long ram, long cpu, String id, String version, boolean isTemplate, long filesize) throws org.apache.thrift.TException;
+ public boolean updateImageData(String name, String newName, String image_path, boolean license, boolean internet, long ram, long cpu, String id, String version, boolean isTemplate, long filesize, long shareMode) throws org.apache.thrift.TException;
public Map<String,String> getLectureData(String lecturename) throws org.apache.thrift.TException;
@@ -82,7 +82,7 @@ public class Server {
public void getPathOfImage(String image_id, String version, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
- public void writeVLdata(String imagename, String login, String firstname, String lastname, String university, String Mail, String Tel, String Fak, boolean license, boolean internet, long ram, long cpu, String imagePath, boolean isTemplate, long filesize, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
+ public void writeVLdata(String imagename, String login, String firstname, String lastname, String university, String Mail, String Tel, String Fak, boolean license, boolean internet, long ram, long cpu, String imagePath, boolean isTemplate, long filesize, long shareMode, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
public void getImageList(org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
@@ -98,7 +98,7 @@ public class Server {
public void getImageData(String imageid, String imageversion, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
- public void updateImageData(String name, String newName, String image_path, boolean license, boolean internet, long ram, long cpu, String id, String version, boolean isTemplate, long filesize, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
+ public void updateImageData(String name, String newName, String image_path, boolean license, boolean internet, long ram, long cpu, String id, String version, boolean isTemplate, long filesize, long shareMode, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
public void getLectureData(String lecturename, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
@@ -203,13 +203,13 @@ public class Server {
throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getPathOfImage failed: unknown result");
}
- public boolean writeVLdata(String imagename, String login, String firstname, String lastname, String university, String Mail, String Tel, String Fak, boolean license, boolean internet, long ram, long cpu, String imagePath, boolean isTemplate, long filesize) throws org.apache.thrift.TException
+ public boolean writeVLdata(String imagename, String login, String firstname, String lastname, String university, String Mail, String Tel, String Fak, boolean license, boolean internet, long ram, long cpu, String imagePath, boolean isTemplate, long filesize, long shareMode) throws org.apache.thrift.TException
{
- send_writeVLdata(imagename, login, firstname, lastname, university, Mail, Tel, Fak, license, internet, ram, cpu, imagePath, isTemplate, filesize);
+ send_writeVLdata(imagename, login, firstname, lastname, university, Mail, Tel, Fak, license, internet, ram, cpu, imagePath, isTemplate, filesize, shareMode);
return recv_writeVLdata();
}
- public void send_writeVLdata(String imagename, String login, String firstname, String lastname, String university, String Mail, String Tel, String Fak, boolean license, boolean internet, long ram, long cpu, String imagePath, boolean isTemplate, long filesize) throws org.apache.thrift.TException
+ public void send_writeVLdata(String imagename, String login, String firstname, String lastname, String university, String Mail, String Tel, String Fak, boolean license, boolean internet, long ram, long cpu, String imagePath, boolean isTemplate, long filesize, long shareMode) throws org.apache.thrift.TException
{
writeVLdata_args args = new writeVLdata_args();
args.setImagename(imagename);
@@ -227,6 +227,7 @@ public class Server {
args.setImagePath(imagePath);
args.setIsTemplate(isTemplate);
args.setFilesize(filesize);
+ args.setShareMode(shareMode);
sendBase("writeVLdata", args);
}
@@ -413,13 +414,13 @@ public class Server {
throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getImageData failed: unknown result");
}
- public boolean updateImageData(String name, String newName, String image_path, boolean license, boolean internet, long ram, long cpu, String id, String version, boolean isTemplate, long filesize) throws org.apache.thrift.TException
+ public boolean updateImageData(String name, String newName, String image_path, boolean license, boolean internet, long ram, long cpu, String id, String version, boolean isTemplate, long filesize, long shareMode) throws org.apache.thrift.TException
{
- send_updateImageData(name, newName, image_path, license, internet, ram, cpu, id, version, isTemplate, filesize);
+ send_updateImageData(name, newName, image_path, license, internet, ram, cpu, id, version, isTemplate, filesize, shareMode);
return recv_updateImageData();
}
- public void send_updateImageData(String name, String newName, String image_path, boolean license, boolean internet, long ram, long cpu, String id, String version, boolean isTemplate, long filesize) throws org.apache.thrift.TException
+ public void send_updateImageData(String name, String newName, String image_path, boolean license, boolean internet, long ram, long cpu, String id, String version, boolean isTemplate, long filesize, long shareMode) throws org.apache.thrift.TException
{
updateImageData_args args = new updateImageData_args();
args.setName(name);
@@ -433,6 +434,7 @@ public class Server {
args.setVersion(version);
args.setIsTemplate(isTemplate);
args.setFilesize(filesize);
+ args.setShareMode(shareMode);
sendBase("updateImageData", args);
}
@@ -717,9 +719,9 @@ public class Server {
}
}
- public void writeVLdata(String imagename, String login, String firstname, String lastname, String university, String Mail, String Tel, String Fak, boolean license, boolean internet, long ram, long cpu, String imagePath, boolean isTemplate, long filesize, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
+ public void writeVLdata(String imagename, String login, String firstname, String lastname, String university, String Mail, String Tel, String Fak, boolean license, boolean internet, long ram, long cpu, String imagePath, boolean isTemplate, long filesize, long shareMode, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
checkReady();
- writeVLdata_call method_call = new writeVLdata_call(imagename, login, firstname, lastname, university, Mail, Tel, Fak, license, internet, ram, cpu, imagePath, isTemplate, filesize, resultHandler, this, ___protocolFactory, ___transport);
+ writeVLdata_call method_call = new writeVLdata_call(imagename, login, firstname, lastname, university, Mail, Tel, Fak, license, internet, ram, cpu, imagePath, isTemplate, filesize, shareMode, resultHandler, this, ___protocolFactory, ___transport);
this.___currentMethod = method_call;
___manager.call(method_call);
}
@@ -740,7 +742,8 @@ public class Server {
private String imagePath;
private boolean isTemplate;
private long filesize;
- public writeVLdata_call(String imagename, String login, String firstname, String lastname, String university, String Mail, String Tel, String Fak, boolean license, boolean internet, long ram, long cpu, String imagePath, boolean isTemplate, long filesize, 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 long shareMode;
+ public writeVLdata_call(String imagename, String login, String firstname, String lastname, String university, String Mail, String Tel, String Fak, boolean license, boolean internet, long ram, long cpu, String imagePath, boolean isTemplate, long filesize, long shareMode, 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.imagename = imagename;
this.login = login;
@@ -757,6 +760,7 @@ public class Server {
this.imagePath = imagePath;
this.isTemplate = isTemplate;
this.filesize = filesize;
+ this.shareMode = shareMode;
}
public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
@@ -777,6 +781,7 @@ public class Server {
args.setImagePath(imagePath);
args.setIsTemplate(isTemplate);
args.setFilesize(filesize);
+ args.setShareMode(shareMode);
args.write(prot);
prot.writeMessageEnd();
}
@@ -1051,9 +1056,9 @@ public class Server {
}
}
- public void updateImageData(String name, String newName, String image_path, boolean license, boolean internet, long ram, long cpu, String id, String version, boolean isTemplate, long filesize, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
+ public void updateImageData(String name, String newName, String image_path, boolean license, boolean internet, long ram, long cpu, String id, String version, boolean isTemplate, long filesize, long shareMode, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
checkReady();
- updateImageData_call method_call = new updateImageData_call(name, newName, image_path, license, internet, ram, cpu, id, version, isTemplate, filesize, resultHandler, this, ___protocolFactory, ___transport);
+ updateImageData_call method_call = new updateImageData_call(name, newName, image_path, license, internet, ram, cpu, id, version, isTemplate, filesize, shareMode, resultHandler, this, ___protocolFactory, ___transport);
this.___currentMethod = method_call;
___manager.call(method_call);
}
@@ -1070,7 +1075,8 @@ public class Server {
private String version;
private boolean isTemplate;
private long filesize;
- public updateImageData_call(String name, String newName, String image_path, boolean license, boolean internet, long ram, long cpu, String id, String version, boolean isTemplate, long filesize, 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 long shareMode;
+ public updateImageData_call(String name, String newName, String image_path, boolean license, boolean internet, long ram, long cpu, String id, String version, boolean isTemplate, long filesize, long shareMode, 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.name = name;
this.newName = newName;
@@ -1083,6 +1089,7 @@ public class Server {
this.version = version;
this.isTemplate = isTemplate;
this.filesize = filesize;
+ this.shareMode = shareMode;
}
public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
@@ -1099,6 +1106,7 @@ public class Server {
args.setVersion(version);
args.setIsTemplate(isTemplate);
args.setFilesize(filesize);
+ args.setShareMode(shareMode);
args.write(prot);
prot.writeMessageEnd();
}
@@ -1472,7 +1480,7 @@ public class Server {
public writeVLdata_result getResult(I iface, writeVLdata_args args) throws org.apache.thrift.TException {
writeVLdata_result result = new writeVLdata_result();
- result.success = iface.writeVLdata(args.imagename, args.login, args.firstname, args.lastname, args.university, args.Mail, args.Tel, args.Fak, args.license, args.internet, args.ram, args.cpu, args.imagePath, args.isTemplate, args.filesize);
+ result.success = iface.writeVLdata(args.imagename, args.login, args.firstname, args.lastname, args.university, args.Mail, args.Tel, args.Fak, args.license, args.internet, args.ram, args.cpu, args.imagePath, args.isTemplate, args.filesize, args.shareMode);
result.setSuccessIsSet(true);
return result;
}
@@ -1635,7 +1643,7 @@ public class Server {
public updateImageData_result getResult(I iface, updateImageData_args args) throws org.apache.thrift.TException {
updateImageData_result result = new updateImageData_result();
- result.success = iface.updateImageData(args.name, args.newName, args.image_path, args.license, args.internet, args.ram, args.cpu, args.id, args.version, args.isTemplate, args.filesize);
+ result.success = iface.updateImageData(args.name, args.newName, args.image_path, args.license, args.internet, args.ram, args.cpu, args.id, args.version, args.isTemplate, args.filesize, args.shareMode);
result.setSuccessIsSet(true);
return result;
}
@@ -2002,7 +2010,7 @@ public class Server {
}
public void start(I iface, writeVLdata_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws TException {
- iface.writeVLdata(args.imagename, args.login, args.firstname, args.lastname, args.university, args.Mail, args.Tel, args.Fak, args.license, args.internet, args.ram, args.cpu, args.imagePath, args.isTemplate, args.filesize,resultHandler);
+ iface.writeVLdata(args.imagename, args.login, args.firstname, args.lastname, args.university, args.Mail, args.Tel, args.Fak, args.license, args.internet, args.ram, args.cpu, args.imagePath, args.isTemplate, args.filesize, args.shareMode,resultHandler);
}
}
@@ -2413,7 +2421,7 @@ public class Server {
}
public void start(I iface, updateImageData_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws TException {
- iface.updateImageData(args.name, args.newName, args.image_path, args.license, args.internet, args.ram, args.cpu, args.id, args.version, args.isTemplate, args.filesize,resultHandler);
+ iface.updateImageData(args.name, args.newName, args.image_path, args.license, args.internet, args.ram, args.cpu, args.id, args.version, args.isTemplate, args.filesize, args.shareMode,resultHandler);
}
}
@@ -4869,6 +4877,7 @@ public class Server {
private static final org.apache.thrift.protocol.TField IMAGE_PATH_FIELD_DESC = new org.apache.thrift.protocol.TField("imagePath", org.apache.thrift.protocol.TType.STRING, (short)-13);
private static final org.apache.thrift.protocol.TField IS_TEMPLATE_FIELD_DESC = new org.apache.thrift.protocol.TField("isTemplate", org.apache.thrift.protocol.TType.BOOL, (short)-14);
private static final org.apache.thrift.protocol.TField FILESIZE_FIELD_DESC = new org.apache.thrift.protocol.TField("filesize", org.apache.thrift.protocol.TType.I64, (short)-15);
+ private static final org.apache.thrift.protocol.TField SHARE_MODE_FIELD_DESC = new org.apache.thrift.protocol.TField("shareMode", org.apache.thrift.protocol.TType.I64, (short)-16);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
@@ -4891,6 +4900,7 @@ public class Server {
public String imagePath; // required
public boolean isTemplate; // required
public long filesize; // required
+ public long shareMode; // 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 {
@@ -4908,7 +4918,8 @@ public class Server {
CPU((short)-12, "cpu"),
IMAGE_PATH((short)-13, "imagePath"),
IS_TEMPLATE((short)-14, "isTemplate"),
- FILESIZE((short)-15, "filesize");
+ FILESIZE((short)-15, "filesize"),
+ SHARE_MODE((short)-16, "shareMode");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@@ -4953,6 +4964,8 @@ public class Server {
return IS_TEMPLATE;
case -15: // FILESIZE
return FILESIZE;
+ case -16: // SHARE_MODE
+ return SHARE_MODE;
default:
return null;
}
@@ -4999,6 +5012,7 @@ public class Server {
private static final int __CPU_ISSET_ID = 3;
private static final int __ISTEMPLATE_ISSET_ID = 4;
private static final int __FILESIZE_ISSET_ID = 5;
+ private static final int __SHAREMODE_ISSET_ID = 6;
private byte __isset_bitfield = 0;
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
@@ -5033,6 +5047,8 @@ public class Server {
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
tmpMap.put(_Fields.FILESIZE, new org.apache.thrift.meta_data.FieldMetaData("filesize", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
+ tmpMap.put(_Fields.SHARE_MODE, new org.apache.thrift.meta_data.FieldMetaData("shareMode", org.apache.thrift.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64 , "int")));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(writeVLdata_args.class, metaDataMap);
}
@@ -5055,7 +5071,8 @@ public class Server {
long cpu,
String imagePath,
boolean isTemplate,
- long filesize)
+ long filesize,
+ long shareMode)
{
this();
this.imagename = imagename;
@@ -5079,6 +5096,8 @@ public class Server {
setIsTemplateIsSet(true);
this.filesize = filesize;
setFilesizeIsSet(true);
+ this.shareMode = shareMode;
+ setShareModeIsSet(true);
}
/**
@@ -5119,6 +5138,7 @@ public class Server {
}
this.isTemplate = other.isTemplate;
this.filesize = other.filesize;
+ this.shareMode = other.shareMode;
}
public writeVLdata_args deepCopy() {
@@ -5148,6 +5168,8 @@ public class Server {
this.isTemplate = false;
setFilesizeIsSet(false);
this.filesize = 0;
+ setShareModeIsSet(false);
+ this.shareMode = 0;
}
public String getImagename() {
@@ -5504,6 +5526,29 @@ public class Server {
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __FILESIZE_ISSET_ID, value);
}
+ public long getShareMode() {
+ return this.shareMode;
+ }
+
+ public writeVLdata_args setShareMode(long shareMode) {
+ this.shareMode = shareMode;
+ setShareModeIsSet(true);
+ return this;
+ }
+
+ public void unsetShareMode() {
+ __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __SHAREMODE_ISSET_ID);
+ }
+
+ /** Returns true if field shareMode is set (has been assigned a value) and false otherwise */
+ public boolean isSetShareMode() {
+ return EncodingUtils.testBit(__isset_bitfield, __SHAREMODE_ISSET_ID);
+ }
+
+ public void setShareModeIsSet(boolean value) {
+ __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __SHAREMODE_ISSET_ID, value);
+ }
+
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case IMAGENAME:
@@ -5626,6 +5671,14 @@ public class Server {
}
break;
+ case SHARE_MODE:
+ if (value == null) {
+ unsetShareMode();
+ } else {
+ setShareMode((Long)value);
+ }
+ break;
+
}
}
@@ -5676,6 +5729,9 @@ public class Server {
case FILESIZE:
return Long.valueOf(getFilesize());
+ case SHARE_MODE:
+ return Long.valueOf(getShareMode());
+
}
throw new IllegalStateException();
}
@@ -5717,6 +5773,8 @@ public class Server {
return isSetIsTemplate();
case FILESIZE:
return isSetFilesize();
+ case SHARE_MODE:
+ return isSetShareMode();
}
throw new IllegalStateException();
}
@@ -5869,6 +5927,15 @@ public class Server {
return false;
}
+ boolean this_present_shareMode = true;
+ boolean that_present_shareMode = true;
+ if (this_present_shareMode || that_present_shareMode) {
+ if (!(this_present_shareMode && that_present_shareMode))
+ return false;
+ if (this.shareMode != that.shareMode)
+ return false;
+ }
+
return true;
}
@@ -6035,6 +6102,16 @@ public class Server {
return lastComparison;
}
}
+ lastComparison = Boolean.valueOf(isSetShareMode()).compareTo(other.isSetShareMode());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetShareMode()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.shareMode, other.shareMode);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
return 0;
}
@@ -6150,6 +6227,10 @@ public class Server {
sb.append("filesize:");
sb.append(this.filesize);
first = false;
+ if (!first) sb.append(", ");
+ sb.append("shareMode:");
+ sb.append(this.shareMode);
+ first = false;
sb.append(")");
return sb.toString();
}
@@ -6315,6 +6396,14 @@ public class Server {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
+ case -16: // SHARE_MODE
+ if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
+ struct.shareMode = iprot.readI64();
+ struct.setShareModeIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
@@ -6330,6 +6419,9 @@ public class Server {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
+ oprot.writeFieldBegin(SHARE_MODE_FIELD_DESC);
+ oprot.writeI64(struct.shareMode);
+ oprot.writeFieldEnd();
oprot.writeFieldBegin(FILESIZE_FIELD_DESC);
oprot.writeI64(struct.filesize);
oprot.writeFieldEnd();
@@ -6456,7 +6548,10 @@ public class Server {
if (struct.isSetFilesize()) {
optionals.set(14);
}
- oprot.writeBitSet(optionals, 15);
+ if (struct.isSetShareMode()) {
+ optionals.set(15);
+ }
+ oprot.writeBitSet(optionals, 16);
if (struct.isSetImagename()) {
oprot.writeString(struct.imagename);
}
@@ -6502,12 +6597,15 @@ public class Server {
if (struct.isSetFilesize()) {
oprot.writeI64(struct.filesize);
}
+ if (struct.isSetShareMode()) {
+ oprot.writeI64(struct.shareMode);
+ }
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, writeVLdata_args struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
- BitSet incoming = iprot.readBitSet(15);
+ BitSet incoming = iprot.readBitSet(16);
if (incoming.get(0)) {
struct.imagename = iprot.readString();
struct.setImagenameIsSet(true);
@@ -6568,6 +6666,10 @@ public class Server {
struct.filesize = iprot.readI64();
struct.setFilesizeIsSet(true);
}
+ if (incoming.get(15)) {
+ struct.shareMode = iprot.readI64();
+ struct.setShareModeIsSet(true);
+ }
}
}
@@ -13332,6 +13434,7 @@ public class Server {
private static final org.apache.thrift.protocol.TField VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("version", org.apache.thrift.protocol.TType.STRING, (short)-9);
private static final org.apache.thrift.protocol.TField IS_TEMPLATE_FIELD_DESC = new org.apache.thrift.protocol.TField("isTemplate", org.apache.thrift.protocol.TType.BOOL, (short)-10);
private static final org.apache.thrift.protocol.TField FILESIZE_FIELD_DESC = new org.apache.thrift.protocol.TField("filesize", org.apache.thrift.protocol.TType.I64, (short)-11);
+ private static final org.apache.thrift.protocol.TField SHARE_MODE_FIELD_DESC = new org.apache.thrift.protocol.TField("shareMode", org.apache.thrift.protocol.TType.I64, (short)-12);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
@@ -13350,6 +13453,7 @@ public class Server {
public String version; // required
public boolean isTemplate; // required
public long filesize; // required
+ public long shareMode; // 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 {
@@ -13363,7 +13467,8 @@ public class Server {
ID((short)-8, "id"),
VERSION((short)-9, "version"),
IS_TEMPLATE((short)-10, "isTemplate"),
- FILESIZE((short)-11, "filesize");
+ FILESIZE((short)-11, "filesize"),
+ SHARE_MODE((short)-12, "shareMode");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@@ -13400,6 +13505,8 @@ public class Server {
return IS_TEMPLATE;
case -11: // FILESIZE
return FILESIZE;
+ case -12: // SHARE_MODE
+ return SHARE_MODE;
default:
return null;
}
@@ -13446,6 +13553,7 @@ public class Server {
private static final int __CPU_ISSET_ID = 3;
private static final int __ISTEMPLATE_ISSET_ID = 4;
private static final int __FILESIZE_ISSET_ID = 5;
+ private static final int __SHAREMODE_ISSET_ID = 6;
private byte __isset_bitfield = 0;
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
@@ -13472,6 +13580,8 @@ public class Server {
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
tmpMap.put(_Fields.FILESIZE, new org.apache.thrift.meta_data.FieldMetaData("filesize", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
+ tmpMap.put(_Fields.SHARE_MODE, new org.apache.thrift.meta_data.FieldMetaData("shareMode", org.apache.thrift.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64 , "int")));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(updateImageData_args.class, metaDataMap);
}
@@ -13490,7 +13600,8 @@ public class Server {
String id,
String version,
boolean isTemplate,
- long filesize)
+ long filesize,
+ long shareMode)
{
this();
this.name = name;
@@ -13510,6 +13621,8 @@ public class Server {
setIsTemplateIsSet(true);
this.filesize = filesize;
setFilesizeIsSet(true);
+ this.shareMode = shareMode;
+ setShareModeIsSet(true);
}
/**
@@ -13538,6 +13651,7 @@ public class Server {
}
this.isTemplate = other.isTemplate;
this.filesize = other.filesize;
+ this.shareMode = other.shareMode;
}
public updateImageData_args deepCopy() {
@@ -13563,6 +13677,8 @@ public class Server {
this.isTemplate = false;
setFilesizeIsSet(false);
this.filesize = 0;
+ setShareModeIsSet(false);
+ this.shareMode = 0;
}
public String getName() {
@@ -13823,6 +13939,29 @@ public class Server {
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __FILESIZE_ISSET_ID, value);
}
+ public long getShareMode() {
+ return this.shareMode;
+ }
+
+ public updateImageData_args setShareMode(long shareMode) {
+ this.shareMode = shareMode;
+ setShareModeIsSet(true);
+ return this;
+ }
+
+ public void unsetShareMode() {
+ __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __SHAREMODE_ISSET_ID);
+ }
+
+ /** Returns true if field shareMode is set (has been assigned a value) and false otherwise */
+ public boolean isSetShareMode() {
+ return EncodingUtils.testBit(__isset_bitfield, __SHAREMODE_ISSET_ID);
+ }
+
+ public void setShareModeIsSet(boolean value) {
+ __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __SHAREMODE_ISSET_ID, value);
+ }
+
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case NAME:
@@ -13913,6 +14052,14 @@ public class Server {
}
break;
+ case SHARE_MODE:
+ if (value == null) {
+ unsetShareMode();
+ } else {
+ setShareMode((Long)value);
+ }
+ break;
+
}
}
@@ -13951,6 +14098,9 @@ public class Server {
case FILESIZE:
return Long.valueOf(getFilesize());
+ case SHARE_MODE:
+ return Long.valueOf(getShareMode());
+
}
throw new IllegalStateException();
}
@@ -13984,6 +14134,8 @@ public class Server {
return isSetIsTemplate();
case FILESIZE:
return isSetFilesize();
+ case SHARE_MODE:
+ return isSetShareMode();
}
throw new IllegalStateException();
}
@@ -14100,6 +14252,15 @@ public class Server {
return false;
}
+ boolean this_present_shareMode = true;
+ boolean that_present_shareMode = true;
+ if (this_present_shareMode || that_present_shareMode) {
+ if (!(this_present_shareMode && that_present_shareMode))
+ return false;
+ if (this.shareMode != that.shareMode)
+ return false;
+ }
+
return true;
}
@@ -14226,6 +14387,16 @@ public class Server {
return lastComparison;
}
}
+ lastComparison = Boolean.valueOf(isSetShareMode()).compareTo(other.isSetShareMode());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetShareMode()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.shareMode, other.shareMode);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
return 0;
}
@@ -14309,6 +14480,10 @@ public class Server {
sb.append("filesize:");
sb.append(this.filesize);
first = false;
+ if (!first) sb.append(", ");
+ sb.append("shareMode:");
+ sb.append(this.shareMode);
+ first = false;
sb.append(")");
return sb.toString();
}
@@ -14442,6 +14617,14 @@ public class Server {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
+ case -12: // SHARE_MODE
+ if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
+ struct.shareMode = iprot.readI64();
+ struct.setShareModeIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
@@ -14457,6 +14640,9 @@ public class Server {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
+ oprot.writeFieldBegin(SHARE_MODE_FIELD_DESC);
+ oprot.writeI64(struct.shareMode);
+ oprot.writeFieldEnd();
oprot.writeFieldBegin(FILESIZE_FIELD_DESC);
oprot.writeI64(struct.filesize);
oprot.writeFieldEnd();
@@ -14551,7 +14737,10 @@ public class Server {
if (struct.isSetFilesize()) {
optionals.set(10);
}
- oprot.writeBitSet(optionals, 11);
+ if (struct.isSetShareMode()) {
+ optionals.set(11);
+ }
+ oprot.writeBitSet(optionals, 12);
if (struct.isSetName()) {
oprot.writeString(struct.name);
}
@@ -14585,12 +14774,15 @@ public class Server {
if (struct.isSetFilesize()) {
oprot.writeI64(struct.filesize);
}
+ if (struct.isSetShareMode()) {
+ oprot.writeI64(struct.shareMode);
+ }
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, updateImageData_args struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
- BitSet incoming = iprot.readBitSet(11);
+ BitSet incoming = iprot.readBitSet(12);
if (incoming.get(0)) {
struct.name = iprot.readString();
struct.setNameIsSet(true);
@@ -14635,6 +14827,10 @@ public class Server {
struct.filesize = iprot.readI64();
struct.setFilesizeIsSet(true);
}
+ if (incoming.get(11)) {
+ struct.shareMode = iprot.readI64();
+ struct.setShareModeIsSet(true);
+ }
}
}
diff --git a/Dozentenmodulserver/src/server/ServerHandler.java b/Dozentenmodulserver/src/server/ServerHandler.java
index 5744003a..5ce72615 100644
--- a/Dozentenmodulserver/src/server/ServerHandler.java
+++ b/Dozentenmodulserver/src/server/ServerHandler.java
@@ -8,10 +8,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
-import java.sql.Connection;
-import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -26,9 +23,11 @@ import org.apache.thrift.TException;
import sql.SQL;
import util.XMLCreator;
+
+
public class ServerHandler implements Server.Iface {
static SQL sql = new SQL();
- static Connection con = sql.getConnection();
+
private static Logger log = Logger.getLogger(ServerHandler.class);
@Override
@@ -38,18 +37,15 @@ public class ServerHandler implements Server.Iface {
user.setUserName(UUID.randomUUID().toString().substring(0, 8));
user.setPassword(getEncodedSha1Sum(UUID.randomUUID().toString()
.substring(0, 8)));
- if(Configuration.config.getAbsolute_path().endsWith("/"))
- {
+ if (Configuration.config.getAbsolute_path().endsWith("/")) {
user.setPath(Configuration.config.getAbsolute_path());
+ } else {
+ user.setPath(Configuration.config.getAbsolute_path() + "/");
}
- else{
- user.setPath(Configuration.config.getAbsolute_path()+"/");
- }
- SQL sql = new SQL();
- Connection con = sql.getConnection();
+
// check if folder temp exists
if (folderTempExists() == true) {
- sql.writeFTPUser(con, user.getUserName(), user.getPassword());
+ sql.writeFTPUser(user.getUserName(), user.getPassword());
return user;
} else {
log.info(new Date() + " - returning null user");
@@ -59,15 +55,11 @@ public class ServerHandler implements Server.Iface {
public boolean folderTempExists() {
// check if folder temp exists, otherwise create it
- Path path=null;
- if(Configuration.config.getAbsolute_path().endsWith("/"))
- {
- path = Paths
- .get(Configuration.config.getAbsolute_path() + "temp");
- }
- else{
- path = Paths
- .get(Configuration.config.getAbsolute_path() + "/temp");
+ Path path = null;
+ if (Configuration.config.getAbsolute_path().endsWith("/")) {
+ path = Paths.get(Configuration.config.getAbsolute_path() + "temp");
+ } else {
+ path = Paths.get(Configuration.config.getAbsolute_path() + "/temp");
}
if (Files.exists(path) == true) {
@@ -83,9 +75,9 @@ public class ServerHandler implements Server.Iface {
+ "'");
return false;
} else {
- //set permissions
+ // set permissions
try {
- Runtime.getRuntime().exec("chmod 777 "+path);
+ Runtime.getRuntime().exec("chmod 777 " + path);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -112,26 +104,16 @@ public class ServerHandler implements Server.Iface {
@Override
public long DeleteFtpUser(String user) throws TException {
- int ret = sql.DeleteUser(con, user);
- return ret;
+ return sql.DeleteUser(user);
}
@Override
public String getPathOfImage(String image_id, String version)
throws TException {
+ log.info(new Date() + " - successfully returned PathOfImage: "
+ + sql.getPathOfImage(image_id, version));
+ return sql.getPathOfImage(image_id, version);
- try {
- ResultSet rs = sql.getPathOfImage(con, image_id, version);
- rs.next();
- log.info(new Date() + " - successfully returned PathOfImage: "
- + rs.getString("image_path"));
- return rs.getString("image_path");
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- log.info(new Date() + " - returning PathOfImage: null");
- return null;
}
@Override
@@ -139,15 +121,25 @@ public class ServerHandler implements Server.Iface {
String firstname, String lastname, String university, String Mail,
String Tel, String Fak, boolean license, boolean internet,
long ram, long cpu, String imagePath, boolean isTemplate,
- long filesize) throws TException {
+ long filesize, long shareMode) throws TException {
+
+ String mode=null;
+
+ if(shareMode==0)
+ {
+ mode="only_local";
+ }
+ else{
+ mode="to_be_published";
+ }
- String pk_institution = sql.setInstitution(con, university);
+ String pk_institution = sql.setInstitution(university);
- String pk_person = sql.setPerson(con, login, lastname, firstname, Mail,
+ String pk_person = sql.setPerson(login, lastname, firstname, Mail,
new Date(), pk_institution);
-
- sql.setImageData(con, pk_person, license, internet, cpu, ram,
- imagename, imagePath, isTemplate, filesize);
+
+ sql.setImageData(pk_person, license, internet, cpu, ram, imagename,
+ imagePath, isTemplate, filesize,mode);
log.info(new Date() + " - written VLdata");
// TODO Auto-generated method stub
@@ -156,73 +148,21 @@ public class ServerHandler implements Server.Iface {
@Override
public List<Image> getImageList() throws TException {
- ResultSet res = sql.getImageList(con);
-
- List<Image> list = new ArrayList<Image>();
+ return sql.getImageList();
- try {
-
- 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("lecture"),
- res.getString("image_update_time"), res
- .getString("user")));
-
- }
-
- return list;
- } catch (SQLException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- log.info(new Date() + " - returning ImageList: " + list.size()
- + " items.");
- return null;
}
@Override
public List<String> getAllOS() throws TException {
- List<String> list = new ArrayList<>();
- ResultSet rs = sql.getAllOS(con);
- try {
- while (rs.next()) {
- list.add(rs.getString("name"));
- }
- return list;
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return null;
+ return sql.getAllOS();
+
}
@Override
public Map<String, String> getPersonData(String Vorname, String Nachname)
throws TException {
- Map<String, String> map = new HashMap<String, String>();
-
- ResultSet rs = sql.getPersonData(con, Vorname, Nachname);
- try {
- while (rs.next()) {
-
- map.put("mail", rs.getString("mail"));
- map.put("Nachname", rs.getString("Nachname"));
- map.put("Vorname", rs.getString("Vorname"));
- map.put("Hochschule", rs.getString("name"));
+ return sql.getPersonData(Vorname, Nachname);
- }
- return map;
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- log.info(new Date() + " - returning PersonData: " + map.size()
- + " items.");
- return null;
}
@Override
@@ -232,27 +172,19 @@ public class ServerHandler implements Server.Iface {
String university, String Mail, String Tel, String Fak)
throws TException {
String pk_image = null;
-
+ Map<String, String> map = new HashMap<String, String>();
int imageversion = 0;
- String pk_institution = sql.setInstitution(con, university);
- String pk_person = sql.setPerson(con, login, lastname, firstname, Mail,
+ String pk_institution = sql.setInstitution(university);
+ String pk_person = sql.setPerson(login, lastname, firstname, Mail,
new Date(), pk_institution);
- ResultSet image = sql.getImageIDandVersion(con, imagename);
-
- try {
- while (image.next()) {
- pk_image = image.getString("GUID_imageID");
- imageversion = image.getInt("imageVersion");
- }
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ map = sql.getImageIDandVersion(imagename);
- sql.setLectureData(con, pk_person, pk_image, imageversion, name, desc,
+ pk_image = map.get("GUID");
+ imageversion = Integer.parseInt(map.get("version"));
+ sql.setLectureData(pk_person, pk_image, imageversion, name, desc,
shortdesc, startDate, endDate, isActive);
- XMLCreator xml = new XMLCreator(con, name);
+ XMLCreator xml = new XMLCreator(sql.getConnection(), name);
try {
xml.create(name);
log.info(new Date() + " - XML created.");
@@ -271,6 +203,7 @@ public class ServerHandler implements Server.Iface {
@Override
public boolean startFileCopy(String filename) throws TException {
+ //copy file from folder temp to folder prod
String file = Configuration.config.getAbsolute_path() + "temp/"
+ filename;
File tmpFile = new File(file);
@@ -279,17 +212,13 @@ public class ServerHandler implements Server.Iface {
+ " - Trying to move file to '/srv/openslx/nfs/prod/"
+ tmpFile.getName() + "'");
try {
-
- // der übergebene Filename ist falsch - hier muss der generierte
- // name geholt werden, nicht der ursprüngliche name. wo wird dieser
- // eingelesen?
-
FileUtils.moveFile(tmpFile,
new File(Configuration.config.getAbsolute_path() + "prod/"
+ filename));
- int ret = sql.UpdateImagePath(con, filename);
- log.info(new Date() + " - update " + ret);
- log.info(new Date() + " - file moved");
+ // int ret = sql.UpdateImagePath(filename);
+ if (sql.UpdateImagePath(filename) == 0) {
+ log.info(new Date() + " - file moved and database updated.");
+ }
} catch (IOException e) {
// TODO Auto-generated catch block
@@ -302,43 +231,27 @@ public class ServerHandler implements Server.Iface {
@Override
public Map<String, String> getImageData(String imageid, String imageversion)
throws TException {
-
- ResultSet data = sql.getImageData(con, imageid, imageversion);
-
- Map<String, String> map = new HashMap<String, String>();
- try {
- while (data.next()) {
- System.out.println(data
- .getString("cond_hasInternetRestriction")
- + data.getString("cond_hasLicenseRestriction")
- + data.getString("cond_minCPUs")
- + data.getString("cond_minRAM"));
- map.put("name", data.getString("image_name"));
- map.put("internet",
- data.getString("cond_hasInternetRestriction"));
- map.put("license", data.getString("cond_hasLicenseRestriction"));
- map.put("cpu", data.getString("cond_minCPUs"));
- map.put("ram", data.getString("cond_minRAM"));
-
- }
- return map;
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- log.info(new Date() + " - returning ImageData: " + map.size()
- + "items.");
- return null;
-
+ log.info(new Date() + " - returning ImageData: "
+ + sql.getImageData(imageid, imageversion).size() + "items.");
+ return sql.getImageData(imageid, imageversion);
}
@Override
public boolean updateImageData(String name, String newName,
String image_path, boolean license, boolean internet, long ram,
long cpu, String id, String version, boolean isTemplate,
- long filesize) throws TException {
- sql.UpdateImageData(con, name, newName, image_path, license, internet,
- cpu, ram, id, version, isTemplate, filesize);
+ long filesize, long shareMode) throws TException {
+ String mode=null;
+
+ if(shareMode==0)
+ {
+ mode="only_local";
+ }
+ else{
+ mode="to_be_published";
+ }
+ sql.UpdateImageData(name, newName, image_path, license, internet, cpu,
+ ram, id, version, isTemplate, filesize,mode);
return false;
}
@@ -351,29 +264,13 @@ public class ServerHandler implements Server.Iface {
@Override
public List<Lecture> getLectureList() throws TException {
- ResultSet res = sql.getLectureList(con);
- List<Lecture> list = new ArrayList<Lecture>();
- try {
-
- while (res.next()) {
-
- list.add(new Lecture(res.getString("lectureID"), res
- .getString("name"), res.getString("isActive"), res
- .getString("startTime"), res.getString("endTime"), res
- .getString("lastUsed"), res.getString("description"),
- res.getString("image_name"), res.getString("user")));
+ log.info(new Date().toString() + " - returning LectureList: "
+ + sql.getLectureList().size() + " items.");
+ return sql.getLectureList();
+
- }
- return list;
- } catch (SQLException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- log.info(new Date() + " - returning LectureList: " + list.size()
- + " items.");
- return null;
}
@Override
@@ -384,21 +281,14 @@ public class ServerHandler implements Server.Iface {
String Fak, String id) throws TException {
String pk_image = "";
int imageversion = 0;
- ResultSet image = sql.getImageIDandVersion(con, imagename);
+ Map<String, String> image = sql.getImageIDandVersion(imagename);
- try {
- while (image.next()) {
- pk_image = image.getString("GUID_imageID");
- imageversion = image.getInt("imageVersion");
- }
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- sql.updateLectureData(con, pk_image, imageversion, lastname, newName,
- desc, shortdesc, startDate, endDate, isActive, id);
+ pk_image = image.get("GUID");
+ imageversion = Integer.parseInt(image.get("version"));
+ sql.updateLectureData(pk_image, imageversion, lastname, newName, desc,
+ shortdesc, startDate, endDate, isActive, id);
- XMLCreator xml = new XMLCreator(con, newName);
+ XMLCreator xml = new XMLCreator(sql.getConnection(), newName);
try {
xml.create(newName);
} catch (SQLException | ParserConfigurationException
@@ -416,14 +306,14 @@ public class ServerHandler implements Server.Iface {
public boolean deleteImageServer(String imageid, String imageversion)
throws TException {
- String stringFile = sql.getFile(con, imageid, imageversion);
+ String stringFile = sql.getFile(imageid, imageversion);
log.info(new Date() + " - File to Delete: " + stringFile);
File tmpFile = new File(Configuration.config.getAbsolute_path()
+ stringFile);
try {
- // File wird von Server gelöscht
+ // File wird von Server gel�scht
FileUtils.forceDelete(tmpFile);
return true;
@@ -439,36 +329,33 @@ public class ServerHandler implements Server.Iface {
@Override
public boolean deleteImageData(String id, String version) throws TException {
- return sql.deleteImage(con, id, version);
+ return sql.deleteImage(id, version);
}
@Override
public boolean connectedToLecture(String id, String version)
throws TException {
// TODO Auto-generated method stub
- return sql.connectedToLecture(con, id, version);
+ return sql.connectedToLecture(id, version);
}
public boolean deleteLecture(String id, String hs, String user) {
- ResultSet rs = sql.getDeleteXMLData(con, id);
+ Map<String, String> map = new HashMap<String, String>();
+ map = sql.getDeleteXMLData(id);
try {
- rs.next();
- String date = rs.getString("admin_createTime").replace(" ", "")
- .replace("-", "").replace(":", "");
- String name = rs.getString("name");
- String path = Configuration.config.getAbsolute_path() + "temp/"
- + date.substring(0, date.length() - 2) + "_" + hs + "_"
- + user + "_" + name + ".xml";
+
+ String path = Configuration.config.getAbsolute_path()
+ + "temp/"
+ + map.get("date")
+ .substring(0, map.get("date").length() - 2) + "_"
+ + hs + "_" + user + "_" + map.get("name") + ".xml";
File xmlFile = new File(path);
FileUtils.forceDelete(xmlFile);
- } catch (SQLException e) {
- log.info(new Date() + " - Failed to execute deleteLecture");
- e.printStackTrace();
} catch (IOException e) {
log.info(new Date() + " - Failed to execute deleteLecture");
e.printStackTrace();
}
- return sql.deleteLecture(con, id);
+ return sql.deleteLecture(id);
}
diff --git a/Dozentenmodulserver/src/server/TBinaryProtocolSafe.java b/Dozentenmodulserver/src/server/TBinaryProtocolSafe.java
new file mode 100644
index 00000000..843b58b1
--- /dev/null
+++ b/Dozentenmodulserver/src/server/TBinaryProtocolSafe.java
@@ -0,0 +1,123 @@
+package server;
+
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+
+import org.apache.thrift.TException;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TMessage;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.protocol.TProtocolException;
+import org.apache.thrift.protocol.TProtocolFactory;
+import org.apache.thrift.transport.TTransport;
+
+/**
+ * Binary protocol implementation for thrift.
+ * Will not read messages bigger than 12MiB.
+ *
+ */
+public class TBinaryProtocolSafe extends TBinaryProtocol
+{
+ /**
+ * Factory
+ */
+ @SuppressWarnings( "serial" )
+ public static class Factory implements TProtocolFactory
+ {
+
+ protected boolean strictRead_ = false;
+ protected boolean strictWrite_ = true;
+
+ public Factory()
+ {
+ this( false, true );
+ }
+
+ public Factory(boolean strictRead, boolean strictWrite)
+ {
+ strictRead_ = strictRead;
+ strictWrite_ = strictWrite;
+ }
+
+ public TProtocol getProtocol( TTransport trans )
+ {
+ return new TBinaryProtocolSafe( trans, strictRead_, strictWrite_ );
+ }
+ }
+
+ private static final int maxLen = 12 * 1024 * 1024; // 12 MiB
+
+ /**
+ * Constructor
+ */
+ public TBinaryProtocolSafe(TTransport trans)
+ {
+ this( trans, false, true );
+ }
+
+ public TBinaryProtocolSafe(TTransport trans, boolean strictRead, boolean strictWrite)
+ {
+ super( trans );
+ strictRead_ = strictRead;
+ strictWrite_ = strictWrite;
+ }
+
+ /**
+ * Reading methods.
+ */
+
+ public TMessage readMessageBegin() throws TException
+ {
+ int size = readI32();
+ if ( size > maxLen )
+ throw new TProtocolException( TProtocolException.SIZE_LIMIT, "Payload too big." );
+ if ( size < 0 ) {
+ int version = size & VERSION_MASK;
+ if ( version != VERSION_1 ) {
+ throw new TProtocolException( TProtocolException.BAD_VERSION, "Bad version in readMessageBegin" );
+ }
+ return new TMessage( readString(), (byte) ( size & 0x000000ff ), readI32() );
+ } else {
+ if ( strictRead_ ) {
+ throw new TProtocolException( TProtocolException.BAD_VERSION, "Missing version in readMessageBegin, old client?" );
+ }
+ return new TMessage( readStringBody( size ), readByte(), readI32() );
+ }
+ }
+
+ public String readString() throws TException
+ {
+ int size = readI32();
+ if ( size > maxLen )
+ throw new TProtocolException( TProtocolException.SIZE_LIMIT, "Payload too big." );
+ if ( trans_.getBytesRemainingInBuffer() >= size ) {
+ try {
+ String s = new String( trans_.getBuffer(), trans_.getBufferPosition(), size, "UTF-8" );
+ trans_.consumeBuffer( size );
+ return s;
+ } catch ( UnsupportedEncodingException e ) {
+ throw new TException( "JVM DOES NOT SUPPORT UTF-8" );
+ }
+ }
+
+ return readStringBody( size );
+ }
+
+ public ByteBuffer readBinary() throws TException
+ {
+ int size = readI32();
+ if ( size > maxLen )
+ throw new TProtocolException( TProtocolException.SIZE_LIMIT, "Payload too big." );
+ if ( trans_.getBytesRemainingInBuffer() >= size ) {
+ ByteBuffer bb = ByteBuffer.wrap( trans_.getBuffer(), trans_.getBufferPosition(), size );
+ trans_.consumeBuffer( size );
+ return bb;
+ }
+
+ byte[] buf = new byte[ size ];
+ trans_.readAll( buf, 0, size );
+ return ByteBuffer.wrap( buf );
+ }
+
+}
+
diff --git a/Dozentenmodulserver/src/server/startServer.java b/Dozentenmodulserver/src/server/startServer.java
index 949b3538..a5509d04 100644
--- a/Dozentenmodulserver/src/server/startServer.java
+++ b/Dozentenmodulserver/src/server/startServer.java
@@ -16,6 +16,13 @@ import org.ini4j.Wini;
import server.BinaryListener;
+import org.apache.thrift.protocol.TProtocolFactory;
+import org.apache.thrift.server.TServer;
+import org.apache.thrift.server.TThreadPoolServer;
+import org.apache.thrift.transport.TServerSocket;
+import org.apache.thrift.transport.TServerTransport;
+import org.apache.thrift.transport.TTransportException;
+import org.apache.thrift.server.TThreadPoolServer.Args;
public class startServer {
/**
@@ -28,6 +35,27 @@ public class startServer {
public static void main(String[] args) {
+
+
+
+ //final ImageServerHandler handler = new ImageServerHandler();
+ //final ImageServer.Processor<ImageServerHandler> processor = new ImageServer.Processor<ImageServerHandler>(handler);
+
+ /*
+ try{
+ TServerTransport serverTransport = new TServerSocket(9090);
+ //TServer server = new TSimpleServer(new Args(serverTransport).processor(processor));
+ TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));
+ server.serve();
+ } catch (Exception e){
+ e.printStackTrace();
+ }
+ */
+
+ //deprecated
+
+
+
//get Configuration
try {
Wini ini=new Wini(new File("Server_Config.ini"));
@@ -43,14 +71,15 @@ public class startServer {
e1.printStackTrace();
}
//Start Server
+
BasicConfigurator.configure();
- log.info( new Date() + " - starting Application\n" );
+ log.info("***** "+ new Date() + " - starting Application *****" );
Thread t;
t = new Thread(new BinaryListener());
servers.add(t);
t.start();
//information
- log.info( new Date()+" - new thread created. Now "+servers.size()+" thread(s).\n" );
+ //log.info( new Date()+" - new thread created. Now "+servers.size()+" thread(s).\n" );
// Run more servers
// ...
// Wait for all servers to die
@@ -66,7 +95,7 @@ public class startServer {
}
}
log.info( new Date()+" - all Servers shut down, exiting...\n" );
-
+
}
}
diff --git a/Dozentenmodulserver/src/sql/SQL.java b/Dozentenmodulserver/src/sql/SQL.java
index 69843988..98fc8ef7 100644
--- a/Dozentenmodulserver/src/sql/SQL.java
+++ b/Dozentenmodulserver/src/sql/SQL.java
@@ -4,7 +4,11 @@ import java.sql.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.Random;
import java.util.UUID;
@@ -12,6 +16,8 @@ import models.Configuration;
import org.apache.log4j.Logger;
import server.BinaryListener;
+import server.Image;
+import server.Lecture;
public class SQL {
@@ -29,7 +35,7 @@ public class SQL {
Connection con = DriverManager
.getConnection("jdbc:mysql://"+Configuration.config.getSql_connection()+"?user="+Configuration.config.getSql_user()+"&password="+Configuration.config.getSql_pass()+"");
con.setAutoCommit(false);
- log.info(new Date() + " - Connection returned to Client.");
+
return con;
} catch (SQLException e) {
// TODO Auto-generated catch block
@@ -39,9 +45,10 @@ public class SQL {
return null;
}
- public int writeFTPUser(Connection con, String user, String pass) {
+ public int writeFTPUser(String user, String pass) {
Statement stm;
try {
+ Connection con=getConnection();
stm = con.createStatement();
int ret = stm
@@ -51,6 +58,7 @@ public class SQL {
+ pass
+ "'),'10001','12345','"+Configuration.config.getAbsolute_path()+"temp/');");
con.commit();
+ con.close();
log.info(new Date() + " - created FTPUser " + user + " : " + pass
+ ".");
return ret;
@@ -62,15 +70,17 @@ public class SQL {
return -1;
}
- public int DeleteUser(Connection con, String user) {
+ public int DeleteUser(String user) {
Statement stm;
try {
+ Connection con=getConnection();
stm = con.createStatement();
int ret = stm
.executeUpdate("DELETE FROM `bwLehrpool`.`FtpUsers` where User like '"
+ user + "';");
con.commit();
+ con.close();
log.info(new Date() + " - FTPUser " + user + " deleted.");
return ret;
} catch (SQLException e) {
@@ -81,13 +91,15 @@ public class SQL {
return -1;
}
- public ResultSet getImage(Connection con) {
+ public ResultSet getImage() {
try {
+ Connection con=getConnection();
Statement stm = con.createStatement();
-
- return stm
+ ResultSet rs=stm
.executeQuery("SELECT image_name FROM bwLehrpool.m_VLData_imageInfo;");
-
+ con.close();
+ return rs;
+
} catch (SQLException e) {
// TODO Auto-generated catch block
log.info(new Date() + " - Failed to getImage.");
@@ -97,17 +109,21 @@ public class SQL {
return null;
}
- public ResultSet getPathOfImage(Connection con, String image_id,
+ public String getPathOfImage(String image_id,
String version) {
try {
+ Connection con=getConnection();
Statement stm = con.createStatement();
-
- return stm
+ ResultSet rs=stm
.executeQuery("SELECT image_path FROM bwLehrpool.m_VLData_imageInfo where GUID_imageID='"
+ image_id
+ "' and imageVersion='"
+ version
+ "';");
+ rs.first();
+ String path=rs.getString("image_path");
+ con.close();
+ return path;
} catch (SQLException e) {
// TODO Auto-generated catch block
@@ -118,13 +134,15 @@ public class SQL {
return null;
}
- public String setInstitution(Connection con, String university) {
+ public String setInstitution(String university) {
try {
+ Connection con=getConnection();
Statement stm = con.createStatement();
ResultSet ret = stm
.executeQuery("SELECT * FROM bwLehrpool.m_institution where name like'"
+ university + "';");
+
if (ret.next() == false) {
String id = UUID.randomUUID().toString();
@@ -135,9 +153,14 @@ public class SQL {
.executeQuery("SELECT institutionID FROM bwLehrpool.m_institution WHERE name like '"
+ university + "';");
rs.next();
- return rs.getString("institutionID");
+ String institution=rs.getString("institutionID");
+ con.close();
+
+ return institution;
} else {
- return ret.getString("institutionID");
+ String institution=ret.getString("institutionID");
+ con.close();
+ return institution;
}
} catch (SQLException e) {
@@ -148,10 +171,11 @@ public class SQL {
return "-1";
}
- public String setPerson(Connection con, String login, String lastname,
+ public String setPerson(String login, String lastname,
String firstname, String mail, Date lastlogin, String Institution) {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
try {
+ Connection con=getConnection();
Statement stm = con.createStatement();
ResultSet ret = stm
@@ -187,10 +211,14 @@ public class SQL {
+ firstname
+ "';");
rs.next();
- return rs.getString("userID");
+ String userid=rs.getString("userID");
+ con.close();
+ return userid;
} else {
ret.first();
- return ret.getString("userID");
+ String userid=ret.getString("userID");
+ con.close();
+ return userid;
}
} catch (SQLException e) {
@@ -201,9 +229,9 @@ public class SQL {
return "-1";
}
- public boolean setImageData(Connection con, String pk_person, boolean license,
+ public boolean setImageData(String pk_person, boolean license,
boolean internet, long cpu, long ram, String imagename,
- String imagePath, boolean isTemplate, long filesize) {
+ String imagePath, boolean isTemplate, long filesize, String shareMode) {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
@@ -217,10 +245,11 @@ public class SQL {
}
try {
+ Connection con=getConnection();
Statement stm = con.createStatement();
String uid = UUID.randomUUID().toString();
- stm.executeUpdate("INSERT INTO `bwLehrpool`.`m_VLData_imageInfo`(`GUID_imageID`,`imageVersion`,`image_name`,`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`)VALUES('"
+ stm.executeUpdate("INSERT INTO `bwLehrpool`.`m_VLData_imageInfo`(`GUID_imageID`,`imageVersion`,`image_name`,`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
+ "',1,'" // imageVersion
+ imagename // image_name
@@ -248,9 +277,10 @@ public class SQL {
+ "','" + cpu // cond_minCPUs
+ "','" + isTemplate //image_isTemplate
+ "','" + filesize //image_filesize
+ + "','" + shareMode //shareMode
+ "');");
con.commit();
-
+ con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
log.info(new Date() + " - Failed to setImageData.");
@@ -260,28 +290,60 @@ public class SQL {
}
- public ResultSet getImageList(Connection con) {
- try {
- Statement stm = con.createStatement();
+ public List<Image> getImageList() {
+
+ Connection con=getConnection();
+ Statement stm;
+ List<Image> list = new ArrayList<Image>();
+ try {
+ stm = con.createStatement();
+ ResultSet res=stm
+ .executeQuery("SELECT vl.GUID_imageID, vl.imageVersion,vl.image_name, vl.cond_hasLicenseRestriction, os.name, '' as lecture,vl.image_update_time, Concat(u.Nachname,' ',u.Vorname) as user FROM 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, lect.name as lecture, vl.image_update_time, Concat(u.Nachname,' ',u.Vorname) as user 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;");
+
- return stm
- .executeQuery("SELECT vl.GUID_imageID, vl.imageVersion,vl.image_name, vl.cond_hasLicenseRestriction, os.name, '' as lecture,vl.image_update_time, Concat(u.Nachname,' ',u.Vorname) as user FROM 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, lect.name as lecture, vl.image_update_time, Concat(u.Nachname,' ',u.Vorname) as user 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;");
+
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- log.info(new Date() + " - Failed to getImageList.");
- e.printStackTrace();
- }
- return null;
+ 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("lecture"),
+ res.getString("image_update_time"), res
+ .getString("user")));
+
+ }
+
+ con.close();
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+ return list;
+
}
- public ResultSet getLectureList(Connection con) {
+ public List<Lecture> getLectureList() {
+ List<Lecture> list = new ArrayList<Lecture>();
try {
+ Connection con=getConnection();
Statement stm = con.createStatement();
-
- return stm
+ ResultSet res=stm
.executeQuery("SELECT l.lectureID, l.name, l.isActive,l.startTime,l.endTime,l.lastUsed,l.description, i.image_name, concat(u.Nachname,' ',u.Vorname) as user FROM bwLehrpool.m_VLData_lecture l, bwLehrpool.m_VLData_imageInfo i, bwLehrpool.m_user u where i.GUID_imageID=l.imageID and l.admin_owner=u.userID;");
+ while (res.next()) {
+
+ list.add(new Lecture(res.getString("lectureID"), res
+ .getString("name"), res.getString("isActive"), res
+ .getString("startTime"), res.getString("endTime"), res
+ .getString("lastUsed"), res.getString("description"),
+ res.getString("image_name"), res.getString("user")));
+ }
+ con.close();
+ return list;
} catch (SQLException e) {
// TODO Auto-generated catch block
log.info(new Date() + " - Failed to getLectureList.");
@@ -290,12 +352,18 @@ public class SQL {
return null;
}
- public ResultSet getAllOS(Connection con) {
-
+ public List<String> getAllOS() {
+ List<String> list = new ArrayList<>();
try {
+ Connection con=getConnection();
Statement stm = con.createStatement();
- return stm
+ ResultSet rs=stm
.executeQuery("SELECT name FROM bwLehrpool.m_operatingSystem;");
+ while (rs.next()) {
+ list.add(rs.getString("name"));
+ }
+ return list;
+
} catch (SQLException e) {
// TODO Auto-generated catch block
log.info(new Date() + " - Failed to getAllOS.");
@@ -306,16 +374,28 @@ public class SQL {
}
- public ResultSet getPersonData(Connection con, String Vorname,
+ public Map<String,String> getPersonData(String Vorname,
String Nachname) {
+ Map<String, String> map = new HashMap<String, String>();
try {
+ Connection con=getConnection();
Statement stm = con.createStatement();
- return stm
+ ResultSet rs= stm
.executeQuery("SELECT u.Nachname, u.Vorname, u.mail, i.name FROM bwLehrpool.m_user u, bwLehrpool.m_institution i where u.Nachname like '"
+ Nachname
+ "' and u.Vorname like '"
+ Vorname
+ "' and u.institution=i.institutionID;");
+ while (rs.next()) {
+
+ map.put("mail", rs.getString("mail"));
+ map.put("Nachname", rs.getString("Nachname"));
+ map.put("Vorname", rs.getString("Vorname"));
+ map.put("Hochschule", rs.getString("name"));
+
+ }
+ con.close();
+ return map;
} catch (SQLException e) {
// TODO Auto-generated catch block
log.info(new Date() + " - Failed to getPersonData.");
@@ -324,7 +404,7 @@ public class SQL {
return null;
}
- public int setLectureData(Connection con, String pk_person, String pk_image,
+ public int setLectureData(String pk_person, String pk_image,
int imageversion, String name, String desc, String shortdesc,
String start, String end, boolean isactive) {
@@ -335,6 +415,7 @@ public class SQL {
active_bol = 1;
}
try {
+ Connection con=getConnection();
Statement stm = con.createStatement();
String uid = UUID.randomUUID().toString();
@@ -367,7 +448,7 @@ public class SQL {
+ "','"
+ pk_person + "');");
con.commit();
-
+ con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
log.info(new Date() + " - Failed to setLectureData.");
@@ -377,12 +458,21 @@ public class SQL {
}
- public ResultSet getImageIDandVersion(Connection con, String name) {
+ public Map<String,String> getImageIDandVersion(String name) {
+ Map<String, String> map = new HashMap<String, String>();
try {
+ Connection con=getConnection();
Statement stm = con.createStatement();
- return stm
+ ResultSet image= stm
.executeQuery("SELECT GUID_imageID, imageVersion FROM bwLehrpool.m_VLData_imageInfo where image_name like '"
+ name + "';");
+ while (image.next()) {
+ map.put("GUID", image.getString("GUID_imageID"));
+ map.put("version", String.valueOf(image.getString("imageVersion")));
+
+ }
+ con.close();
+ return map;
} catch (SQLException e) {
// TODO Auto-generated catch block
log.info(new Date() + " - Failed to getImageIDandVersion.");
@@ -391,12 +481,27 @@ public class SQL {
return null;
}
- public ResultSet getImageData(Connection con, String id, String version) {
+ public Map<String,String> getImageData(String id, String version) {
+ Map<String, String> map = new HashMap<String, String>();
try {
+ Connection con=getConnection();
Statement stm = con.createStatement();
- return stm
- .executeQuery("SELECT image_name,cond_hasInternetRestriction,cond_hasLicenseRestriction, cond_minCPUs, cond_minRAM FROM bwLehrpool.m_VLData_imageInfo where GUID_imageID = '"
+ ResultSet data=stm
+ .executeQuery("SELECT image_name,cond_hasInternetRestriction,cond_hasLicenseRestriction, cond_minCPUs, cond_minRAM, image_syncMode,image_filesize,image_path FROM bwLehrpool.m_VLData_imageInfo where GUID_imageID = '"
+ id + "' and imageVersion = '" + version + "' ;");
+ while (data.next()) {
+ map.put("name", data.getString("image_name"));
+ map.put("internet",
+ data.getString("cond_hasInternetRestriction"));
+ map.put("license", data.getString("cond_hasLicenseRestriction"));
+ map.put("cpu", data.getString("cond_minCPUs"));
+ map.put("ram", data.getString("cond_minRAM"));
+ map.put("shareMode", data.getString("image_syncMode"));
+ map.put("filesize", data.getString("image_filesize"));
+ map.put("path", data.getString("image_path"));
+ }
+ con.close();
+ return map;
} catch (SQLException e) {
// TODO Auto-generated catch block
log.info(new Date() + " - Failed to getImageData.");
@@ -405,10 +510,11 @@ public class SQL {
return null;
}
- public int UpdateImageData(Connection con, String name, String newName,String image_path,
+ public int UpdateImageData(String name, String newName,String image_path,
boolean license, boolean internet, long cpu, long ram, String id,
- String version, boolean isTemplate, long filesize) {
+ String version, boolean isTemplate, long filesize, String shareMode) {
try {
+ Connection con=getConnection();
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Statement stm = con.createStatement();
int newVersion = Integer.parseInt(version) + 1;
@@ -445,10 +551,13 @@ public class SQL {
+ isTemplate
+ "',`image_filesize` = '"
+ filesize
+ + "',`image_syncMode` = '"
+ + shareMode
+ "' WHERE `GUID_imageID` = '"
+ id
+ "' AND `imageVersion` = '" + version + "';");
con.commit();
+ con.close();
return 0;
} catch (SQLException e) {
// TODO Auto-generated catch block
@@ -458,17 +567,17 @@ public class SQL {
return -1;
}
- public boolean deleteImage(Connection con, String id, String version) {
+ public boolean deleteImage(String id, String version) {
try {
-
+ Connection con=getConnection();
Statement stm = con.createStatement();
stm.executeUpdate("DELETE FROM bwLehrpool.m_VLData_imageInfo where GUID_imageID = '"
+ id + "' " + "AND imageVersion = '" + version + "';");
con.commit();
-
+ con.close();
return true;
} catch (SQLException e) {
@@ -480,7 +589,7 @@ public class SQL {
return false;
}
- public int updateLectureData(Connection con, String pk_image,
+ public int updateLectureData(String pk_image,
int imageversion, String name, String newName, String desc,
String shortdesc, String start, String end, boolean isactive,
String id) {
@@ -492,6 +601,7 @@ public class SQL {
active_bol = 1;
}
try {
+ Connection con=getConnection();
Statement stm = con.createStatement();
stm.executeUpdate("UPDATE `bwLehrpool`.`m_VLData_lecture` SET `name` = '"
+ newName
@@ -511,6 +621,7 @@ public class SQL {
+ formatter.format(new Date())
+ "'WHERE `lectureID` = '" + id + "';");
con.commit();
+ con.close();
log.info(new Date() + " - Succeeded to updateLectureData.");
} catch (SQLException e) {
@@ -523,16 +634,16 @@ public class SQL {
}
- public boolean connectedToLecture(Connection con, String id, String version) {
+ public boolean connectedToLecture(String id, String version) {
try {
-
+ Connection con=getConnection();
Statement stm = con.createStatement();
ResultSet rs = stm.executeQuery("SELECT lectureID FROM "
+ "bwLehrpool.m_VLData_lecture WHERE imageID = '" + id
+ "' AND imageVersion = '" + version + "';");
-
+ con.close();
return rs.first();
} catch (SQLException e) {
@@ -546,15 +657,16 @@ public class SQL {
}
- public boolean deleteLecture(Connection con, String id) {
+ public boolean deleteLecture(String id) {
try {
+ Connection con=getConnection();
Statement stm = con.createStatement();
stm.executeUpdate("DELETE FROM bwLehrpool.m_VLData_lecture WHERE lectureID = '"
+ id + "';");
-
+
con.commit();
-
+ con.close();
return true;
} catch (SQLException e) {
// TODO Auto-generated catch block
@@ -565,9 +677,10 @@ public class SQL {
return false;
}
- public String getFile(Connection con, String imageid, String imageversion) {
+ public String getFile(String imageid, String imageversion) {
try {
+ Connection con=getConnection();
Statement stm = con.createStatement();
ResultSet rs = stm
@@ -577,7 +690,9 @@ public class SQL {
+ imageversion
+ "';");
rs.next();
- return rs.getString("image_path");
+ String path=rs.getString("image_path");
+ con.close();
+ return path;
} catch (SQLException e) {
// TODO Auto-generated catch block
@@ -588,15 +703,23 @@ public class SQL {
return null;
}
- public ResultSet getDeleteXMLData(Connection con, String id) {
+ public Map<String,String> getDeleteXMLData(String id) {
+ Map<String, String> map = new HashMap<String, String>();
try {
+ Connection con=getConnection();
Statement stm = con.createStatement();
ResultSet rs = stm
.executeQuery("SELECT name, admin_createTime FROM bwLehrpool.m_VLData_lecture where lectureID='"
+ id + "';");
+ rs.next();
+ map.put("date", rs.getString("admin_createTime").replace(" ", "")
+ .replace("-", "").replace(":", ""));
+ map.put("name", rs.getString("name"));
+
- return rs;
+ con.close();
+ return map;
} catch (SQLException e) {
// TODO Auto-generated catch block
@@ -607,9 +730,9 @@ public class SQL {
return null;
}
- public int UpdateImagePath(Connection con, String name) {
+ public int UpdateImagePath(String name) {
try {
-
+ Connection con=getConnection();
Statement stm = con.createStatement();
String image_path="prod/"+name;
@@ -618,6 +741,7 @@ public class SQL {
+ "' WHERE `image_path` = '"
+ "temp/"+name + "';");
con.commit();
+ con.close();
return 0;
} catch (SQLException e) {
// TODO Auto-generated catch block
diff --git a/Dozentenmodulserver/src/util/XMLCreator.java b/Dozentenmodulserver/src/util/XMLCreator.java
index bf49dfe3..564543fa 100644
--- a/Dozentenmodulserver/src/util/XMLCreator.java
+++ b/Dozentenmodulserver/src/util/XMLCreator.java
@@ -26,6 +26,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
import server.BinaryListener;
+import sql.SQL;
public class XMLCreator {
@@ -42,6 +43,7 @@ public class XMLCreator {
private String imageName;
private String xmlName;
private static Logger log = Logger.getLogger( BinaryListener.class );
+
// phone param not existing
private String query = "SELECT m_VLData_imageInfo.image_path ,vorname, nachname, mail, shortdescription, description, m_operatingSystem.name as os, m_VLData_lecture.admin_changeTime as time, m_VLData_lecture.name as lectureName, m_user.institution as userInstitution, m_user.loginName as loginName, m_institution.name as institutionName "