summaryrefslogtreecommitdiffstats
path: root/dozentenmodulserver/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'dozentenmodulserver/src/main/java')
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java93
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/Database.java (renamed from dozentenmodulserver/src/main/java/sql/SQL.java)49
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/MysqlConnection.java (renamed from dozentenmodulserver/src/main/java/sql/MysqlConnection.java)9
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/MysqlStatement.java (renamed from dozentenmodulserver/src/main/java/sql/MysqlStatement.java)6
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbImage.java62
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbImagePermissions.java64
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbOrganization.java34
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/ActiveUpload.java (renamed from dozentenmodulserver/src/main/java/fileserv/ActiveUpload.java)10
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/ChunkList.java (renamed from dozentenmodulserver/src/main/java/fileserv/ChunkList.java)2
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileChunk.java (renamed from dozentenmodulserver/src/main/java/fileserv/FileChunk.java)2
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java (renamed from dozentenmodulserver/src/main/java/fileserv/FileServer.java)7
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/BinaryListener.java65
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java (renamed from dozentenmodulserver/src/main/java/server/ServerHandler.java)11
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/SessionManager.java (renamed from dozentenmodulserver/src/main/java/server/SessionManager.java)2
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/cache/CachedList.java33
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/cache/OperatingSystemList.java26
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/cache/OrganizationList.java29
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Configuration.java (renamed from dozentenmodulserver/src/main/java/models/Configuration.java)2
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Constants.java (renamed from dozentenmodulserver/src/main/java/util/Constants.java)4
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/FileSystem.java (renamed from dozentenmodulserver/src/main/java/util/FileSystem.java)2
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Formatter.java (renamed from dozentenmodulserver/src/main/java/util/Formatter.java)4
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/QuickTimer.java38
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Util.java (renamed from dozentenmodulserver/src/main/java/util/Util.java)2
-rw-r--r--dozentenmodulserver/src/main/java/server/BinaryListener.java49
-rw-r--r--dozentenmodulserver/src/main/java/server/StartServer.java62
-rw-r--r--dozentenmodulserver/src/main/java/server/TBinaryProtocolSafe.java123
-rw-r--r--dozentenmodulserver/src/main/java/sql/models/DbImage.java41
-rw-r--r--dozentenmodulserver/src/main/java/thrift/OperatingSystemList.java37
28 files changed, 517 insertions, 351 deletions
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java
new file mode 100644
index 00000000..8aac1fcb
--- /dev/null
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java
@@ -0,0 +1,93 @@
+package org.openslx.bwlp.sat;
+
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.TimerTask;
+
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.Logger;
+import org.apache.thrift.transport.TTransportException;
+import org.openslx.bwlp.sat.database.Database;
+import org.openslx.bwlp.sat.database.mappers.DbImage;
+import org.openslx.bwlp.sat.fileserv.FileServer;
+import org.openslx.bwlp.sat.thrift.BinaryListener;
+import org.openslx.bwlp.sat.thrift.cache.OperatingSystemList;
+import org.openslx.bwlp.sat.thrift.cache.OrganizationList;
+import org.openslx.bwlp.sat.util.Configuration;
+import org.openslx.bwlp.sat.util.QuickTimer;
+import org.openslx.bwlp.thrift.iface.ImageSummaryRead;
+import org.openslx.bwlp.thrift.iface.UserInfo;
+
+public class App {
+
+ private static Logger log = Logger.getLogger(App.class);
+
+ private static List<Thread> servers = new ArrayList<>();
+
+ public static boolean DEBUG = false;
+
+ public static void main(String[] args) throws TTransportException, NoSuchAlgorithmException {
+ //get going and show basic information in log file
+ BasicConfigurator.configure();
+ if (args.length != 0 && args[0].equals("debug")) {
+ DEBUG = true;
+ }
+ log.info("****************************************************************");
+ log.info("******************* Starting Application ***********************");
+ log.info("****************************************************************");
+
+ // get Configuration
+ try {
+ log.info("Loading configuration");
+ Configuration.load();
+ } catch (Exception e1) {
+ log.fatal("Could not load configuration", e1);
+ System.exit(1);
+ }
+
+ // Load useful things from master server
+ OrganizationList.get();
+ //OperatingSystemList.get();
+
+ // Start file transfer server
+ if (!FileServer.instance().start()) {
+ log.error("Could not start internal file server.");
+ return;
+ }
+ // Start Server
+ Thread t;
+ t = new Thread(new BinaryListener(9090, false));
+ servers.add(t);
+ t.start();
+ // DEBUG
+ if (DEBUG) {
+ Database.printCharsetInformation();
+ List<ImageSummaryRead> allVisible = DbImage.getAllVisible(new UserInfo("bla", "blu", null, null,
+ null), null);
+ log.info("Got " + allVisible.size());
+ QuickTimer.scheduleAtFixedDelay(new TimerTask() {
+ @Override
+ public void run() {
+ Database.printDebug();
+ }
+ }, 100, 5000);
+ }
+ // Wait for servers
+ for (Thread wait : servers) {
+ boolean success = false;
+ while (!success) {
+ try {
+ wait.join();
+ success = true;
+ } catch (InterruptedException e) {
+ // Do nothing...
+ }
+ }
+ }
+ QuickTimer.cancel();
+ log.info(new Date() + " - all Servers shut down, exiting...\n");
+ }
+
+}
diff --git a/dozentenmodulserver/src/main/java/sql/SQL.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/Database.java
index af79b521..cfc6530b 100644
--- a/dozentenmodulserver/src/main/java/sql/SQL.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/Database.java
@@ -1,7 +1,8 @@
-package sql;
+package org.openslx.bwlp.sat.database;
import java.sql.Connection;
import java.sql.DriverManager;
+import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collections;
import java.util.Queue;
@@ -9,13 +10,12 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
-import models.Configuration;
-
import org.apache.log4j.Logger;
+import org.openslx.bwlp.sat.util.Configuration;
-public class SQL {
+public class Database {
- private static final Logger LOGGER = Logger.getLogger(SQL.class);
+ private static final Logger LOGGER = Logger.getLogger(Database.class);
/**
* Pool of available connections.
*/
@@ -35,6 +35,13 @@ public class SQL {
}
}
+ /**
+ * Get a connection to the database. If there is a valid connection in the
+ * pool, it will be returned. Otherwise, a new connection is created. If
+ * there are more than 20 busy connections, <code>null</code> is returned.
+ *
+ * @return connection to database, or <code>null</code>
+ */
public static MysqlConnection getConnection() {
MysqlConnection con;
for (;;) {
@@ -72,10 +79,42 @@ public class SQL {
return null;
}
+ /**
+ * Called by a {@link MysqlConnection} when its <code>close()</code>-method
+ * is called, so the connection will be added to the pool of available
+ * connections again.
+ *
+ * @param connection
+ */
static void returnConnection(MysqlConnection connection) {
if (!busyConnections.remove(connection))
throw new RuntimeException("Tried to return a mysql connection to the pool that was not taken!");
pool.add(connection);
}
+ public static void printCharsetInformation() {
+ LOGGER.info("MySQL charset related variables:");
+ try (MysqlConnection connection = Database.getConnection()) {
+ MysqlStatement stmt = connection.prepareStatement("SHOW VARIABLES LIKE :what");
+ stmt.setString("what", "char%");
+ ResultSet rs = stmt.executeQuery();
+ while (rs.next()) {
+ LOGGER.info(rs.getString("Variable_name") + ": " + rs.getString("Value"));
+ }
+ stmt.setString("what", "collat%");
+ rs = stmt.executeQuery();
+ while (rs.next()) {
+ LOGGER.info(rs.getString("Variable_name") + ": " + rs.getString("Value"));
+ }
+ } catch (SQLException e) {
+ LOGGER.error("Query failed in Database.printCharsetInformation()", e);
+ }
+ LOGGER.info("End of variables");
+ }
+
+ public static void printDebug() {
+ LOGGER.info("Available: " + pool.size());
+ LOGGER.info("Busy: " + busyConnections.size());
+ }
+
}// end class
diff --git a/dozentenmodulserver/src/main/java/sql/MysqlConnection.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/MysqlConnection.java
index dbbddfe1..24aaf1e8 100644
--- a/dozentenmodulserver/src/main/java/sql/MysqlConnection.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/MysqlConnection.java
@@ -1,4 +1,4 @@
-package sql;
+package org.openslx.bwlp.sat.database;
import java.sql.Connection;
import java.sql.SQLException;
@@ -26,7 +26,8 @@ public class MysqlConnection implements AutoCloseable {
}
public MysqlStatement prepareStatement(String sql) throws SQLException {
- hasPendingQueries = true;
+ if (!sql.startsWith("SELECT"))
+ hasPendingQueries = true;
MysqlStatement statement = new MysqlStatement(rawConnection, sql);
openStatements.add(statement);
return statement;
@@ -55,12 +56,14 @@ public class MysqlConnection implements AutoCloseable {
} catch (SQLException e) {
LOGGER.warn("Rolling back uncommited queries failed!", e);
}
+ }
+ if (!openStatements.isEmpty()) {
for (MysqlStatement statement : openStatements) {
statement.close();
}
openStatements.clear();
}
- SQL.returnConnection(this);
+ Database.returnConnection(this);
}
void release() {
diff --git a/dozentenmodulserver/src/main/java/sql/MysqlStatement.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/MysqlStatement.java
index efef88b0..3d5f9065 100644
--- a/dozentenmodulserver/src/main/java/sql/MysqlStatement.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/MysqlStatement.java
@@ -1,4 +1,4 @@
-package sql;
+package org.openslx.bwlp.sat.database;
import java.io.Closeable;
import java.sql.Connection;
@@ -13,9 +13,7 @@ import java.util.List;
import java.util.Map;
/**
- * Class for creating {@link java.sql.PreparedStatement}s with
- * named parameters.
- * Based on
+ * Class for creating {@link PreparedStatement}s with named parameters. Based on
* <a href=
* "http://www.javaworld.com/article/2077706/core-java/named-parameters-for-preparedstatement.html?page=2"
* >Named Parameters for PreparedStatement</a>
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbImage.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbImage.java
new file mode 100644
index 00000000..b772edb4
--- /dev/null
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbImage.java
@@ -0,0 +1,62 @@
+package org.openslx.bwlp.sat.database.mappers;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.openslx.bwlp.sat.database.Database;
+import org.openslx.bwlp.sat.database.MysqlConnection;
+import org.openslx.bwlp.sat.database.MysqlStatement;
+import org.openslx.bwlp.thrift.iface.ImagePermissions;
+import org.openslx.bwlp.thrift.iface.ImageSummaryRead;
+import org.openslx.bwlp.thrift.iface.ShareMode;
+import org.openslx.bwlp.thrift.iface.UserInfo;
+
+public class DbImage {
+
+ private static final Logger LOGGER = Logger.getLogger(DbImage.class);
+
+ public static List<ImageSummaryRead> getAllVisible(UserInfo user, List<String> tagSearch) {
+ try (MysqlConnection connection = Database.getConnection()) {
+ MysqlStatement stmt = connection.prepareStatement("SELECT"
+ + " i.imagebaseid, i.currentversionid, i.latestversionid, i.displayname,"
+ + " i.osid, i.virtid, i.createtime, i.updatetime, i.ownerid,"
+ + " i.sharemode, i.istemplate, i.canlinkdefault, i.candownloaddefault,"
+ + " i.caneditdefault, i.canadmindefault,"
+ + " cur.expiretime, cur.filesize, cur.isenabled, cur.isrestricted, cur.isvalid,"
+ + " lat.uploaderid, lat.isprocessed,"
+ + " perm.canlink, perm.candownload, perm.canedit, perm.canadmin"
+ + " FROM imagebase i"
+ + " LEFT JOIN imageversion cur ON (cur.imageversionid = i.currentversionid)"
+ + " LEFT JOIN imageversion lat ON (lat.imageversionid = i.latestversionid)"
+ + " LEFT JOIN imagepermission perm ON (i.imagebaseid = perm.imagebaseid AND perm.userid = :userid)");
+ stmt.setString("userid", user.userId);
+ ResultSet rs = stmt.executeQuery();
+ List<ImageSummaryRead> list = new ArrayList<>();
+ while (rs.next()) {
+ ImagePermissions defaultPermissions = DbImagePermissions.fromResultSetDefault(rs);
+ ImageSummaryRead entry = new ImageSummaryRead(rs.getString("imagebaseid"),
+ rs.getString("currentversionid"), rs.getString("latestversionid"),
+ rs.getString("displayname"), rs.getInt("osid"), rs.getString("virtid"),
+ rs.getLong("createtime"), rs.getLong("updatetime"), rs.getLong("expiretime"),
+ rs.getString("ownerid"), rs.getString("uploaderid"),
+ toShareMode(rs.getString("sharemode")), rs.getLong("filesize"),
+ rs.getByte("isrestricted") != 0, rs.getByte("isvalid") != 0,
+ rs.getByte("isprocessed") != 0, rs.getByte("istemplate") != 0, defaultPermissions);
+ entry.userPermissions = DbImagePermissions.fromResultSetUser(rs);
+ list.add(entry);
+ }
+ return list;
+ } catch (SQLException e) {
+ LOGGER.error("Query failed in DbImage.getAllVisible()", e);
+ return null;
+ }
+ }
+
+ private static ShareMode toShareMode(String string) {
+ return ShareMode.valueOf(string);
+ }
+
+}
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbImagePermissions.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbImagePermissions.java
new file mode 100644
index 00000000..e254b085
--- /dev/null
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbImagePermissions.java
@@ -0,0 +1,64 @@
+package org.openslx.bwlp.sat.database.mappers;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.openslx.bwlp.thrift.iface.ImagePermissions;
+
+public class DbImagePermissions {
+
+ /**
+ * Build an instance of {@link ImagePermissions} by reading the given
+ * columns from the given {@link ResultSet}. If there are no permissions
+ * given in the ResultSet, <code>null</code> is returned.
+ *
+ * @param rs the {@link ResultSet} to read from
+ * @param canLink Name of the column to read the "can link" permission from
+ * @param canDownload Name of the column to read the "can download"
+ * permission from
+ * @param canEdit Name of the column to read the "can edit" permission from
+ * @param canAdmin Name of the column to read the "can admin" permission
+ * from
+ * @return instance of {@link ImagePermissions}, or <code>null</code>
+ * @throws SQLException
+ */
+ private static ImagePermissions fromResultSet(ResultSet rs, String canLink, String canDownload,
+ String canEdit, String canAdmin) throws SQLException {
+ byte link = rs.getByte(canLink);
+ if (rs.wasNull())
+ return null;
+ return new ImagePermissions(link != 0, rs.getByte(canDownload) != 0, rs.getByte(canEdit) != 0,
+ rs.getByte(canAdmin) != 0);
+ }
+
+ /**
+ * Build an instance of {@link ImagePermissions} by reading the
+ * columns <code>canlink</code>, <code>candownload</code>,
+ * <code>canedit</code>, <code>canadmin</code> from the given
+ * {@link ResultSet}. If there are no permissions
+ * given in the ResultSet, <code>null</code> is returned.
+ *
+ * @param rs the {@link ResultSet} to read from
+ * @return instance of {@link ImagePermissions}, or <code>null</code>
+ * @throws SQLException
+ */
+ public static ImagePermissions fromResultSetUser(ResultSet rs) throws SQLException {
+ return fromResultSet(rs, "canlink", "candownload", "canedit", "canadmin");
+ }
+
+ /**
+ * Build an instance of {@link ImagePermissions} by reading the
+ * columns <code>canlinkdefault</code>, <code>candownloaddefault</code>,
+ * <code>caneditdefault</code>, <code>canadmindefault</code> from the given
+ * {@link ResultSet}. If there are no permissions
+ * given in the ResultSet, <code>null</code> is returned.
+ *
+ * @param rs the {@link ResultSet} to read from
+ * @return instance of {@link ImagePermissions}, or <code>null</code>
+ * @throws SQLException
+ */
+ public static ImagePermissions fromResultSetDefault(ResultSet rs) throws SQLException {
+ return fromResultSet(rs, "canlinkdefault", "candownloaddefault", "caneditdefault", "canadmindefault");
+ }
+
+}
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbOrganization.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbOrganization.java
new file mode 100644
index 00000000..cc401af9
--- /dev/null
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbOrganization.java
@@ -0,0 +1,34 @@
+package org.openslx.bwlp.sat.database.mappers;
+
+import java.sql.SQLException;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.openslx.bwlp.sat.database.Database;
+import org.openslx.bwlp.sat.database.MysqlConnection;
+import org.openslx.bwlp.sat.database.MysqlStatement;
+import org.openslx.bwlp.thrift.iface.Organization;
+
+public class DbOrganization {
+
+ private static final Logger LOGGER = Logger.getLogger(DbOrganization.class);
+
+ public static boolean storeOrganizations(List<Organization> organizations) {
+ try (MysqlConnection connection = Database.getConnection()) {
+ MysqlStatement stmt = connection.prepareStatement("INSERT INTO organization"
+ + " (organizationid, displayname, canlogin) VALUES (:id, :name, 0)"
+ + " ON DUPLICATE KEY UPDATE displayname = VALUES(displayname)");
+ for (Organization organization : organizations) {
+ stmt.setString("id", organization.organizationId);
+ stmt.setString("name", organization.displayName);
+ stmt.executeUpdate();
+ }
+ connection.commit();
+ return true;
+ } catch (SQLException e) {
+ LOGGER.error("Query failed in DbOrganization.storeOrganization()", e);
+ return false;
+ }
+ }
+
+}
diff --git a/dozentenmodulserver/src/main/java/fileserv/ActiveUpload.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/ActiveUpload.java
index 334345f3..a2474587 100644
--- a/dozentenmodulserver/src/main/java/fileserv/ActiveUpload.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/ActiveUpload.java
@@ -1,4 +1,4 @@
-package fileserv;
+package org.openslx.bwlp.sat.fileserv;
import java.io.File;
import java.io.FileNotFoundException;
@@ -9,9 +9,10 @@ import java.util.List;
import java.util.UUID;
import java.util.concurrent.ThreadPoolExecutor;
-import models.Configuration;
-
import org.apache.log4j.Logger;
+import org.openslx.bwlp.sat.util.Configuration;
+import org.openslx.bwlp.sat.util.FileSystem;
+import org.openslx.bwlp.sat.util.Formatter;
import org.openslx.bwlp.thrift.iface.ImageDetailsRead;
import org.openslx.bwlp.thrift.iface.UserInfo;
import org.openslx.filetransfer.DataReceivedCallback;
@@ -19,9 +20,6 @@ import org.openslx.filetransfer.Downloader;
import org.openslx.filetransfer.FileRange;
import org.openslx.filetransfer.WantRangeCallback;
-import util.FileSystem;
-import util.Formatter;
-
public class ActiveUpload {
private static final Logger LOGGER = Logger.getLogger(ActiveUpload.class);
diff --git a/dozentenmodulserver/src/main/java/fileserv/ChunkList.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/ChunkList.java
index 95b3e1fa..b07193c5 100644
--- a/dozentenmodulserver/src/main/java/fileserv/ChunkList.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/ChunkList.java
@@ -1,4 +1,4 @@
-package fileserv;
+package org.openslx.bwlp.sat.fileserv;
import java.nio.ByteBuffer;
import java.util.LinkedList;
diff --git a/dozentenmodulserver/src/main/java/fileserv/FileChunk.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileChunk.java
index 1a95d27c..ffa033a5 100644
--- a/dozentenmodulserver/src/main/java/fileserv/FileChunk.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileChunk.java
@@ -1,4 +1,4 @@
-package fileserv;
+package org.openslx.bwlp.sat.fileserv;
import java.nio.ByteBuffer;
import java.util.Collection;
diff --git a/dozentenmodulserver/src/main/java/fileserv/FileServer.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java
index e82fa39c..c357c292 100644
--- a/dozentenmodulserver/src/main/java/fileserv/FileServer.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java
@@ -1,4 +1,4 @@
-package fileserv;
+package org.openslx.bwlp.sat.fileserv;
import java.io.File;
import java.io.FileNotFoundException;
@@ -10,6 +10,8 @@ import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
+import org.openslx.bwlp.sat.util.Constants;
+import org.openslx.bwlp.sat.util.Formatter;
import org.openslx.bwlp.thrift.iface.TTransferRejectedException;
import org.openslx.bwlp.thrift.iface.UserInfo;
import org.openslx.filetransfer.Downloader;
@@ -17,9 +19,6 @@ import org.openslx.filetransfer.IncomingEvent;
import org.openslx.filetransfer.Listener;
import org.openslx.filetransfer.Uploader;
-import util.Constants;
-import util.Formatter;
-
public class FileServer implements IncomingEvent {
/**
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/BinaryListener.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/BinaryListener.java
new file mode 100644
index 00000000..70c47edb
--- /dev/null
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/BinaryListener.java
@@ -0,0 +1,65 @@
+package org.openslx.bwlp.sat.thrift;
+
+import java.security.NoSuchAlgorithmException;
+
+import org.apache.log4j.Logger;
+import org.apache.thrift.protocol.TProtocolFactory;
+import org.apache.thrift.server.THsHaServer;
+import org.apache.thrift.server.TServer;
+import org.apache.thrift.transport.TNonblockingServerSocket;
+import org.apache.thrift.transport.TNonblockingServerTransport;
+import org.apache.thrift.transport.TTransportException;
+import org.openslx.bwlp.thrift.iface.SatelliteServer;
+import org.openslx.thrifthelper.TBinaryProtocolSafe;
+
+public class BinaryListener implements Runnable {
+ private static final Logger log = Logger.getLogger(BinaryListener.class);
+
+ private static final int MAX_MSG_LEN = 30 * 1000 * 1000;
+ private static final int MINWORKERTHREADS = 2;
+ private static final int MAXWORKERTHREADS = 64;
+
+ private final SatelliteServer.Processor<ServerHandler> processor = new SatelliteServer.Processor<ServerHandler>(
+ new ServerHandler());
+ private final TProtocolFactory protFactory = new TBinaryProtocolSafe.Factory(true, true);
+
+ private final TServer server;
+
+ public BinaryListener(int port, boolean secure) throws TTransportException, NoSuchAlgorithmException {
+ if (secure)
+ server = initSecure(port);
+ else
+ server = initNormal(port);
+ }
+
+ @Override
+ public void run() {
+ log.info("Starting Listener");
+ server.serve();
+ log.fatal("Listener stopped unexpectedly");
+ // TODO: Restart listener; if it fails, quit server so it will be restarted by the OS
+ }
+
+ private TServer initSecure(int port) throws NoSuchAlgorithmException, TTransportException {
+ // TODO
+ return null;
+ }
+
+ private TServer initNormal(int port) throws TTransportException {
+ final TNonblockingServerTransport serverTransport;
+ try {
+ serverTransport = new TNonblockingServerSocket(port);
+ log.fatal("Listening on port " + port + " (plain handler)");
+ } catch (TTransportException e) {
+ log.fatal("Could not listen on port " + port + " (plain handler)");
+ throw e;
+ }
+ THsHaServer.Args args = new THsHaServer.Args(serverTransport);
+ args.protocolFactory(protFactory);
+ args.processor(processor);
+ args.workerThreads(8);
+ args.maxReadBufferBytes = MAX_MSG_LEN;
+ return new THsHaServer(args);
+ }
+
+}
diff --git a/dozentenmodulserver/src/main/java/server/ServerHandler.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java
index dddec9be..cf26b510 100644
--- a/dozentenmodulserver/src/main/java/server/ServerHandler.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java
@@ -1,4 +1,4 @@
-package server;
+package org.openslx.bwlp.sat.thrift;
import java.nio.ByteBuffer;
import java.util.List;
@@ -6,6 +6,10 @@ import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
+import org.openslx.bwlp.sat.database.mappers.DbImage;
+import org.openslx.bwlp.sat.fileserv.ActiveUpload;
+import org.openslx.bwlp.sat.fileserv.FileServer;
+import org.openslx.bwlp.sat.thrift.cache.OperatingSystemList;
import org.openslx.bwlp.thrift.iface.ImageBaseWrite;
import org.openslx.bwlp.thrift.iface.ImageDetailsRead;
import org.openslx.bwlp.thrift.iface.ImagePermissions;
@@ -28,11 +32,6 @@ import org.openslx.bwlp.thrift.iface.UserInfo;
import org.openslx.bwlp.thrift.iface.Virtualizer;
import org.openslx.sat.thrift.version.Version;
-import sql.models.DbImage;
-import thrift.OperatingSystemList;
-import fileserv.ActiveUpload;
-import fileserv.FileServer;
-
public class ServerHandler implements SatelliteServer.Iface {
private static final Logger log = Logger.getLogger(ServerHandler.class);
diff --git a/dozentenmodulserver/src/main/java/server/SessionManager.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/SessionManager.java
index 3f4d4257..bf444a20 100644
--- a/dozentenmodulserver/src/main/java/server/SessionManager.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/SessionManager.java
@@ -1,4 +1,4 @@
-package server;
+package org.openslx.bwlp.sat.thrift;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/cache/CachedList.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/cache/CachedList.java
new file mode 100644
index 00000000..4c986fd2
--- /dev/null
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/cache/CachedList.java
@@ -0,0 +1,33 @@
+package org.openslx.bwlp.sat.thrift.cache;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.apache.thrift.TException;
+import org.openslx.util.TimeoutReference;
+
+
+public abstract class CachedList<T> {
+
+ private static final Logger LOGGER = Logger.getLogger(CachedList.class);
+
+ private final TimeoutReference<List<T>> cachedList = new TimeoutReference<>(600000, null);
+
+ protected abstract List<T> getCallback() throws TException;
+
+ protected synchronized List<T> getInternal() {
+ List<T> list = cachedList.get();
+ if (list == null) {
+ try {
+ list = getCallback();
+ } catch (TException e) {
+ LOGGER.warn("Could not retrieve " + getClass().getSimpleName() + " list from master server",
+ e);
+ return null;
+ }
+ cachedList.set(list);
+ }
+ return list;
+ }
+
+}
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/cache/OperatingSystemList.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/cache/OperatingSystemList.java
new file mode 100644
index 00000000..020ae4ff
--- /dev/null
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/cache/OperatingSystemList.java
@@ -0,0 +1,26 @@
+package org.openslx.bwlp.sat.thrift.cache;
+
+import java.util.List;
+
+import org.apache.thrift.TException;
+import org.openslx.bwlp.thrift.iface.OperatingSystem;
+import org.openslx.thrifthelper.ThriftManager;
+
+/**
+ * Holds the list of all known organizations. The list is synchronized with
+ * the master server.
+ */
+public class OperatingSystemList extends CachedList<OperatingSystem> {
+
+ private static final OperatingSystemList instance = new OperatingSystemList();
+
+ public static List<OperatingSystem> get() {
+ return instance.getInternal();
+ }
+
+ @Override
+ protected List<OperatingSystem> getCallback() throws TException {
+ return ThriftManager.getMasterClient().getOperatingSystems();
+ }
+
+}
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/cache/OrganizationList.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/cache/OrganizationList.java
new file mode 100644
index 00000000..8db7e7e5
--- /dev/null
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/cache/OrganizationList.java
@@ -0,0 +1,29 @@
+package org.openslx.bwlp.sat.thrift.cache;
+
+import java.util.List;
+
+import org.apache.thrift.TException;
+import org.openslx.bwlp.sat.database.mappers.DbOrganization;
+import org.openslx.bwlp.thrift.iface.Organization;
+import org.openslx.thrifthelper.ThriftManager;
+
+/**
+ * Holds the list of all known organizations. The list is synchronized with
+ * the master server.
+ */
+public class OrganizationList extends CachedList<Organization> {
+
+ private static final OrganizationList instance = new OrganizationList();
+
+ public static List<Organization> get() {
+ return instance.getInternal();
+ }
+
+ @Override
+ protected List<Organization> getCallback() throws TException {
+ List<Organization> organizations = ThriftManager.getMasterClient().getOrganizations();
+ DbOrganization.storeOrganizations(organizations);
+ return organizations;
+ }
+
+}
diff --git a/dozentenmodulserver/src/main/java/models/Configuration.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Configuration.java
index 244e542b..07cd3a8d 100644
--- a/dozentenmodulserver/src/main/java/models/Configuration.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Configuration.java
@@ -1,4 +1,4 @@
-package models;
+package org.openslx.bwlp.sat.util;
import java.io.File;
import java.io.FileInputStream;
diff --git a/dozentenmodulserver/src/main/java/util/Constants.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Constants.java
index 8ac5dabd..6c2dc31b 100644
--- a/dozentenmodulserver/src/main/java/util/Constants.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Constants.java
@@ -1,6 +1,6 @@
-package util;
+package org.openslx.bwlp.sat.util;
-import fileserv.FileChunk;
+import org.openslx.bwlp.sat.fileserv.FileChunk;
public class Constants {
public static final String INCOMPLETE_UPLOAD_SUFFIX = ".part";
diff --git a/dozentenmodulserver/src/main/java/util/FileSystem.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/FileSystem.java
index 5f5a1e08..38841cd9 100644
--- a/dozentenmodulserver/src/main/java/util/FileSystem.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/FileSystem.java
@@ -1,4 +1,4 @@
-package util;
+package org.openslx.bwlp.sat.util;
import java.io.File;
diff --git a/dozentenmodulserver/src/main/java/util/Formatter.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Formatter.java
index 2f6fbae2..0839ad24 100644
--- a/dozentenmodulserver/src/main/java/util/Formatter.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Formatter.java
@@ -1,10 +1,8 @@
-package util;
+package org.openslx.bwlp.sat.util;
import java.io.File;
import java.util.UUID;
-import models.Configuration;
-
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.openslx.bwlp.thrift.iface.UserInfo;
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/QuickTimer.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/QuickTimer.java
new file mode 100644
index 00000000..7a317ff7
--- /dev/null
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/QuickTimer.java
@@ -0,0 +1,38 @@
+package org.openslx.bwlp.sat.util;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+/**
+ * This is a global, static {@link Timer} you can use anywhere for repeating
+ * tasks that will <b>not take a significant amount of time to execute</b>. This
+ * means they should not run any complex data base queries (better yet, none at
+ * all) or do heavy file I/O, etc..
+ * The main reason for this class is to prevent having {@link Timer} threads
+ * everywhere in the server for trivial tasks.
+ */
+public class QuickTimer {
+
+ private static final Timer timer = new Timer("QuickTimer");
+
+ public static void scheduleAtFixedDelay(TimerTask task, long delay, long period) {
+ timer.schedule(task, delay, period);
+ }
+
+ public static void scheduleAtFixedRate(TimerTask task, long delay, long period) {
+ timer.scheduleAtFixedRate(task, delay, period);
+ }
+
+ public static void scheduleOnce(TimerTask task, long delay) {
+ timer.schedule(task, delay);
+ }
+
+ /**
+ * Cancel this timer. Should only be called when the server is shutting
+ * down.
+ */
+ public static void cancel() {
+ timer.cancel();
+ }
+
+}
diff --git a/dozentenmodulserver/src/main/java/util/Util.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Util.java
index 28f522b8..338ed325 100644
--- a/dozentenmodulserver/src/main/java/util/Util.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/util/Util.java
@@ -1,4 +1,4 @@
-package util;
+package org.openslx.bwlp.sat.util;
import java.io.Closeable;
diff --git a/dozentenmodulserver/src/main/java/server/BinaryListener.java b/dozentenmodulserver/src/main/java/server/BinaryListener.java
deleted file mode 100644
index 92954322..00000000
--- a/dozentenmodulserver/src/main/java/server/BinaryListener.java
+++ /dev/null
@@ -1,49 +0,0 @@
-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.TThreadPoolServer;
-import org.apache.thrift.server.TThreadPoolServer.Args;
-import org.apache.thrift.transport.TServerSocket;
-import org.apache.thrift.transport.TServerTransport;
-import org.apache.thrift.transport.TTransportException;
-import org.openslx.bwlp.thrift.iface.SatelliteServer;
-
-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() {
- final ServerHandler handler = new ServerHandler();
- final SatelliteServer.Processor<ServerHandler> processor = new SatelliteServer.Processor<ServerHandler>(
- handler);
- final TServerTransport transport;
- final TProtocolFactory protFactory = new TBinaryProtocolSafe.Factory(
- true, true);
- try {
- transport = new TServerSocket(9090);
- log.info(new Date() + " - Listening on Port 9090");
-
- } catch (TTransportException e) {
- log.fatal(new Date() + " - Could not listen on port 9090");
- return;
- }
- 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/main/java/server/StartServer.java b/dozentenmodulserver/src/main/java/server/StartServer.java
deleted file mode 100644
index a5631622..00000000
--- a/dozentenmodulserver/src/main/java/server/StartServer.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package server;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import models.Configuration;
-
-import org.apache.log4j.BasicConfigurator;
-import org.apache.log4j.Logger;
-
-import fileserv.FileServer;
-
-public class StartServer {
-
- private static Logger log = Logger.getLogger(StartServer.class);
-
- private static List<Thread> servers = new ArrayList<>();
-
- public static void main(String[] args) {
-
- //get going and show basic information in logfile
- BasicConfigurator.configure();
- log.info("****************************************************************");
- log.info("******************* starting Application ***********************");
- log.info("****************************************************************");
-
- // get Configuration
- try {
- log.info("Loading configuration");
- Configuration.load();
- } catch (Exception e1) {
- log.fatal("Could not load configuration", e1);
- System.exit(1);
- }
-
- // Start file transfer server
- if (!FileServer.instance().start()) {
- log.error("Could not start internal file server.");
- return;
- }
- // Start Server
- Thread t;
- t = new Thread(new BinaryListener());
- servers.add(t);
- t.start();
- // Wait for servers
- for (Thread wait : servers) {
- boolean success = false;
- while (!success) {
- try {
- wait.join();
- success = true;
- } catch (InterruptedException e) {
- // Do nothing...
- }
- }
- }
- log.info(new Date() + " - all Servers shut down, exiting...\n");
- }
-
-}
diff --git a/dozentenmodulserver/src/main/java/server/TBinaryProtocolSafe.java b/dozentenmodulserver/src/main/java/server/TBinaryProtocolSafe.java
deleted file mode 100644
index 843b58b1..00000000
--- a/dozentenmodulserver/src/main/java/server/TBinaryProtocolSafe.java
+++ /dev/null
@@ -1,123 +0,0 @@
-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/main/java/sql/models/DbImage.java b/dozentenmodulserver/src/main/java/sql/models/DbImage.java
deleted file mode 100644
index fe59dac8..00000000
--- a/dozentenmodulserver/src/main/java/sql/models/DbImage.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package sql.models;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.openslx.bwlp.thrift.iface.ImageSummaryRead;
-import org.openslx.bwlp.thrift.iface.UserInfo;
-
-import sql.MysqlConnection;
-import sql.MysqlStatement;
-import sql.SQL;
-
-public class DbImage {
-
- private static final Logger LOGGER = Logger.getLogger(DbImage.class);
-
- public static List<ImageSummaryRead> getAllVisible(UserInfo user, List<String> tagSearch) {
- try (MysqlConnection connection = SQL.getConnection()) {
- MysqlStatement stmt = connection.prepareStatement("SELECT"
- + " i.imagebaseid, i.currentversionid, i.latestversionid, i.displayname,"
- + " i.osid, i.virtid, i.createtime, i.updatetime, i.ownerid, i.uploaderid,"
- + " i.sharemode, i.istemplate, i.canlinkdefault, i.candownloaddefault,"
- + " i.caneditdefault, i.canadmindefault,"
- + " cur.filesize, cur.isenabled, cur.isrestricted, cur.isvalid," + " lat.isprocessed"
- + " FROM imagebase i"
- + " LEFT JOIN imageversion cur ON (cur.imageversionid = i.currentversionid)"
- + " LEFT JOIN imageversion lat ON (lat.imageversionid = i.latestversionid)");
- ResultSet rs = stmt.executeQuery();
- while (rs.next()) {
- ImageSummaryRead entry = new ImageSummaryRead();
- }
- return null;
- } catch (SQLException e) {
- LOGGER.error("Query failed in DbImage.getAllVisible()", e);
- return null;
- }
- }
-
-}
diff --git a/dozentenmodulserver/src/main/java/thrift/OperatingSystemList.java b/dozentenmodulserver/src/main/java/thrift/OperatingSystemList.java
deleted file mode 100644
index 6d5404f7..00000000
--- a/dozentenmodulserver/src/main/java/thrift/OperatingSystemList.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package thrift;
-
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.apache.thrift.TException;
-import org.openslx.bwlp.thrift.iface.OperatingSystem;
-import org.openslx.thrifthelper.ThriftManager;
-import org.openslx.util.TimeoutReference;
-
-/**
- * Holds the list of all known operating systems. The list is synchronized with
- * the master server.
- */
-public class OperatingSystemList {
-
- private static final Logger LOGGER = Logger.getLogger(OperatingSystemList.class);
-
- private static final TimeoutReference<List<OperatingSystem>> cachedList = new TimeoutReference<List<OperatingSystem>>(
- 600000, null);
-
- public static synchronized List<OperatingSystem> get() {
- List<OperatingSystem> list = cachedList.get();
- if (list == null) {
- try {
- list = ThriftManager.getMasterClient().getOperatingSystems();
- // TODO: Write to DB
- } catch (TException e) {
- LOGGER.warn("Could not retrieve OS list from master server", e);
- return null;
- }
- cachedList.set(list);
- }
- return list;
- }
-
-}