aboutsummaryrefslogtreecommitdiff
path: root/server-core/src/main/java/com/juick/util
diff options
context:
space:
mode:
Diffstat (limited to 'server-core/src/main/java/com/juick/util')
-rw-r--r--server-core/src/main/java/com/juick/util/TagUtils.java24
-rw-r--r--server-core/src/main/java/com/juick/util/ThreadHelper.java37
-rw-r--r--server-core/src/main/java/com/juick/util/UserUtils.java27
3 files changed, 0 insertions, 88 deletions
diff --git a/server-core/src/main/java/com/juick/util/TagUtils.java b/server-core/src/main/java/com/juick/util/TagUtils.java
deleted file mode 100644
index 157522ab..00000000
--- a/server-core/src/main/java/com/juick/util/TagUtils.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.juick.util;
-
-import com.juick.Tag;
-import org.apache.commons.collections4.CollectionUtils;
-
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * Created by aalexeev on 11/13/16.
- */
-public class TagUtils {
- private TagUtils() {
- throw new IllegalStateException();
- }
-
- public static String toString(final List<Tag> tags) {
- if (CollectionUtils.isEmpty(tags))
- return "";
-
- return tags.stream().map(t -> " *" + t.getName())
- .collect(Collectors.joining());
- }
-}
diff --git a/server-core/src/main/java/com/juick/util/ThreadHelper.java b/server-core/src/main/java/com/juick/util/ThreadHelper.java
deleted file mode 100644
index 64a56f7c..00000000
--- a/server-core/src/main/java/com/juick/util/ThreadHelper.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.juick.util;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Created by aalexeev on 11/11/16.
- */
-public class ThreadHelper {
- private ThreadHelper() {
- throw new IllegalStateException();
- }
-
- private static Logger logger = LoggerFactory.getLogger(ThreadHelper.class);
-
- public static void shutdownAndAwaitTermination(ExecutorService pool) {
- pool.shutdown(); // Disable new tasks from being submitted
- try {
- // Wait a while for existing tasks to terminate
- if (!pool.awaitTermination(5, TimeUnit.SECONDS)) {
- logger.info("Calls shutDownNow for pool");
- pool.shutdownNow(); // Cancel currently executing tasks
- // Wait a while for tasks to respond to being cancelled
- if (!pool.awaitTermination(5, TimeUnit.SECONDS))
- logger.error("Pool did not terminate");
- }
- } catch (InterruptedException ie) {
- // (Re-)Cancel if current thread also interrupted
- pool.shutdownNow();
- // Preserve interrupt status
- Thread.currentThread().interrupt();
- }
- }
-}
diff --git a/server-core/src/main/java/com/juick/util/UserUtils.java b/server-core/src/main/java/com/juick/util/UserUtils.java
deleted file mode 100644
index 611a3b15..00000000
--- a/server-core/src/main/java/com/juick/util/UserUtils.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.juick.util;
-
-import java.util.Random;
-
-/**
- * Created by aalexeev on 11/14/16.
- */
-public class UserUtils {
- private UserUtils() {
- throw new IllegalStateException();
- }
-
- private static final String ABCDEF = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-
- public static String generateHash(final int len) {
- Random rnd = new Random();
- StringBuilder sb = new StringBuilder(len);
- for (int i = 0; i < len; i++) {
- sb.append(ABCDEF.charAt(rnd.nextInt(ABCDEF.length())));
- }
- return sb.toString();
- }
-
- public static boolean checkUserNameValid(final String uname) {
- return uname != null && uname.length() >= 2 && uname.length() <= 16 && uname.matches("[a-zA-Z0-9\\-]+");
- }
-}