diff options
Diffstat (limited to 'dozentenmodulserver/src/main/java/util')
4 files changed, 0 insertions, 150 deletions
diff --git a/dozentenmodulserver/src/main/java/util/Constants.java b/dozentenmodulserver/src/main/java/util/Constants.java deleted file mode 100644 index 8ac5dabd..00000000 --- a/dozentenmodulserver/src/main/java/util/Constants.java +++ /dev/null @@ -1,21 +0,0 @@ -package util; - -import fileserv.FileChunk; - -public class Constants { - public static final String INCOMPLETE_UPLOAD_SUFFIX = ".part"; - public static final int MAX_UPLOADS; - - static { - long maxMem = Runtime.getRuntime().maxMemory(); - if (maxMem == Long.MAX_VALUE) { - // Apparently the JVM was started without a memory limit (no -Xmx cmdline), - // so we assume a default of 256MB - maxMem = 256l * 1024l * 1024l; - } - maxMem /= 1024l * 1024l; - // Now maxMem is the amount of memory in MiB - - MAX_UPLOADS = (int) Math.max(1, (maxMem - 64) / (FileChunk.CHUNK_SIZE_MIB + 1)); - } -} diff --git a/dozentenmodulserver/src/main/java/util/FileSystem.java b/dozentenmodulserver/src/main/java/util/FileSystem.java deleted file mode 100644 index 5f5a1e08..00000000 --- a/dozentenmodulserver/src/main/java/util/FileSystem.java +++ /dev/null @@ -1,25 +0,0 @@ -package util; - -import java.io.File; - -import org.apache.log4j.Logger; - -public class FileSystem { - - private static final Logger LOGGER = Logger.getLogger(FileSystem.class); - - public static String getRelativePath(File absolutePath, File parentDir) { - String file; - String dir; - try { - file = absolutePath.getCanonicalPath(); - dir = parentDir.getCanonicalPath() + File.separator; - } catch (Exception e) { - LOGGER.error("Could not get relative path for " + absolutePath.toString(), e); - return null; - } - if (!file.startsWith(dir)) - return null; - return file.substring(dir.length()); - } -} diff --git a/dozentenmodulserver/src/main/java/util/Formatter.java b/dozentenmodulserver/src/main/java/util/Formatter.java deleted file mode 100644 index 2f6fbae2..00000000 --- a/dozentenmodulserver/src/main/java/util/Formatter.java +++ /dev/null @@ -1,59 +0,0 @@ -package 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; - -public class Formatter { - - private static final DateTimeFormatter vmNameDateFormat = DateTimeFormat.forPattern("dd_HH-mm-ss"); - - /** - * Generate a unique file name used for a virtual machine - * image that is currently uploading. - * - * @return Absolute path name of file - */ - public static File getTempImageName() { - return new File(Configuration.getCurrentVmStorePath(), UUID.randomUUID().toString() - + Constants.INCOMPLETE_UPLOAD_SUFFIX); - } - - /** - * Generate a file name for the given VM based on owner and display name. - * - * @param user The user associated with the VM, e.g. the owner - * @param imageName Name of the VM - * @return File name for the VM derived from the function's input - */ - public static String vmName(UserInfo user, String imageName) { - return cleanFileName(vmNameDateFormat.print(System.currentTimeMillis()) + "_" + user.lastName + "_" - + imageName); - } - - /** - * Make sure file name contains only a subset of ascii characters and is not - * too long. - * - * @param name What we want to turn into a file name - * @return A sanitized form of name that should be safe to use as a file - * name - */ - public static String cleanFileName(String name) { - if (name == null) - return "null"; - name = name.replaceAll("[^a-zA-Z0-9_\\.\\-]+", "_"); - if (name.length() > 120) - name = name.substring(0, 120); - return name; - } - - public static String userFullName(UserInfo ui) { - return ui.firstName + " " + ui.lastName; - } -} diff --git a/dozentenmodulserver/src/main/java/util/Util.java b/dozentenmodulserver/src/main/java/util/Util.java deleted file mode 100644 index 28f522b8..00000000 --- a/dozentenmodulserver/src/main/java/util/Util.java +++ /dev/null @@ -1,45 +0,0 @@ -package util; - -import java.io.Closeable; - -public class Util { - - /** - * Try to close everything passed to this method. Never throw an exception - * if it fails, just silently continue. - * - * @param item One or more objects that are Closeable - */ - public static void safeClose(Closeable... item) { - if (item == null) - return; - for (Closeable c : item) { - if (c == null) - continue; - try { - c.close(); - } catch (Exception e) { - } - } - } - - /** - * Try to close everything passed to this method. Never throw an exception - * if it fails, just silently continue. - * - * @param item One or more objects that are AutoCloseable - */ - public static void safeClose(AutoCloseable... item) { - if (item == null) - return; - for (AutoCloseable c : item) { - if (c == null) - continue; - try { - c.close(); - } catch (Exception e) { - } - } - } - -} |
