summaryrefslogtreecommitdiffstats
path: root/dozentenmodulserver/src/main/java/util/Formatter.java
diff options
context:
space:
mode:
authorSimon Rettberg2015-06-11 18:40:49 +0200
committerSimon Rettberg2015-06-11 18:40:49 +0200
commite0005ceecfd9281230c4add7575b18ee88307774 (patch)
treea73bbcfc213df478c701aac120ae2b7c6e52bb1b /dozentenmodulserver/src/main/java/util/Formatter.java
parent[server] db stuff, new interface, ... (diff)
downloadtutor-module-e0005ceecfd9281230c4add7575b18ee88307774.tar.gz
tutor-module-e0005ceecfd9281230c4add7575b18ee88307774.tar.xz
tutor-module-e0005ceecfd9281230c4add7575b18ee88307774.zip
[server] On mah way (lots of restructuring, some early db classes, sql dump of current schema)
Diffstat (limited to 'dozentenmodulserver/src/main/java/util/Formatter.java')
-rw-r--r--dozentenmodulserver/src/main/java/util/Formatter.java59
1 files changed, 0 insertions, 59 deletions
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;
- }
-}