The Unified and Autonomous Development Platform
Refactoring some basic utility into gitplex.utils
robin shen22e3d26cf835
diff --git a/core/pom.xml b/core/pom.xmlindex e774e50501..9063616d27 100644--- a/core/pom.xml+++ b/core/pom.xml@@ -49,6 +49,12 @@<groupId>org.apache.shiro</groupId><artifactId>shiro-guice</artifactId><version>${shiro.version}</version>+ <exclusions>+ <exclusion>+ <groupId>com.google.guava</groupId>+ <artifactId>guava</artifactId>+ </exclusion>+ </exclusions></dependency><dependency><groupId>org.hibernate</groupId>@@ -129,10 +135,6 @@<groupId>org.unbescape</groupId><artifactId>unbescape</artifactId></dependency>- <dependency>- <groupId>com.google.guava</groupId>- <artifactId>guava</artifactId>- </dependency><dependency><groupId>com.gitplex</groupId><artifactId>launcher-bootstrap</artifactId>@@ -154,14 +156,6 @@<groupId>org.apache.commons</groupId><artifactId>commons-email</artifactId></dependency>- <dependency>- <groupId>org.apache.commons</groupId>- <artifactId>commons-collections4</artifactId>- </dependency>- <dependency>- <groupId>org.apache.ant</groupId>- <artifactId>ant</artifactId>- </dependency><dependency><groupId>org.javassist</groupId><artifactId>javassist</artifactId>@@ -231,16 +225,6 @@<artifactId>jsyntax</artifactId><version>1.0.0-SNAPSHOT</version></dependency>- <dependency>- <groupId>org.quartz-scheduler</groupId>- <artifactId>quartz</artifactId>- <exclusions>- <exclusion>- <groupId>c3p0</groupId>- <artifactId>c3p0</artifactId>- </exclusion>- </exclusions>- </dependency><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId>diff --git a/core/src/main/java/com/gitplex/server/CoreModule.java b/core/src/main/java/com/gitplex/server/CoreModule.javaindex f4bece0ba1..a8f0e5c525 100644--- a/core/src/main/java/com/gitplex/server/CoreModule.java+++ b/core/src/main/java/com/gitplex/server/CoreModule.java@@ -142,17 +142,15 @@ import com.gitplex.server.security.DefaultWebSecurityManager;import com.gitplex.server.security.FilterChainConfigurator;import com.gitplex.server.security.GitPlexAuthorizingRealm;import com.gitplex.server.security.authenticator.Authenticator;-import com.gitplex.server.util.ClassUtils;import com.gitplex.server.util.jackson.ObjectMapperConfigurator;import com.gitplex.server.util.jackson.ObjectMapperProvider;import com.gitplex.server.util.jackson.hibernate.HibernateObjectMapperConfigurator;import com.gitplex.server.util.jetty.DefaultJettyRunner;import com.gitplex.server.util.jetty.JettyRunner;-import com.gitplex.server.util.schedule.DefaultTaskScheduler;-import com.gitplex.server.util.schedule.TaskScheduler;import com.gitplex.server.util.validation.DefaultEntityValidator;import com.gitplex.server.util.validation.EntityValidator;import com.gitplex.server.util.validation.ValidatorProvider;+import com.gitplex.utils.ClassUtils;import com.google.inject.matcher.AbstractMatcher;import com.google.inject.matcher.Matchers;import com.thoughtworks.xstream.XStream;@@ -190,8 +188,6 @@ public class CoreModule extends AbstractPluginModule {}).in(Singleton.class);bind(Validator.class).toProvider(ValidatorProvider.class).in(Singleton.class);-- bind(TaskScheduler.class).to(DefaultTaskScheduler.class);// configure markdownbind(MarkdownManager.class).to(DefaultMarkdownManager.class);diff --git a/core/src/main/java/com/gitplex/server/GitPlex.java b/core/src/main/java/com/gitplex/server/GitPlex.javaindex c496754c3a..09a77bbeba 100644--- a/core/src/main/java/com/gitplex/server/GitPlex.java+++ b/core/src/main/java/com/gitplex/server/GitPlex.java@@ -32,11 +32,11 @@ import com.gitplex.server.manager.UserManager;import com.gitplex.server.persistence.PersistManager;import com.gitplex.server.persistence.UnitOfWork;import com.gitplex.server.persistence.annotation.Sessional;-import com.gitplex.server.util.init.InitStage;-import com.gitplex.server.util.init.ManualConfig;import com.gitplex.server.util.jetty.JettyRunner;-import com.gitplex.server.util.schedule.TaskScheduler;import com.gitplex.server.util.serverconfig.ServerConfig;+import com.gitplex.utils.init.InitStage;+import com.gitplex.utils.init.ManualConfig;+import com.gitplex.utils.schedule.TaskScheduler;public class GitPlex extends AbstractPlugin implements Serializable {@@ -48,8 +48,6 @@ public class GitPlex extends AbstractPlugin implements Serializable {private final JettyRunner jettyRunner;- private final TaskScheduler taskScheduler;-private final PersistManager persistManager;private final UnitOfWork unitOfWork;@@ -67,11 +65,10 @@ public class GitPlex extends AbstractPlugin implements Serializable {private volatile InitStage initStage;@Inject- public GitPlex(JettyRunner jettyRunner, TaskScheduler taskScheduler, PersistManager persistManager,+ public GitPlex(JettyRunner jettyRunner, PersistManager persistManager,UnitOfWork unitOfWork, ServerConfig serverConfig, DataManager dataManager, ConfigManager configManager,UserManager userManager, ListenerRegistry listenerRegistry) {this.jettyRunner = jettyRunner;- this.taskScheduler = taskScheduler;this.persistManager = persistManager;this.unitOfWork = unitOfWork;this.configManager = configManager;@@ -88,7 +85,7 @@ public class GitPlex extends AbstractPlugin implements Serializable {jettyRunner.start();if (Bootstrap.command == null) {- taskScheduler.start();+ TaskScheduler.getInstance().start();}persistManager.start();@@ -181,7 +178,7 @@ public class GitPlex extends AbstractPlugin implements Serializable {}persistManager.stop();- taskScheduler.stop();+ TaskScheduler.getInstance().stop();jettyRunner.stop();}diff --git a/core/src/main/java/com/gitplex/server/command/BackupDBCommand.java b/core/src/main/java/com/gitplex/server/command/BackupDBCommand.javaindex fa18ad028a..92e1643e98 100644--- a/core/src/main/java/com/gitplex/server/command/BackupDBCommand.java+++ b/core/src/main/java/com/gitplex/server/command/BackupDBCommand.java@@ -12,13 +12,13 @@ import org.slf4j.Logger;import org.slf4j.LoggerFactory;import com.gitplex.launcher.bootstrap.Bootstrap;-import com.gitplex.launcher.bootstrap.BootstrapUtils;import com.gitplex.server.persistence.DefaultPersistManager;import com.gitplex.server.persistence.HibernateProperties;import com.gitplex.server.persistence.IdManager;import com.gitplex.server.persistence.dao.Dao;-import com.gitplex.server.util.FileUtils;import com.gitplex.server.util.validation.EntityValidator;+import com.gitplex.utils.FileUtils;+import com.gitplex.utils.ZipUtils;import com.google.common.base.Throwables;@Singleton@@ -60,10 +60,10 @@ public class BackupDBCommand extends DefaultPersistManager {Metadata metadata = buildMetadata();sessionFactory = metadata.getSessionFactoryBuilder().applyInterceptor(interceptor).build();- File tempDir = BootstrapUtils.createTempDir("backup");+ File tempDir = FileUtils.createTempDir("backup");try {exportData(tempDir);- BootstrapUtils.zip(tempDir, backupFile);+ ZipUtils.zip(tempDir, backupFile);} catch (Exception e) {throw Throwables.propagate(e);} finally {diff --git a/core/src/main/java/com/gitplex/server/command/RestoreDBCommand.java b/core/src/main/java/com/gitplex/server/command/RestoreDBCommand.javaindex 124e3951ec..470faf5250 100644--- a/core/src/main/java/com/gitplex/server/command/RestoreDBCommand.java+++ b/core/src/main/java/com/gitplex/server/command/RestoreDBCommand.java@@ -12,14 +12,14 @@ import org.slf4j.Logger;import org.slf4j.LoggerFactory;import com.gitplex.launcher.bootstrap.Bootstrap;-import com.gitplex.launcher.bootstrap.BootstrapUtils;import com.gitplex.launcher.bootstrap.Command;import com.gitplex.server.persistence.DefaultPersistManager;import com.gitplex.server.persistence.HibernateProperties;import com.gitplex.server.persistence.IdManager;import com.gitplex.server.persistence.dao.Dao;-import com.gitplex.server.util.FileUtils;import com.gitplex.server.util.validation.EntityValidator;+import com.gitplex.utils.FileUtils;+import com.gitplex.utils.ZipUtils;@Singletonpublic class RestoreDBCommand extends DefaultPersistManager {@@ -59,9 +59,9 @@ public class RestoreDBCommand extends DefaultPersistManager {sessionFactory = metadata.getSessionFactoryBuilder().applyInterceptor(interceptor).build();if (backupFile.isFile()) {- File dataDir = BootstrapUtils.createTempDir("restore");+ File dataDir = FileUtils.createTempDir("restore");try {- BootstrapUtils.unzip(backupFile, dataDir);+ ZipUtils.unzip(backupFile, dataDir);doRestore(metadata, dataDir);} finally {FileUtils.deleteDir(dataDir);diff --git a/core/src/main/java/com/gitplex/server/command/UpgradeCommand.java b/core/src/main/java/com/gitplex/server/command/UpgradeCommand.javaindex b95b9a5b86..572bd64459 100644--- a/core/src/main/java/com/gitplex/server/command/UpgradeCommand.java+++ b/core/src/main/java/com/gitplex/server/command/UpgradeCommand.java@@ -25,11 +25,11 @@ import com.gitplex.server.persistence.DefaultPersistManager;import com.gitplex.server.persistence.HibernateProperties;import com.gitplex.server.persistence.IdManager;import com.gitplex.server.persistence.dao.Dao;-import com.gitplex.server.util.FileUtils;-import com.gitplex.server.util.StringUtils;-import com.gitplex.server.util.execution.Commandline;-import com.gitplex.server.util.execution.LineConsumer;+import com.gitplex.utils.FileUtils;import com.gitplex.server.util.validation.EntityValidator;+import com.gitplex.utils.StringUtils;+import com.gitplex.utils.command.Commandline;+import com.gitplex.utils.command.LineConsumer;import com.google.common.base.Charsets;@Singletondiff --git a/core/src/main/java/com/gitplex/server/git/BlameBlock.java b/core/src/main/java/com/gitplex/server/git/BlameBlock.javaindex 2e16a6b633..2cf3d798d3 100644--- a/core/src/main/java/com/gitplex/server/git/BlameBlock.java+++ b/core/src/main/java/com/gitplex/server/git/BlameBlock.java@@ -4,7 +4,7 @@ import java.util.List;import org.apache.commons.lang3.StringUtils;-import com.gitplex.jsymbol.Range;+import com.gitplex.utils.Range;public class BlameBlock {diff --git a/core/src/main/java/com/gitplex/server/git/GitFilter.java b/core/src/main/java/com/gitplex/server/git/GitFilter.javaindex 7b9355fe73..71b1c6fafa 100644--- a/core/src/main/java/com/gitplex/server/git/GitFilter.java+++ b/core/src/main/java/com/gitplex/server/git/GitFilter.java@@ -39,8 +39,8 @@ import com.gitplex.server.model.Project;import com.gitplex.server.model.User;import com.gitplex.server.persistence.annotation.Sessional;import com.gitplex.server.security.SecurityUtils;-import com.gitplex.server.util.concurrent.PrioritizedRunnable;import com.gitplex.server.util.serverconfig.ServerConfig;+import com.gitplex.utils.concurrent.PrioritizedRunnable;@Singletonpublic class GitFilter implements Filter {diff --git a/core/src/main/java/com/gitplex/server/git/GitPostReceiveCallback.java b/core/src/main/java/com/gitplex/server/git/GitPostReceiveCallback.javaindex 4cd4849be2..95889aac8b 100644--- a/core/src/main/java/com/gitplex/server/git/GitPostReceiveCallback.java+++ b/core/src/main/java/com/gitplex/server/git/GitPostReceiveCallback.java@@ -26,7 +26,7 @@ import com.gitplex.server.manager.ProjectManager;import com.gitplex.server.model.User;import com.gitplex.server.model.Project;import com.gitplex.server.persistence.UnitOfWork;-import com.gitplex.server.util.StringUtils;+import com.gitplex.utils.StringUtils;import com.google.common.base.Preconditions;@SuppressWarnings("serial")diff --git a/core/src/main/java/com/gitplex/server/git/GitPreReceiveCallback.java b/core/src/main/java/com/gitplex/server/git/GitPreReceiveCallback.javaindex 4613e67a98..8e004535a9 100644--- a/core/src/main/java/com/gitplex/server/git/GitPreReceiveCallback.java+++ b/core/src/main/java/com/gitplex/server/git/GitPreReceiveCallback.java@@ -29,7 +29,7 @@ import com.gitplex.server.model.support.TagProtection;import com.gitplex.server.persistence.annotation.Sessional;import com.gitplex.server.security.ProjectPrivilege;import com.gitplex.server.security.permission.ProjectPermission;-import com.gitplex.server.util.StringUtils;+import com.gitplex.utils.StringUtils;import com.google.common.base.Preconditions;@SuppressWarnings("serial")diff --git a/core/src/main/java/com/gitplex/server/git/GitUtils.java b/core/src/main/java/com/gitplex/server/git/GitUtils.javaindex 572790b2d8..fce4903125 100644--- a/core/src/main/java/com/gitplex/server/git/GitUtils.java+++ b/core/src/main/java/com/gitplex/server/git/GitUtils.java@@ -45,8 +45,8 @@ import org.eclipse.jgit.util.io.NullOutputStream;import com.gitplex.server.git.command.FetchCommand;import com.gitplex.server.git.exception.ObsoleteCommitException;import com.gitplex.server.git.exception.RefUpdateException;-import com.gitplex.server.util.LockUtils;import com.gitplex.server.util.diff.WhitespaceOption;+import com.gitplex.utils.LockUtils;import com.google.common.base.Joiner;import com.google.common.base.Objects;import com.google.common.base.Preconditions;diff --git a/core/src/main/java/com/gitplex/server/git/GitVersion.java b/core/src/main/java/com/gitplex/server/git/GitVersion.javaindex bf6abb3138..a2b5c79fbd 100644--- a/core/src/main/java/com/gitplex/server/git/GitVersion.java+++ b/core/src/main/java/com/gitplex/server/git/GitVersion.java@@ -7,7 +7,7 @@ import java.util.List;import org.apache.commons.lang3.math.NumberUtils;import com.gitplex.launcher.loader.LoaderUtils;-import com.gitplex.server.util.StringUtils;+import com.gitplex.utils.StringUtils;public class GitVersion implements Comparable<GitVersion> {diff --git a/core/src/main/java/com/gitplex/server/git/command/AdvertiseReceiveRefsCommand.java b/core/src/main/java/com/gitplex/server/git/command/AdvertiseReceiveRefsCommand.javaindex 818398a83a..dc78ac8523 100644--- a/core/src/main/java/com/gitplex/server/git/command/AdvertiseReceiveRefsCommand.java+++ b/core/src/main/java/com/gitplex/server/git/command/AdvertiseReceiveRefsCommand.java@@ -6,8 +6,8 @@ import java.io.OutputStream;import org.slf4j.Logger;import org.slf4j.LoggerFactory;-import com.gitplex.server.util.execution.Commandline;-import com.gitplex.server.util.execution.LineConsumer;+import com.gitplex.utils.command.Commandline;+import com.gitplex.utils.command.LineConsumer;import com.google.common.base.Preconditions;public class AdvertiseReceiveRefsCommand extends GitCommand<Void> {diff --git a/core/src/main/java/com/gitplex/server/git/command/AdvertiseUploadRefsCommand.java b/core/src/main/java/com/gitplex/server/git/command/AdvertiseUploadRefsCommand.javaindex 117aeba3ea..a4a964c7af 100644--- a/core/src/main/java/com/gitplex/server/git/command/AdvertiseUploadRefsCommand.java+++ b/core/src/main/java/com/gitplex/server/git/command/AdvertiseUploadRefsCommand.java@@ -6,8 +6,8 @@ import java.io.OutputStream;import org.slf4j.Logger;import org.slf4j.LoggerFactory;-import com.gitplex.server.util.execution.Commandline;-import com.gitplex.server.util.execution.LineConsumer;+import com.gitplex.utils.command.Commandline;+import com.gitplex.utils.command.LineConsumer;import com.google.common.base.Preconditions;public class AdvertiseUploadRefsCommand extends GitCommand<Void> {diff --git a/core/src/main/java/com/gitplex/server/git/command/BlameCommand.java b/core/src/main/java/com/gitplex/server/git/command/BlameCommand.javaindex ad1175fdde..800f86fc16 100644--- a/core/src/main/java/com/gitplex/server/git/command/BlameCommand.java+++ b/core/src/main/java/com/gitplex/server/git/command/BlameCommand.java@@ -18,13 +18,13 @@ import org.apache.commons.lang3.StringUtils;import org.slf4j.Logger;import org.slf4j.LoggerFactory;-import com.gitplex.jsymbol.Range;import com.gitplex.server.git.BlameBlock;import com.gitplex.server.git.BlameCommit;import com.gitplex.server.git.GitUtils;-import com.gitplex.server.util.execution.Commandline;-import com.gitplex.server.util.execution.ExecuteResult;-import com.gitplex.server.util.execution.LineConsumer;+import com.gitplex.utils.Range;+import com.gitplex.utils.command.Commandline;+import com.gitplex.utils.command.ExecuteResult;+import com.gitplex.utils.command.LineConsumer;import com.google.common.base.Preconditions;public class BlameCommand extends GitCommand<Collection<BlameBlock>> {diff --git a/core/src/main/java/com/gitplex/server/git/command/CloneCommand.java b/core/src/main/java/com/gitplex/server/git/command/CloneCommand.javaindex fe9cd49440..93d3defd1b 100644--- a/core/src/main/java/com/gitplex/server/git/command/CloneCommand.java+++ b/core/src/main/java/com/gitplex/server/git/command/CloneCommand.java@@ -5,8 +5,8 @@ import java.io.File;import org.slf4j.Logger;import org.slf4j.LoggerFactory;-import com.gitplex.server.util.execution.Commandline;-import com.gitplex.server.util.execution.LineConsumer;+import com.gitplex.utils.command.Commandline;+import com.gitplex.utils.command.LineConsumer;import com.google.common.base.Preconditions;public class CloneCommand extends GitCommand<Void> {diff --git a/core/src/main/java/com/gitplex/server/git/command/FetchCommand.java b/core/src/main/java/com/gitplex/server/git/command/FetchCommand.javaindex d4ba3c9796..830cd851e0 100644--- a/core/src/main/java/com/gitplex/server/git/command/FetchCommand.java+++ b/core/src/main/java/com/gitplex/server/git/command/FetchCommand.java@@ -5,8 +5,8 @@ import java.io.File;import org.slf4j.Logger;import org.slf4j.LoggerFactory;-import com.gitplex.server.util.execution.Commandline;-import com.gitplex.server.util.execution.LineConsumer;+import com.gitplex.utils.command.Commandline;+import com.gitplex.utils.command.LineConsumer;import com.google.common.base.Preconditions;public class FetchCommand extends GitCommand<Void> {diff --git a/core/src/main/java/com/gitplex/server/git/command/GitCommand.java b/core/src/main/java/com/gitplex/server/git/command/GitCommand.javaindex d8dab280e0..28f220e629 100644--- a/core/src/main/java/com/gitplex/server/git/command/GitCommand.java+++ b/core/src/main/java/com/gitplex/server/git/command/GitCommand.java@@ -13,9 +13,9 @@ import org.slf4j.LoggerFactory;import com.gitplex.launcher.loader.AppLoader;import com.gitplex.server.git.GitVersion;import com.gitplex.server.git.config.GitConfig;-import com.gitplex.server.util.FileUtils;-import com.gitplex.server.util.execution.Commandline;-import com.gitplex.server.util.execution.LineConsumer;+import com.gitplex.utils.FileUtils;+import com.gitplex.utils.command.Commandline;+import com.gitplex.utils.command.LineConsumer;public abstract class GitCommand<V> implements Callable<V> {diff --git a/core/src/main/java/com/gitplex/server/git/command/LogCommand.java b/core/src/main/java/com/gitplex/server/git/command/LogCommand.javaindex b63fc5e8a0..880ffb058a 100644--- a/core/src/main/java/com/gitplex/server/git/command/LogCommand.java+++ b/core/src/main/java/com/gitplex/server/git/command/LogCommand.java@@ -12,8 +12,8 @@ import org.slf4j.Logger;import org.slf4j.LoggerFactory;import com.gitplex.server.git.GitUtils;-import com.gitplex.server.util.execution.Commandline;-import com.gitplex.server.util.execution.LineConsumer;+import com.gitplex.utils.command.Commandline;+import com.gitplex.utils.command.LineConsumer;public abstract class LogCommand extends GitCommand<Void> {diff --git a/core/src/main/java/com/gitplex/server/git/command/ReceiveCommand.java b/core/src/main/java/com/gitplex/server/git/command/ReceiveCommand.javaindex a6219c4a81..655dca0162 100644--- a/core/src/main/java/com/gitplex/server/git/command/ReceiveCommand.java+++ b/core/src/main/java/com/gitplex/server/git/command/ReceiveCommand.java@@ -8,8 +8,8 @@ import java.util.Map;import org.slf4j.Logger;import org.slf4j.LoggerFactory;-import com.gitplex.server.util.execution.Commandline;-import com.gitplex.server.util.execution.LineConsumer;+import com.gitplex.utils.command.Commandline;+import com.gitplex.utils.command.LineConsumer;import com.google.common.base.Preconditions;public class ReceiveCommand extends GitCommand<Void> {diff --git a/core/src/main/java/com/gitplex/server/git/command/RevListCommand.java b/core/src/main/java/com/gitplex/server/git/command/RevListCommand.javaindex 81337000f4..33c02ddafd 100644--- a/core/src/main/java/com/gitplex/server/git/command/RevListCommand.java+++ b/core/src/main/java/com/gitplex/server/git/command/RevListCommand.java@@ -9,8 +9,8 @@ import org.apache.commons.lang3.time.DateFormatUtils;import org.slf4j.Logger;import org.slf4j.LoggerFactory;-import com.gitplex.server.util.execution.Commandline;-import com.gitplex.server.util.execution.LineConsumer;+import com.gitplex.utils.command.Commandline;+import com.gitplex.utils.command.LineConsumer;public class RevListCommand extends GitCommand<List<String>> {diff --git a/core/src/main/java/com/gitplex/server/git/command/UploadCommand.java b/core/src/main/java/com/gitplex/server/git/command/UploadCommand.javaindex 5d670223f7..ff7123250a 100644--- a/core/src/main/java/com/gitplex/server/git/command/UploadCommand.java+++ b/core/src/main/java/com/gitplex/server/git/command/UploadCommand.java@@ -8,8 +8,8 @@ import java.util.Map;import org.slf4j.Logger;import org.slf4j.LoggerFactory;-import com.gitplex.server.util.execution.Commandline;-import com.gitplex.server.util.execution.LineConsumer;+import com.gitplex.utils.command.Commandline;+import com.gitplex.utils.command.LineConsumer;import com.google.common.base.Preconditions;public class UploadCommand extends GitCommand<Void> {diff --git a/core/src/main/java/com/gitplex/server/git/config/CurlConfig.java b/core/src/main/java/com/gitplex/server/git/config/CurlConfig.javaindex de600f5850..52149244b1 100644--- a/core/src/main/java/com/gitplex/server/git/config/CurlConfig.java+++ b/core/src/main/java/com/gitplex/server/git/config/CurlConfig.java@@ -9,10 +9,10 @@ import org.slf4j.Logger;import org.slf4j.LoggerFactory;import com.gitplex.server.util.editable.annotation.Editable;-import com.gitplex.server.util.execution.Commandline;-import com.gitplex.server.util.execution.LineConsumer;import com.gitplex.server.util.validation.Validatable;import com.gitplex.server.util.validation.annotation.ClassValidating;+import com.gitplex.utils.command.Commandline;+import com.gitplex.utils.command.LineConsumer;/*** Git relevant settings.diff --git a/core/src/main/java/com/gitplex/server/manager/BatchWorkManager.java b/core/src/main/java/com/gitplex/server/manager/BatchWorkManager.javaindex 9f15e9c5fa..6b9416fde9 100644--- a/core/src/main/java/com/gitplex/server/manager/BatchWorkManager.java+++ b/core/src/main/java/com/gitplex/server/manager/BatchWorkManager.java@@ -1,7 +1,7 @@package com.gitplex.server.manager;import com.gitplex.server.util.BatchWorker;-import com.gitplex.server.util.concurrent.Prioritized;+import com.gitplex.utils.concurrent.Prioritized;public interface BatchWorkManager {diff --git a/core/src/main/java/com/gitplex/server/manager/DataManager.java b/core/src/main/java/com/gitplex/server/manager/DataManager.javaindex 56686b283e..a589b0e7d6 100644--- a/core/src/main/java/com/gitplex/server/manager/DataManager.java+++ b/core/src/main/java/com/gitplex/server/manager/DataManager.java@@ -5,7 +5,7 @@ import java.util.List;import javax.annotation.Nullable;import com.gitplex.server.model.support.setting.BackupSetting;-import com.gitplex.server.util.init.ManualConfig;+import com.gitplex.utils.init.ManualConfig;public interface DataManager {diff --git a/core/src/main/java/com/gitplex/server/manager/WorkExecutor.java b/core/src/main/java/com/gitplex/server/manager/WorkExecutor.javaindex 619bf913c5..0a18c8ad56 100644--- a/core/src/main/java/com/gitplex/server/manager/WorkExecutor.java+++ b/core/src/main/java/com/gitplex/server/manager/WorkExecutor.java@@ -7,8 +7,8 @@ import java.util.concurrent.Future;import java.util.concurrent.TimeUnit;import java.util.concurrent.TimeoutException;-import com.gitplex.server.util.concurrent.PrioritizedCallable;-import com.gitplex.server.util.concurrent.PrioritizedRunnable;+import com.gitplex.utils.concurrent.PrioritizedCallable;+import com.gitplex.utils.concurrent.PrioritizedRunnable;/*** This executor is intended to run resource intensive long running tasksdiff --git a/core/src/main/java/com/gitplex/server/manager/impl/AbstractEnvironmentManager.java b/core/src/main/java/com/gitplex/server/manager/impl/AbstractEnvironmentManager.javaindex ec7972ac53..110256a827 100644--- a/core/src/main/java/com/gitplex/server/manager/impl/AbstractEnvironmentManager.java+++ b/core/src/main/java/com/gitplex/server/manager/impl/AbstractEnvironmentManager.java@@ -11,7 +11,7 @@ import javax.annotation.Nullable;import com.gitplex.launcher.loader.Listen;import com.gitplex.server.event.lifecycle.SystemStopping;-import com.gitplex.server.util.FileUtils;+import com.gitplex.utils.FileUtils;import com.google.common.base.Charsets;import jetbrains.exodus.ArrayByteIterable;diff --git a/core/src/main/java/com/gitplex/server/manager/impl/DefaultAttachmentManager.java b/core/src/main/java/com/gitplex/server/manager/impl/DefaultAttachmentManager.javaindex eac6498e9e..a6968f5796 100644--- a/core/src/main/java/com/gitplex/server/manager/impl/DefaultAttachmentManager.java+++ b/core/src/main/java/com/gitplex/server/manager/impl/DefaultAttachmentManager.java@@ -24,10 +24,10 @@ import com.gitplex.server.persistence.annotation.Transactional;import com.gitplex.server.persistence.dao.Dao;import com.gitplex.server.persistence.dao.EntityPersisted;import com.gitplex.server.persistence.dao.EntityRemoved;-import com.gitplex.server.util.FileUtils;import com.gitplex.server.util.facade.ProjectFacade;-import com.gitplex.server.util.schedule.SchedulableTask;-import com.gitplex.server.util.schedule.TaskScheduler;+import com.gitplex.utils.FileUtils;+import com.gitplex.utils.schedule.SchedulableTask;+import com.gitplex.utils.schedule.TaskScheduler;@Singletonpublic class DefaultAttachmentManager implements AttachmentManager, SchedulableTask {@@ -38,17 +38,14 @@ public class DefaultAttachmentManager implements AttachmentManager, SchedulableTprivate final StorageManager storageManager;- private final TaskScheduler taskScheduler;-private final Dao dao;private String taskId;@Inject- public DefaultAttachmentManager(Dao dao, StorageManager storageManager, TaskScheduler taskScheduler) {+ public DefaultAttachmentManager(Dao dao, StorageManager storageManager) {this.dao = dao;this.storageManager = storageManager;- this.taskScheduler = taskScheduler;}@Override@@ -88,12 +85,12 @@ public class DefaultAttachmentManager implements AttachmentManager, SchedulableT@Listenpublic void on(SystemStarted event) {- taskId = taskScheduler.schedule(this);+ taskId = TaskScheduler.getInstance().schedule(this);}@Listenpublic void on(SystemStopping event) {- taskScheduler.unschedule(taskId);+ TaskScheduler.getInstance().unschedule(taskId);}@Sessionaldiff --git a/core/src/main/java/com/gitplex/server/manager/impl/DefaultBatchWorkManager.java b/core/src/main/java/com/gitplex/server/manager/impl/DefaultBatchWorkManager.javaindex da428487f2..f5c1c4def6 100644--- a/core/src/main/java/com/gitplex/server/manager/impl/DefaultBatchWorkManager.java+++ b/core/src/main/java/com/gitplex/server/manager/impl/DefaultBatchWorkManager.java@@ -21,8 +21,8 @@ import com.gitplex.server.event.lifecycle.SystemStopping;import com.gitplex.server.manager.BatchWorkManager;import com.gitplex.server.manager.WorkExecutor;import com.gitplex.server.util.BatchWorker;-import com.gitplex.server.util.concurrent.Prioritized;-import com.gitplex.server.util.concurrent.PrioritizedRunnable;+import com.gitplex.utils.concurrent.Prioritized;+import com.gitplex.utils.concurrent.PrioritizedRunnable;@Singletonpublic class DefaultBatchWorkManager implements BatchWorkManager, Runnable {diff --git a/core/src/main/java/com/gitplex/server/manager/impl/DefaultCodeCommentRelationInfoManager.java b/core/src/main/java/com/gitplex/server/manager/impl/DefaultCodeCommentRelationInfoManager.javaindex c91c7d4fd6..2c2a1ad343 100644--- a/core/src/main/java/com/gitplex/server/manager/impl/DefaultCodeCommentRelationInfoManager.java+++ b/core/src/main/java/com/gitplex/server/manager/impl/DefaultCodeCommentRelationInfoManager.java@@ -41,8 +41,8 @@ import com.gitplex.server.persistence.dao.Dao;import com.gitplex.server.persistence.dao.EntityPersisted;import com.gitplex.server.persistence.dao.EntityRemoved;import com.gitplex.server.util.BatchWorker;-import com.gitplex.server.util.FileUtils;-import com.gitplex.server.util.concurrent.Prioritized;+import com.gitplex.utils.FileUtils;+import com.gitplex.utils.concurrent.Prioritized;import jetbrains.exodus.ArrayByteIterable;import jetbrains.exodus.ByteIterable;diff --git a/core/src/main/java/com/gitplex/server/manager/impl/DefaultCommitInfoManager.java b/core/src/main/java/com/gitplex/server/manager/impl/DefaultCommitInfoManager.javaindex c7feab25a7..5fb57fee32 100644--- a/core/src/main/java/com/gitplex/server/manager/impl/DefaultCommitInfoManager.java+++ b/core/src/main/java/com/gitplex/server/manager/impl/DefaultCommitInfoManager.java@@ -54,12 +54,12 @@ import com.gitplex.server.persistence.annotation.Sessional;import com.gitplex.server.persistence.dao.Dao;import com.gitplex.server.persistence.dao.EntityRemoved;import com.gitplex.server.util.BatchWorker;-import com.gitplex.server.util.FileUtils;-import com.gitplex.server.util.PathUtils;-import com.gitplex.server.util.StringUtils;-import com.gitplex.server.util.concurrent.Prioritized;import com.gitplex.server.util.facade.ProjectFacade;import com.gitplex.server.util.facade.UserFacade;+import com.gitplex.utils.FileUtils;+import com.gitplex.utils.PathUtils;+import com.gitplex.utils.StringUtils;+import com.gitplex.utils.concurrent.Prioritized;import com.google.common.base.Charsets;import com.google.common.base.Splitter;import com.google.common.base.Throwables;diff --git a/core/src/main/java/com/gitplex/server/manager/impl/DefaultDataManager.java b/core/src/main/java/com/gitplex/server/manager/impl/DefaultDataManager.javaindex aee62cef67..a49380506a 100644--- a/core/src/main/java/com/gitplex/server/manager/impl/DefaultDataManager.java+++ b/core/src/main/java/com/gitplex/server/manager/impl/DefaultDataManager.java@@ -16,19 +16,18 @@ import org.joda.time.format.DateTimeFormat;import org.quartz.CronScheduleBuilder;import org.quartz.ScheduleBuilder;+import com.gitplex.launcher.bootstrap.Bootstrap;import com.gitplex.launcher.loader.Listen;import com.gitplex.launcher.loader.ManagedSerializedForm;-import com.gitplex.launcher.bootstrap.Bootstrap;-import com.gitplex.launcher.bootstrap.BootstrapUtils;import com.gitplex.server.GitPlex;import com.gitplex.server.event.lifecycle.SystemStarting;-import com.gitplex.server.manager.UserManager;import com.gitplex.server.manager.ConfigManager;import com.gitplex.server.manager.DataManager;import com.gitplex.server.manager.MailManager;-import com.gitplex.server.model.User;+import com.gitplex.server.manager.UserManager;import com.gitplex.server.model.Config;import com.gitplex.server.model.Config.Key;+import com.gitplex.server.model.User;import com.gitplex.server.model.support.setting.BackupSetting;import com.gitplex.server.model.support.setting.MailSetting;import com.gitplex.server.model.support.setting.SecuritySetting;@@ -37,11 +36,12 @@ import com.gitplex.server.persistence.IdManager;import com.gitplex.server.persistence.PersistManager;import com.gitplex.server.persistence.annotation.Sessional;import com.gitplex.server.persistence.annotation.Transactional;-import com.gitplex.server.util.FileUtils;-import com.gitplex.server.util.init.ManualConfig;-import com.gitplex.server.util.init.Skippable;-import com.gitplex.server.util.schedule.SchedulableTask;-import com.gitplex.server.util.schedule.TaskScheduler;+import com.gitplex.utils.FileUtils;+import com.gitplex.utils.ZipUtils;+import com.gitplex.utils.init.ManualConfig;+import com.gitplex.utils.init.Skippable;+import com.gitplex.utils.schedule.SchedulableTask;+import com.gitplex.utils.schedule.TaskScheduler;import com.google.common.base.Throwables;import com.google.common.collect.Lists;import com.google.common.collect.Sets;@@ -57,8 +57,6 @@ public class DefaultDataManager implements DataManager, Serializable {private final IdManager idManager;- private final TaskScheduler taskScheduler;-private final Validator validator;private final PersistManager persistManager;@@ -71,14 +69,13 @@ public class DefaultDataManager implements DataManager, Serializable {@Injectpublic DefaultDataManager(IdManager idManager, UserManager userManager,- ConfigManager configManager, TaskScheduler taskScheduler,- PersistManager persistManager, MailManager mailManager,- Validator validator, PasswordService passwordService) {+ ConfigManager configManager, PersistManager persistManager,+ MailManager mailManager, Validator validator,+ PasswordService passwordService) {this.userManager = userManager;this.configManager = configManager;this.validator = validator;this.idManager = idManager;- this.taskScheduler = taskScheduler;this.persistManager = persistManager;this.mailManager = mailManager;this.passwordService = passwordService;@@ -192,13 +189,13 @@ public class DefaultDataManager implements DataManager, Serializable {@Overridepublic void scheduleBackup(BackupSetting backupSetting) {if (backupTaskId != null)- taskScheduler.unschedule(backupTaskId);+ TaskScheduler.getInstance().unschedule(backupTaskId);if (backupSetting != null) {- backupTaskId = taskScheduler.schedule(new SchedulableTask() {+ backupTaskId = TaskScheduler.getInstance().schedule(new SchedulableTask() {@Overridepublic void execute() {- File tempDir = BootstrapUtils.createTempDir("backup");+ File tempDir = FileUtils.createTempDir("backup");try {File backupDir = new File(backupSetting.getFolder());if (!backupDir.isAbsolute())@@ -209,7 +206,7 @@ public class DefaultDataManager implements DataManager, Serializable {persistManager.exportData(tempDir);File backupFile = new File(backupDir,DateTimeFormat.forPattern(BACKUP_DATETIME_FORMAT).print(new DateTime()) + ".zip");- BootstrapUtils.zip(tempDir, backupFile);+ ZipUtils.zip(tempDir, backupFile);} catch (Exception e) {notifyBackupError(e);throw Throwables.propagate(e);diff --git a/core/src/main/java/com/gitplex/server/manager/impl/DefaultProjectManager.java b/core/src/main/java/com/gitplex/server/manager/impl/DefaultProjectManager.javaindex 8ceb64bfc5..90cd341c6b 100644--- a/core/src/main/java/com/gitplex/server/manager/impl/DefaultProjectManager.java+++ b/core/src/main/java/com/gitplex/server/manager/impl/DefaultProjectManager.java@@ -52,13 +52,13 @@ import com.gitplex.server.persistence.dao.AbstractEntityManager;import com.gitplex.server.persistence.dao.Dao;import com.gitplex.server.security.ProjectPrivilege;import com.gitplex.server.security.SecurityUtils;-import com.gitplex.server.util.FileUtils;-import com.gitplex.server.util.StringUtils;import com.gitplex.server.util.Verification;import com.gitplex.server.util.facade.GroupAuthorizationFacade;import com.gitplex.server.util.facade.MembershipFacade;import com.gitplex.server.util.facade.ProjectFacade;import com.gitplex.server.util.facade.UserAuthorizationFacade;+import com.gitplex.utils.FileUtils;+import com.gitplex.utils.StringUtils;import com.google.common.base.Preconditions;import com.google.common.base.Throwables;diff --git a/core/src/main/java/com/gitplex/server/manager/impl/DefaultPullRequestManager.java b/core/src/main/java/com/gitplex/server/manager/impl/DefaultPullRequestManager.javaindex ae5dd3392e..75df2ae68c 100644--- a/core/src/main/java/com/gitplex/server/manager/impl/DefaultPullRequestManager.java+++ b/core/src/main/java/com/gitplex/server/manager/impl/DefaultPullRequestManager.java@@ -78,7 +78,7 @@ import com.gitplex.server.security.SecurityUtils;import com.gitplex.server.util.BatchWorker;import com.gitplex.server.util.QualityCheckStatus;import com.gitplex.server.util.Verification;-import com.gitplex.server.util.concurrent.Prioritized;+import com.gitplex.utils.concurrent.Prioritized;import com.google.common.base.Preconditions;import com.google.common.base.Throwables;diff --git a/core/src/main/java/com/gitplex/server/manager/impl/DefaultStorageManager.java b/core/src/main/java/com/gitplex/server/manager/impl/DefaultStorageManager.javaindex 3b82f5207d..171202ccdb 100644--- a/core/src/main/java/com/gitplex/server/manager/impl/DefaultStorageManager.java+++ b/core/src/main/java/com/gitplex/server/manager/impl/DefaultStorageManager.java@@ -18,7 +18,7 @@ import com.gitplex.server.model.User;import com.gitplex.server.persistence.annotation.Transactional;import com.gitplex.server.persistence.dao.Dao;import com.gitplex.server.persistence.dao.EntityRemoved;-import com.gitplex.server.util.FileUtils;+import com.gitplex.utils.FileUtils;@Singletonpublic class DefaultStorageManager implements StorageManager {diff --git a/core/src/main/java/com/gitplex/server/manager/impl/DefaultUserManager.java b/core/src/main/java/com/gitplex/server/manager/impl/DefaultUserManager.javaindex 8d0c37933b..6931b9eca7 100644--- a/core/src/main/java/com/gitplex/server/manager/impl/DefaultUserManager.java+++ b/core/src/main/java/com/gitplex/server/manager/impl/DefaultUserManager.java@@ -22,7 +22,7 @@ import com.gitplex.server.persistence.annotation.Transactional;import com.gitplex.server.persistence.dao.AbstractEntityManager;import com.gitplex.server.persistence.dao.Dao;import com.gitplex.server.persistence.dao.EntityPersisted;-import com.gitplex.server.util.StringUtils;+import com.gitplex.utils.StringUtils;@Singletonpublic class DefaultUserManager extends AbstractEntityManager<User> implements UserManager {diff --git a/core/src/main/java/com/gitplex/server/manager/impl/DefaultVerificationManager.java b/core/src/main/java/com/gitplex/server/manager/impl/DefaultVerificationManager.javaindex 2bb03ce650..84311905ec 100644--- a/core/src/main/java/com/gitplex/server/manager/impl/DefaultVerificationManager.java+++ b/core/src/main/java/com/gitplex/server/manager/impl/DefaultVerificationManager.java@@ -29,7 +29,7 @@ import com.gitplex.server.model.Project;import com.gitplex.server.model.PullRequest;import com.gitplex.server.persistence.annotation.Transactional;import com.gitplex.server.persistence.dao.EntityRemoved;-import com.gitplex.server.util.FileUtils;+import com.gitplex.utils.FileUtils;import com.gitplex.server.util.Verification;import com.gitplex.server.util.Verification.Status;diff --git a/core/src/main/java/com/gitplex/server/manager/impl/DefaultVisitManager.java b/core/src/main/java/com/gitplex/server/manager/impl/DefaultVisitManager.javaindex 0f82da2828..b369f29a00 100644--- a/core/src/main/java/com/gitplex/server/manager/impl/DefaultVisitManager.java+++ b/core/src/main/java/com/gitplex/server/manager/impl/DefaultVisitManager.java@@ -20,7 +20,7 @@ import com.gitplex.server.model.PullRequest;import com.gitplex.server.model.User;import com.gitplex.server.persistence.annotation.Transactional;import com.gitplex.server.persistence.dao.EntityRemoved;-import com.gitplex.server.util.FileUtils;+import com.gitplex.utils.FileUtils;import jetbrains.exodus.ArrayByteIterable;import jetbrains.exodus.env.Environment;diff --git a/core/src/main/java/com/gitplex/server/manager/impl/DefaultWorkExecutor.java b/core/src/main/java/com/gitplex/server/manager/impl/DefaultWorkExecutor.javaindex 88deef6444..92703d8240 100644--- a/core/src/main/java/com/gitplex/server/manager/impl/DefaultWorkExecutor.java+++ b/core/src/main/java/com/gitplex/server/manager/impl/DefaultWorkExecutor.java@@ -12,9 +12,9 @@ import javax.inject.Singleton;import com.gitplex.launcher.loader.Listen;import com.gitplex.server.event.lifecycle.SystemStopping;import com.gitplex.server.manager.WorkExecutor;-import com.gitplex.server.util.concurrent.PrioritizedCallable;-import com.gitplex.server.util.concurrent.PrioritizedExecutor;-import com.gitplex.server.util.concurrent.PrioritizedRunnable;+import com.gitplex.utils.concurrent.PrioritizedCallable;+import com.gitplex.utils.concurrent.PrioritizedExecutor;+import com.gitplex.utils.concurrent.PrioritizedRunnable;@Singletonpublic class DefaultWorkExecutor implements WorkExecutor {diff --git a/core/src/main/java/com/gitplex/server/migration/DatabaseMigrator.java b/core/src/main/java/com/gitplex/server/migration/DatabaseMigrator.javaindex d468d15348..885dafb1cf 100644--- a/core/src/main/java/com/gitplex/server/migration/DatabaseMigrator.java+++ b/core/src/main/java/com/gitplex/server/migration/DatabaseMigrator.java@@ -4,7 +4,6 @@ import java.io.File;import java.io.IOException;import java.util.HashMap;import java.util.HashSet;-import java.util.List;import java.util.Map;import java.util.Set;import java.util.Stack;@@ -13,11 +12,8 @@ import javax.inject.Singleton;import org.dom4j.Element;-import com.gitplex.server.GitPlex;-import com.gitplex.server.manager.CodeCommentManager;-import com.gitplex.server.model.CodeComment;-import com.gitplex.server.util.FileUtils;-import com.gitplex.server.util.StringUtils;+import com.gitplex.utils.FileUtils;+import com.gitplex.utils.StringUtils;import com.google.common.base.Charsets;@Singletondiff --git a/core/src/main/java/com/gitplex/server/migration/JpaConverter.java b/core/src/main/java/com/gitplex/server/migration/JpaConverter.javaindex f237e3228a..9953ead7d0 100644--- a/core/src/main/java/com/gitplex/server/migration/JpaConverter.java+++ b/core/src/main/java/com/gitplex/server/migration/JpaConverter.java@@ -14,13 +14,13 @@ import org.dom4j.Element;import org.hibernate.collection.internal.PersistentBag;import org.hibernate.proxy.HibernateProxy;-import com.google.common.base.Throwables;import com.gitplex.launcher.loader.AppLoader;import com.gitplex.server.model.AbstractEntity;import com.gitplex.server.persistence.dao.Dao;-import com.gitplex.server.util.ClassUtils;-import com.gitplex.server.util.ReflectionUtils;-import com.gitplex.server.util.StringUtils;+import com.gitplex.utils.ClassUtils;+import com.gitplex.utils.ReflectionUtils;+import com.gitplex.utils.StringUtils;+import com.google.common.base.Throwables;import com.thoughtworks.xstream.converters.MarshallingContext;import com.thoughtworks.xstream.converters.UnmarshallingContext;import com.thoughtworks.xstream.converters.reflection.ReflectionConverter;diff --git a/core/src/main/java/com/gitplex/server/migration/MigrationHelper.java b/core/src/main/java/com/gitplex/server/migration/MigrationHelper.javaindex 1ae8f31b44..ca951fe984 100644--- a/core/src/main/java/com/gitplex/server/migration/MigrationHelper.java+++ b/core/src/main/java/com/gitplex/server/migration/MigrationHelper.java@@ -15,7 +15,7 @@ import java.util.regex.Pattern;import org.slf4j.Logger;import org.slf4j.LoggerFactory;-import com.gitplex.server.util.StringUtils;+import com.gitplex.utils.StringUtils;import com.google.common.base.Throwables;public class MigrationHelper {diff --git a/core/src/main/java/com/gitplex/server/migration/VersionedDocument.java b/core/src/main/java/com/gitplex/server/migration/VersionedDocument.javaindex 99c8c1e138..a10b6be087 100644--- a/core/src/main/java/com/gitplex/server/migration/VersionedDocument.java+++ b/core/src/main/java/com/gitplex/server/migration/VersionedDocument.java@@ -37,8 +37,8 @@ import org.dom4j.io.XMLWriter;import org.xml.sax.EntityResolver;import com.gitplex.launcher.loader.AppLoader;-import com.gitplex.server.util.ClassUtils;-import com.gitplex.server.util.FileUtils;+import com.gitplex.utils.FileUtils;+import com.gitplex.utils.ClassUtils;import com.google.common.base.Charsets;import com.google.common.base.Preconditions;import com.google.common.base.Throwables;diff --git a/core/src/main/java/com/gitplex/server/model/Project.java b/core/src/main/java/com/gitplex/server/model/Project.javaindex 9b590db0c1..b8bdb97c76 100644--- a/core/src/main/java/com/gitplex/server/model/Project.java+++ b/core/src/main/java/com/gitplex/server/model/Project.java@@ -58,7 +58,6 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;import org.hibernate.annotations.DynamicUpdate;import org.hibernate.validator.constraints.NotEmpty;-import com.gitplex.jsymbol.Range;import com.gitplex.launcher.loader.ListenerRegistry;import com.gitplex.launcher.loader.LoaderUtils;import com.gitplex.server.GitPlex;@@ -82,14 +81,15 @@ import com.gitplex.server.model.support.CommitMessageTransformSetting;import com.gitplex.server.model.support.TagProtection;import com.gitplex.server.persistence.UnitOfWork;import com.gitplex.server.security.SecurityUtils;-import com.gitplex.server.util.FileUtils;-import com.gitplex.server.util.LockUtils;-import com.gitplex.server.util.PathUtils;-import com.gitplex.server.util.StringUtils;import com.gitplex.server.util.editable.annotation.Editable;import com.gitplex.server.util.editable.annotation.Markdown;import com.gitplex.server.util.facade.ProjectFacade;import com.gitplex.server.util.validation.annotation.ProjectName;+import com.gitplex.utils.FileUtils;+import com.gitplex.utils.LockUtils;+import com.gitplex.utils.PathUtils;+import com.gitplex.utils.Range;+import com.gitplex.utils.StringUtils;import com.google.common.base.Optional;import com.google.common.base.Preconditions;import com.google.common.base.Throwables;diff --git a/core/src/main/java/com/gitplex/server/model/support/BranchProtection.java b/core/src/main/java/com/gitplex/server/model/support/BranchProtection.javaindex c28a2b7eaf..5a78bf9af0 100644--- a/core/src/main/java/com/gitplex/server/model/support/BranchProtection.java+++ b/core/src/main/java/com/gitplex/server/model/support/BranchProtection.java@@ -14,12 +14,12 @@ import org.hibernate.validator.constraints.NotEmpty;import com.gitplex.server.model.Group;import com.gitplex.server.model.User;-import com.gitplex.server.util.PathUtils;import com.gitplex.server.util.editable.annotation.BranchPattern;import com.gitplex.server.util.editable.annotation.Editable;import com.gitplex.server.util.editable.annotation.ReviewRequirementSpec;import com.gitplex.server.util.editable.annotation.VerificationChoice;import com.gitplex.server.util.reviewrequirement.ReviewRequirement;+import com.gitplex.utils.PathUtils;@Editablepublic class BranchProtection implements Serializable {diff --git a/core/src/main/java/com/gitplex/server/persistence/DefaultPersistManager.java b/core/src/main/java/com/gitplex/server/persistence/DefaultPersistManager.javaindex ae2ccb8ad7..f92d4d2843 100644--- a/core/src/main/java/com/gitplex/server/persistence/DefaultPersistManager.java+++ b/core/src/main/java/com/gitplex/server/persistence/DefaultPersistManager.java@@ -49,9 +49,9 @@ import com.gitplex.server.model.AbstractEntity;import com.gitplex.server.model.ModelVersion;import com.gitplex.server.persistence.annotation.Sessional;import com.gitplex.server.persistence.dao.Dao;-import com.gitplex.server.util.BeanUtils;-import com.gitplex.server.util.FileUtils;import com.gitplex.server.util.validation.EntityValidator;+import com.gitplex.utils.BeanUtils;+import com.gitplex.utils.FileUtils;import com.google.common.base.Preconditions;import com.google.common.base.Throwables;import com.google.inject.Inject;diff --git a/core/src/main/java/com/gitplex/server/persistence/DefaultUnitOfWork.java b/core/src/main/java/com/gitplex/server/persistence/DefaultUnitOfWork.javaindex 732a996355..d7b1714fe6 100644--- a/core/src/main/java/com/gitplex/server/persistence/DefaultUnitOfWork.java+++ b/core/src/main/java/com/gitplex/server/persistence/DefaultUnitOfWork.java@@ -8,7 +8,7 @@ import org.hibernate.Session;import org.slf4j.Logger;import org.slf4j.LoggerFactory;-import com.gitplex.server.util.ObjectReference;+import com.gitplex.utils.ObjectReference;import com.google.common.base.Throwables;import com.google.inject.Inject;import com.google.inject.Singleton;diff --git a/core/src/main/java/com/gitplex/server/persistence/dao/AbstractEntityManager.java b/core/src/main/java/com/gitplex/server/persistence/dao/AbstractEntityManager.javaindex a7d9d751d8..8106f33449 100644--- a/core/src/main/java/com/gitplex/server/persistence/dao/AbstractEntityManager.java+++ b/core/src/main/java/com/gitplex/server/persistence/dao/AbstractEntityManager.java@@ -5,7 +5,7 @@ import java.util.List;import org.hibernate.Session;import com.gitplex.server.model.AbstractEntity;-import com.gitplex.server.util.ReflectionUtils;+import com.gitplex.utils.ReflectionUtils;public abstract class AbstractEntityManager<T extends AbstractEntity> implements EntityManager<T> {diff --git a/core/src/main/java/com/gitplex/server/persistence/dao/DefaultDao.java b/core/src/main/java/com/gitplex/server/persistence/dao/DefaultDao.javaindex 1beedb9b76..8a358db3f0 100644--- a/core/src/main/java/com/gitplex/server/persistence/dao/DefaultDao.java+++ b/core/src/main/java/com/gitplex/server/persistence/dao/DefaultDao.java@@ -19,7 +19,7 @@ import com.gitplex.server.model.AbstractEntity;import com.gitplex.server.persistence.UnitOfWork;import com.gitplex.server.persistence.annotation.Sessional;import com.gitplex.server.persistence.annotation.Transactional;-import com.gitplex.server.util.ClassUtils;+import com.gitplex.utils.ClassUtils;@Singleton@SuppressWarnings("unchecked")diff --git a/core/src/main/java/com/gitplex/server/security/BasicAuthenticationFilter.java b/core/src/main/java/com/gitplex/server/security/BasicAuthenticationFilter.javaindex ac6bfc52fe..415f0cb0b5 100644--- a/core/src/main/java/com/gitplex/server/security/BasicAuthenticationFilter.java+++ b/core/src/main/java/com/gitplex/server/security/BasicAuthenticationFilter.java@@ -23,8 +23,8 @@ import org.apache.shiro.web.filter.PathMatchingFilter;import org.apache.shiro.web.util.WebUtils;import com.gitplex.launcher.loader.PluginManager;-import com.gitplex.server.util.ExceptionUtils;-import com.gitplex.server.util.StringUtils;+import com.gitplex.utils.ExceptionUtils;+import com.gitplex.utils.StringUtils;@Singletonpublic class BasicAuthenticationFilter extends PathMatchingFilter {diff --git a/core/src/main/java/com/gitplex/server/security/DefaultPasswordService.java b/core/src/main/java/com/gitplex/server/security/DefaultPasswordService.javaindex c067a5c0fe..afd4b58ca4 100644--- a/core/src/main/java/com/gitplex/server/security/DefaultPasswordService.java+++ b/core/src/main/java/com/gitplex/server/security/DefaultPasswordService.java@@ -4,7 +4,7 @@ import javax.inject.Singleton;import org.apache.shiro.authc.credential.PasswordService;-import com.gitplex.server.util.StringUtils;+import com.gitplex.utils.StringUtils;import com.pmease.security.shiro.bcrypt.BCryptPasswordService;@Singletondiff --git a/core/src/main/java/com/gitplex/server/security/GitPlexAuthorizingRealm.java b/core/src/main/java/com/gitplex/server/security/GitPlexAuthorizingRealm.javaindex b13668e187..29df60d973 100644--- a/core/src/main/java/com/gitplex/server/security/GitPlexAuthorizingRealm.java+++ b/core/src/main/java/com/gitplex/server/security/GitPlexAuthorizingRealm.java@@ -39,12 +39,12 @@ import com.gitplex.server.security.permission.ProjectPermission;import com.gitplex.server.security.permission.PublicPermission;import com.gitplex.server.security.permission.SystemAdministration;import com.gitplex.server.security.permission.UserAdministration;-import com.gitplex.server.util.StringUtils;import com.gitplex.server.util.facade.GroupAuthorizationFacade;import com.gitplex.server.util.facade.GroupFacade;import com.gitplex.server.util.facade.MembershipFacade;import com.gitplex.server.util.facade.UserAuthorizationFacade;import com.gitplex.server.util.facade.UserFacade;+import com.gitplex.utils.StringUtils;import com.google.common.base.Throwables;@Singletondiff --git a/core/src/main/java/com/gitplex/server/security/authenticator/ldap/LdapAuthenticator.java b/core/src/main/java/com/gitplex/server/security/authenticator/ldap/LdapAuthenticator.javaindex 9a0e9ad229..cd03e3e6a2 100644--- a/core/src/main/java/com/gitplex/server/security/authenticator/ldap/LdapAuthenticator.java+++ b/core/src/main/java/com/gitplex/server/security/authenticator/ldap/LdapAuthenticator.java@@ -30,9 +30,9 @@ import org.slf4j.LoggerFactory;import com.gitplex.server.security.authenticator.Authenticated;import com.gitplex.server.security.authenticator.Authenticator;-import com.gitplex.server.util.StringUtils;import com.gitplex.server.util.editable.annotation.Editable;import com.gitplex.server.util.editable.annotation.Password;+import com.gitplex.utils.StringUtils;@Editable(name="Generic LDAP", order=200)public class LdapAuthenticator extends Authenticator {diff --git a/core/src/main/java/com/gitplex/server/util/BatchWorker.java b/core/src/main/java/com/gitplex/server/util/BatchWorker.javaindex 734050109a..b5c94d63db 100644--- a/core/src/main/java/com/gitplex/server/util/BatchWorker.java+++ b/core/src/main/java/com/gitplex/server/util/BatchWorker.java@@ -5,7 +5,7 @@ import java.util.Collection;import org.apache.commons.lang3.builder.EqualsBuilder;import org.apache.commons.lang3.builder.HashCodeBuilder;-import com.gitplex.server.util.concurrent.Prioritized;+import com.gitplex.utils.concurrent.Prioritized;import com.google.common.base.Preconditions;public abstract class BatchWorker {diff --git a/core/src/main/java/com/gitplex/server/util/BeanUtils.java b/core/src/main/java/com/gitplex/server/util/BeanUtils.javadeleted file mode 100644index 3166b58ba9..0000000000--- a/core/src/main/java/com/gitplex/server/util/BeanUtils.java+++ /dev/null@@ -1,219 +0,0 @@-package com.gitplex.server.util;--import java.lang.reflect.Field;-import java.lang.reflect.Method;-import java.lang.reflect.Modifier;-import java.util.ArrayList;-import java.util.HashSet;-import java.util.LinkedHashMap;-import java.util.List;-import java.util.Map;-import java.util.Set;--import com.google.common.base.Preconditions;--public class BeanUtils {-- /**- * Check if specified method is a getter method.- * <p>- * @param method- * method to be checked- * @return- * whether or not the method represents a getter method- */- public static boolean isGetter(Method method) {- if ((method.getName().startsWith("get") || method.getName().startsWith("is")) &&- !Modifier.isStatic(method.getModifiers()) && method.getParameterTypes().length == 0) {- return true;- } else {- return false;- }- }-- /**- * Get declared fields in the whole class hierarchy.- * If there are fields with the same name in super-class and sub-class,- * fields in the sub-class with be returned only.- */- public static List<Field> getFields(Class<?> clazz) {- List<Field> fields = new ArrayList<Field>();- Set<String> existingNames = new HashSet<String>();-- Class<?> current = clazz;- while (current != null) {- for (Field field: current.getDeclaredFields()) {- if (!Modifier.isStatic(field.getModifiers()) && !existingNames.contains(field.getName())) {- fields.add(field);- existingNames.add(field.getName());- }- }- current = current.getSuperclass();- }- return fields;- }-- /**- * Get suffix of accessor method name for specified property. For instance,- * getter suffix for property "value" would be "Value".- * However if the property name starts with underscore, the accessor suffix- * will be the same as property name.- * <p>- * @param propertyName- * name of the property- * @return- * accessor method name suffix of specified property- */- public static String getAccessorSuffix(String propertyName) {- char[] chars = propertyName.toCharArray();- if (chars[0] != '_') {- chars[0] = Character.toUpperCase(chars[0]);- return new String(chars);- } else {- return propertyName;- }- }-- /**- * Get property name given its accessor method name suffix. For instance,- * accessor suffix "Value" will return property name of- * "value". Note that if accessor suffix starts with underscore,- * the property name will be the same as accessor suffix.- *- * @param accessorSuffix name suffix of the getter method of the property- * @return property name corresponding to specified accessor suffix- */- private static String getPropertyName(String accessorSuffix) {- char[] chars = accessorSuffix.toCharArray();- if (chars[0] != '_') {- Preconditions.checkArgument(Character.isUpperCase(chars[0]));- chars[0] = Character.toLowerCase(chars[0]);- return new String(chars);- } else {- return accessorSuffix;- }- }-- /**- * Find all getter methods in specified class and all its super classes.- * Note that if a getter method declared in sub class overrides another- * getter method declared in super class, only the getter method in- * sub class will be returned.- *- * @param clazz- * the class to find getter methods. All its super classes will- * also be consulted- * @return- * list of found getter methods, with getter methods belonging- * to sub classes coming first- */- public static List<Method> findGetters(Class<?> clazz) {- Map<String, Method> getters = new LinkedHashMap<String, Method>();-- Class<?> current = clazz;- while (current != null) {- for (Method method: current.getDeclaredMethods()) {- if (!method.isSynthetic() && isGetter(method) && !getters.containsKey(method.getName())) {- getters.put(method.getName(), method);- }- }- current = current.getSuperclass();- }- return new ArrayList<Method>(getters.values());- }-- /**- * Find getter method by property name in specified class and super classes.- *- * @param clazz- * class to search getter method. All super classes will also be- * searched if not found in current class- * @param propertyName- * name of the property to search getter for- * @return- * getter method- * @throws- * RuntimeException if not found in class hierarchy- */- public static Method getGetter(Class<?> clazz, String propertyName) {- Method getter = findGetter(clazz, propertyName);- if (getter == null) {- throw new GeneralException(String.format("Getter not found (class: %s, property: %s)", clazz.getName(), propertyName));- }- return getter;- }-- /**- * Find getter method by property name in specified class and super classes.- *- * @param clazz- * class to search getter method. All super classes will also be- * searched if not found in current class- * @param propertyName- * name of the property to search getter for- * @return- * getter method, or <tt>null</tt> if not found in class hierarchy- */- public static Method findGetter(Class<?> clazz, String propertyName) {- String methodSuffix = getAccessorSuffix(propertyName);- Method getter = ReflectionUtils.findMethod(clazz, "get" + methodSuffix);- if (getter == null)- getter = ReflectionUtils.findMethod(clazz, "is" + methodSuffix);- return getter;- }-- /**- * Get property name associated with the getter method.- *- * @param getter- * getter method to retrieve property name from- * @return- * property name associated with the getter method- * @throws- * RuntimeException if specified method is not a getter method- */- public static String getPropertyName(Method getter) {- if (getter.getName().startsWith("get")) {- return getPropertyName(getter.getName().substring(3));- } else if (getter.getName().startsWith("is")) {- return getPropertyName(getter.getName().substring(2));- } else {- throw new GeneralException(String.format("Not recognized getter method (class: %s, method: %s)",- getter.getDeclaringClass().getName(), getter.getName()));- }- }-- /**- * Find corresponding setter method by getter in specified class and super classes.- *- * @param getter- * getter method to search setter for- * @return- * setter method, or <tt>null</tt> if not found in class hierarchy- */- public static Method findSetter(Method getter) {- String propertyName = getPropertyName(getter);- String setterName = "set" + getAccessorSuffix(propertyName);- return ReflectionUtils.findMethod(getter.getDeclaringClass(), setterName, getter.getReturnType());- }-- /**- * Find corresponding setter method by getter in specified class and super classes.- * <p>- * @param getter- * getter method to search setter for- * @return- * setter method- * @throws- * RuntimeException if not found in class hierarchy- */- public static Method getSetter(Method getter) {- Method setter = findSetter(getter);- if (setter == null) {- throw new RuntimeException("Can not find corresponding setter for getter '"- + getter.getName() + "'.");- }- return setter;- }--}diff --git a/core/src/main/java/com/gitplex/server/util/ClassUtils.java b/core/src/main/java/com/gitplex/server/util/ClassUtils.javadeleted file mode 100644index 8812960cee..0000000000--- a/core/src/main/java/com/gitplex/server/util/ClassUtils.java+++ /dev/null@@ -1,35 +0,0 @@-package com.gitplex.server.util;--import java.io.InputStream;--import javax.annotation.Nullable;--import javassist.util.proxy.ProxyFactory;--public class ClassUtils extends org.apache.commons.lang3.ClassUtils {-- public static @Nullable InputStream getResourceAsStream(@Nullable Class<?> locator, String path) {- path = StringUtils.stripStart(path, "/");- if (locator == null)- return ClassUtils.class.getClassLoader().getResourceAsStream(path);- else- return locator.getClassLoader().getResourceAsStream(locator.getPackage().getName().replace(".", "/") + "/" + path);- }-- @SuppressWarnings("unchecked")- public static <T> Class<T> unproxy(Class<T> clazz) {- Class<T> superClass = clazz;- while (ProxyFactory.isProxyClass(superClass))- superClass = (Class<T>) clazz.getSuperclass();- return superClass;- }-- public static boolean isSystemType(Class<?> type) {- return type.getName().startsWith("java")- || type.getName().startsWith("javax")- || type.isArray()- || type.isPrimitive()- || type.isEnum();- }--}diff --git a/core/src/main/java/com/gitplex/server/util/DependencyAware.java b/core/src/main/java/com/gitplex/server/util/DependencyAware.javadeleted file mode 100644index f47b548634..0000000000--- a/core/src/main/java/com/gitplex/server/util/DependencyAware.java+++ /dev/null@@ -1,21 +0,0 @@-package com.gitplex.server.util;--import java.util.Set;--public interface DependencyAware<K> {-- /**- * Get key of the dependent object.- * @return- */- K getId();-- /**- * Get set of keys of other dependency objects this dependency object directly depends on.- * @return- * Should not be null. In case of no dependencies, please return an empty collection- * instead of a null value.- */- Set<K> getDependencies();--}diff --git a/core/src/main/java/com/gitplex/server/util/DependencyUtils.java b/core/src/main/java/com/gitplex/server/util/DependencyUtils.javadeleted file mode 100644index 8147835eee..0000000000--- a/core/src/main/java/com/gitplex/server/util/DependencyUtils.java+++ /dev/null@@ -1,98 +0,0 @@-package com.gitplex.server.util;--import java.util.ArrayList;-import java.util.Collection;-import java.util.HashMap;-import java.util.HashSet;-import java.util.LinkedHashMap;-import java.util.LinkedHashSet;-import java.util.List;-import java.util.Map;-import java.util.Set;--import com.google.common.base.Preconditions;--public class DependencyUtils {-- public static <K, T extends DependencyAware<K>> Map<K, Set<K>> getDependentMap(Map<K, T> dependencyMap) {- Map<K, Set<K>> dependentMap = new HashMap<>();- for (T depenencyAware: dependencyMap.values()) {- for (K dependencyId: depenencyAware.getDependencies()) {- Set<K> dependents = dependentMap.get(dependencyId);- if (dependents == null) {- dependents = new HashSet<>();- dependentMap.put(dependencyId, dependents);- }- dependents.add(depenencyAware.getId());- }- }- for (K id: dependencyMap.keySet()) {- if (!dependentMap.containsKey(id)) {- dependentMap.put(id, new HashSet<>());- }- }- return dependentMap;- }-- public static <K, T extends DependencyAware<K>> Set<K> getTransitiveDependents(- Map<K, Set<K>> dependentMap, K dependency) {- Set<K> transitiveDependents = new HashSet<>();-- transitiveDependents.addAll(Preconditions.checkNotNull(dependentMap.get(dependency)));- while (true) {- Set<K> newTransitiveDependents = new HashSet<>(transitiveDependents);- for (K dependent: transitiveDependents) {- newTransitiveDependents.addAll(Preconditions.checkNotNull(dependentMap.get(dependent)));- }- if (!transitiveDependents.equals(newTransitiveDependents)) {- transitiveDependents = newTransitiveDependents;- } else {- break;- }- }- return transitiveDependents;- }-- /**- * Sort dependencies in context. If "dependency1" depends on "dependency2", "dependency2" will- * appear before "dependency1" in the result list.- * @param dependencyMap- * @return- * Sorted dependency list with elements without dependencies appear before elements- * with dependencies.- * @throws- * {@link DependencyException} if circular dependencies are found in the context, or- * if some dependency object refers to non-existent dependencies in the context.- */- public static <K, T extends DependencyAware<K>> List<K> sortDependencies(Map<K, T> dependencyMap) {- List<K> sorted = new ArrayList<>();-- Map<K, Collection<K>> dependencyIds = new LinkedHashMap<K, Collection<K>>();- for (Map.Entry<K, T> entry: dependencyMap.entrySet())- dependencyIds.put(entry.getKey(), new HashSet<K>(entry.getValue().getDependencies()));-- while (!dependencyIds.isEmpty()) {- Set<K> leafs = new LinkedHashSet<>();- for (K id: dependencyIds.keySet()) {- if (dependencyIds.get(id).isEmpty()) {- leafs.add(id);- }- }- if (leafs.isEmpty()) {- Set<K> unprocessed = new HashSet<>();- for (K id: dependencyIds.keySet())- unprocessed.add(id);- throw new RuntimeException("Unable to process dependencies: " + unprocessed- + ". This is either because circular exists in these dependencies, or because "- + "some of these dependencies depends on non-existent dependencies.");- } else {- sorted.addAll(leafs);- }- dependencyIds.keySet().removeAll(leafs);- for (Collection<K> value: dependencyIds.values())- value.removeAll(leafs);- }-- return sorted;- }-}diff --git a/core/src/main/java/com/gitplex/server/util/EasyMap.java b/core/src/main/java/com/gitplex/server/util/EasyMap.javadeleted file mode 100644index 6857e7fc75..0000000000--- a/core/src/main/java/com/gitplex/server/util/EasyMap.java+++ /dev/null@@ -1,44 +0,0 @@-package com.gitplex.server.util;--import java.util.HashMap;-import java.util.LinkedHashMap;-import java.util.Map;--import com.google.common.base.Preconditions;--public class EasyMap {-- @SuppressWarnings("unchecked")- public static <K, V> Map<K, V> fill(Map<K, V> map, Object...objects) {- Preconditions.checkArgument(objects.length % 2 == 0, "Number of arguments should be even.");- for (int i=0; i<objects.length / 2; i++)- map.put((K)objects[i*2], (V)objects[i*2+1]);-- return map;- }-- public static Map<Object, Object> of(Object...objects) {- Map<Object, Object> map = new HashMap<Object, Object>();- fill(map, objects);- return map;- }-- public static Map<String, String> of(String...strings) {- Map<String, String> map = new HashMap<String, String>();- fill(map, (Object[])strings);- return map;- }-- public static Map<Object, Object> ofOrdered(Object...objects) {- Map<Object, Object> map = new LinkedHashMap<Object, Object>();- fill(map, objects);- return map;- }-- public static Map<String, String> ofOrdered(String...strings) {- Map<String, String> map = new LinkedHashMap<String, String>();- fill(map, (Object[])strings);- return map;- }--}diff --git a/core/src/main/java/com/gitplex/server/util/ExceptionUtils.java b/core/src/main/java/com/gitplex/server/util/ExceptionUtils.javadeleted file mode 100644index 87ec445a22..0000000000--- a/core/src/main/java/com/gitplex/server/util/ExceptionUtils.java+++ /dev/null@@ -1,69 +0,0 @@-package com.gitplex.server.util;--import java.io.File;-import java.util.HashSet;-import java.util.Set;--import javax.annotation.Nullable;-import javax.net.ssl.SSLHandshakeException;--import com.gitplex.launcher.bootstrap.BootstrapUtils;--public class ExceptionUtils extends org.apache.commons.lang3.exception.ExceptionUtils {-- @SuppressWarnings("unchecked")- public static <T extends Throwable> T find(Throwable throwable, Class<T> exceptionClass) {- if (exceptionClass.isAssignableFrom(throwable.getClass()))- return (T) throwable;- Set<Throwable> examinedCauses = new HashSet<Throwable>();- examinedCauses.add(throwable);- Throwable cause = throwable.getCause();- while (cause != null) {- if (exceptionClass.isAssignableFrom(cause.getClass()))- return (T) cause;- examinedCauses.add(cause);-- // cause.getCause() may return a previously examined cause- if (examinedCauses.contains(cause.getCause()))- break;- cause = cause.getCause();- }- return null;- }-- public static RuntimeException unchecked(Exception e) {- return BootstrapUtils.unchecked(e);- }-- @Nullable- public static String suggestSolution(Exception e) {- if (find(e, SSLHandshakeException.class) != null && System.getProperty("java.vendor").contains("Oracle")) {- File securityDir;- String javaHome = System.getProperty("java.home");- if (javaHome != null) {- if (new File(javaHome, "lib/security/local_policy.jar").exists()) {- securityDir = new File(javaHome, "lib/security");- } else if (new File(javaHome, "jre/lib/security/local_policy.jar").exists()) {- securityDir = new File(javaHome, "jre/lib/security");- } else {- securityDir = null;- }- } else {- securityDir = null;- }- String downloadUrl;- String javaVersion = System.getProperty("java.version");- if (javaVersion.startsWith("1.8.")) {- downloadUrl = "http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html";- } else {- downloadUrl = null;- }- return String.format("You probably need to download Oracle JCE unlimited strength policy package %s, "- + "and place extracted jar files into %s to overwrite existing files, followed by restarting GitPlex",- downloadUrl!=null?"from \"" + downloadUrl + "\"":"for your JVM version",- securityDir!=null?"directory \""+securityDir.getAbsolutePath()+"\"":"security directory of your JVM");- }- return null;- }--}diff --git a/core/src/main/java/com/gitplex/server/util/FileUtils.java b/core/src/main/java/com/gitplex/server/util/FileUtils.javadeleted file mode 100644index a2e2574f34..0000000000--- a/core/src/main/java/com/gitplex/server/util/FileUtils.java+++ /dev/null@@ -1,336 +0,0 @@-package com.gitplex.server.util;--import java.io.ByteArrayInputStream;-import java.io.File;-import java.io.FileInputStream;-import java.io.IOException;-import java.io.InputStream;-import java.io.InputStreamReader;-import java.io.Serializable;-import java.util.ArrayList;-import java.util.Collection;-import java.util.Iterator;-import java.util.Map.Entry;-import java.util.Properties;-import java.util.concurrent.Callable;-import java.util.concurrent.locks.Lock;-import java.util.zip.ZipEntry;-import java.util.zip.ZipFile;--import javax.annotation.Nullable;--import org.apache.commons.io.IOUtils;-import org.apache.commons.lang3.SerializationUtils;-import org.apache.tools.ant.DirectoryScanner;-import org.slf4j.Logger;-import org.slf4j.LoggerFactory;--import com.gitplex.launcher.bootstrap.Bootstrap;-import com.gitplex.launcher.bootstrap.BootstrapUtils;-import com.google.common.base.Preconditions;-import com.google.common.base.Throwables;--public class FileUtils extends org.apache.commons.io.FileUtils {-- private static final Logger logger = LoggerFactory.getLogger(FileUtils.class);-- /**- * Load properties from specified file. Surrounding white spaces of property values will- * be trimmed off. And a property is considered not defined if the value is trimmed to- * empty.- * @param file- * file to load properties from- * @return- */- public static Properties loadProperties(File file) {- Properties props = new Properties();- InputStream is = null;- try {- is = new FileInputStream(file);- props.load(is);-- for (Iterator<Entry<Object, Object>> it = props.entrySet().iterator(); it.hasNext();) {- Entry<Object, Object> entry = it.next();- String value = (String) entry.getValue();- value = value.trim();- if (value.length() == 0)- it.remove();- else- entry.setValue(value);- }- return props;- } catch (Exception e) {- throw BootstrapUtils.unchecked(e);- } finally {- IOUtils.closeQuietly(is);- }- }-- /**- * Load properties from specified path inside specified directory or jar file.- * @param file- * A jar file or a directory to load property file from.- * @param path- * relative path of the property file inside the jar or to the directory.- * @return- * Content of the property file. Null if not found.- */- @Nullable- public static Properties loadProperties(File file, String path) {- if (file.isFile() && file.getName().endsWith(".jar")) {- ZipFile zip = null;- try {- zip = new ZipFile(file);- ZipEntry entry = zip.getEntry(path);- if (entry != null) {- InputStream is = null;- try {- is = zip.getInputStream(entry);- Properties props = new Properties();- props.load(is);- return props;- } catch (IOException e) {- throw new RuntimeException(e);- } finally {- if (is != null) {- is.close();- }- }- } else {- return null;- }- } catch (Exception e) {- throw BootstrapUtils.unchecked(e);- } finally {- if (zip != null) {- try {- zip.close();- } catch (IOException e) {- }- }- }- } else if (file.isDirectory() && new File(file, path).exists()) {- Properties props = new Properties();- InputStream is = null;- try {- is = new FileInputStream(new File(file, path));- props.load(is);- return props;- } catch (IOException e) {- throw new RuntimeException(e);- } finally {- if (is != null) {- try {- is.close();- } catch (IOException e) {- }- }- }- } else {- return null;- }- }-- public static boolean isWritable(File dir) {- boolean dirExists = dir.exists();- File tempFile = null;- try {- FileUtils.createDir(dir);- tempFile = File.createTempFile("test", "test", dir);- return true;- } catch (Exception e) {- return false;- } finally {- if (tempFile != null)- tempFile.delete();- if (!dirExists)- deleteDir(dir);- }- }-- public static boolean isOutsideOfInstallDir(File dir) {- File normalizedDir;- try {- normalizedDir = dir.getCanonicalFile();- } catch (IOException e) {- throw new RuntimeException(e);- }- return !normalizedDir.toPath().startsWith(Bootstrap.installDir.toPath());- }-- /**- * Get default file encoding of underlying OS- * @return- */- public static String getDefaultEncoding() {- return new InputStreamReader(new ByteArrayInputStream(new byte[0])).getEncoding();- }-- /**- * List all files matching specified patterns under specified base directory.- *- * @param baseDir- * Base directory to scan files in- * @param pathPattern- * Pattern of file path to be used for search- * @return- * Collection of files matching specified path pattern. Directories will not be included even- * if its path matches the pattern- */- public static Collection<File> listFiles(File baseDir, String pathPattern) {- Collection<File> files = new ArrayList<File>();-- DirectoryScanner scanner = new DirectoryScanner();- scanner.setBasedir(baseDir);- scanner.setIncludes(new String[]{pathPattern});- scanner.scan();-- for (String path: scanner.getIncludedFiles())- files.add(new File(baseDir, path));- return files;- }-- /**- * Delete directory if specified directory exists, or do nothing if the- * directory does not exist.- *- * @param dir- * directory to be deleted. Does not have to be exist- */- public static void deleteDir(File dir) {- try {- deleteDirectory(dir);- } catch (IOException e) {- throw new RuntimeException(e);- }- }-- public static void deleteFile(File file) {- /*- * Do not test existence of file here as broken symbol link will report file as non-existent- if (!file.exists())- return;- */-- int maxTries = 10;- int numTries = 1;-- while (true) {- if (file.delete())- break;-- if (file.exists()) {- if (numTries == maxTries) {- throw new GeneralException("Failed to delete file '" +- file.getAbsolutePath() + "'.");- } else {- System.gc();- try {- Thread.sleep(100);- } catch (InterruptedException e2) {- }- numTries++;- }- } else {- break;- }- }- }-- public static void writeFile(File file, String content, String encoding) {- try {- org.apache.commons.io.FileUtils.writeStringToFile(file, content, encoding);- } catch (IOException e) {- throw new RuntimeException(e);- }- }-- public static void writeFile(File file, String content) {- try {- org.apache.commons.io.FileUtils.writeStringToFile(file, content);- } catch (IOException e) {- throw new RuntimeException(e);- }- }-- public static void touchFile(File file) {- try {- org.apache.commons.io.FileUtils.touch(file);- } catch (IOException e) {- throw new RuntimeException(e);- }- }-- /**- * Create the directory if it does not exist, or do nothing if it- * already exists.- *- * @param dir- * directory to be created. Does not have to be non-existent- */- public static void createDir(File dir) {- BootstrapUtils.createDir(dir);- }-- /**- * Delete all files/sub directories under specified directory. If the directory- * does not exist, create the directory.- *- * @param dir- * directory to be cleaned up- */- public static void cleanDir(File dir) {- if (dir.exists()) {- try {- org.apache.commons.io.FileUtils.cleanDirectory(dir);- } catch (IOException e) {- throw new RuntimeException(e);- }- } else {- createDir(dir);- }- }-- @SuppressWarnings("unchecked")- public static <T> T readFile(File file, Callable<T> callable) {- T result = null;- String lockName;- try {- lockName = file.getCanonicalPath();- } catch (IOException e) {- throw new RuntimeException(e);- }- Lock lock = LockUtils.getReadWriteLock(lockName).readLock();- try {- lock.lockInterruptibly();- if (file.exists()) {- byte[] bytes = FileUtils.readFileToByteArray(file);- result = (T) SerializationUtils.deserialize(bytes);- }- } catch (Exception e) {- logger.error("Error reading callable result from file '" + file.getAbsolutePath()- + "', fall back to execute callable.", e);- } finally {- lock.unlock();- }-- if (result == null) {- FileUtils.createDir(file.getParentFile());-- lock = LockUtils.getReadWriteLock(lockName).writeLock();- try {- lock.lockInterruptibly();- Preconditions.checkNotNull(result = callable.call());-- FileUtils.writeByteArrayToFile(file, SerializationUtils.serialize((Serializable) result));- } catch (Exception e) {- Throwables.propagate(e);- } finally {- lock.unlock();- }- }-- return result;- }--}diff --git a/core/src/main/java/com/gitplex/server/util/GeneralException.java b/core/src/main/java/com/gitplex/server/util/GeneralException.javadeleted file mode 100644index 7533df1734..0000000000--- a/core/src/main/java/com/gitplex/server/util/GeneralException.java+++ /dev/null@@ -1,14 +0,0 @@-package com.gitplex.server.util;--@SuppressWarnings("serial")-public class GeneralException extends RuntimeException {-- public GeneralException(String message) {- super(message);- }-- public GeneralException(String message, Throwable cause) {- super(message, cause);- }--}diff --git a/core/src/main/java/com/gitplex/server/util/Highlighter.java b/core/src/main/java/com/gitplex/server/util/Highlighter.javadeleted file mode 100644index 84aae2db8b..0000000000--- a/core/src/main/java/com/gitplex/server/util/Highlighter.java+++ /dev/null@@ -1,60 +0,0 @@-package com.gitplex.server.util;--import java.util.ArrayList;-import java.util.List;-import java.util.regex.Matcher;-import java.util.regex.Pattern;--import com.gitplex.jsymbol.Range;--public class Highlighter {-- public static String highlightRanges(String text, List<Range> ranges,- Transformer<String> matchedTransformer, Transformer<String> unmatchedTransformer) {- StringBuffer buffer = new StringBuffer();- int start = 0;- for (Range range: RangeUtils.merge(ranges)) {- buffer.append(unmatchedTransformer.transform(text.substring(start, range.getFrom())));- buffer.append(matchedTransformer.transform(text.substring(range.getFrom(), range.getTo())));- start = range.getTo();- }- buffer.append(unmatchedTransformer.transform(text.substring(start, text.length())));- return buffer.toString();- }-- public static String highlightPatterns(String text, List<Pattern> patterns,- Transformer<String> matchedTransformer, Transformer<String> unmatchedTransformer) {- List<Range> ranges = new ArrayList<>();- for (Pattern pattern: patterns) {- Matcher matcher = pattern.matcher(text);- while (matcher.find())- ranges.add(new Range(matcher.start(), matcher.end()));- }- return highlightRanges(text, ranges, matchedTransformer, unmatchedTransformer);- }-- public static String highlightLiterals(String text, List<String> literals, boolean caseSensitive,- Transformer<String> matchedTransformer, Transformer<String> unmatchedTransformer) {- String normalizedText;- if (!caseSensitive)- normalizedText = text.toLowerCase();- else- normalizedText = text;- List<Range> ranges = new ArrayList<>();- for (String literal: literals) {- String normalizedLiteral;- if (!caseSensitive)- normalizedLiteral = literal.toLowerCase();- else- normalizedLiteral = literal;- int index = normalizedText.indexOf(normalizedLiteral);- while (index != -1) {- Range range = new Range(index, index+normalizedLiteral.length());- ranges.add(range);- index = normalizedText.indexOf(normalizedLiteral, range.getTo());- }- }- return highlightRanges(text, ranges, matchedTransformer, unmatchedTransformer);- }--}diff --git a/core/src/main/java/com/gitplex/server/util/LockUtils.java b/core/src/main/java/com/gitplex/server/util/LockUtils.javadeleted file mode 100644index a1dcd8d6dc..0000000000--- a/core/src/main/java/com/gitplex/server/util/LockUtils.java+++ /dev/null@@ -1,127 +0,0 @@-package com.gitplex.server.util;--import java.util.Map;-import java.util.concurrent.Callable;-import java.util.concurrent.locks.Lock;-import java.util.concurrent.locks.ReadWriteLock;-import java.util.concurrent.locks.ReentrantLock;-import java.util.concurrent.locks.ReentrantReadWriteLock;--import org.apache.commons.collections4.map.AbstractReferenceMap.ReferenceStrength;-import org.apache.commons.collections4.map.ReferenceMap;--public class LockUtils {-- private final static Map<String, Lock> locks =- new ReferenceMap<String, Lock>(ReferenceStrength.HARD, ReferenceStrength.WEAK);-- private final static Map<String, ReadWriteLock> rwLocks =- new ReferenceMap<String, ReadWriteLock>(ReferenceStrength.HARD, ReferenceStrength.WEAK);-- /**- * Get named lock.- *- * @param name- * name of the lock- * @return- * lock associated with specified name- */- public static Lock getLock(String name) {- Lock lock;- synchronized (locks) {- lock = locks.get(name);- if (lock == null) {- lock = new ReentrantLock();- locks.put(name, lock);- }- }- return lock;- }-- /**- * Get named read write lock.- *- * @param name- * name of the read write lock- * @return- * read write lock associated with specified name- */- public static ReadWriteLock getReadWriteLock(String name) {- ReadWriteLock lock;- synchronized (rwLocks) {- lock = rwLocks.get(name);- if (lock == null) {- lock = new ReentrantReadWriteLock();- rwLocks.put(name, lock);- }- }- return lock;- }-- /**- * Execute specified callable in lock of specified name.- *- * @param name- * name of the lock to be acquired- * @param callable- * callable to be execute within the named lock- * @return- * return value of the callable- */- public static <T> T call(String name, Callable<T> callable) {- Lock lock = getLock(name);- try {- lock.lockInterruptibly();- return callable.call();- } catch (Exception e) {- throw new RuntimeException(e);- } finally {- lock.unlock();- }- }-- /**- * Execute specified callable in read lock of specified name.- *- * @param name- * name of the lock to be acquired- * @param callable- * callable to be execute within the named read lock- * @return- * return value of the callable- */- public static <T> T read(String name, Callable<T> callable) {- Lock lock = getReadWriteLock(name).readLock();- try {- lock.lockInterruptibly();- return callable.call();- } catch (Exception e) {- throw new RuntimeException(e);- } finally {- lock.unlock();- }- }-- /**- * Execute specified callable in write lock of specified name.- *- * @param name- * name of the lock to be acquired- * @param callable- * callable to be execute within the named write lock- * @return- * return value of the callable- */- public static <T> T write(String name, Callable<T> callable) {- Lock lock = getReadWriteLock(name).writeLock();- try {- lock.lockInterruptibly();- return callable.call();- } catch (Exception e) {- throw new RuntimeException(e);- } finally {- lock.unlock();- }- }--}\ No newline at end of filediff --git a/core/src/main/java/com/gitplex/server/util/ObjectReference.java b/core/src/main/java/com/gitplex/server/util/ObjectReference.javadeleted file mode 100644index f8ca8ee7db..0000000000--- a/core/src/main/java/com/gitplex/server/util/ObjectReference.java+++ /dev/null@@ -1,37 +0,0 @@-package com.gitplex.server.util;--import java.io.Closeable;--import com.google.common.base.Preconditions;--public abstract class ObjectReference<T> implements Closeable {-- private int count;-- private T object;-- protected abstract T openObject();-- protected abstract void closeObject(T object);-- public synchronized T open() {- if (count == 0)- object = openObject();- count++;- return object;- }-- @Override- public synchronized void close() {- if (count == 1) {- closeObject(object);- object = null;- }- count--;- }-- public synchronized T get() {- return Preconditions.checkNotNull(object);- }--}diff --git a/core/src/main/java/com/gitplex/server/util/Pair.java b/core/src/main/java/com/gitplex/server/util/Pair.javadeleted file mode 100644index cf51af6e71..0000000000--- a/core/src/main/java/com/gitplex/server/util/Pair.java+++ /dev/null@@ -1,70 +0,0 @@-package com.gitplex.server.util;--import java.util.ArrayList;-import java.util.List;-import java.util.Map;--import org.apache.commons.lang3.builder.EqualsBuilder;-import org.apache.commons.lang3.builder.HashCodeBuilder;--public class Pair<FirstType, SecondType> {-- private FirstType first;-- private SecondType second;-- public Pair() {-- }-- public Pair(FirstType first, SecondType second) {- this.first = first;- this.second = second;- }-- public FirstType getFirst() {- return first;- }-- public void setFirst(FirstType first) {- this.first = first;- }-- public SecondType getSecond() {- return second;- }-- public void setSecond(SecondType second) {- this.second = second;- }-- public static <FirstType, SecondType> List<Pair<FirstType, SecondType>> getPairs(Map<FirstType, SecondType> map) {- List<Pair<FirstType, SecondType>> pairs = new ArrayList<Pair<FirstType, SecondType>>();- for (Map.Entry<FirstType, SecondType> entry: map.entrySet()) {- pairs.add(new Pair<FirstType, SecondType>(entry.getKey(), entry.getValue()));- }- return pairs;- }-- @SuppressWarnings("rawtypes")- @Override- public boolean equals(Object other) {- if (!(other instanceof Pair))- return false;- if (this == other)- return true;- Pair otherPair = (Pair) other;- return new EqualsBuilder()- .append(first, otherPair.getFirst())- .append(second, otherPair.getSecond())- .isEquals();- }-- @Override- public int hashCode() {- return new HashCodeBuilder(17, 37)- .append(first)- .append(second)- .toHashCode();- }-}diff --git a/core/src/main/java/com/gitplex/server/util/PathComparator.java b/core/src/main/java/com/gitplex/server/util/PathComparator.javadeleted file mode 100644index 397dc00eaf..0000000000--- a/core/src/main/java/com/gitplex/server/util/PathComparator.java+++ /dev/null@@ -1,17 +0,0 @@-package com.gitplex.server.util;--import java.util.Comparator;-import java.util.List;--import com.google.common.base.Splitter;--public class PathComparator implements Comparator<String> {-- @Override- public int compare(String path1, String path2) {- List<String> segments1 = Splitter.on('/').splitToList(path1);- List<String> segments2 = Splitter.on('/').splitToList(path2);- return PathUtils.compare(segments1, segments2);- }--}diff --git a/core/src/main/java/com/gitplex/server/util/PathUtils.java b/core/src/main/java/com/gitplex/server/util/PathUtils.javadeleted file mode 100644index c6878c6312..0000000000--- a/core/src/main/java/com/gitplex/server/util/PathUtils.java+++ /dev/null@@ -1,214 +0,0 @@-package com.gitplex.server.util;--import java.util.Collection;-import java.util.List;--import javax.annotation.Nullable;--import com.gitplex.jsymbol.Range;-import com.gitplex.launcher.loader.LoaderUtils;-import com.gitplex.server.util.stringmatch.ChildAwareMatcher;-import com.gitplex.server.util.stringmatch.Matcher;-import com.google.common.base.Splitter;--public class PathUtils {-- private static final Matcher CHILDAWARE_MATCHER = new ChildAwareMatcher();-- /**- * Match specified path against a collection of base paths to find out the longest match.- * For instance, if collection contains /path1/path2/path3 and /path1/path2, the eager- * match for /path1/path2/path3/path4 should be /path1/path2/path3.- *- * @param basePaths- * Collection of base paths to match against specified path.- * @param path- * The path used for eager matching.- * @return- * The longest matching base path. Null if no any matched base paths.- */- public static String matchLongest(Collection<String> basePaths, String path) {- int unmatchedSegments = Integer.MAX_VALUE;- String matchedBasePath = null;-- for (String each: basePaths) {- String relative = LoaderUtils.parseRelative(path, each);- if (relative != null) {- int currentSegments = LoaderUtils.splitAndTrim(relative, "/").size();- if (unmatchedSegments > currentSegments) {- unmatchedSegments = currentSegments;- matchedBasePath = each;- }- }- }-- return matchedBasePath;- }-- public @Nullable static Range matchSegments(String path, String match, boolean ignoreExt) {- int beginIndex = path.indexOf(match);- while (beginIndex != -1) {- int endIndex = beginIndex+match.length();- char leftCh = beginIndex==0?'/':path.charAt(beginIndex-1);- char rightCh = endIndex==path.length()?'/':path.charAt(endIndex);- if (leftCh == '/' && (rightCh=='/' || ignoreExt&&rightCh=='.'))- return new Range(beginIndex, endIndex);- beginIndex = path.indexOf(match, beginIndex+1);- }- return null;- }-- public static boolean matchChildAware(String pattern, String value) {- return CHILDAWARE_MATCHER.matches(pattern, value);- }-- /**- * Normalize a path separated with forward slash, adapted from FilenameUtils.normalize(filename)- * @param path- * @return- */- public static String normalize(String path) {- if (path == null) {- return null;- }- int size = path.length();- if (size == 0) {- return path;- }-- int prefix = path.startsWith("/")?1:0;-- char[] array = new char[size + 2]; // +1 for possible extra slash, +2 for arraycopy- path.getChars(0, path.length(), array, 0);-- // add extra separator on the end to simplify code below- boolean lastIsDirectory = true;- if (array[size - 1] != '/') {- array[size++] = '/';- lastIsDirectory = false;- }-- // adjoining slashes- for (int i = prefix + 1; i < size; i++) {- if (array[i] == '/' && array[i - 1] == '/') {- System.arraycopy(array, i, array, i - 1, size - i);- size--;- i--;- }- }-- // dot slash- for (int i = prefix + 1; i < size; i++) {- if (array[i] == '/' && array[i - 1] == '.' &&- (i == prefix + 1 || array[i - 2] == '/')) {- if (i == size - 1) {- lastIsDirectory = true;- }- System.arraycopy(array, i + 1, array, i - 1, size - i);- size -=2;- i--;- }- }-- // double dot slash- outer:- for (int i = prefix + 2; i < size; i++) {- if (array[i] == '/' && array[i - 1] == '.' && array[i - 2] == '.' &&- (i == prefix + 2 || array[i - 3] == '/')) {- if (i == prefix + 2) {- return null;- }- if (i == size - 1) {- lastIsDirectory = true;- }- int j;- for (j = i - 4 ; j >= prefix; j--) {- if (array[j] == '/') {- // remove b/../ from a/b/../c- System.arraycopy(array, i + 1, array, j + 1, size - i);- size -= i - j;- i = j + 1;- continue outer;- }- }- // remove a/../ from a/../c- System.arraycopy(array, i + 1, array, prefix, size - i);- size -= i + 1 - prefix;- i = prefix + 1;- }- }-- if (size <= 0) { // should never be less than 0- return "";- }- if (size <= prefix) { // should never be less than prefix- return new String(array, 0, size);- }- if (lastIsDirectory) {- return new String(array, 0, size); // keep trailing separator- }- return new String(array, 0, size - 1); // lose trailing separator- }-- public static String resolve(String base, String path) {- if (path.startsWith("/")) {- return path;- } else if (base.endsWith("/")) {- return base + path;- } else {- return base + "/" + path;- }- }-- public static String resolveSibling(String base, String path) {- if (base.indexOf('/') == -1 || path.startsWith("/")) {- return path;- } else if (base.endsWith("/")) {- return base + path;- } else {- return StringUtils.substringBeforeLast(base, "/") + "/" + path;- }- }-- public static String relativize(String base, String path) {- List<String> baseSegments = Splitter.on("/").splitToList(base);- List<String> pathSegments = Splitter.on("/").splitToList(path);- int index = baseSegments.size();- for (int i=0; i<baseSegments.size(); i++) {- if (i >= pathSegments.size() || !baseSegments.get(i).equals(pathSegments.get(i))) {- index = i;- break;- }- }- StringBuilder builder = new StringBuilder();- for (int i=index; i<baseSegments.size(); i++) {- if (baseSegments.get(i).length() != 0) {- if (builder.length() != 0)- builder.append("/");- builder.append("..");- }- }- for (int i=index; i<pathSegments.size(); i++) {- if (pathSegments.get(i).length() != 0) {- if (builder.length() != 0)- builder.append("/");- builder.append(pathSegments.get(i));- }- }- return builder.toString();- }-- public static int compare(List<String> pathSegments1, List<String> pathSegments2) {- for (int i=0; i<pathSegments1.size(); i++) {- if (i<pathSegments2.size()) {- int compareResult = pathSegments1.get(i).compareTo(pathSegments2.get(i));- if (compareResult != 0)- return compareResult;- } else {- return 1;- }- }- return pathSegments2.size()==pathSegments1.size()? 0: -1;- }--}diff --git a/core/src/main/java/com/gitplex/server/util/Provider.java b/core/src/main/java/com/gitplex/server/util/Provider.javadeleted file mode 100644index 424fe4e107..0000000000--- a/core/src/main/java/com/gitplex/server/util/Provider.java+++ /dev/null@@ -1,7 +0,0 @@-package com.gitplex.server.util;--import java.io.Serializable;--public interface Provider<T> extends Serializable {- T get();-}\ No newline at end of filediff --git a/core/src/main/java/com/gitplex/server/util/RangeUtils.java b/core/src/main/java/com/gitplex/server/util/RangeUtils.javadeleted file mode 100644index 540b91eb91..0000000000--- a/core/src/main/java/com/gitplex/server/util/RangeUtils.java+++ /dev/null@@ -1,31 +0,0 @@-package com.gitplex.server.util;--import java.util.ArrayList;-import java.util.Collection;-import java.util.List;--import com.gitplex.jsymbol.Range;--public class RangeUtils {-- public static List<Range> merge(Collection<Range> ranges) {- List<Range> sorted = new ArrayList<>(ranges);- sorted.sort((o1, o2) -> o1.getFrom() - o2.getFrom());- List<Range> merged = new ArrayList<>();- Range current = null;- for (Range range: sorted) {- if (current == null) {- current = range;- } else if (range.getFrom() <= current.getTo()) {- current = new Range(current.getFrom(), Math.max(current.getTo(), range.getTo()));- } else {- merged.add(current);- current = range;- }- }- if (current != null)- merged.add(current);- return merged;- }--}diff --git a/core/src/main/java/com/gitplex/server/util/ReflectionUtils.java b/core/src/main/java/com/gitplex/server/util/ReflectionUtils.javadeleted file mode 100644index 8d2bbec613..0000000000--- a/core/src/main/java/com/gitplex/server/util/ReflectionUtils.java+++ /dev/null@@ -1,436 +0,0 @@-package com.gitplex.server.util;--import java.lang.reflect.Array;-import java.lang.reflect.Constructor;-import java.lang.reflect.Field;-import java.lang.reflect.GenericArrayType;-import java.lang.reflect.Method;-import java.lang.reflect.Modifier;-import java.lang.reflect.ParameterizedType;-import java.lang.reflect.Type;-import java.lang.reflect.TypeVariable;-import java.util.ArrayList;-import java.util.Collection;-import java.util.HashMap;-import java.util.LinkedHashMap;-import java.util.List;-import java.util.Map;--import com.google.common.base.Preconditions;--public class ReflectionUtils {-- /**- * Get the actual type arguments a child class has used to extend a generic- * base class.<p>- * (Taken from http://www.artima.com/weblogs/viewpost.jsp?thread=208860.- * Thanks mathieu.grenonville for finding this solution!)- * <p>- * @param baseClass- * the base class- * @param childClass- * the child class- * @return a list of the raw classes for the actual type arguments.- */- public static <T> List<Class<?>> getTypeArguments(Class<T> baseClass, Class<? extends T> childClass) {- Preconditions.checkArgument(!baseClass.isInterface(), "baseClass should not be an interface");- Preconditions.checkArgument(baseClass.isAssignableFrom(childClass), "childClass should be a sub class of baseClass");-- Map<Type, Type> resolvedTypes = new HashMap<Type, Type>();- Type type = childClass;- // start walking up the inheritance hierarchy until we hit baseClass- while (!getClass(type).equals(baseClass)) {- if (type instanceof Class) {- // there is no useful information for us in raw types, so just- // keep going.- type = ((Class<?>) type).getGenericSuperclass();- } else {- ParameterizedType parameterizedType = (ParameterizedType) type;- Class<?> rawType = (Class<?>) parameterizedType.getRawType();-- Type[] actualTypeArguments = parameterizedType- .getActualTypeArguments();- TypeVariable<?>[] typeParameters = rawType.getTypeParameters();- for (int i = 0; i < actualTypeArguments.length; i++) {- resolvedTypes- .put(typeParameters[i], actualTypeArguments[i]);- }-- if (!rawType.equals(baseClass)) {- type = rawType.getGenericSuperclass();- }- }- }-- // finally, for each actual type argument provided to baseClass,- // determine (if possible)- // the raw class for that type argument.- Type[] actualTypeArguments;- if (type instanceof Class) {- actualTypeArguments = ((Class<?>) type).getTypeParameters();- } else {- actualTypeArguments = ((ParameterizedType) type)- .getActualTypeArguments();- }- List<Class<?>> typeArgumentsAsClasses = new ArrayList<Class<?>>();- // resolve types by chasing down type variables.- for (Type baseType : actualTypeArguments) {- while (resolvedTypes.containsKey(baseType)) {- baseType = resolvedTypes.get(baseType);- }- typeArgumentsAsClasses.add(getClass(baseType));- }- return typeArgumentsAsClasses;- }-- /**- * Get the underlying class for a type.- * <p>- * @param type- * the type to get class from- * @return- * the underlying class, or <tt>null</tt> if the type is a variable type- */- private static Class<?> getClass(Type type) {- if (type instanceof Class) {- return (Class<?>) type;- } else if (type instanceof ParameterizedType) {- return getClass(((ParameterizedType) type).getRawType());- } else if (type instanceof GenericArrayType) {- Type componentType = ((GenericArrayType) type)- .getGenericComponentType();- Class<?> componentClass = getClass(componentType);- if (componentClass != null) {- return Array.newInstance(componentClass, 0).getClass();- } else {- return null;- }- } else {- return null;- }- }-- /**- * Find method of specified name and parameter types in specified class and its super classes- * in turn.- * <p>- * @param clazz- * class to find method in. Super classes will be searched for the method if not- * found in current class- * @param methodName- * method name to find- * @param paramTypes- * parameter types to find- * @return- * method matching specified name and parameter types. Or <tt>null</tt> if not found- */- public static Method findMethod(Class<?> clazz, String methodName, Class<?>... paramTypes) {- Class<?> current = clazz;- while (true) {- try {- return current.getDeclaredMethod(methodName, paramTypes);- } catch (SecurityException e) {- throw new RuntimeException(e);- } catch (NoSuchMethodException e) {- // ignore- }- if (current == Object.class)- break;- current = current.getSuperclass();- }-- return null;- }-- /**- * Find non-static field in specified class hierarchy with specified name.- * <p>- * @param clazz- * class to search non-static field in. All the super classes will also- * be consulted if not found in sub class- * @param fieldName- * name of the field to search for- * @return- * found non-static field, or <tt>null</tt> if not found- */- public static Field findField(Class<?> clazz, String fieldName) {- Field field = null;- Class<?> current = clazz;- while (current != null) {- for (Field declaredField: current.getDeclaredFields()) {- if (!Modifier.isStatic(declaredField.getModifiers())- && fieldName.equals(declaredField.getName())) {- field = declaredField;- break;- }- }- current = current.getSuperclass();- }- return field;- }-- /**- * Find all non-static fields in specified class and all its super classes.- * If a non-static field declared in sub class has the same name as another- * non-static field declared in super class, only the non-static field in- * sub class will be returned.- * <p>- * @param clazz- * the class to find non-static fields. All its super classes will- * also be consulted- * @return- * list of found non-static fields, with non-static fields belonging- * to sub classes coming first- */- public static List<Field> findFields(Class<?> clazz) {- Map<String, Field> fields = new LinkedHashMap<String, Field>();-- Class<?> current = clazz;- while (current != null) {- for (Field field: current.getDeclaredFields()) {- if (!Modifier.isStatic(field.getModifiers())- && !field.isSynthetic()- && !fields.containsKey(field.getName())) {- fields.put(field.getName(), field);- }- }- current = current.getSuperclass();- }- return new ArrayList<Field>(fields.values());- }-- /**- * Get declared method in specified class and super classes.- * <p>- * @param clazz- * clazz to search the method. If not found, its super classes- * will also be searched- * @param methodName- * name of the method to find- * @param paramTypes- * parameter types of the method to find- * @return- * method matching specified name and parameter types- * @throws- * RuntimeException if the method can not be found- */- public static Method getMethod(Class<?> clazz, String methodName, Class<?>...paramTypes) {- Method method = findMethod(clazz, methodName, paramTypes);- if (method == null) {- throw new RuntimeException("Can not find method named '" +- methodName + "' in class hierarchy of '" + clazz.getName() +- "'.");- } else {- return method;- }- }-- /**- * Invoke specified static method with specified parameters. Parameter types- * of invoked static method should be compatible with types of specified- * parameters. The static method will be searched in specified class and all- * its super classes in turn.- * <p>- * @param clazz- * class to invoke static method in. Static method will be searched- * in super classes if not found in specified class- * @param methodName- * name of the static method- * @param params- * parameters to be passed to the static method- * @return- * return value of invoked static method- * @throws- * RuntimeException if no static method matching specified name and parameters- */- public static Object invokeStaticMethod(Class<?> clazz, String methodName, Object...params) {- Class<?>[] paramTypes = new Class<?>[params.length];-- for (int i = 0; i < params.length; i++)- paramTypes[i] = params[i].getClass();-- Method method = getMethod(clazz, methodName, paramTypes);- if (!Modifier.isStatic(method.getModifiers())) {- throw new RuntimeException("Method '" + methodName + "' should be a static method.");- }- method.setAccessible(true);- try {- return method.invoke(null, params);- } catch (Exception e) {- throw ExceptionUtils.unchecked(e);- }- }-- /**- * Invoke specified method with specified parameters. Parameter types- * of invoked method should be compatible with types of specified- * parameters. The method will be searched in specified class and all- * its super classes in turn.- * <p>- * @param clazz- * class to invoke method in. Method will be searched- * in super classes if not found in specified class- * @param methodName- * name of the method- * @param params- * parameters to be passed to the method- * @return- * return value of invoked method- * @throws- * RuntimeException if no method matching specified name and parameters- */- public static Object invokeMethod(Object object, String methodName, Object...params) {- Class<?>[] paramTypes = new Class<?>[params.length];-- for (int i = 0; i < params.length; i++)- paramTypes[i] = params[i].getClass();-- Method method = getMethod(object.getClass(), methodName, paramTypes);- if (Modifier.isStatic(method.getModifiers())) {- throw new RuntimeException("Method '" + methodName + "' should not be a static method.");- }- method.setAccessible(true);- try {- return method.invoke(object, params);- } catch (Exception e) {- throw ExceptionUtils.unchecked(e);- }- }-- /**- * Instantiate specified class with specified parameters. The constructor- * used for instantiation should match types of specified parameters.- * <p>- * @param clazz- * class to be instantiated- * @param params- * parameters passed to constructor- * @return- * instance of the class- * @throws- * RuntimeException if constructor with parameter types- * matching specified parameters can not be found- */- public static <T> T instantiateClass(Class<T> clazz, Object... params) {- Class<?>[] paramTypes = new Class<?>[params.length];-- for (int i = 0; i < params.length; i++)- paramTypes[i] = params[i].getClass();-- Constructor<T> constructor = findConstructor(clazz, paramTypes);-- if (constructor == null) {- StringBuilder sb = new StringBuilder();-- if (paramTypes.length > 0) {- for (Class<?> type : paramTypes)- sb.append(type).append(", ");- }-- throw new RuntimeException("Unable to find constructor for " + clazz +- " with param type: " + sb.toString());- }-- try {- return constructor.newInstance(params);- } catch (Exception e) {- throw ExceptionUtils.unchecked(e);- }- }-- /**- * Find constructor of specified parameter types in specified class.- * <p>- * @param clazz- * class to find constructor in- * @param expectedParamTypes- * expected parameter types of the constructor- * @return- * matched constructor, or <tt>null</tt> if not found- */- @SuppressWarnings("unchecked")- public static <T> Constructor<T> findConstructor(Class<T> clazz, Class<?>... expectedParamTypes) {- if (expectedParamTypes.length == 0) {- try {- return clazz.getConstructor();- } catch (Exception e) {- throw ExceptionUtils.unchecked(e);- }- }-- Constructor<?>[] constructors = clazz.getConstructors();-- for (Constructor<?> constructor : constructors) {- Class<?>[] paramTypes = constructor.getParameterTypes();- if (paramTypes.length != expectedParamTypes.length)- continue;-- boolean found = true;- for (int i = 0; i < paramTypes.length; i++) {- if (!paramTypes[i].isAssignableFrom(expectedParamTypes[i])) {- found = false;- break;- }- }-- if (found)- return (Constructor<T>) constructor;- }-- return null;- }-- public static Class<?> getCollectionElementType(Type type) {- if (type instanceof ParameterizedType) {- ParameterizedType parameterizedType = (ParameterizedType)type;- Type rawType = parameterizedType.getRawType();- if (rawType instanceof Class<?>) {- Class<?> rawClazz = (Class<?>) rawType;- if (Collection.class.isAssignableFrom(rawClazz)) {- Type elementType = parameterizedType.getActualTypeArguments()[0];- if (elementType instanceof Class<?>)- return (Class<?>) elementType;- }- }- }- return null;- }-- public static Class<?> getMapKeyType(Type type) {- if (type instanceof ParameterizedType) {- ParameterizedType parameterizedType = (ParameterizedType)type;- Type rawType = parameterizedType.getRawType();-- if (rawType instanceof Class<?>) {- Class<?> rawClazz = (Class<?>) rawType;- if (Map.class.isAssignableFrom(rawClazz)) {- Type valueType = parameterizedType.getActualTypeArguments()[0];- if (valueType instanceof Class<?>)- return (Class<?>) valueType;- }- }- }- return null;- }-- public static Class<?> getMapValueType(Type type) {- if (type instanceof ParameterizedType) {- ParameterizedType parameterizedType = (ParameterizedType)type;- Type rawType = parameterizedType.getRawType();-- if (rawType instanceof Class<?>) {- Class<?> rawClazz = (Class<?>) rawType;- if (Map.class.isAssignableFrom(rawClazz)) {- Type valueType = parameterizedType.getActualTypeArguments()[1];- if (valueType instanceof Class<?>) {- return (Class<?>) valueType;- } else if (valueType instanceof ParameterizedType) {- return (Class<?>) ((ParameterizedType)valueType).getRawType();- }- }- }- }- return null;- }--}diff --git a/core/src/main/java/com/gitplex/server/util/StringUtils.java b/core/src/main/java/com/gitplex/server/util/StringUtils.javadeleted file mode 100644index f1b328ac45..0000000000--- a/core/src/main/java/com/gitplex/server/util/StringUtils.java+++ /dev/null@@ -1,305 +0,0 @@-package com.gitplex.server.util;--import java.io.BufferedReader;-import java.io.IOException;-import java.io.StreamTokenizer;-import java.io.StringReader;-import java.util.ArrayList;-import java.util.Collection;-import java.util.List;-import java.util.StringTokenizer;--import javax.annotation.Nullable;--import com.google.common.base.CaseFormat;--public class StringUtils extends org.apache.commons.lang3.StringUtils {-- public static String trimStart(String str) {- return StringUtils.stripStart(str, " \r\n\t");- }-- public static String trimEnd(String str) {- return StringUtils.stripEnd(str, " \r\n\t");- }-- /**- * Remove UTF BOM marker which might exists in some source code. UTF standard does not allow this marker and we- * should remove it before doing something such as parsing source with ANTLR- */- public static String removeBOM(String str) {- return str.replace("\uFEFF", "");- }-- /**- * Parse specified string into tokens. Content surrounded with " character- * is considered as a single token. For example: echo "hello world" will be parsed- * into two tokens, respectively [echo], and [hello world]. The quote character- * itself can be quoted and escaped in order to return as ordinary character. For- * example: echo "hello \" world" will be parsed into two tokens: [echo] and- * [hello " world].- * @param string- * @return- */- public static String[] parseQuoteTokens(String string) {- List<String> commandTokens = new ArrayList<String>();-- StreamTokenizer st = new StreamTokenizer(- new BufferedReader(new StringReader(string)));- st.resetSyntax();- st.wordChars(0, 255);- st.ordinaryChar(' ');- st.ordinaryChar('\n');- st.ordinaryChar('\t');- st.ordinaryChar('\r');- st.quoteChar('"');-- try {- String token = null;- while (st.nextToken() != StreamTokenizer.TT_EOF) {- if (st.ttype == '"' || st.ttype == StreamTokenizer.TT_WORD) {- if (token == null)- token = st.sval;- else- token += st.sval;- } else if (token != null) {- commandTokens.add(token);- token = null;- }- }- if (token != null)- commandTokens.add(token);- } catch (IOException e) {- throw new RuntimeException(e);- }-- return commandTokens.toArray(new String[commandTokens.size()]);- }-- /**- * Tokenize the given String into a String array via a StringTokenizer.- * Trims tokens and omits empty tokens.- * <p>The given delimiters string is supposed to consist of any number of- * delimiter characters. Each of those characters can be used to separate- * tokens. A delimiter is always a single character; for multi-character- * delimiters, consider using <code>delimitedListToStringArray</code>- * <p/>- * <p>Copied from the Spring Framework while retaining all license, copyright and author information.- *- * @param str the String to tokenize- * @param delimiters the delimiter characters, assembled as String- * (each of those characters is individually considered as delimiter).- * @return an array of the tokens- * @see java.util.StringTokenizer- * @see java.lang.String#trim()- */- public static String[] tokenizeToStringArray(String str, String delimiters) {- return tokenizeToStringArray(str, delimiters, true, true);- }-- /**- * Tokenize the given String into a String array via a StringTokenizer.- * <p>The given delimiters string is supposed to consist of any number of- * delimiter characters. Each of those characters can be used to separate- * tokens. A delimiter is always a single character; for multi-character- * delimiters, consider using <code>delimitedListToStringArray</code>- * <p/>- * <p>Copied from the Spring Framework while retaining all license, copyright and author information.- *- * @param str the String to tokenize- * @param delimiters the delimiter characters, assembled as String- * (each of those characters is individually considered as delimiter)- * @param trimTokens trim the tokens via String's <code>trim</code>- * @param ignoreEmptyTokens omit empty tokens from the result array- * (only applies to tokens that are empty after trimming; StringTokenizer- * will not consider subsequent delimiters as token in the first place).- * @return an array of the tokens (<code>null</code> if the input String- * was <code>null</code>)- * @see java.util.StringTokenizer- * @see java.lang.String#trim()- */- public static String[] tokenizeToStringArray(- String str, String delimiters, boolean trimTokens, boolean ignoreEmptyTokens) {-- if (str == null) {- return null;- }- StringTokenizer st = new StringTokenizer(str, delimiters);- List<String> tokens = new ArrayList<String>();- while (st.hasMoreTokens()) {- String token = st.nextToken();- if (trimTokens) {- token = token.trim();- }- if (!ignoreEmptyTokens || token.length() > 0) {- tokens.add(token);- }- }- return toStringArray(tokens);- }-- /**- * Copy the given Collection into a String array.- * The Collection must contain String elements only.- * <p/>- * <p>Copied from the Spring Framework while retaining all license, copyright and author information.- *- * @param collection the Collection to copy- * @return the String array (<code>null</code> if the passed-in- * Collection was <code>null</code>)- */- public static String[] toStringArray(Collection<?> collection) {- if (collection == null) {- return null;- }- return collection.toArray(new String[collection.size()]);- }-- /**- * Convert camel case string into lower case with underscore, for example:- * input: FirstSecondThird- * output: first_second_third- *- * @param input- * @return lower case string with underscore- */- public static @Nullable String camelCaseToLowerCaseWithUnderscore(@Nullable String input) {- if (input == null)- return input;-- return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, input);- }-- /**- * Convert camel case string into lower case with hyphen, for example:- * input: FirstSecondThird- * output: first-second-third- *- * @param input- * @return lower case string with hyphen- */- public static @Nullable String camelCaseToLowerCaseWithHyphen(@Nullable String input) {- if (input == null)- return input;-- return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, input);- }-- public static String camelCaseToLowerCaseWithConnector(String input, char connector) {- if (input == null) return input; // garbage in, garbage out- int length = input.length();- StringBuilder result = new StringBuilder(length * 2);- int resultLength = 0;- boolean wasPrevTranslated = false;- for (int i = 0; i < length; i++)- {- char c = input.charAt(i);- if (i > 0 || c != connector) // skip first starting underscore- {- if (Character.isUpperCase(c))- {- if (!wasPrevTranslated && resultLength > 0 && result.charAt(resultLength - 1) != connector)- {- result.append(connector);- resultLength++;- }- c = Character.toLowerCase(c);- wasPrevTranslated = true;- }- else- {- wasPrevTranslated = false;- }- result.append(c);- resultLength++;- }- }- return resultLength > 0 ? result.toString() : input;- }-- private static final String SINGLE_QUOTE = "\'";- private static final String DOUBLE_QUOTE = "\"";- /**- * Put quotes around the given String if necessary.- * <p>- * If the argument doesn't include spaces or quotes, return it as is. If it- * contains double quotes, use single quotes - else surround the argument by- * double quotes.- * </p>- *- * @param argument the argument to be quoted- * @return the quoted argument- * @throws IllegalArgumentException If argument contains both types of quotes- */- public static String quoteArgument(final String argument) {-- String cleanedArgument = argument.trim();-- // strip the quotes from both ends- while(cleanedArgument.startsWith(SINGLE_QUOTE) || cleanedArgument.startsWith(DOUBLE_QUOTE)) {- cleanedArgument = cleanedArgument.substring(1);- }-- while(cleanedArgument.endsWith(SINGLE_QUOTE) || cleanedArgument.endsWith(DOUBLE_QUOTE)) {- cleanedArgument = cleanedArgument.substring(0, cleanedArgument.length() - 1);- }-- final StringBuffer buf = new StringBuffer();- if (cleanedArgument.indexOf(DOUBLE_QUOTE) > -1) {- if (cleanedArgument.indexOf(SINGLE_QUOTE) > -1) {- throw new IllegalArgumentException(- "Can't handle single and double quotes in same argument");- } else {- return buf.append(SINGLE_QUOTE).append(cleanedArgument).append(- SINGLE_QUOTE).toString();- }- } else if (cleanedArgument.indexOf(SINGLE_QUOTE) > -1- || cleanedArgument.indexOf(" ") > -1) {- return buf.append(DOUBLE_QUOTE).append(cleanedArgument).append(- DOUBLE_QUOTE).toString();- } else {- return cleanedArgument;- }- }-- public static int calcLevenshteinDistance(String str1, String str2) {- int len0 = str1.length() + 1;- int len1 = str2.length() + 1;-- // the array of distances- int[] cost = new int[len0];- int[] newcost = new int[len0];-- // initial cost of skipping prefix in String s0- for (int i = 0; i < len0; i++) cost[i] = i;-- // dynamically computing the array of distances-- // transformation cost for each letter in s1- for (int j = 1; j < len1; j++) {- // initial cost of skipping prefix in String s1- newcost[0] = j;-- // transformation cost for each letter in s0- for(int i = 1; i < len0; i++) {- // matching current letters in both strings- int match = (str1.charAt(i - 1) == str2.charAt(j - 1)) ? 0 : 1;-- // computing cost for each transformation- int cost_replace = cost[i - 1] + match;- int cost_insert = cost[i] + 1;- int cost_delete = newcost[i - 1] + 1;-- // keep minimum cost- newcost[i] = Math.min(Math.min(cost_insert, cost_delete), cost_replace);- }-- // swap cost/newcost arrays- int[] swap = cost; cost = newcost; newcost = swap;- }-- // the distance is the cost for transforming all letters in both strings- return cost[len0 - 1];- }--}diff --git a/core/src/main/java/com/gitplex/server/util/Transformer.java b/core/src/main/java/com/gitplex/server/util/Transformer.javadeleted file mode 100644index 6df81dc850..0000000000--- a/core/src/main/java/com/gitplex/server/util/Transformer.java+++ /dev/null@@ -1,7 +0,0 @@-package com.gitplex.server.util;--import java.io.Serializable;--public interface Transformer<T> extends Serializable {- T transform(T text);-}diff --git a/core/src/main/java/com/gitplex/server/util/Version.java b/core/src/main/java/com/gitplex/server/util/Version.javadeleted file mode 100644index 29b1c046ac..0000000000--- a/core/src/main/java/com/gitplex/server/util/Version.java+++ /dev/null@@ -1,155 +0,0 @@-package com.gitplex.server.util;--import com.google.common.base.Preconditions;--/**- * A version composed of major, minor, patch, qualifier and build. All fields except- * major is optional, and optional fields are denoted using negative value (in case- * of integer type or empty string in case of string type).- * @author robin- *- */-public class Version implements Comparable<Version> {-- private int major = 0;-- private int minor = -1;-- private int patch = -1;-- private String qualifier = "";-- private int build = -1;-- public int getMajor() {- return major;- }-- public int getMinor() {- return minor;- }-- public int getPatch() {- return patch;- }-- public String getQualifier() {- return qualifier;- }-- public int getBuild() {- return build;- }-- public Version(String versionStr) {- versionStr = StringUtils.deleteWhitespace(versionStr);- String[] fields = StringUtils.split(versionStr, '-');- Preconditions.checkState(fields.length >= 1);- String[] parts = StringUtils.split(fields[0], '.');-- major = Integer.parseInt(parts[0]);- Preconditions.checkArgument(major>=0);-- if (parts.length >= 2) {- minor = Integer.parseInt(parts[1]);- Preconditions.checkArgument(minor>=0);- }- if (parts.length >= 3) {- patch = Integer.parseInt(parts[2]);- Preconditions.checkArgument(patch>=0);- }-- if (parts.length >= 4)- throw new RuntimeException("Invalid version string '" + versionStr + "'.");-- if (fields.length >= 2)- qualifier = fields[1];- if (fields.length >= 3) {- build = Integer.parseInt(fields[2]);- Preconditions.checkArgument(build>=0);- }-- if (fields.length >= 4)- throw new RuntimeException("Invalid version string '" + versionStr + "'.");- }-- public Version(int major, int minor, int patch, String qualifier, int build) {- Preconditions.checkArgument(major>=0, "Major version should be a positive integer.");- this.major = major;-- if (minor >= 0) {- this.minor = minor;- this.patch = patch;- } else {- Preconditions.checkArgument(patch<0,- "Minor version should also be specified if patch version is specified.");- }-- if (qualifier == null)- qualifier = "";- else- qualifier = StringUtils.deleteWhitespace(qualifier);-- if (qualifier.length() != 0) {- this.qualifier = qualifier;- this.build = build;- } else {- Preconditions.checkArgument(build<0,- "Qualifier should also be specified if build number is specified.");- }- }-- public Version(int major, int minor, int patch) {- this(major, minor, patch, "", -1);- }-- public Version(int major, int minor) {- this(major, minor, -1);- }-- public Version(int major) {- this(major, -1);- }-- public boolean isCompatible(Version version) {- return major == version.getMajor() && (minor<0?0:minor) == (version.getMinor()<0?0:version.getMinor());- }-- @Override- public int compareTo(Version version) {- if (major < version.getMajor())- return -1;- else if (major > version.getMajor())- return 1;- else if ((minor<0?0:minor) < (version.getMinor()<0?0:version.getMinor()))- return -1;- else if ((minor<0?0:minor) > (version.getMinor()<0?0:version.getMinor()))- return 1;- else if ((patch<0?0:patch) < (version.getPatch()<0?0:version.getPatch()))- return -1;- else if ((patch<0?0:patch) > (version.getPatch()<0?0:version.getPatch()))- return 1;- else if (!qualifier.equals(version.getQualifier()))- return qualifier.compareTo(version.getQualifier());- else- return (build<0?0:build) - (version.getBuild()<0?0:version.getBuild());- }-- @Override- public String toString() {- StringBuffer buffer = new StringBuffer();- buffer.append(major);- if (minor >= 0) {- buffer.append(".").append(minor);- if (patch >= 0)- buffer.append(".").append(patch);- }- if (qualifier.length() != 0) {- buffer.append("-").append(qualifier);- if (build >= 0)- buffer.append("-").append(build);- }- return buffer.toString();- }--}diff --git a/core/src/main/java/com/gitplex/server/util/WordUtils.java b/core/src/main/java/com/gitplex/server/util/WordUtils.javadeleted file mode 100644index 0c4bb772b1..0000000000--- a/core/src/main/java/com/gitplex/server/util/WordUtils.java+++ /dev/null@@ -1,36 +0,0 @@-package com.gitplex.server.util;--public class WordUtils extends org.apache.commons.lang3.text.WordUtils {-- public static String uncamel(String name) {- StringBuffer b = new StringBuffer();- char[] chars = name.toCharArray();- for (int i = 0; i < chars.length; i++) {- char c = chars[i];- if (Character.isUpperCase(c) && (nextCharacterIsNotUpperCase(chars, i) ||- previousCharacterIsNotUpperCase(chars, i))) {- b.append(" ");- } else if (Character.isDigit(c) && previousCharacterIsNotDigit(chars, i)) {- b.append(" ");- }- b.append(c);- }- String result = b.toString();- return result.trim();- }-- public static boolean previousCharacterIsNotDigit(char[] chars, int i) {- boolean hasPreviousCharacter = (i < 1);- return hasPreviousCharacter || !Character.isDigit(chars[i - 1]);- }-- private static boolean previousCharacterIsNotUpperCase(char[] chars, int i) {- boolean hasPreviousCharacter = (i < 1);- return hasPreviousCharacter || !Character.isUpperCase(chars[i - 1]);- }-- public static boolean nextCharacterIsNotUpperCase(char[] chars, int i) {- boolean hasNextCharacter = (i + 1 < chars.length);- return hasNextCharacter && !Character.isUpperCase(chars[i + 1]);- }-}diff --git a/core/src/main/java/com/gitplex/server/util/concurrent/Prioritized.java b/core/src/main/java/com/gitplex/server/util/concurrent/Prioritized.javadeleted file mode 100644index a1011b7e86..0000000000--- a/core/src/main/java/com/gitplex/server/util/concurrent/Prioritized.java+++ /dev/null@@ -1,21 +0,0 @@-package com.gitplex.server.util.concurrent;--public class Prioritized implements PriorityAware {-- private final int priority;-- public Prioritized(int priority) {- this.priority = priority;- }-- @Override- public int getPriority() {- return priority;- }-- @Override- public int compareTo(PriorityAware o) {- return priority - o.getPriority();- }--}diff --git a/core/src/main/java/com/gitplex/server/util/concurrent/PrioritizedCallable.java b/core/src/main/java/com/gitplex/server/util/concurrent/PrioritizedCallable.javadeleted file mode 100644index 7f5063fda2..0000000000--- a/core/src/main/java/com/gitplex/server/util/concurrent/PrioritizedCallable.java+++ /dev/null@@ -1,11 +0,0 @@-package com.gitplex.server.util.concurrent;--import java.util.concurrent.Callable;--public abstract class PrioritizedCallable<T> extends Prioritized implements Callable<T> {-- public PrioritizedCallable(int priority) {- super(priority);- }--}diff --git a/core/src/main/java/com/gitplex/server/util/concurrent/PrioritizedExecutor.java b/core/src/main/java/com/gitplex/server/util/concurrent/PrioritizedExecutor.javadeleted file mode 100644index abf56e24e8..0000000000--- a/core/src/main/java/com/gitplex/server/util/concurrent/PrioritizedExecutor.java+++ /dev/null@@ -1,88 +0,0 @@-package com.gitplex.server.util.concurrent;--import java.util.Collection;-import java.util.List;-import java.util.concurrent.Callable;-import java.util.concurrent.ExecutionException;-import java.util.concurrent.Future;-import java.util.concurrent.PriorityBlockingQueue;-import java.util.concurrent.RunnableFuture;-import java.util.concurrent.ThreadPoolExecutor;-import java.util.concurrent.TimeUnit;-import java.util.concurrent.TimeoutException;--import com.google.common.base.Preconditions;--public class PrioritizedExecutor extends ThreadPoolExecutor {-- public PrioritizedExecutor(int poolSize) {- super(poolSize, poolSize, 0L, TimeUnit.MILLISECONDS, new PriorityBlockingQueue<Runnable>());- }-- @Override- protected <T> RunnableFuture<T> newTaskFor(Callable<T> callable) {- return new PrioritizedFutureTask<T>((PrioritizedCallable<T>)callable);- }-- @Override- protected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value) {- return new PrioritizedFutureTask<T>((PrioritizedRunnable)runnable, value);- }-- @Override- public void execute(Runnable command) {- Preconditions.checkArgument(command instanceof PriorityAware);- super.execute(command);- }-- @Override- public Future<?> submit(Runnable task) {- Preconditions.checkArgument(task instanceof PriorityAware);- return super.submit(task);- }-- @Override- public <T> Future<T> submit(Runnable task, T result) {- Preconditions.checkArgument(task instanceof PriorityAware);- return super.submit(task, result);- }-- @Override- public <T> Future<T> submit(Callable<T> task) {- Preconditions.checkArgument(task instanceof PriorityAware);- return super.submit(task);- }-- @Override- public <T> T invokeAny(Collection<? extends Callable<T>> tasks)- throws InterruptedException, ExecutionException {- for (Callable<T> task: tasks)- Preconditions.checkArgument(task instanceof PriorityAware);- return super.invokeAny(tasks);- }-- @Override- public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)- throws InterruptedException, ExecutionException, TimeoutException {- for (Callable<T> task: tasks)- Preconditions.checkArgument(task instanceof PriorityAware);- return super.invokeAny(tasks, timeout, unit);- }-- @Override- public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)- throws InterruptedException {- for (Callable<T> task: tasks)- Preconditions.checkArgument(task instanceof PriorityAware);- return super.invokeAll(tasks);- }-- @Override- public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)- throws InterruptedException {- for (Callable<T> task: tasks)- Preconditions.checkArgument(task instanceof PriorityAware);- return super.invokeAll(tasks, timeout, unit);- }--}diff --git a/core/src/main/java/com/gitplex/server/util/concurrent/PrioritizedFutureTask.java b/core/src/main/java/com/gitplex/server/util/concurrent/PrioritizedFutureTask.javadeleted file mode 100644index 3bfcdfe29a..0000000000--- a/core/src/main/java/com/gitplex/server/util/concurrent/PrioritizedFutureTask.java+++ /dev/null@@ -1,30 +0,0 @@-package com.gitplex.server.util.concurrent;--import java.util.concurrent.FutureTask;--public class PrioritizedFutureTask<T> extends FutureTask<T>- implements PriorityAware, Comparable<PriorityAware> {-- private final int priority;-- public PrioritizedFutureTask(PrioritizedCallable<T> callable) {- super(callable);- this.priority = callable.getPriority();- }-- public PrioritizedFutureTask(PrioritizedRunnable runnable, T value) {- super(runnable, value);- this.priority = runnable.getPriority();- }-- @Override- public int getPriority() {- return priority;- }-- @Override- public int compareTo(PriorityAware o) {- return priority - o.getPriority();- }--}diff --git a/core/src/main/java/com/gitplex/server/util/concurrent/PrioritizedRunnable.java b/core/src/main/java/com/gitplex/server/util/concurrent/PrioritizedRunnable.javadeleted file mode 100644index cf223c7932..0000000000--- a/core/src/main/java/com/gitplex/server/util/concurrent/PrioritizedRunnable.java+++ /dev/null@@ -1,9 +0,0 @@-package com.gitplex.server.util.concurrent;--public abstract class PrioritizedRunnable extends Prioritized implements Runnable {-- public PrioritizedRunnable(int priority) {- super(priority);- }--}diff --git a/core/src/main/java/com/gitplex/server/util/concurrent/PriorityAware.java b/core/src/main/java/com/gitplex/server/util/concurrent/PriorityAware.javadeleted file mode 100644index 3b8bd36d76..0000000000--- a/core/src/main/java/com/gitplex/server/util/concurrent/PriorityAware.java+++ /dev/null@@ -1,5 +0,0 @@-package com.gitplex.server.util.concurrent;--public interface PriorityAware extends Comparable<PriorityAware> {- int getPriority();-}diff --git a/core/src/main/java/com/gitplex/server/util/diff/DiffUtils.java b/core/src/main/java/com/gitplex/server/util/diff/DiffUtils.javaindex b9f743c645..f5e90988d0 100644--- a/core/src/main/java/com/gitplex/server/util/diff/DiffUtils.java+++ b/core/src/main/java/com/gitplex/server/util/diff/DiffUtils.java@@ -16,9 +16,9 @@ import com.gitplex.jsyntax.Tokenized;import com.gitplex.jsyntax.Tokenizer;import com.gitplex.jsyntax.TokenizerRegistry;import com.gitplex.server.model.support.TextRange;-import com.gitplex.server.util.StringUtils;import com.gitplex.server.util.diff.DiffMatchPatch.Diff;import com.gitplex.server.util.diff.DiffMatchPatch.Operation;+import com.gitplex.utils.StringUtils;import com.gitplex.jsyntax.TokenUtils;import com.google.common.base.Preconditions;diff --git a/core/src/main/java/com/gitplex/server/util/editable/EditableUtils.java b/core/src/main/java/com/gitplex/server/util/editable/EditableUtils.javaindex e25334140c..58d6c61148 100644--- a/core/src/main/java/com/gitplex/server/util/editable/EditableUtils.java+++ b/core/src/main/java/com/gitplex/server/util/editable/EditableUtils.java@@ -12,13 +12,12 @@ import javax.annotation.Nullable;import javax.validation.Validator;import com.gitplex.launcher.loader.AppLoader;-import com.gitplex.server.util.BeanUtils;-import com.gitplex.server.util.ClassUtils;-import com.gitplex.server.util.GeneralException;-import com.gitplex.server.util.ReflectionUtils;-import com.gitplex.server.util.StringUtils;-import com.gitplex.server.util.WordUtils;import com.gitplex.server.util.editable.annotation.Editable;+import com.gitplex.utils.BeanUtils;+import com.gitplex.utils.ClassUtils;+import com.gitplex.utils.ReflectionUtils;+import com.gitplex.utils.StringUtils;+import com.gitplex.utils.WordUtils;public class EditableUtils {@@ -45,7 +44,7 @@ public class EditableUtils {else if (element instanceof Package)return ((Package)element).getName();else- throw new GeneralException("Invalid element type: " + element.getClass().getName());+ throw new RuntimeException("Invalid element type: " + element.getClass().getName());}/**diff --git a/core/src/main/java/com/gitplex/server/util/execution/Argument.java b/core/src/main/java/com/gitplex/server/util/execution/Argument.javadeleted file mode 100644index 83636dee63..0000000000--- a/core/src/main/java/com/gitplex/server/util/execution/Argument.java+++ /dev/null@@ -1,21 +0,0 @@-package com.gitplex.server.util.execution;--import com.gitplex.server.util.StringUtils;--public class Argument {-- private String[] values;-- public void setValue(String value) {- values = new String[] {value};- }-- public void setLine(String line) {- values = StringUtils.parseQuoteTokens(line);- }-- public String[] getParts() {- return values;- }--}\ No newline at end of filediff --git a/core/src/main/java/com/gitplex/server/util/execution/Commandline.java b/core/src/main/java/com/gitplex/server/util/execution/Commandline.javadeleted file mode 100644index 977b0a576b..0000000000--- a/core/src/main/java/com/gitplex/server/util/execution/Commandline.java+++ /dev/null@@ -1,227 +0,0 @@-package com.gitplex.server.util.execution;--import java.io.ByteArrayInputStream;-import java.io.File;-import java.io.IOException;-import java.io.InputStream;-import java.io.OutputStream;-import java.util.ArrayList;-import java.util.HashMap;-import java.util.List;-import java.util.Map;-import java.util.concurrent.ExecutorService;-import java.util.concurrent.Executors;--import javax.annotation.Nullable;--import org.slf4j.Logger;-import org.slf4j.LoggerFactory;--import com.gitplex.server.util.StringUtils;-import com.google.common.base.Preconditions;--public class Commandline {-- static final ExecutorService EXECUTOR_SERVICE = Executors.newCachedThreadPool();-- private static final Logger logger = LoggerFactory.getLogger(Commandline.class);-- private String executable;-- private List<String> arguments = new ArrayList<String>();-- private File workingDir;-- private Map<String, String> environments = new HashMap<String, String>();-- public Commandline(String executable) {- Preconditions.checkNotNull(executable);- this.executable = executable.replace('/', File.separatorChar).replace('\\', File.separatorChar);- }-- public Commandline arguments(List<String> arguments) {- this.arguments.clear();- this.arguments.addAll(arguments);- return this;- }-- public Commandline addArgs(String... args) {- for (String each: args)- arguments.add(each);- return this;- }-- public Commandline workingDir(File workingDir) {- this.workingDir = workingDir;- return this;- }-- public Commandline environments(Map<String, String> environments) {- this.environments.clear();- this.environments.putAll(environments);- return this;- }-- public String toString() {- List<String> command = new ArrayList<String>();- command.add(executable);- command.addAll(arguments);-- StringBuffer buf = new StringBuffer();- for (String each: command) {- if (each.contains(" ") || each.contains("\t")) {- buf.append("\"").append(StringUtils.replace(- each, "\n", "\\n")).append("\"").append(" ");- } else {- buf.append(StringUtils.replace(- each, "\n", "\\n")).append(" ");- }- }- return buf.toString();- }-- public Commandline clear() {- executable = null;- arguments.clear();- environments.clear();- workingDir = null;-- return this;- }-- public Commandline clearArgs() {- arguments.clear();- return this;- }-- private ProcessBuilder createProcessBuilder() {- File workingDir = this.workingDir;- if (workingDir == null)- workingDir = new File(".");-- String executable = this.executable;-- if (!new File(executable).isAbsolute()) {- if (new File(workingDir, executable).isFile())- executable = new File(workingDir, executable).getAbsolutePath();- else if (new File(workingDir, executable + ".exe").isFile())- executable = new File(workingDir, executable + ".exe").getAbsolutePath();- else if (new File(workingDir, executable + ".bat").isFile())- executable = new File(workingDir, executable + ".bat").getAbsolutePath();- else if (new File(workingDir, executable + ".cmd").isFile())- executable = new File(workingDir, executable + ".cmd").getAbsolutePath();- }-- List<String> command = new ArrayList<String>();- command.add(executable);- command.addAll(arguments);-- ProcessBuilder processBuilder = new ProcessBuilder(command);- processBuilder.directory(workingDir);-- processBuilder.environment().putAll(environments);-- if (logger.isDebugEnabled()) {- logger.trace("Executing command: " + this);- logger.trace("Command working directory: " +- processBuilder.directory().getAbsolutePath());- StringBuffer buffer = new StringBuffer();- for (Map.Entry<String, String> entry: processBuilder.environment().entrySet())- buffer.append(" " + entry.getKey() + "=" + entry.getValue() + "\n");- logger.trace("Command execution environments:\n" +- StringUtils.stripEnd(buffer.toString(), "\n"));- }-- return processBuilder;- }-- /**- * Execute the command.- *- * @param stdout- * output stream to write standard output, caller is responsible for closing the stream- * @param stderr- * line consumer to handle standard error- * @param stdin- * input stream to read standard input from, caller is responsible for closing the stream- * @return- * execution result- */- public ExecuteResult execute(OutputStream stdout, final LineConsumer stderr, @Nullable InputStream stdin) {- Process process;- try {- ProcessBuilder processBuilder = createProcessBuilder();- process = processBuilder.redirectErrorStream(stderr == null).start();- } catch (IOException e) {- throw new RuntimeException(e);- }-- final StringBuffer errorMessage = new StringBuffer();- OutputStream errorMessageCollector = null;- if (stderr != null) {- errorMessageCollector = new LineConsumer(stderr.getEncoding()) {-- @Override- public void consume(String line) {- if (errorMessage.length() != 0)- errorMessage.append("\n");- errorMessage.append(line);- stderr.consume(line);- }-- };- }-- ProcessStreamPumper streamPumper = ProcessStreamPumper.pump(process, stdout,- errorMessageCollector, stdin);-- ExecuteResult result = new ExecuteResult(this);-- try {- result.setReturnCode(process.waitFor());- } catch (InterruptedException e) {- process.destroy();- throw new RuntimeException(e);- } finally {- streamPumper.waitFor();- }-- if (errorMessage.length() != 0)- result.setErrorMessage(errorMessage.toString());-- return result;- }-- /**- * Execute the command.- *- * @param stdout- * output stream to write standard output, caller is responsible for closing the stream- * @param stderr- * line consumer to handle standard error- * @return- * execution result- */- public ExecuteResult execute(OutputStream stdout, LineConsumer stderr) {- return execute(stdout, stderr, null);- }-- /**- * Execute the command without waiting for command completion.- *- * @param stdinBytes- * standard input bytes to feed into command- */- public void executeWithoutWait(@Nullable byte[] stdinBytes) {- ByteArrayInputStream stdinStream = null;- if (stdinBytes != null && stdinBytes.length != 0)- stdinStream = new ByteArrayInputStream(stdinBytes);-- try {- ProcessStreamPumper.pump(createProcessBuilder().start(), null, null, stdinStream);- } catch (IOException e) {- throw new RuntimeException(e);- }- }--}diff --git a/core/src/main/java/com/gitplex/server/util/execution/ExecuteResult.java b/core/src/main/java/com/gitplex/server/util/execution/ExecuteResult.javadeleted file mode 100644index f78b506699..0000000000--- a/core/src/main/java/com/gitplex/server/util/execution/ExecuteResult.java+++ /dev/null@@ -1,56 +0,0 @@-package com.gitplex.server.util.execution;--import com.gitplex.server.util.GeneralException;--public class ExecuteResult {-- private int returnCode;-- private String errorMessage;-- private String commandDescription;-- public ExecuteResult(Commandline cmdline) {- commandDescription = cmdline.toString();- }-- public int getReturnCode() {- return returnCode;- }-- public void setReturnCode(int returnCode) {- this.returnCode = returnCode;- }-- public String getErrorMessage() {- return errorMessage;- }-- public void setErrorMessage(String errorMessage) {- this.errorMessage = errorMessage;- }-- /**- * Build an exception object with command description, stderr output and return code.- * @return- */- public RuntimeException buildException() {- if (errorMessage != null) {- throw new GeneralException("Failed to run command: " + commandDescription +- "\nCommand return code: " + getReturnCode() +- "\nCommand error output: " + errorMessage);- } else {- throw new GeneralException("Failed to run command: " + commandDescription +- "\nCommand return code: " + getReturnCode());- }-- }-- /**- * Check return code and throw exception if it does not equal to 0.- */- public void checkReturnCode() {- if (getReturnCode() != 0)- throw buildException();- }-}\ No newline at end of filediff --git a/core/src/main/java/com/gitplex/server/util/execution/LineConsumer.java b/core/src/main/java/com/gitplex/server/util/execution/LineConsumer.javadeleted file mode 100644index f55c72aed7..0000000000--- a/core/src/main/java/com/gitplex/server/util/execution/LineConsumer.java+++ /dev/null@@ -1,121 +0,0 @@-/*- * Copyright 2003-2004 The Apache Software Foundation- *- * Licensed under the Apache License, Version 2.0 (the "License");- * you may not use this file except in compliance with the License.- * You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- *- */--package com.gitplex.server.util.execution;--import java.io.ByteArrayOutputStream;-import java.io.IOException;-import java.io.OutputStream;-import java.io.UnsupportedEncodingException;--import com.google.common.base.Charsets;--/**- * heavily inspired from LogOutputStream- * this stream class calls back the P4Handler on each line of stdout or stderr read- * @author : <a href="mailto:[email protected]">Antoine Levy-Lambert</a>- *- * Modified by <a href="mailto:[email protected]">robin shen</a> to seperate- * output and error handling- *- */-public abstract class LineConsumer extends OutputStream {-- /**- * If this property is not empty, output will be re-directed to this stream- * instead of the ant log stream- */- private ByteArrayOutputStream buffer = new ByteArrayOutputStream();-- private boolean skip = false;-- private String encoding;-- public LineConsumer(String encoding) {- this.encoding = encoding;- }-- public LineConsumer() {- this(Charsets.UTF_8.name());- }-- public String getEncoding() {- return encoding;- }-- /**- * Write the data to the buffer and flush the buffer, if a line- * separator is detected.- *- * @param cc data to log (byte).- * @throws IOException IOException if an I/O error occurs. In particular,- * an <code>IOException</code> may be thrown if the- * output stream has been closed.- */- @Override- public void write(int cc) throws IOException {- final byte c = (byte) cc;- if ((c == '\n') || (c == '\r')) {- if (!skip) {- processBuffer();- }- } else {- buffer.write(cc);- }- skip = (c == '\r');- }-- /**- * Converts the buffer to a string and sends it to <code>processLine</code>- */- protected void processBuffer() {- try {- consume(encoding!=null?buffer.toString(encoding):buffer.toString());- } catch (UnsupportedEncodingException e) {- throw new RuntimeException(e);- } finally {- buffer.reset();- }- }-- /**- * Sub class must implement this method to handle a line of output- * @param line- */- public abstract void consume(String line);-- @Override- public void flush() throws IOException {- if (buffer.size() > 0) {- processBuffer();- }- super.flush();- }-- /**- * Writes all remaining- * @throws IOException if an I/O error occurs.- */- @Override- public void close() throws IOException {- flush();- super.close();- }--}--diff --git a/core/src/main/java/com/gitplex/server/util/execution/ProcessStreamPumper.java b/core/src/main/java/com/gitplex/server/util/execution/ProcessStreamPumper.javadeleted file mode 100644index 501bb7dfe3..0000000000--- a/core/src/main/java/com/gitplex/server/util/execution/ProcessStreamPumper.java+++ /dev/null@@ -1,103 +0,0 @@-package com.gitplex.server.util.execution;--import java.io.IOException;-import java.io.InputStream;-import java.io.OutputStream;-import java.util.concurrent.ExecutionException;-import java.util.concurrent.Future;--import javax.annotation.Nullable;--import com.google.common.base.Throwables;--public class ProcessStreamPumper {-- private static final int BUFFER_SIZE = 64*1024;-- private final Future<?> stdoutPumper;-- private final Future<?> stderrPumper;-- private final Future<?> stdinPumper;-- private final OutputStream stdout;-- private final OutputStream stderr;-- private ProcessStreamPumper(Process process, @Nullable OutputStream stdout,- @Nullable OutputStream stderr, @Nullable InputStream stdin) {- this.stdout = stdout;- this.stderr = stderr;-- stdoutPumper = createPump(process.getInputStream(), stdout, true, false);- stderrPumper = createPump(process.getErrorStream(), stderr, true, false);-- if (stdin != null)- stdinPumper = createPump(stdin, process.getOutputStream(), false, true);- else- stdinPumper = null;- }-- public static ProcessStreamPumper pump(Process process, @Nullable OutputStream stdoutStream,- @Nullable OutputStream stderrStream, @Nullable InputStream stdinStream) {- return new ProcessStreamPumper(process, stdoutStream, stderrStream, stdinStream);- }-- public void waitFor() {- while (!stdoutPumper.isDone() || !stderrPumper.isDone() ||- (stdinPumper != null && !stdinPumper.isDone())) {- try {- Thread.sleep(10);- } catch (InterruptedException e) {- }- }-- try {- // call get() to re-throw possible exception generated by pumper- stdoutPumper.get();- stderrPumper.get();- if (stdinPumper != null)- stdinPumper.get();-- if (stdout != null)- stdout.flush();- if (stderr != null)- stderr.flush();- } catch (InterruptedException | ExecutionException | IOException e) {- Throwables.propagate(e);- }-- }-- private Future<?> createPump(final InputStream input, @Nullable final OutputStream output,- final boolean closeInputWhenExhausted, final boolean closeOutputWhenExhausted) {-- return Commandline.EXECUTOR_SERVICE.submit(new Runnable() {-- public void run() {- byte[] buf = new byte[BUFFER_SIZE];-- try {- int length;- while ((length = input.read(buf)) > 0) {- if (output != null)- output.write(buf, 0, length);- }-- if (closeInputWhenExhausted)- input.close();- if (closeOutputWhenExhausted && output!=null)- output.close();- } catch (Exception e) {- try {- while (input.read(buf) > 0); // drain command outputs to avoid blocking- } catch (IOException e2) {- }- Throwables.propagate(e);- }- }-- });- }--}diff --git a/core/src/main/java/com/gitplex/server/util/execution/StreamConsumer.java b/core/src/main/java/com/gitplex/server/util/execution/StreamConsumer.javadeleted file mode 100644index aa62d07d8b..0000000000--- a/core/src/main/java/com/gitplex/server/util/execution/StreamConsumer.java+++ /dev/null@@ -1,52 +0,0 @@-package com.gitplex.server.util.execution;--import java.io.IOException;-import java.io.InputStream;-import java.io.PipedInputStream;-import java.io.PipedOutputStream;--import org.apache.commons.io.IOUtils;--public abstract class StreamConsumer extends PipedOutputStream {-- private static final int BUFFER_SIZE = 64*1024;-- public StreamConsumer() {- final PipedInputStream input = new PipedInputStream(BUFFER_SIZE);- try {- connect(input);- } catch (IOException e) {- throw new RuntimeException(e);- }-- Commandline.EXECUTOR_SERVICE.submit(new Runnable() {-- @Override- public void run() {- try {- consume(input);-- // In case consumer does not care about the stream, we pump to the end- // of the input stream so that the other side of the pipe will not- // block.- byte[] buffer = new byte[BUFFER_SIZE];- while (input.read(buffer) != -1);- } catch (IOException e) {- throw new RuntimeException(e);- } finally {- IOUtils.closeQuietly(input);- }- }-- });- }-- /**- * Consume specified input stream.- *- * @param input- * input stream supplied by caller. Will be closed by caller- */- protected abstract void consume(InputStream input);--}diff --git a/core/src/main/java/com/gitplex/server/util/facade/UserFacade.java b/core/src/main/java/com/gitplex/server/util/facade/UserFacade.javaindex 55016d142c..2c9e5c7cb3 100644--- a/core/src/main/java/com/gitplex/server/util/facade/UserFacade.java+++ b/core/src/main/java/com/gitplex/server/util/facade/UserFacade.java@@ -3,7 +3,7 @@ package com.gitplex.server.util.facade;import javax.annotation.Nullable;import com.gitplex.server.model.User;-import com.gitplex.server.util.matchscore.MatchScoreUtils;+import com.gitplex.utils.matchscore.MatchScoreUtils;public class UserFacade extends EntityFacade {diff --git a/core/src/main/java/com/gitplex/server/util/init/InitStage.java b/core/src/main/java/com/gitplex/server/util/init/InitStage.javadeleted file mode 100644index 61e47988b0..0000000000--- a/core/src/main/java/com/gitplex/server/util/init/InitStage.java+++ /dev/null@@ -1,47 +0,0 @@-package com.gitplex.server.util.init;--import java.io.Serializable;-import java.util.ArrayList;-import java.util.List;--@SuppressWarnings("serial")-public class InitStage implements Serializable, Cloneable {-- private String message;-- private final List<ManualConfig> manualConfigs;-- public InitStage(String message, List<ManualConfig> manualConfigs) {- this.message = message;- this.manualConfigs = manualConfigs;- }-- public InitStage(String message) {- this(message, new ArrayList<ManualConfig>());- }-- public String getMessage() {- return message;- }-- public List<ManualConfig> getManualConfigs() {- return manualConfigs;- }-- public synchronized void waitForFinish() {- if (!manualConfigs.isEmpty()) {- try {- wait();- } catch (InterruptedException e) {- throw new RuntimeException(e);- }- }- }-- public synchronized void finished() {- message = "Please wait...";- manualConfigs.clear();- notify();- }--}diff --git a/core/src/main/java/com/gitplex/server/util/init/ManualConfig.java b/core/src/main/java/com/gitplex/server/util/init/ManualConfig.javadeleted file mode 100644index f3c01a80e3..0000000000--- a/core/src/main/java/com/gitplex/server/util/init/ManualConfig.java+++ /dev/null@@ -1,42 +0,0 @@-package com.gitplex.server.util.init;--import java.io.Serializable;-import java.util.HashSet;-import java.util.Set;--@SuppressWarnings("serial")-public abstract class ManualConfig implements Serializable {-- private final String message;-- private final Serializable setting;-- private final Set<String> excludeProperties;-- public ManualConfig(String message, Serializable setting, Set<String> excludeProperties) {- this.message = message;- this.setting = setting;- this.excludeProperties = excludeProperties;- }-- public ManualConfig(String message, Serializable setting) {- this(message, setting, new HashSet<>());- }-- public String getMessage() {- return message;- }-- public Serializable getSetting() {- return setting;- }-- public Set<String> getExcludeProperties() {- return excludeProperties;- }-- public abstract Skippable getSkippable();-- public abstract void complete();--}diff --git a/core/src/main/java/com/gitplex/server/util/init/Skippable.java b/core/src/main/java/com/gitplex/server/util/init/Skippable.javadeleted file mode 100644index 4b5eecaeed..0000000000--- a/core/src/main/java/com/gitplex/server/util/init/Skippable.java+++ /dev/null@@ -1,5 +0,0 @@-package com.gitplex.server.util.init;--public interface Skippable {- void skip();-}diff --git a/core/src/main/java/com/gitplex/server/util/jetty/DefaultJettyRunner.java b/core/src/main/java/com/gitplex/server/util/jetty/DefaultJettyRunner.javaindex 7d799ca4e3..df44403880 100644--- a/core/src/main/java/com/gitplex/server/util/jetty/DefaultJettyRunner.java+++ b/core/src/main/java/com/gitplex/server/util/jetty/DefaultJettyRunner.java@@ -17,8 +17,7 @@ import org.eclipse.jetty.servlet.ErrorPageErrorHandler;import org.eclipse.jetty.servlet.ServletContextHandler;import com.gitplex.launcher.bootstrap.Bootstrap;-import com.gitplex.launcher.bootstrap.BootstrapUtils;-import com.gitplex.server.util.schedule.TaskScheduler;+import com.google.common.base.Throwables;import com.google.inject.servlet.GuiceFilter;@Singleton@@ -45,7 +44,7 @@ public class DefaultJettyRunner implements JettyRunner, Provider<ServletContextH@Injectpublic DefaultJettyRunner(Provider<Set<ServerConfigurator>> serverConfiguratorsProvider,- Provider<Set<ServletConfigurator>> servletConfiguratorsProvider, TaskScheduler taskScheduler) {+ Provider<Set<ServletConfigurator>> servletConfiguratorsProvider) {this.serverConfiguratorsProvider = serverConfiguratorsProvider;this.servletConfiguratorsProvider = servletConfiguratorsProvider;}@@ -94,7 +93,7 @@ public class DefaultJettyRunner implements JettyRunner, Provider<ServletContextHtry {jettyServer.start();} catch (Exception e) {- throw BootstrapUtils.unchecked(e);+ throw Throwables.propagate(e);}}}@@ -105,7 +104,7 @@ public class DefaultJettyRunner implements JettyRunner, Provider<ServletContextHtry {jettyServer.stop();} catch (Exception e) {- throw BootstrapUtils.unchecked(e);+ throw Throwables.propagate(e);}}}diff --git a/core/src/main/java/com/gitplex/server/util/markdown/UrlResolveExtension.java b/core/src/main/java/com/gitplex/server/util/markdown/UrlResolveExtension.javaindex 67d9f4f656..360948ca60 100644--- a/core/src/main/java/com/gitplex/server/util/markdown/UrlResolveExtension.java+++ b/core/src/main/java/com/gitplex/server/util/markdown/UrlResolveExtension.java@@ -3,7 +3,7 @@ package com.gitplex.server.util.markdown;import java.util.HashSet;import java.util.Set;-import com.gitplex.server.util.PathUtils;+import com.gitplex.utils.PathUtils;import com.vladsch.flexmark.ast.Image;import com.vladsch.flexmark.ast.Link;import com.vladsch.flexmark.ast.util.TextCollectingVisitor;diff --git a/core/src/main/java/com/gitplex/server/util/matchscore/MatchScoreProvider.java b/core/src/main/java/com/gitplex/server/util/matchscore/MatchScoreProvider.javadeleted file mode 100644index cf5e27bea4..0000000000--- a/core/src/main/java/com/gitplex/server/util/matchscore/MatchScoreProvider.java+++ /dev/null@@ -1,7 +0,0 @@-package com.gitplex.server.util.matchscore;--public interface MatchScoreProvider<T> {-- double getMatchScore(T object);--}diff --git a/core/src/main/java/com/gitplex/server/util/matchscore/MatchScoreUtils.java b/core/src/main/java/com/gitplex/server/util/matchscore/MatchScoreUtils.javadeleted file mode 100644index 73d4d07c7e..0000000000--- a/core/src/main/java/com/gitplex/server/util/matchscore/MatchScoreUtils.java+++ /dev/null@@ -1,64 +0,0 @@-package com.gitplex.server.util.matchscore;--import java.util.ArrayList;-import java.util.Collection;-import java.util.Collections;-import java.util.Comparator;-import java.util.HashMap;-import java.util.List;-import java.util.Map;--import javax.annotation.Nullable;--public class MatchScoreUtils {-- public static <T> List<T> filterAndSort(Collection<T> list, MatchScoreProvider<T> matchScoreProvider) {- Map<T, Double> matchScores = new HashMap<>();- List<T> newList = new ArrayList<>();- for (T item: list) {- double matchScore = matchScoreProvider.getMatchScore(item);- if (matchScore > 0) {- matchScores.put(item, matchScore);- newList.add(item);- }- }- Collections.sort(newList, new Comparator<T>() {-- @Override- public int compare(T o1, T o2) {- double result = matchScores.get(o1) - matchScores.get(o2);- if (result < 0)- return 1;- else if (result > 0)- return -1;- else- return 0;- }-- });-- return newList;- }-- public static double getMatchScore(@Nullable String text, @Nullable String query) {- if (query == null)- query = "";- else- query = query.toLowerCase().trim();- if (text == null)- text = "";- else- text = text.toLowerCase().trim();-- if (query.length() != 0) {- int index = text.indexOf(query);- if (index == -1)- return -1;- else- return query.length() * 1.0 / text.length();- } else {- return 1;- }- }--}diff --git a/core/src/main/java/com/gitplex/server/util/schedule/DefaultTaskScheduler.java b/core/src/main/java/com/gitplex/server/util/schedule/DefaultTaskScheduler.javadeleted file mode 100644index 514c44025b..0000000000--- a/core/src/main/java/com/gitplex/server/util/schedule/DefaultTaskScheduler.java+++ /dev/null@@ -1,109 +0,0 @@-package com.gitplex.server.util.schedule;--import java.util.Properties;-import java.util.UUID;--import javax.inject.Singleton;--import org.quartz.Job;-import org.quartz.JobBuilder;-import org.quartz.JobDetail;-import org.quartz.JobExecutionContext;-import org.quartz.JobExecutionException;-import org.quartz.JobKey;-import org.quartz.Scheduler;-import org.quartz.SchedulerException;-import org.quartz.Trigger;-import org.quartz.TriggerBuilder;-import org.quartz.impl.StdSchedulerFactory;-import org.slf4j.Logger;-import org.slf4j.LoggerFactory;--@Singleton-public class DefaultTaskScheduler implements TaskScheduler {-- private static final Logger logger = LoggerFactory.getLogger(DefaultTaskScheduler.class);-- private Scheduler quartz;-- public DefaultTaskScheduler() {- StdSchedulerFactory schedFactory = new StdSchedulerFactory();- Properties props = new Properties();- props.setProperty("org.quartz.scheduler.instanceName", "DefaultQuartzScheduler");- props.setProperty("org.quartz.scheduler.rmi.export", "false");- props.setProperty("org.quartz.scheduler.rmi.proxy", "false");- props.setProperty("org.quartz.scheduler.wrapJobExecutionInUserTransaction", "false");- props.setProperty("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");- props.setProperty("org.quartz.threadPool.threadCount", "10");- props.setProperty("org.quartz.jobStore.misfireThreshold", "60000");- props.setProperty("org.quartz.jobStore.class", "org.quartz.simpl.RAMJobStore");- try {- schedFactory.initialize(props);- quartz = schedFactory.getScheduler();- } catch (SchedulerException e) {- throw new RuntimeException(e);- }- }-- @Override- public void start() {- try {- quartz.start();- } catch (SchedulerException e) {- throw new RuntimeException(e);- }- }-- @Override- public synchronized String schedule(SchedulableTask task) {- try {- JobDetail job = JobBuilder.newJob(HelperTask.class)- .withIdentity(UUID.randomUUID().toString())- .build();- Trigger trigger = TriggerBuilder.newTrigger()- .withIdentity(UUID.randomUUID().toString())- .withSchedule(task.getScheduleBuilder())- .forJob(job)- .build();- trigger.getJobDataMap().put("task", task);- quartz.scheduleJob(job, trigger);- return job.getKey().getName();- } catch (SchedulerException e) {- throw new RuntimeException(e);- }- }-- @Override- public synchronized void unschedule(String taskId) {- try {- quartz.deleteJob(new JobKey(taskId));- } catch (SchedulerException e) {- throw new RuntimeException(e);- }- }-- @Override- public void stop() {- try {- if (quartz.isStarted())- quartz.shutdown();- } catch (SchedulerException e) {- throw new RuntimeException(e);- }- }-- public static class HelperTask implements Job {-- @Override- public void execute(JobExecutionContext context) throws JobExecutionException {- SchedulableTask task = (SchedulableTask) context.getTrigger().getJobDataMap().get("task");- try {- task.execute();- } catch (Exception e) {- logger.error("Error executing scheduled task", e);- }- }-- }--}diff --git a/core/src/main/java/com/gitplex/server/util/schedule/SchedulableTask.java b/core/src/main/java/com/gitplex/server/util/schedule/SchedulableTask.javadeleted file mode 100644index 705c0677cd..0000000000--- a/core/src/main/java/com/gitplex/server/util/schedule/SchedulableTask.java+++ /dev/null@@ -1,9 +0,0 @@-package com.gitplex.server.util.schedule;--import org.quartz.ScheduleBuilder;--public interface SchedulableTask {- void execute();-- ScheduleBuilder<?> getScheduleBuilder();-}diff --git a/core/src/main/java/com/gitplex/server/util/schedule/TaskScheduler.java b/core/src/main/java/com/gitplex/server/util/schedule/TaskScheduler.javadeleted file mode 100644index b37be405fa..0000000000--- a/core/src/main/java/com/gitplex/server/util/schedule/TaskScheduler.java+++ /dev/null@@ -1,12 +0,0 @@-package com.gitplex.server.util.schedule;--public interface TaskScheduler {-- String schedule(SchedulableTask task);-- void unschedule(String taskId);-- void start();-- void stop();-}diff --git a/core/src/main/java/com/gitplex/server/util/stringmatch/ChildAwareMatcher.java b/core/src/main/java/com/gitplex/server/util/stringmatch/ChildAwareMatcher.javadeleted file mode 100644index ff76df7ef2..0000000000--- a/core/src/main/java/com/gitplex/server/util/stringmatch/ChildAwareMatcher.java+++ /dev/null@@ -1,23 +0,0 @@-package com.gitplex.server.util.stringmatch;--/**- * Besides the normal wildcard string match, this matcher also matches- * paths beneath a parent path if the parent path ends with slash. For- * instance, if the pattern is "parent/", it will match value- * "parent/child"- *- * @author robin- *- */-public class ChildAwareMatcher extends WildcardStringMatcher {-- @Override- public boolean matches(String rule, String value) {- if (value.startsWith(rule) && rule.endsWith("/")) {- return true;- } else {- return super.matches(rule, value);- }- }--}diff --git a/core/src/main/java/com/gitplex/server/util/stringmatch/Matcher.java b/core/src/main/java/com/gitplex/server/util/stringmatch/Matcher.javadeleted file mode 100644index ab823dae16..0000000000--- a/core/src/main/java/com/gitplex/server/util/stringmatch/Matcher.java+++ /dev/null@@ -1,5 +0,0 @@-package com.gitplex.server.util.stringmatch;--public interface Matcher {- boolean matches(String pattern, String value);-}diff --git a/core/src/main/java/com/gitplex/server/util/stringmatch/PatternApplied.java b/core/src/main/java/com/gitplex/server/util/stringmatch/PatternApplied.javadeleted file mode 100644index bfd486db35..0000000000--- a/core/src/main/java/com/gitplex/server/util/stringmatch/PatternApplied.java+++ /dev/null@@ -1,32 +0,0 @@-package com.gitplex.server.util.stringmatch;--import java.io.Serializable;--import com.gitplex.jsymbol.Range;--public class PatternApplied implements Serializable {-- private static final long serialVersionUID = 1L;-- private final String text;-- private final Range matchRange;-- public PatternApplied(String text, Range matchRange) {- this.text = text;- this.matchRange = matchRange;- }-- public String getText() {- return text;- }-- public Range getMatchRange() {- return matchRange;- }-- @Override- public String toString() {- return text + ":" + matchRange;- }-}diff --git a/core/src/main/java/com/gitplex/server/util/stringmatch/WildcardPathMatcher.java b/core/src/main/java/com/gitplex/server/util/stringmatch/WildcardPathMatcher.javadeleted file mode 100644index d90dba01b9..0000000000--- a/core/src/main/java/com/gitplex/server/util/stringmatch/WildcardPathMatcher.java+++ /dev/null@@ -1,277 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one- * or more contributor license agreements. See the NOTICE file- * distributed with this work for additional information- * regarding copyright ownership. The ASF licenses this file- * to you under the Apache License, Version 2.0 (the- * "License"); you may not use this file except in compliance- * with the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing,- * software distributed under the License is distributed on an- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY- * KIND, either express or implied. See the License for the- * specific language governing permissions and limitations- * under the License.- */-package com.gitplex.server.util.stringmatch;--import com.gitplex.server.util.StringUtils;--/**- * <p>PathMatcher implementation for Ant-style path patterns.- * Examples are provided below.</p>- *- * <p>Part of this mapping code has been kindly borrowed from- * <a href="http://ant.apache.org">Apache Ant</a>.- *- * <p>The mapping matches URLs using the following rules:<br>- * <ul>- * <li>? matches one character</li>- * <li>* matches zero or more characters</li>- * <li>** matches zero or more 'directories' in a path</li>- * </ul>- *- * <p>Some examples:<br>- * <ul>- * <li><code>com/t?st.jsp</code> - matches <code>com/test.jsp</code> but also- * <code>com/tast.jsp</code> or <code>com/txst.jsp</code></li>- * <li><code>com/*.jsp</code> - matches all <code>.jsp</code> files in the- * <code>com</code> directory</li>- * <li><code>com/**/test.jsp</code> - matches all <code>test.jsp</code>- * files underneath the <code>com</code> path</li>- * <li><code>org/apache/shiro/**/*.jsp</code> - matches all <code>.jsp</code>- * files underneath the <code>org/apache/shiro</code> path</li>- * <li><code>org/**/servlet/bla.jsp</code> - matches- * <code>org/apache/shiro/servlet/bla.jsp</code> but also- * <code>org/apache/shiro/testing/servlet/bla.jsp</code> and- * <code>org/servlet/bla.jsp</code></li>- * </ul>- *- * <p><b>N.B.</b>: This class was borrowed (with much appreciation) from the- * <a href="http://www.springframework.org">Spring Framework</a> with modifications. We didn't want to reinvent the- * wheel of great work they've done, but also didn't want to force every Shiro user to depend on Spring</p>- *- * <p>As per the Apache 2.0 license, the original copyright notice and all author and copyright information have- * remained in tact.</p>- *- * @since 16.07.2003- */-public class WildcardPathMatcher implements Matcher {-- private static final Matcher STRING_MATCHER = new WildcardStringMatcher();-- //TODO - complete JavaDoc-- /**- * Default path separator: "/"- */- public static final String DEFAULT_PATH_SEPARATOR = "/";-- private String pathSeparator = DEFAULT_PATH_SEPARATOR;--- /**- * Set the path separator to use for pattern parsing.- * Default is "/", as in Ant.- */- public void setPathSeparator(String pathSeparator) {- this.pathSeparator = (pathSeparator != null ? pathSeparator : DEFAULT_PATH_SEPARATOR);- }--- public boolean isPattern(String path) {- return (path.indexOf('*') != -1 || path.indexOf('?') != -1);- }-- public boolean matches(String pattern, String str) {- return doMatch(pattern, str, true);- }-- public boolean matchStart(String pattern, String str) {- return doMatch(pattern, str, false);- }-- /**- * Actually match the given <code>path</code> against the given <code>pattern</code>.- *- * @param pattern the pattern to match against- * @param path the path String to test- * @param fullMatch whether a full pattern match is required- * (else a pattern match as far as the given base path goes is sufficient)- * @return <code>true</code> if the supplied <code>path</code> matched,- * <code>false</code> if it didn't- */- protected boolean doMatch(String pattern, String str, boolean fullMatch) {- if (str.startsWith(this.pathSeparator) != pattern.startsWith(this.pathSeparator)) {- return false;- }-- String[] pattDirs = StringUtils.tokenizeToStringArray(pattern, this.pathSeparator);- String[] pathDirs = StringUtils.tokenizeToStringArray(str, this.pathSeparator);-- int pattIdxStart = 0;- int pattIdxEnd = pattDirs.length - 1;- int pathIdxStart = 0;- int pathIdxEnd = pathDirs.length - 1;-- // Match all elements up to the first **- while (pattIdxStart <= pattIdxEnd && pathIdxStart <= pathIdxEnd) {- String patDir = pattDirs[pattIdxStart];- if ("**".equals(patDir)) {- break;- }- if (!STRING_MATCHER.matches(patDir, pathDirs[pathIdxStart])) {- return false;- }- pattIdxStart++;- pathIdxStart++;- }-- if (pathIdxStart > pathIdxEnd) {- // Path is exhausted, only match if rest of pattern is * or **'s- if (pattIdxStart > pattIdxEnd) {- return (pattern.endsWith(this.pathSeparator) ?- str.endsWith(this.pathSeparator) : !str.endsWith(this.pathSeparator));- }- if (!fullMatch) {- return true;- }- if (pattIdxStart == pattIdxEnd && pattDirs[pattIdxStart].equals("*") &&- str.endsWith(this.pathSeparator)) {- return true;- }- for (int i = pattIdxStart; i <= pattIdxEnd; i++) {- if (!pattDirs[i].equals("**")) {- return false;- }- }- return true;- } else if (pattIdxStart > pattIdxEnd) {- // String not exhausted, but pattern is. Failure.- return false;- } else if (!fullMatch && "**".equals(pattDirs[pattIdxStart])) {- // Path start definitely matches due to "**" part in pattern.- return true;- }-- // up to last '**'- while (pattIdxStart <= pattIdxEnd && pathIdxStart <= pathIdxEnd) {- String patDir = pattDirs[pattIdxEnd];- if (patDir.equals("**")) {- break;- }- if (!STRING_MATCHER.matches(patDir, pathDirs[pathIdxEnd])) {- return false;- }- pattIdxEnd--;- pathIdxEnd--;- }- if (pathIdxStart > pathIdxEnd) {- // String is exhausted- for (int i = pattIdxStart; i <= pattIdxEnd; i++) {- if (!pattDirs[i].equals("**")) {- return false;- }- }- return true;- }-- while (pattIdxStart != pattIdxEnd && pathIdxStart <= pathIdxEnd) {- int patIdxTmp = -1;- for (int i = pattIdxStart + 1; i <= pattIdxEnd; i++) {- if (pattDirs[i].equals("**")) {- patIdxTmp = i;- break;- }- }- if (patIdxTmp == pattIdxStart + 1) {- // '**/**' situation, so skip one- pattIdxStart++;- continue;- }- // Find the pattern between padIdxStart & padIdxTmp in str between- // strIdxStart & strIdxEnd- int patLength = (patIdxTmp - pattIdxStart - 1);- int strLength = (pathIdxEnd - pathIdxStart + 1);- int foundIdx = -1;-- strLoop:- for (int i = 0; i <= strLength - patLength; i++) {- for (int j = 0; j < patLength; j++) {- String subPat = (String) pattDirs[pattIdxStart + j + 1];- String subStr = (String) pathDirs[pathIdxStart + i + j];- if (!STRING_MATCHER.matches(subPat, subStr)) {- continue strLoop;- }- }- foundIdx = pathIdxStart + i;- break;- }-- if (foundIdx == -1) {- return false;- }-- pattIdxStart = patIdxTmp;- pathIdxStart = foundIdx + patLength;- }-- for (int i = pattIdxStart; i <= pattIdxEnd; i++) {- if (!pattDirs[i].equals("**")) {- return false;- }- }-- return true;- }-- /**- * Given a pattern and a full path, determine the pattern-mapped part.- * <p>For example:- * <ul>- * <li>'<code>/docs/cvs/commit.html</code>' and '<code>/docs/cvs/commit.html</code> -> ''</li>- * <li>'<code>/docs/*</code>' and '<code>/docs/cvs/commit</code> -> '<code>cvs/commit</code>'</li>- * <li>'<code>/docs/cvs/*.html</code>' and '<code>/docs/cvs/commit.html</code> -> '<code>commit.html</code>'</li>- * <li>'<code>/docs/**</code>' and '<code>/docs/cvs/commit</code> -> '<code>cvs/commit</code>'</li>- * <li>'<code>/docs/**\/*.html</code>' and '<code>/docs/cvs/commit.html</code> -> '<code>cvs/commit.html</code>'</li>- * <li>'<code>/*.html</code>' and '<code>/docs/cvs/commit.html</code> -> '<code>docs/cvs/commit.html</code>'</li>- * <li>'<code>*.html</code>' and '<code>/docs/cvs/commit.html</code> -> '<code>/docs/cvs/commit.html</code>'</li>- * <li>'<code>*</code>' and '<code>/docs/cvs/commit.html</code> -> '<code>/docs/cvs/commit.html</code>'</li>- * </ul>- * <p>Assumes that {@link #match} returns <code>true</code> for '<code>pattern</code>'- * and '<code>path</code>', but does <strong>not</strong> enforce this.- */- public String extractPathWithinPattern(String pattern, String path) {- String[] patternParts = StringUtils.tokenizeToStringArray(pattern, this.pathSeparator);- String[] pathParts = StringUtils.tokenizeToStringArray(path, this.pathSeparator);-- StringBuilder buffer = new StringBuilder();-- // Add any path parts that have a wildcarded pattern part.- int puts = 0;- for (int i = 0; i < patternParts.length; i++) {- String patternPart = patternParts[i];- if ((patternPart.indexOf('*') > -1 || patternPart.indexOf('?') > -1) && pathParts.length >= i + 1) {- if (puts > 0 || (i == 0 && !pattern.startsWith(this.pathSeparator))) {- buffer.append(this.pathSeparator);- }- buffer.append(pathParts[i]);- puts++;- }- }-- // Append any trailing path parts.- for (int i = patternParts.length; i < pathParts.length; i++) {- if (puts > 0 || i > 0) {- buffer.append(this.pathSeparator);- }- buffer.append(pathParts[i]);- }-- return buffer.toString();- }--}diff --git a/core/src/main/java/com/gitplex/server/util/stringmatch/WildcardStringMatcher.java b/core/src/main/java/com/gitplex/server/util/stringmatch/WildcardStringMatcher.javadeleted file mode 100644index 2d010b3c07..0000000000--- a/core/src/main/java/com/gitplex/server/util/stringmatch/WildcardStringMatcher.java+++ /dev/null@@ -1,138 +0,0 @@-package com.gitplex.server.util.stringmatch;--public class WildcardStringMatcher implements Matcher {-- @Override- public boolean matches(String pattern, String str) {- char[] patArr = pattern.toCharArray();- char[] strArr = str.toCharArray();- int patIdxStart = 0;- int patIdxEnd = patArr.length - 1;- int strIdxStart = 0;- int strIdxEnd = strArr.length - 1;- char ch;-- boolean containsStar = false;- for (char aPatArr : patArr) {- if (aPatArr == '*') {- containsStar = true;- break;- }- }-- if (!containsStar) {- // No '*'s, so we make a shortcut- if (patIdxEnd != strIdxEnd) {- return false; // Pattern and string do not have the same size- }- for (int i = 0; i <= patIdxEnd; i++) {- ch = patArr[i];- if (ch != '?') {- if (ch != strArr[i]) {- return false;// Character mismatch- }- }- }- return true; // String matches against pattern- }-- if (patIdxEnd == 0) {- return true; // Pattern contains only '*', which matches anything- }-- // Process characters before first star- while ((ch = patArr[patIdxStart]) != '*' && strIdxStart <= strIdxEnd) {- if (ch != '?') {- if (ch != strArr[strIdxStart]) {- return false;// Character mismatch- }- }- patIdxStart++;- strIdxStart++;- }- if (strIdxStart > strIdxEnd) {- // All characters in the string are used. Check if only '*'s are- // left in the pattern. If so, we succeeded. Otherwise failure.- for (int i = patIdxStart; i <= patIdxEnd; i++) {- if (patArr[i] != '*') {- return false;- }- }- return true;- }-- // Process characters after last star- while ((ch = patArr[patIdxEnd]) != '*' && strIdxStart <= strIdxEnd) {- if (ch != '?') {- if (ch != strArr[strIdxEnd]) {- return false;// Character mismatch- }- }- patIdxEnd--;- strIdxEnd--;- }- if (strIdxStart > strIdxEnd) {- // All characters in the string are used. Check if only '*'s are- // left in the pattern. If so, we succeeded. Otherwise failure.- for (int i = patIdxStart; i <= patIdxEnd; i++) {- if (patArr[i] != '*') {- return false;- }- }- return true;- }-- // process pattern between stars. padIdxStart and patIdxEnd point- // always to a '*'.- while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) {- int patIdxTmp = -1;- for (int i = patIdxStart + 1; i <= patIdxEnd; i++) {- if (patArr[i] == '*') {- patIdxTmp = i;- break;- }- }- if (patIdxTmp == patIdxStart + 1) {- // Two stars next to each other, skip the first one.- patIdxStart++;- continue;- }- // Find the pattern between padIdxStart & padIdxTmp in str between- // strIdxStart & strIdxEnd- int patLength = (patIdxTmp - patIdxStart - 1);- int strLength = (strIdxEnd - strIdxStart + 1);- int foundIdx = -1;- strLoop: for (int i = 0; i <= strLength - patLength; i++) {- for (int j = 0; j < patLength; j++) {- ch = patArr[patIdxStart + j + 1];- if (ch != '?') {- if (ch != strArr[strIdxStart + i + j]) {- continue strLoop;- }- }- }-- foundIdx = strIdxStart + i;- break;- }-- if (foundIdx == -1) {- return false;- }-- patIdxStart = patIdxTmp;- strIdxStart = foundIdx + patLength;- }-- // All characters in the string are used. Check if only '*'s are left- // in the pattern. If so, we succeeded. Otherwise failure.- for (int i = patIdxStart; i <= patIdxEnd; i++) {- if (patArr[i] != '*') {- return false;- }- }-- return true;- }--}diff --git a/core/src/main/java/com/gitplex/server/util/stringmatch/WildcardUtils.java b/core/src/main/java/com/gitplex/server/util/stringmatch/WildcardUtils.javadeleted file mode 100644index 6b6dae0c7c..0000000000--- a/core/src/main/java/com/gitplex/server/util/stringmatch/WildcardUtils.java+++ /dev/null@@ -1,185 +0,0 @@-package com.gitplex.server.util.stringmatch;--import java.util.ArrayList;-import java.util.List;--import javax.annotation.Nullable;--import com.gitplex.jsymbol.Range;--public class WildcardUtils {-- private static final Matcher PATH_MATCHER = new WildcardPathMatcher();-- private static final Matcher STRING_MATCHER = new WildcardStringMatcher();-- /**- * Tests whether or not a given path matches a given pattern using of- * <a href="http://ant.apache.org/manual/dirtasks.html">Ant path pattern</a>.- *- * @param pattern- * the pattern to match against. Must not be null- * @param str- * the path to match, as a String. Must not be null- *- * @return- * true if the pattern matches the string, or false otherwise- *- */- public static boolean matchPath(String pattern, String path) {- return PATH_MATCHER.matches(pattern, path);- }-- /**- * Tests whether or not a string matches specified pattern, which may contain- * two special characters:<br>- * '*' means zero or more characters<br>- * '?' means one and only one character- *- * @param pattern- * the pattern to match against. Must not be null.- * @param str- * the string which must be matched against the pattern. Must not be null.- * @return- * true if the string matches against the pattern, or false otherwise.- */- public static boolean matchString(String pattern, String str) {- return STRING_MATCHER.matches(pattern, str);- }-- public static boolean hasWildcards(String str) {- return (str.indexOf('*') != -1 || str.indexOf('?') != -1);- }-- private static int indexOf(String str, String substr, int index) {- if (index >= str.length()) {- return (substr.length() == 0 ? str.length(): -1);- }- if (index < 0) {- index = 0;- }- if (substr.length() == 0) {- return index;- }-- char first = substr.charAt(0);- int max = (str.length() - substr.length());-- for (int i = index; i <= max; i++) {- /* Look for first character. */- if ('?' != first && str.charAt(i) != first) {- while (++i <= max && '?' != first && str.charAt(i) != first);- }-- /* Found first character, now look at the rest of v2 */- if (i <= max) {- int j = i + 1;- int end = j + substr.length() - 1;- for (int k = 1; j < end && ('?' == substr.charAt(k) || str.charAt(j) == substr.charAt(k)); j++, k++);-- if (j == end) {- /* Found whole string. */- return i;- }- }- }- return -1;- }-- public static List<Range> getLiteralRanges(String pattern) {- List<Range> literalRanges = new ArrayList<>();- int pos = 0;- int index = pattern.indexOf('*');- while (index != -1) {- if (index>pos)- literalRanges.add(new Range(pos, index));- pos = index+1;- index = pattern.indexOf('*', pos);- }- if (pattern.length()>pos)- literalRanges.add(new Range(pos, pattern.length()));- return literalRanges;- }-- /**- * Check the unit test for explanation.- *- * @param str- * @param pattern- * @param caseSensitive- * @return- */- @Nullable- public static PatternApplied applyPattern(String pattern, String str, boolean caseSensitive) {- String normalizedText;- String normalizedPattern;- if (caseSensitive) {- normalizedText = str;- normalizedPattern = pattern;- } else {- normalizedText = str.toLowerCase();- normalizedPattern = pattern.toLowerCase();- }- List<Range> literalRanges = getLiteralRanges(normalizedPattern);-- StringBuilder appliedText = new StringBuilder(pattern);- int first = -1;- int last = 0;- int pos = 0;- for (Range literalRange: literalRanges) {- String literal = normalizedPattern.substring(literalRange.getFrom(), literalRange.getTo());- int index = indexOf(normalizedText, literal, pos);- if (index != -1) {- if (first == -1)- first = index;- pos = index+literal.length();- last = pos;-- String temp = appliedText.toString();- appliedText = new StringBuilder(appliedText.substring(0, literalRange.getFrom()));- for (int i=0; i<literal.length(); i++) {- if (literal.charAt(i) == '?')- appliedText.append('?');- else- appliedText.append(str.charAt(index+i));- }- appliedText.append(temp.substring(literalRange.getTo()));- } else {- return null;- }- }- if (first != -1 && pattern.charAt(0) != '*')- appliedText = new StringBuilder(str.substring(0, first) + appliedText.toString());- else- first = 0;- if (pattern.length() == 0 || pattern.charAt(pattern.length()-1) != '*') {- String suffix = str.substring(last);- last = appliedText.length();- appliedText.append(suffix);- } else {- last = appliedText.length();- }- return new PatternApplied(appliedText.toString(), new Range(first, last));- }-- @Nullable- public static Range rangeOfMatch(String pattern, String str) {- List<Range> literalRanges = getLiteralRanges(pattern);-- int first = -1;- int pos = 0;- for (Range literalRange: literalRanges) {- String literal = pattern.substring(literalRange.getFrom(), literalRange.getTo());- int index = indexOf(str, literal, pos);- if (index != -1) {- if (first == -1)- first = index;- pos = index+literal.length();- } else {- return null;- }- }- return new Range(first, pos);- }--}diff --git a/core/src/main/java/com/gitplex/server/util/validation/DirectoryValidator.java b/core/src/main/java/com/gitplex/server/util/validation/DirectoryValidator.javaindex 1f7d1907ad..f383aaed4f 100644--- a/core/src/main/java/com/gitplex/server/util/validation/DirectoryValidator.java+++ b/core/src/main/java/com/gitplex/server/util/validation/DirectoryValidator.java@@ -5,7 +5,8 @@ import java.io.File;import javax.validation.ConstraintValidator;import javax.validation.ConstraintValidatorContext;-import com.gitplex.server.util.FileUtils;+import com.gitplex.utils.FileUtils;+import com.gitplex.launcher.bootstrap.Bootstrap;import com.gitplex.server.util.validation.annotation.Directory;public class DirectoryValidator implements ConstraintValidator<Directory, String> {@@ -37,7 +38,7 @@ public class DirectoryValidator implements ConstraintValidator<Directory, String}}if (annotation.outsideOfInstallDir()) {- if (!FileUtils.isOutsideOfInstallDir(dir)) {+ if (dir.getCanonicalFile().toPath().startsWith(Bootstrap.installDir.toPath())) {constraintContext.disableDefaultConstraintViolation();constraintContext.buildConstraintViolationWithTemplate("Please specify a directory outside of the installation directory").addConstraintViolation();return false;diff --git a/core/src/main/java/com/gitplex/server/util/validation/NameValidator.java b/core/src/main/java/com/gitplex/server/util/validation/NameValidator.javaindex 035219828b..403dc424fe 100644--- a/core/src/main/java/com/gitplex/server/util/validation/NameValidator.java+++ b/core/src/main/java/com/gitplex/server/util/validation/NameValidator.java@@ -3,8 +3,8 @@ package com.gitplex.server.util.validation;import javax.validation.ConstraintValidator;import javax.validation.ConstraintValidatorContext;-import com.gitplex.server.util.StringUtils;import com.gitplex.server.util.validation.annotation.Name;+import com.gitplex.utils.StringUtils;public class NameValidator implements ConstraintValidator<Name, String> {diff --git a/core/src/main/java/org/eclipse/jgit/revwalk/LastCommitsOfChildren.java b/core/src/main/java/org/eclipse/jgit/revwalk/LastCommitsOfChildren.javaindex 4dc0f219e5..02e5c1eeeb 100644--- a/core/src/main/java/org/eclipse/jgit/revwalk/LastCommitsOfChildren.java+++ b/core/src/main/java/org/eclipse/jgit/revwalk/LastCommitsOfChildren.java@@ -27,7 +27,7 @@ import org.eclipse.jgit.treewalk.filter.TreeFilter;import org.eclipse.jgit.util.RawParseUtils;import com.gitplex.server.git.GitUtils;-import com.gitplex.server.util.StringUtils;+import com.gitplex.utils.StringUtils;import com.google.common.base.Throwables;/**diff --git a/core/src/test/java/com/gitplex/server/git/AbstractGitTest.java b/core/src/test/java/com/gitplex/server/git/AbstractGitTest.javaindex 2a5fdb8217..f35eaceabf 100644--- a/core/src/test/java/com/gitplex/server/git/AbstractGitTest.java+++ b/core/src/test/java/com/gitplex/server/git/AbstractGitTest.java@@ -16,13 +16,11 @@ import org.eclipse.jgit.lib.RefUpdate;import org.junit.Assert;import org.mockito.Mockito;-import com.gitplex.server.git.GitUtils;-import com.gitplex.server.git.command.GitCommand;-import com.gitplex.server.git.config.GitConfig;-import com.gitplex.server.util.FileUtils;import com.gitplex.launcher.loader.AppLoader;import com.gitplex.launcher.loader.AppLoaderMocker;-import com.gitplex.launcher.bootstrap.BootstrapUtils;+import com.gitplex.server.git.command.GitCommand;+import com.gitplex.server.git.config.GitConfig;+import com.gitplex.utils.FileUtils;public abstract class AbstractGitTest extends AppLoaderMocker {@@ -34,7 +32,7 @@ public abstract class AbstractGitTest extends AppLoaderMocker {@Overrideprotected void setup() {- gitDir = BootstrapUtils.createTempDir();+ gitDir = FileUtils.createTempDir();try {git = org.eclipse.jgit.api.Git.init().setBare(false).setDirectory(gitDir).call();diff --git a/core/src/test/java/com/gitplex/server/git/command/BlameCommandTest.java b/core/src/test/java/com/gitplex/server/git/command/BlameCommandTest.javaindex 8b3f741218..f512df1d0b 100644--- a/core/src/test/java/com/gitplex/server/git/command/BlameCommandTest.java+++ b/core/src/test/java/com/gitplex/server/git/command/BlameCommandTest.java@@ -6,7 +6,7 @@ import java.util.Collection;import org.junit.Test;-import com.gitplex.jsymbol.Range;+import com.gitplex.utils.Range;import com.gitplex.server.git.AbstractGitTest;import com.gitplex.server.git.BlameBlock;diff --git a/core/src/test/java/com/gitplex/server/util/BeanUtilsTest.java b/core/src/test/java/com/gitplex/server/util/BeanUtilsTest.javadeleted file mode 100644index 892a2b1475..0000000000--- a/core/src/test/java/com/gitplex/server/util/BeanUtilsTest.java+++ /dev/null@@ -1,56 +0,0 @@-package com.gitplex.server.util;--import static org.junit.Assert.assertEquals;-import static org.junit.Assert.assertTrue;--import java.lang.reflect.Method;-import java.util.List;--import org.junit.Test;--import com.gitplex.server.util.BeanUtils;--public class BeanUtilsTest {-- @Test- public void shouldFindGetter() {- Method getter = BeanUtils.findGetter(SubClass.class, "value");- assertEquals(getter.getReturnType(), String.class);-- List<Method> getters = BeanUtils.findGetters(SubClass.class);- assertEquals(getters.size(), 2);- assertEquals(getters.get(0).getReturnType(), String.class);- assertEquals(getters.get(1).getReturnType(), Class.class);- }-- @Test- public void shouldFindSetter() {- Method getter = BeanUtils.findGetter(SubClass.class, "value");- assertTrue(BeanUtils.findSetter(getter) == null);-- getter = BeanUtils.findGetter(SuperClass.class, "value");- assertTrue(BeanUtils.findSetter(getter) != null);- }-- private static class SuperClass {-- @SuppressWarnings("unused")- public Object getValue() {- return null;- }-- @SuppressWarnings("unused")- public void setValue(Object value) {-- }- }-- private static class SubClass extends SuperClass {-- public String getValue() {- return null;- }-- }--}diff --git a/core/src/test/java/com/gitplex/server/util/ClassUtilsTest.java b/core/src/test/java/com/gitplex/server/util/ClassUtilsTest.javadeleted file mode 100644index 6f3e0d0632..0000000000--- a/core/src/test/java/com/gitplex/server/util/ClassUtilsTest.java+++ /dev/null@@ -1,19 +0,0 @@-package com.gitplex.server.util;--import org.junit.Assert;-import org.junit.Test;--import com.gitplex.server.util.ClassUtils;--public class ClassUtilsTest {-- @Test- public void testGetResourceAsStream() {- String packageName = ClassUtils.class.getPackage().getName();- Assert.assertNotNull(ClassUtils.getResourceAsStream(- null, packageName.replace('.', '/') + "/ClassUtils.class"));- Assert.assertNotNull(ClassUtils.getResourceAsStream(- ClassUtils.class, "ClassUtils.class"));- }--}diff --git a/core/src/test/java/com/gitplex/server/util/DependenceUtilsTest.java b/core/src/test/java/com/gitplex/server/util/DependenceUtilsTest.javadeleted file mode 100644index 759ef2e8ee..0000000000--- a/core/src/test/java/com/gitplex/server/util/DependenceUtilsTest.java+++ /dev/null@@ -1,237 +0,0 @@-package com.gitplex.server.util;--import static org.junit.Assert.assertEquals;-import static org.junit.Assert.fail;--import java.util.HashSet;-import java.util.Map;-import java.util.Set;--import org.junit.Test;--import com.gitplex.server.util.DependencyAware;-import com.gitplex.server.util.DependencyUtils;-import com.google.common.collect.ImmutableMap;-import com.google.common.collect.ImmutableSet;-import com.google.common.collect.Sets;--public class DependenceUtilsTest {-- @Test- public void shouldDetectCircularDependenciesInContext() {- DependencyAware<String> dependency1 = new DependencyAware<String>() {-- @Override- public String getId() {- return "dependency1";- }-- @Override- public Set<String> getDependencies() {- return ImmutableSet.of("dependency2");- }-- };-- DependencyAware<String> dependency2 = new DependencyAware<String>() {-- @Override- public String getId() {- return "dependency2";- }-- @Override- public Set<String> getDependencies() {- return ImmutableSet.of("dependency3");- }-- };- DependencyAware<String> dependency3 = new DependencyAware<String>() {-- @Override- public String getId() {- return "dependency3";- }-- @Override- public Set<String> getDependencies() {- return ImmutableSet.of("dependency2");- }-- };-- Map<String, DependencyAware<String>> context = ImmutableMap.of(- "dependency1", dependency1,- "dependency2", dependency2,- "dependency3", dependency3- );-- try {- DependencyUtils.sortDependencies(context);- fail("Can not detect circular dependencies");- } catch (Exception e) {- }- }-- @Test- public void shouldGetTransitiveDependents() {- DependencyAware<String> dependency1 = new DependencyAware<String>() {-- @Override- public String getId() {- return "dependency1";- }-- @Override- public Set<String> getDependencies() {- return ImmutableSet.of("dependency2", "dependency3");- }-- };-- DependencyAware<String> dependency2 = new DependencyAware<String>() {-- @Override- public String getId() {- return "dependency2";- }-- @Override- public Set<String> getDependencies() {- return ImmutableSet.of("dependency3");- }-- };- DependencyAware<String> dependency3 = new DependencyAware<String>() {-- @Override- public String getId() {- return "dependency3";- }-- @Override- public Set<String> getDependencies() {- return new HashSet<>();- }-- };-- Map<String, DependencyAware<String>> context = ImmutableMap.of(- "dependency1", dependency1,- "dependency2", dependency2,- "dependency3", dependency3- );-- assertEquals(Sets.newHashSet("dependency1", "dependency2"),- DependencyUtils.getTransitiveDependents(DependencyUtils.getDependentMap(context), "dependency3"));- }-- @Test- public void shouldGetTransitiveDependentsWithCircular() {- DependencyAware<String> dependency1 = new DependencyAware<String>() {-- @Override- public String getId() {- return "dependency1";- }-- @Override- public Set<String> getDependencies() {- return ImmutableSet.of("dependency2");- }-- };-- DependencyAware<String> dependency2 = new DependencyAware<String>() {-- @Override- public String getId() {- return "dependency2";- }-- @Override- public Set<String> getDependencies() {- return ImmutableSet.of("dependency3");- }-- };- DependencyAware<String> dependency3 = new DependencyAware<String>() {-- @Override- public String getId() {- return "dependency3";- }-- @Override- public Set<String> getDependencies() {- return ImmutableSet.of("dependency2");- }-- };-- Map<String, DependencyAware<String>> context = ImmutableMap.of(- "dependency1", dependency1,- "dependency2", dependency2,- "dependency3", dependency3- );-- assertEquals(Sets.newHashSet("dependency1", "dependency2", "dependency3"),- DependencyUtils.getTransitiveDependents(DependencyUtils.getDependentMap(context), "dependency3"));- }-- @Test- public void shouldDetectMissedDependenciesInContext() {- DependencyAware<String> dependency1 = new DependencyAware<String>() {-- @Override- public String getId() {- return "dependency1";- }-- @Override- public Set<String> getDependencies() {- return ImmutableSet.of("dependency2");- }-- };-- DependencyAware<String> dependency2 = new DependencyAware<String>() {-- @Override- public String getId() {- return "dependency2";- }-- @Override- public Set<String> getDependencies() {- return ImmutableSet.of("dependency3");- }-- };- DependencyAware<String> dependency3 = new DependencyAware<String>() {-- @Override- public String getId() {- return "dependency3";- }-- @Override- public Set<String> getDependencies() {- return ImmutableSet.of("dependency4");- }-- };-- Map<String, DependencyAware<String>> context = ImmutableMap.of(- "dependency1", dependency1,- "dependency2", dependency2,- "dependency3", dependency3- );-- try {- DependencyUtils.sortDependencies(context);- fail("Can not detect missed dependencies");- } catch (Exception e) {- }- }-}diff --git a/core/src/test/java/com/gitplex/server/util/LoadPropsTest.java b/core/src/test/java/com/gitplex/server/util/LoadPropsTest.javadeleted file mode 100644index b576d26462..0000000000--- a/core/src/test/java/com/gitplex/server/util/LoadPropsTest.java+++ /dev/null@@ -1,75 +0,0 @@-package com.gitplex.server.util;--import static org.junit.Assert.assertEquals;-import static org.junit.Assert.assertNull;--import java.io.File;-import java.io.IOException;-import java.util.Properties;--import org.junit.After;-import org.junit.Before;-import org.junit.Test;--import com.gitplex.server.util.FileUtils;--public class LoadPropsTest {-- private File file;-- @Before- public void setup() {- try {- file = File.createTempFile("load", ".properties");- } catch (IOException e) {- throw new RuntimeException(e);- }- }-- private void populateFile(String content) {- try {- FileUtils.writeStringToFile(file, content);- } catch (IOException e) {- throw new RuntimeException(e);- }- }-- @Test- public void shouldTrimKey() {- populateFile("key1=value1\n key1 =value2");- Properties props = FileUtils.loadProperties(file);- assertEquals("value2", props.getProperty("key1"));- assertEquals(1, props.keySet().size());- }-- @Test- public void shouldTrimValue() {- populateFile("key1 = value1 \r key2= ");- Properties props = FileUtils.loadProperties(file);- assertEquals("value1", props.getProperty("key1"));- assertNull(props.getProperty("key2"));- }-- @Test- public void shouldHandleEqualSignInValue() {- populateFile("key1==\r\nkey2= a =b");- Properties props = FileUtils.loadProperties(file);- assertEquals("=", props.getProperty("key1"));- assertEquals("a =b", props.getProperty("key2"));- }-- @Test- public void shouldHandleColonSeparator() {- populateFile("key1:=\n\rkey2: a :b\r\rkey3=a:b");- Properties props = FileUtils.loadProperties(file);- assertEquals("=", props.getProperty("key1"));- assertEquals("a :b", props.getProperty("key2"));- assertEquals("a:b", props.getProperty("key3"));- }-- @After- public void teardown() {- if (file != null)- file.delete();- }-}diff --git a/core/src/test/java/com/gitplex/server/util/PathComparatorTest.java b/core/src/test/java/com/gitplex/server/util/PathComparatorTest.javadeleted file mode 100644index 908ab1ad94..0000000000--- a/core/src/test/java/com/gitplex/server/util/PathComparatorTest.java+++ /dev/null@@ -1,19 +0,0 @@-package com.gitplex.server.util;--import static org.junit.Assert.*;--import org.junit.Test;--public class PathComparatorTest {-- @Test- public void test() {- assertEquals(new PathComparator().compare("a/b", "b"), -1);- assertEquals(new PathComparator().compare("a", "b"), -1);- assertEquals(new PathComparator().compare("a/c", "a"), 1);- assertEquals(new PathComparator().compare("abc", "ab/c"), 1);- assertEquals(new PathComparator().compare("a/b/c", "a/b/c"), 0);- assertEquals(new PathComparator().compare("a/b/c/d", "a/b/c"), 1);- }--}diff --git a/core/src/test/java/com/gitplex/server/util/PathUtilsTest.java b/core/src/test/java/com/gitplex/server/util/PathUtilsTest.javadeleted file mode 100644index 5d4a8b79cc..0000000000--- a/core/src/test/java/com/gitplex/server/util/PathUtilsTest.java+++ /dev/null@@ -1,48 +0,0 @@-package com.gitplex.server.util;--import static com.gitplex.server.util.PathUtils.matchLongest;-import static com.gitplex.server.util.PathUtils.matchSegments;-import static com.gitplex.server.util.PathUtils.resolveSibling;-import static org.junit.Assert.assertEquals;-import static org.junit.Assert.assertNull;--import java.util.Collection;--import org.junit.Test;--import com.google.common.collect.Lists;--public class PathUtilsTest {-- @Test- public void shouldMatchLongest() {- Collection<String> basePaths = Lists.newArrayList("/path1/path2", "/path1/path2/path3");- assertEquals(matchLongest(basePaths, "/path1/path2/path3/path4"), "/path1/path2/path3");- assertNull(matchLongest(basePaths, "/path1/path23"));- assertNull(matchLongest(basePaths, "/path1/path3"));-- basePaths = Lists.newArrayList("/path1/path2", "/path1\\");- assertEquals(matchLongest(basePaths, "path1\\path234"), "/path1\\");-- basePaths = Lists.newArrayList("/asset1/asset2", "/asset1");- assertEquals(matchLongest(basePaths, "/asset1/asset2/test.html"), "/asset1/asset2");- }-- @Test- public void shouldMatchSegments() {- assertEquals("0-5", matchSegments("hello/world", "hello", true).toString());- assertEquals("5-16", matchSegments("just/hello/world/do", "hello/world", true).toString());- assertEquals("13-18", matchSegments("hello0/world/hello.gif", "hello", true).toString());- assertNull(matchSegments("mayhello/worldtwo", "hello/world", true));- assertNull(matchSegments("hello0/world/hello.gif", "hello", false));- }-- @Test- public void testResolveSibling() {- assertEquals(resolveSibling("hello", "world"), "world");- assertEquals(resolveSibling("hello/", "world"), "hello/world");- assertEquals(resolveSibling("hello/world", "file"), "hello/file");- assertEquals(resolveSibling("hello/world", "/file"), "/file");- }--}diff --git a/core/src/test/java/com/gitplex/server/util/ReflectionUtilsTest.java b/core/src/test/java/com/gitplex/server/util/ReflectionUtilsTest.javadeleted file mode 100644index f541b45dcf..0000000000--- a/core/src/test/java/com/gitplex/server/util/ReflectionUtilsTest.java+++ /dev/null@@ -1,90 +0,0 @@-package com.gitplex.server.util;--import static org.junit.Assert.assertSame;--import java.lang.reflect.Method;-import java.util.List;--import org.junit.Test;--import com.gitplex.server.util.ReflectionUtils;-import com.google.common.base.Optional;--public class ReflectionUtilsTest {-- private static class SuperClass<T1, T2> {}-- private static class SubClass1 extends SuperClass<String, Integer> {}-- private static class SubClass2<T> extends SuperClass<String, T> {}-- private static class SubClass3 extends SubClass2<Integer> {}-- @Test- public void shouldResolveTypeArg() {- List<?> typeArguments = ReflectionUtils.getTypeArguments(SuperClass.class, SubClass1.class);- assertSame(String.class, typeArguments.get(0));- assertSame(Integer.class, typeArguments.get(1));-- typeArguments = ReflectionUtils.getTypeArguments(SuperClass.class, SubClass2.class);- assertSame(String.class, typeArguments.get(0));-- typeArguments = ReflectionUtils.getTypeArguments(SuperClass.class, SubClass3.class);- assertSame(String.class, typeArguments.get(0));- assertSame(Integer.class, typeArguments.get(1));-- typeArguments = ReflectionUtils.getTypeArguments(SubClass2.class, SubClass3.class);- assertSame(Integer.class, typeArguments.get(0));- }-- @Test- public void shouldFindMethodCorrectly() {- Method method = ReflectionUtils.findMethod(SubClass4.class, "method", String.class, int.class);- assertSame(method.getReturnType(), String.class);-- method = ReflectionUtils.findMethod(SuperClass1.class, "method", String.class, int.class);- assertSame(method.getReturnType(), Object.class);-- method = ReflectionUtils.findMethod(SubClass4.class, "method2", String.class);- assertSame(method.getParameterTypes()[0], String.class);-- method = ReflectionUtils.findMethod(SubClass4.class, "method2", Object.class);- assertSame(method.getParameterTypes()[0], Object.class);- }-- private static class SuperClass1 {-- @SuppressWarnings("unused")- public Object method(String param1, int param2) {- return param1.toString() + param2;- }- }-- private static class SubClass4 extends SuperClass1 {-- public String method(String param1, int param2) {- return param1 + param2;- }-- @SuppressWarnings("unused")- public List<String> method2(Object param1) {- return null;- }-- @SuppressWarnings("unused")- public List<String> method2(String param1) {- return null;- }-- @SuppressWarnings("unused")- public List<Optional<String>> method3(String param1) {- return null;- }-- @SuppressWarnings("unused")- public List<String> method4(String param1) {- return null;- }- }--}diff --git a/core/src/test/java/com/gitplex/server/util/StringUtilsTest.java b/core/src/test/java/com/gitplex/server/util/StringUtilsTest.javadeleted file mode 100644index 3ab064cca8..0000000000--- a/core/src/test/java/com/gitplex/server/util/StringUtilsTest.java+++ /dev/null@@ -1,33 +0,0 @@-package com.gitplex.server.util;--import static org.junit.Assert.assertEquals;--import org.junit.Test;--import com.gitplex.server.util.StringUtils;---public class StringUtilsTest {-- @Test public void shouldConvertCameCaseToLowerCaseWithUnderscore() {- String input = null;- assertEquals(StringUtils.camelCaseToLowerCaseWithUnderscore(input), null);-- input = "FirstSecondThird";- assertEquals(StringUtils.camelCaseToLowerCaseWithUnderscore(input), "first_second_third");-- input = "ILoveYou";- assertEquals(StringUtils.camelCaseToLowerCaseWithUnderscore(input), "i_love_you");- }-- @Test public void shouldConvertCamelCaseToLowerCaseWithHyphen() {- String input = null;- assertEquals(StringUtils.camelCaseToLowerCaseWithHyphen(input), null);-- input = "FirstSecondThird";- assertEquals(StringUtils.camelCaseToLowerCaseWithHyphen(input), "first-second-third");-- input = "ILoveYou";- assertEquals(StringUtils.camelCaseToLowerCaseWithHyphen(input), "i-love-you");- }-}diff --git a/core/src/test/java/com/gitplex/server/util/VersionTest.java b/core/src/test/java/com/gitplex/server/util/VersionTest.javadeleted file mode 100644index 560bd8960a..0000000000--- a/core/src/test/java/com/gitplex/server/util/VersionTest.java+++ /dev/null@@ -1,77 +0,0 @@-package com.gitplex.server.util;--import static org.junit.Assert.assertEquals;-import static org.junit.Assert.assertFalse;-import static org.junit.Assert.assertTrue;-import static org.junit.Assert.fail;--import org.junit.Test;--import com.gitplex.server.util.Version;--public class VersionTest {-- @Test- public void shouldDecodeVersionStringCorrectly() {- Version version = new Version("1.2.3-build-100");- assertEquals(version.toString(), "1.2.3-build-100");-- version = new Version("1.2-100");- assertEquals(version.toString(), "1.2-100");-- version = new Version("1-build-10");- assertEquals(version.toString(), "1-build-10");- }-- @Test- public void shouldConstructVersionCorrectly() {- Version version = new Version(1, 2, 3, "beta", 100);- assertEquals(version.toString(), "1.2.3-beta-100");-- version = new Version(1, 2, -1, "beta", -1);- assertEquals(version.toString(), "1.2-beta");-- try {- version = new Version(-1, 2, 1, "build", 1);- fail("Can not detect construction errors.");- } catch (Exception e) {- }-- try {- version = new Version(1, 2, -1, null, 1);- fail("Can not detect construction errors.");- } catch (Exception e) {- }-- try {- version = new Version(1, -1, 0, null, -1);- fail("Can not detect construction errors.");- } catch (Exception e) {- }- }-- @Test- public void shouldCompareVersionCorrectly() {- assertTrue(new Version("1").compareTo(new Version("1")) == 0);- assertTrue(new Version("1.0.1").compareTo(new Version("1.0.1")) == 0);- assertTrue(new Version("1").compareTo(new Version("1.0")) == 0);- assertTrue(new Version("1.2-build").compareTo(new Version("1.2.0-build-0")) == 0);-- assertTrue(new Version("1").compareTo(new Version("2")) < 0);- assertTrue(new Version("1.9.1").compareTo(new Version("1.10.1")) < 0);- assertTrue(new Version("1.9.1-beta-1").compareTo(new Version("1.9.1-beta-4")) < 0);- assertTrue(new Version("1.9.1-alpha-1").compareTo(new Version("1.9.1-beta-1")) < 0);- assertTrue(new Version("1.9.1-alpha").compareTo(new Version("1.9.1-alpha-1")) < 0);- assertTrue(new Version("1.9-alpha").compareTo(new Version("1.9.1-alpha")) < 0);- }-- @Test- public void shouldHandleCompatibleVersions() {- assertTrue(new Version("1.0").isCompatible(new Version("1.0.1")));- assertFalse(new Version("1.0").isCompatible(new Version("1.1")));- assertTrue(new Version("1.0.2").isCompatible(new Version("1.0.3")));- assertTrue(new Version("1.0.2").isCompatible(new Version("1.0.4-build-100")));- assertFalse(new Version("6.0").isCompatible(new Version("5-beta-5")));- assertTrue(new Version("6.3").isCompatible(new Version("6.3.2-rc-4")));- }-}diff --git a/core/src/test/java/com/gitplex/server/util/findsubclassesexploded/DummyAbstractClass.java b/core/src/test/java/com/gitplex/server/util/findsubclassesexploded/DummyAbstractClass.javadeleted file mode 100644index e518d461f9..0000000000--- a/core/src/test/java/com/gitplex/server/util/findsubclassesexploded/DummyAbstractClass.java+++ /dev/null@@ -1,5 +0,0 @@-package com.gitplex.server.util.findsubclassesexploded;--public abstract class DummyAbstractClass implements DummyInterface {--}diff --git a/core/src/test/java/com/gitplex/server/util/findsubclassesexploded/DummyInterface.java b/core/src/test/java/com/gitplex/server/util/findsubclassesexploded/DummyInterface.javadeleted file mode 100644index 8b9e8ee7cf..0000000000--- a/core/src/test/java/com/gitplex/server/util/findsubclassesexploded/DummyInterface.java+++ /dev/null@@ -1,5 +0,0 @@-package com.gitplex.server.util.findsubclassesexploded;--public interface DummyInterface {- void test();-}diff --git a/core/src/test/java/com/gitplex/server/util/findsubclassesexploded/dummy/DummyClass1.java b/core/src/test/java/com/gitplex/server/util/findsubclassesexploded/dummy/DummyClass1.javadeleted file mode 100644index 58712d3321..0000000000--- a/core/src/test/java/com/gitplex/server/util/findsubclassesexploded/dummy/DummyClass1.java+++ /dev/null@@ -1,10 +0,0 @@-package com.gitplex.server.util.findsubclassesexploded.dummy;--import com.gitplex.server.util.findsubclassesexploded.DummyAbstractClass;--public class DummyClass1 extends DummyAbstractClass {-- public void test() {- }--}diff --git a/core/src/test/java/com/gitplex/server/util/findsubclassesexploded/dummy/DummyClass2.java b/core/src/test/java/com/gitplex/server/util/findsubclassesexploded/dummy/DummyClass2.javadeleted file mode 100644index 4484db9ebd..0000000000--- a/core/src/test/java/com/gitplex/server/util/findsubclassesexploded/dummy/DummyClass2.java+++ /dev/null@@ -1,10 +0,0 @@-package com.gitplex.server.util.findsubclassesexploded.dummy;--import com.gitplex.server.util.findsubclassesexploded.DummyAbstractClass;--public class DummyClass2 extends DummyAbstractClass {-- public void test() {- }--}diff --git a/core/src/test/java/com/gitplex/server/util/findsubclassesexploded/dummy/DummyClass3.java b/core/src/test/java/com/gitplex/server/util/findsubclassesexploded/dummy/DummyClass3.javadeleted file mode 100644index 4e96c682b4..0000000000--- a/core/src/test/java/com/gitplex/server/util/findsubclassesexploded/dummy/DummyClass3.java+++ /dev/null@@ -1,11 +0,0 @@-package com.gitplex.server.util.findsubclassesexploded.dummy;--import com.gitplex.server.util.findsubclassesexploded.DummyInterface;--public class DummyClass3 implements DummyInterface {-- public void test() {-- }--}diff --git a/core/src/test/java/com/gitplex/server/util/findsubclassesexploded/dummy/DummyClass4.java b/core/src/test/java/com/gitplex/server/util/findsubclassesexploded/dummy/DummyClass4.javadeleted file mode 100644index e50a6a2bbf..0000000000--- a/core/src/test/java/com/gitplex/server/util/findsubclassesexploded/dummy/DummyClass4.java+++ /dev/null@@ -1,9 +0,0 @@-package com.gitplex.server.util.findsubclassesexploded.dummy;--public class DummyClass4 {-- public void test() {-- }--}diff --git a/core/src/test/java/com/gitplex/server/util/findsubclassesexploded/dummy2/DummyClass5.java b/core/src/test/java/com/gitplex/server/util/findsubclassesexploded/dummy2/DummyClass5.javadeleted file mode 100644index b8edcbff1d..0000000000--- a/core/src/test/java/com/gitplex/server/util/findsubclassesexploded/dummy2/DummyClass5.java+++ /dev/null@@ -1,10 +0,0 @@-package com.gitplex.server.util.findsubclassesexploded.dummy2;--import com.gitplex.server.util.findsubclassesexploded.DummyAbstractClass;--public class DummyClass5 extends DummyAbstractClass {-- public void test() {- }--}diff --git a/core/src/test/java/com/gitplex/server/util/pattern/WildcardUtilsTest.java b/core/src/test/java/com/gitplex/server/util/pattern/WildcardUtilsTest.javadeleted file mode 100644index dccb6c7d4c..0000000000--- a/core/src/test/java/com/gitplex/server/util/pattern/WildcardUtilsTest.java+++ /dev/null@@ -1,55 +0,0 @@-package com.gitplex.server.util.pattern;--import static com.gitplex.server.util.stringmatch.WildcardUtils.*;-import static org.junit.Assert.*;--import org.junit.Test;--public class WildcardUtilsTest {-- @Test- public void shouldMatchPath() {- assertTrue(matchPath("**//*.java", "com/example/Test.java"));- assertFalse(matchPath("**/*.java", "com/example/test.c"));- assertFalse(matchPath("com/*.java", "com/example/Test.java"));- assertTrue(matchPath("com/**//*.java", "com/example/Test.java"));- assertTrue(matchPath("com/*.java", "com/Test.java"));- assertTrue(matchPath("src///**/*.java", "src/com/example/Test.java"));- assertFalse(matchPath("/src/**/*.java", "src/com/example/Test.java"));- assertFalse(matchPath("src/**////*.java", "resource/com/example/Test.java"));- }-- @Test- public void shouldMatchString() {- assertTrue(matchString("hello?world", "hello world"));- assertFalse(matchString("hello?world", "hello world"));- assertTrue(matchString("hello*world", "hello world"));- assertTrue(matchString("**/*.java", "com/example/Test.java"));- assertFalse(matchString("**/*.java", "com/example/test.c"));- assertTrue(matchString("com/*.java", "com/example/Test.java"));- assertTrue(matchString("com/**/*.java", "com/example/Test.java"));- assertTrue(matchString("com/*.java", "com/Test.java"));- assertTrue(matchString("src/**/*.java", "src/com/example/Test.java"));- assertFalse(matchString("src/**/*.java", "resource/com/example/Test.java"));- }-- @Test- public void testRangeOfMatch() {- assertEquals("1-3", rangeOfMatch("el", "hello").toString());- assertEquals(null, rangeOfMatch("tu", "hello"));- assertEquals("3-8", rangeOfMatch("lo*wo", "hello world").toString());- assertEquals("3-9", rangeOfMatch("lo*w?r", "hello world").toString());- assertEquals("12-37", rangeOfMatch("this*my*program", "hello world this is my first program").toString());- }-- @Test- public void shouldApplyPattern() {- assertEquals("he*?lo:1-5", applyPattern("E*?l", "hello", false).toString());- assertEquals(null, applyPattern("*he ?d", "hello world", false));- assertEquals("*he*ld 2:0-6", applyPattern("*hE*ld", "hello world 2", false).toString());- assertEquals("hello:0-0", applyPattern("", "hello", false).toString());- assertEquals("*:0-1", applyPattern("*", "hello", false).toString());- assertEquals("**:0-2", applyPattern("**", "hello", false).toString());- }--}diff --git a/pom.xml b/pom.xmlindex c3ab6e76ff..493547a76d 100644--- a/pom.xml+++ b/pom.xml@@ -64,16 +64,6 @@<artifactId>commons-codec</artifactId><version>1.7</version></dependency>- <dependency>- <groupId>com.google.guava</groupId>- <artifactId>guava</artifactId>- <version>16.0.1</version>- </dependency>- <dependency>- <groupId>org.quartz-scheduler</groupId>- <artifactId>quartz</artifactId>- <version>2.2.1</version>- </dependency><dependency><groupId>org.jetbrains.xodus</groupId><artifactId>xodus-entity-store</artifactId>@@ -109,11 +99,6 @@<artifactId>joda-time</artifactId><version>2.2</version></dependency>- <dependency>- <groupId>org.apache.commons</groupId>- <artifactId>commons-collections4</artifactId>- <version>4.1</version>- </dependency><dependency><groupId>org.javassist</groupId><artifactId>javassist</artifactId>@@ -124,11 +109,6 @@<artifactId>commons-compress</artifactId><version>1.8</version></dependency>- <dependency>- <groupId>org.apache.ant</groupId>- <artifactId>ant</artifactId>- <version>1.9.1</version>- </dependency><dependency><groupId>org.eclipse.jetty</groupId><artifactId>jetty-server</artifactId>diff --git a/product/src/main/java/com/gitplex/server/product/DefaultServerConfig.java b/product/src/main/java/com/gitplex/server/product/DefaultServerConfig.javaindex 12b67a6545..2415b3b0e4 100644--- a/product/src/main/java/com/gitplex/server/product/DefaultServerConfig.java+++ b/product/src/main/java/com/gitplex/server/product/DefaultServerConfig.java@@ -6,9 +6,9 @@ import javax.inject.Inject;import javax.inject.Singleton;import com.gitplex.launcher.bootstrap.Bootstrap;-import com.gitplex.server.util.StringUtils;import com.gitplex.server.util.serverconfig.ServerConfig;import com.gitplex.server.util.serverconfig.SslConfig;+import com.gitplex.utils.StringUtils;@Singletonpublic class DefaultServerConfig implements ServerConfig {diff --git a/product/src/main/java/com/gitplex/server/product/ProductModule.java b/product/src/main/java/com/gitplex/server/product/ProductModule.javaindex 119b73416f..a76094afbb 100644--- a/product/src/main/java/com/gitplex/server/product/ProductModule.java+++ b/product/src/main/java/com/gitplex/server/product/ProductModule.java@@ -7,11 +7,11 @@ import org.hibernate.cfg.Environment;import com.gitplex.launcher.loader.AbstractPluginModule;import com.gitplex.launcher.bootstrap.Bootstrap;import com.gitplex.server.persistence.HibernateProperties;-import com.gitplex.server.util.FileUtils;-import com.gitplex.server.util.StringUtils;+import com.gitplex.utils.FileUtils;import com.gitplex.server.util.jetty.ServerConfigurator;import com.gitplex.server.util.jetty.ServletConfigurator;import com.gitplex.server.util.serverconfig.ServerConfig;+import com.gitplex.utils.StringUtils;public class ProductModule extends AbstractPluginModule {diff --git a/search/src/main/java/com/gitplex/server/search/DefaultIndexManager.java b/search/src/main/java/com/gitplex/server/search/DefaultIndexManager.javaindex af7190900f..19f4e2ab52 100644--- a/search/src/main/java/com/gitplex/server/search/DefaultIndexManager.java+++ b/search/src/main/java/com/gitplex/server/search/DefaultIndexManager.java@@ -78,8 +78,8 @@ import com.gitplex.server.persistence.annotation.Sessional;import com.gitplex.server.util.BatchWorker;import com.gitplex.server.util.ContentDetector;import com.gitplex.server.util.IndexResult;-import com.gitplex.server.util.StringUtils;-import com.gitplex.server.util.concurrent.Prioritized;+import com.gitplex.utils.StringUtils;+import com.gitplex.utils.concurrent.Prioritized;import com.google.common.base.Preconditions;import com.google.common.base.Throwables;diff --git a/search/src/main/java/com/gitplex/server/search/hit/FileHit.java b/search/src/main/java/com/gitplex/server/search/hit/FileHit.javaindex ade3cbd6b3..fee6457adf 100644--- a/search/src/main/java/com/gitplex/server/search/hit/FileHit.java+++ b/search/src/main/java/com/gitplex/server/search/hit/FileHit.java@@ -7,7 +7,7 @@ import org.apache.wicket.Component;import org.apache.wicket.markup.html.image.Image;import org.apache.wicket.request.resource.PackageResourceReference;-import com.gitplex.jsymbol.Range;+import com.gitplex.utils.Range;import com.gitplex.jsymbol.util.HighlightableLabel;import com.gitplex.jsymbol.util.NoAntiCacheImage;diff --git a/search/src/main/java/com/gitplex/server/search/hit/PathHit.java b/search/src/main/java/com/gitplex/server/search/hit/PathHit.javaindex 05956613da..38fd8c899b 100644--- a/search/src/main/java/com/gitplex/server/search/hit/PathHit.java+++ b/search/src/main/java/com/gitplex/server/search/hit/PathHit.java@@ -6,7 +6,7 @@ import org.apache.wicket.Component;import org.apache.wicket.markup.html.image.Image;import org.apache.wicket.request.resource.PackageResourceReference;-import com.gitplex.jsymbol.Range;+import com.gitplex.utils.Range;import com.gitplex.jsymbol.util.HighlightableLabel;import com.gitplex.jsymbol.util.NoAntiCacheImage;diff --git a/search/src/main/java/com/gitplex/server/search/hit/SymbolHit.java b/search/src/main/java/com/gitplex/server/search/hit/SymbolHit.javaindex 9d43371dc8..0e87c6f859 100644--- a/search/src/main/java/com/gitplex/server/search/hit/SymbolHit.java+++ b/search/src/main/java/com/gitplex/server/search/hit/SymbolHit.java@@ -5,7 +5,7 @@ import javax.annotation.Nullable;import org.apache.wicket.Component;import org.apache.wicket.markup.html.image.Image;-import com.gitplex.jsymbol.Range;+import com.gitplex.utils.Range;import com.gitplex.jsymbol.Symbol;public class SymbolHit extends QueryHit {diff --git a/search/src/main/java/com/gitplex/server/search/hit/TextHit.java b/search/src/main/java/com/gitplex/server/search/hit/TextHit.javaindex a6c94be007..5b6327b3e3 100644--- a/search/src/main/java/com/gitplex/server/search/hit/TextHit.java+++ b/search/src/main/java/com/gitplex/server/search/hit/TextHit.java@@ -5,7 +5,7 @@ import org.apache.wicket.Component;import org.apache.wicket.markup.html.image.Image;import org.apache.wicket.request.resource.PackageResourceReference;-import com.gitplex.jsymbol.Range;+import com.gitplex.utils.Range;import com.gitplex.jsymbol.TokenPosition;import com.gitplex.jsymbol.util.HighlightableLabel;import com.gitplex.jsymbol.util.NoAntiCacheImage;diff --git a/search/src/main/java/com/gitplex/server/search/query/FileQuery.java b/search/src/main/java/com/gitplex/server/search/query/FileQuery.javaindex a2b7205c9d..93f213fe96 100644--- a/search/src/main/java/com/gitplex/server/search/query/FileQuery.java+++ b/search/src/main/java/com/gitplex/server/search/query/FileQuery.java@@ -13,10 +13,10 @@ import org.apache.lucene.search.IndexSearcher;import org.apache.lucene.search.WildcardQuery;import org.eclipse.jgit.treewalk.TreeWalk;-import com.gitplex.jsymbol.Range;+import com.gitplex.utils.Range;+import com.gitplex.utils.stringmatch.WildcardUtils;import com.gitplex.server.search.hit.FileHit;import com.gitplex.server.search.hit.QueryHit;-import com.gitplex.server.util.stringmatch.WildcardUtils;import com.google.common.base.Preconditions;import com.google.common.base.Splitter;diff --git a/search/src/main/java/com/gitplex/server/search/query/PathQuery.java b/search/src/main/java/com/gitplex/server/search/query/PathQuery.javaindex 4e946a48ee..3dc53986da 100644--- a/search/src/main/java/com/gitplex/server/search/query/PathQuery.java+++ b/search/src/main/java/com/gitplex/server/search/query/PathQuery.java@@ -15,8 +15,8 @@ import org.eclipse.jgit.treewalk.TreeWalk;import com.gitplex.server.search.hit.PathHit;import com.gitplex.server.search.hit.QueryHit;-import com.gitplex.server.util.PathUtils;-import com.gitplex.jsymbol.Range;+import com.gitplex.utils.PathUtils;+import com.gitplex.utils.Range;public class PathQuery extends BlobQuery {diff --git a/search/src/main/java/com/gitplex/server/search/query/SymbolQuery.java b/search/src/main/java/com/gitplex/server/search/query/SymbolQuery.javaindex 5a413c89e7..ee098088b7 100644--- a/search/src/main/java/com/gitplex/server/search/query/SymbolQuery.java+++ b/search/src/main/java/com/gitplex/server/search/query/SymbolQuery.java@@ -16,13 +16,13 @@ import org.apache.lucene.search.WildcardQuery;import org.eclipse.jgit.lib.ObjectId;import org.eclipse.jgit.treewalk.TreeWalk;-import com.gitplex.jsymbol.Range;+import com.gitplex.utils.Range;+import com.gitplex.utils.stringmatch.WildcardUtils;import com.gitplex.jsymbol.Symbol;import com.gitplex.server.GitPlex;import com.gitplex.server.search.SearchManager;import com.gitplex.server.search.hit.QueryHit;import com.gitplex.server.search.hit.SymbolHit;-import com.gitplex.server.util.stringmatch.WildcardUtils;import com.google.common.base.Preconditions;import com.google.common.base.Splitter;diff --git a/search/src/main/java/com/gitplex/server/search/query/TextQuery.java b/search/src/main/java/com/gitplex/server/search/query/TextQuery.javaindex 1f96012ed7..9fe66d4c4d 100644--- a/search/src/main/java/com/gitplex/server/search/query/TextQuery.java+++ b/search/src/main/java/com/gitplex/server/search/query/TextQuery.java@@ -20,7 +20,7 @@ import org.apache.lucene.search.WildcardQuery;import org.eclipse.jgit.lib.ObjectLoader;import org.eclipse.jgit.treewalk.TreeWalk;-import com.gitplex.jsymbol.Range;+import com.gitplex.utils.Range;import com.gitplex.jsymbol.TokenPosition;import com.gitplex.server.search.IndexConstants;import com.gitplex.server.search.hit.QueryHit;diff --git a/web/src/main/java/com/gitplex/server/web/GitPlexWebApplication.java b/web/src/main/java/com/gitplex/server/web/GitPlexWebApplication.javaindex 59c3e7fd60..0c0232c973 100644--- a/web/src/main/java/com/gitplex/server/web/GitPlexWebApplication.java+++ b/web/src/main/java/com/gitplex/server/web/GitPlexWebApplication.java@@ -47,7 +47,6 @@ import org.apache.wicket.util.IProvider;import com.gitplex.launcher.bootstrap.Bootstrap;import com.gitplex.launcher.loader.AppLoader;-import com.gitplex.server.util.ExceptionUtils;import com.gitplex.server.web.page.base.BasePage;import com.gitplex.server.web.page.dashboard.DashboardPage;import com.gitplex.server.web.page.error.BaseErrorPage;@@ -56,6 +55,7 @@ import com.gitplex.server.web.page.error.UnexpectedExceptionPage;import com.gitplex.server.web.util.AbsoluteUrlRenderer;import com.gitplex.server.web.util.resourcebundle.ResourceBundleReferences;import com.gitplex.server.web.websocket.WebSocketManager;+import com.gitplex.utils.ExceptionUtils;import de.agilecoders.wicket.core.settings.BootstrapSettings;diff --git a/web/src/main/java/com/gitplex/server/web/assets/js/codemirror/ModeUrlResourceReference.java b/web/src/main/java/com/gitplex/server/web/assets/js/codemirror/ModeUrlResourceReference.javaindex 334a8d7d4e..9e59568362 100644--- a/web/src/main/java/com/gitplex/server/web/assets/js/codemirror/ModeUrlResourceReference.java+++ b/web/src/main/java/com/gitplex/server/web/assets/js/codemirror/ModeUrlResourceReference.java@@ -8,7 +8,7 @@ import org.apache.wicket.request.cycle.RequestCycle;import org.apache.wicket.request.mapper.parameter.PageParameters;import org.apache.wicket.request.resource.JavaScriptResourceReference;-import com.gitplex.server.util.StringUtils;+import com.gitplex.utils.StringUtils;import de.agilecoders.wicket.webjars.request.resource.WebjarsJavaScriptResourceReference;diff --git a/web/src/main/java/com/gitplex/server/web/behavior/BranchPatternAssistBehavior.java b/web/src/main/java/com/gitplex/server/web/behavior/BranchPatternAssistBehavior.javaindex 1cf2744852..530f4c598d 100644--- a/web/src/main/java/com/gitplex/server/web/behavior/BranchPatternAssistBehavior.java+++ b/web/src/main/java/com/gitplex/server/web/behavior/BranchPatternAssistBehavior.java@@ -9,7 +9,7 @@ import org.apache.wicket.model.IModel;import com.gitplex.codeassist.InputCompletion;import com.gitplex.codeassist.InputStatus;import com.gitplex.codeassist.InputSuggestion;-import com.gitplex.jsymbol.Range;+import com.gitplex.utils.Range;import com.gitplex.server.model.Project;import com.gitplex.server.web.behavior.inputassist.InputAssistBehavior;import com.gitplex.server.web.util.SuggestionUtils;diff --git a/web/src/main/java/com/gitplex/server/web/behavior/PathPatternAssistBehavior.java b/web/src/main/java/com/gitplex/server/web/behavior/PathPatternAssistBehavior.javaindex 63b616f58a..ac4883ebbb 100644--- a/web/src/main/java/com/gitplex/server/web/behavior/PathPatternAssistBehavior.java+++ b/web/src/main/java/com/gitplex/server/web/behavior/PathPatternAssistBehavior.java@@ -9,7 +9,7 @@ import org.apache.wicket.model.IModel;import com.gitplex.codeassist.InputCompletion;import com.gitplex.codeassist.InputStatus;import com.gitplex.codeassist.InputSuggestion;-import com.gitplex.jsymbol.Range;+import com.gitplex.utils.Range;import com.gitplex.server.model.Project;import com.gitplex.server.web.behavior.inputassist.InputAssistBehavior;import com.gitplex.server.web.util.SuggestionUtils;diff --git a/web/src/main/java/com/gitplex/server/web/behavior/TagPatternAssistBehavior.java b/web/src/main/java/com/gitplex/server/web/behavior/TagPatternAssistBehavior.javaindex 67cb7d1f8f..9e882a8214 100644--- a/web/src/main/java/com/gitplex/server/web/behavior/TagPatternAssistBehavior.java+++ b/web/src/main/java/com/gitplex/server/web/behavior/TagPatternAssistBehavior.java@@ -9,7 +9,7 @@ import org.apache.wicket.model.IModel;import com.gitplex.codeassist.InputCompletion;import com.gitplex.codeassist.InputStatus;import com.gitplex.codeassist.InputSuggestion;-import com.gitplex.jsymbol.Range;+import com.gitplex.utils.Range;import com.gitplex.server.model.Project;import com.gitplex.server.web.behavior.inputassist.InputAssistBehavior;import com.gitplex.server.web.util.SuggestionUtils;diff --git a/web/src/main/java/com/gitplex/server/web/behavior/inputassist/ANTLRAssistBehavior.java b/web/src/main/java/com/gitplex/server/web/behavior/inputassist/ANTLRAssistBehavior.javaindex ad31d5dec1..7144089ecc 100644--- a/web/src/main/java/com/gitplex/server/web/behavior/inputassist/ANTLRAssistBehavior.java+++ b/web/src/main/java/com/gitplex/server/web/behavior/inputassist/ANTLRAssistBehavior.java@@ -27,8 +27,8 @@ import com.gitplex.codeassist.InputStatus;import com.gitplex.codeassist.InputSuggestion;import com.gitplex.codeassist.ParentedElement;import com.gitplex.codeassist.grammar.ElementSpec;-import com.gitplex.jsymbol.Range;-import com.gitplex.server.util.StringUtils;+import com.gitplex.utils.Range;+import com.gitplex.utils.StringUtils;@SuppressWarnings("serial")public abstract class ANTLRAssistBehavior extends InputAssistBehavior {diff --git a/web/src/main/java/com/gitplex/server/web/behavior/inputassist/AssistPanel.java b/web/src/main/java/com/gitplex/server/web/behavior/inputassist/AssistPanel.javaindex efb21e0af4..675527c5d5 100644--- a/web/src/main/java/com/gitplex/server/web/behavior/inputassist/AssistPanel.java+++ b/web/src/main/java/com/gitplex/server/web/behavior/inputassist/AssistPanel.java@@ -13,7 +13,7 @@ import org.apache.wicket.markup.repeater.RepeatingView;import com.gitplex.codeassist.InputCompletion;import com.gitplex.codeassist.InputStatus;-import com.gitplex.jsymbol.Range;+import com.gitplex.utils.Range;import com.gitplex.server.web.behavior.infinitescroll.InfiniteScrollBehavior;@SuppressWarnings("serial")diff --git a/web/src/main/java/com/gitplex/server/web/behavior/inputassist/InputAssistBehavior.java b/web/src/main/java/com/gitplex/server/web/behavior/inputassist/InputAssistBehavior.javaindex 56b29f24f8..de0f26c1b5 100644--- a/web/src/main/java/com/gitplex/server/web/behavior/inputassist/InputAssistBehavior.java+++ b/web/src/main/java/com/gitplex/server/web/behavior/inputassist/InputAssistBehavior.java@@ -22,8 +22,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;import com.gitplex.launcher.loader.AppLoader;import com.gitplex.codeassist.InputCompletion;import com.gitplex.codeassist.InputStatus;-import com.gitplex.jsymbol.Range;-import com.gitplex.server.util.RangeUtils;+import com.gitplex.utils.Range;+import com.gitplex.utils.RangeUtils;import com.gitplex.server.web.behavior.AbstractPostAjaxBehavior;import com.gitplex.server.web.component.floating.AlignPlacement;import com.gitplex.server.web.component.floating.AlignTarget;diff --git a/web/src/main/java/com/gitplex/server/web/behavior/sortable/SortPosition.java b/web/src/main/java/com/gitplex/server/web/behavior/sortable/SortPosition.javaindex 94a7accabb..362c8c0ead 100644--- a/web/src/main/java/com/gitplex/server/web/behavior/sortable/SortPosition.java+++ b/web/src/main/java/com/gitplex/server/web/behavior/sortable/SortPosition.java@@ -21,6 +21,7 @@ public class SortPosition {return itemIndex;}+ @SuppressWarnings("deprecation")@Overridepublic String toString() {return Objects.toStringHelper(this)diff --git a/web/src/main/java/com/gitplex/server/web/component/comment/CommentInput.java b/web/src/main/java/com/gitplex/server/web/component/comment/CommentInput.javaindex 7373ed5b00..932c90bb0a 100644--- a/web/src/main/java/com/gitplex/server/web/component/comment/CommentInput.java+++ b/web/src/main/java/com/gitplex/server/web/component/comment/CommentInput.java@@ -16,13 +16,13 @@ import com.gitplex.server.persistence.dao.Dao;import com.gitplex.server.persistence.dao.EntityCriteria;import com.gitplex.server.security.ProjectPrivilege;import com.gitplex.server.security.SecurityUtils;-import com.gitplex.server.util.StringUtils;import com.gitplex.server.util.facade.UserFacade;-import com.gitplex.server.util.matchscore.MatchScoreProvider;-import com.gitplex.server.util.matchscore.MatchScoreUtils;import com.gitplex.server.web.component.markdown.MarkdownEditor;import com.gitplex.server.web.component.markdown.PullRequestReferenceSupport;import com.gitplex.server.web.component.markdown.UserMentionSupport;+import com.gitplex.utils.StringUtils;+import com.gitplex.utils.matchscore.MatchScoreProvider;+import com.gitplex.utils.matchscore.MatchScoreUtils;@SuppressWarnings("serial")public abstract class CommentInput extends MarkdownEditor {diff --git a/web/src/main/java/com/gitplex/server/web/component/comment/ProjectAttachmentSupport.java b/web/src/main/java/com/gitplex/server/web/component/comment/ProjectAttachmentSupport.javaindex 2fc5cbc672..a4cfdc82df 100644--- a/web/src/main/java/com/gitplex/server/web/component/comment/ProjectAttachmentSupport.java+++ b/web/src/main/java/com/gitplex/server/web/component/comment/ProjectAttachmentSupport.java@@ -16,12 +16,12 @@ import com.gitplex.server.manager.ProjectManager;import com.gitplex.server.model.Project;import com.gitplex.server.persistence.UnitOfWork;import com.gitplex.server.security.SecurityUtils;-import com.gitplex.server.util.FileUtils;-import com.gitplex.server.util.StringUtils;+import com.gitplex.utils.FileUtils;import com.gitplex.server.util.facade.ProjectFacade;import com.gitplex.server.web.component.markdown.AttachmentSupport;import com.gitplex.server.web.util.resource.AttachmentResource;import com.gitplex.server.web.util.resource.AttachmentResourceReference;+import com.gitplex.utils.StringUtils;import com.google.common.base.Preconditions;import com.google.common.base.Throwables;diff --git a/web/src/main/java/com/gitplex/server/web/component/commitmessage/ExpandableCommitMessagePanel.java b/web/src/main/java/com/gitplex/server/web/component/commitmessage/ExpandableCommitMessagePanel.javaindex d62dfd2462..0e30b6fbe6 100644--- a/web/src/main/java/com/gitplex/server/web/component/commitmessage/ExpandableCommitMessagePanel.java+++ b/web/src/main/java/com/gitplex/server/web/component/commitmessage/ExpandableCommitMessagePanel.java@@ -18,10 +18,10 @@ import org.unbescape.html.HtmlEscape;import com.gitplex.server.git.GitUtils;import com.gitplex.server.model.Project;-import com.gitplex.server.util.Highlighter;-import com.gitplex.server.util.Transformer;import com.gitplex.server.web.component.link.ViewStateAwarePageLink;import com.gitplex.server.web.page.project.commit.CommitDetailPage;+import com.gitplex.utils.Highlighter;+import com.gitplex.utils.Transformer;@SuppressWarnings("serial")public class ExpandableCommitMessagePanel extends Panel {diff --git a/web/src/main/java/com/gitplex/server/web/component/diff/blob/image/ImageDiffPanel.java b/web/src/main/java/com/gitplex/server/web/component/diff/blob/image/ImageDiffPanel.javaindex 1725cd7db4..2bf353ff5b 100644--- a/web/src/main/java/com/gitplex/server/web/component/diff/blob/image/ImageDiffPanel.java+++ b/web/src/main/java/com/gitplex/server/web/component/diff/blob/image/ImageDiffPanel.java@@ -12,7 +12,7 @@ import com.gitplex.server.git.Blob;import com.gitplex.server.git.BlobChange;import com.gitplex.server.git.BlobIdent;import com.gitplex.server.git.GitUtils;-import com.gitplex.server.util.Provider;+import com.gitplex.utils.Provider;@SuppressWarnings("serial")public class ImageDiffPanel extends Panel {diff --git a/web/src/main/java/com/gitplex/server/web/component/diff/blob/text/TextDiffPanel.java b/web/src/main/java/com/gitplex/server/web/component/diff/blob/text/TextDiffPanel.javaindex 330fd39016..2d516b573d 100644--- a/web/src/main/java/com/gitplex/server/web/component/diff/blob/text/TextDiffPanel.java+++ b/web/src/main/java/com/gitplex/server/web/component/diff/blob/text/TextDiffPanel.java@@ -37,7 +37,9 @@ import org.unbescape.javascript.JavaScriptEscape;import com.fasterxml.jackson.core.JsonProcessingException;import com.fasterxml.jackson.databind.ObjectMapper;-import com.gitplex.jsymbol.Range;+import com.gitplex.utils.Range;+import com.gitplex.utils.RangeUtils;+import com.gitplex.utils.StringUtils;import com.gitplex.jsyntax.TextToken;import com.gitplex.jsyntax.Tokenized;import com.gitplex.server.GitPlex;@@ -55,8 +57,6 @@ import com.gitplex.server.model.support.MarkPos;import com.gitplex.server.model.support.TextRange;import com.gitplex.server.search.hit.QueryHit;import com.gitplex.server.security.SecurityUtils;-import com.gitplex.server.util.RangeUtils;-import com.gitplex.server.util.StringUtils;import com.gitplex.server.util.diff.DiffBlock;import com.gitplex.server.util.diff.DiffMatchPatch.Operation;import com.gitplex.server.util.diff.DiffUtils;diff --git a/web/src/main/java/com/gitplex/server/web/component/diff/revision/RevisionDiffPanel.java b/web/src/main/java/com/gitplex/server/web/component/diff/revision/RevisionDiffPanel.javaindex 9176142933..c97a92bf6c 100644--- a/web/src/main/java/com/gitplex/server/web/component/diff/revision/RevisionDiffPanel.java+++ b/web/src/main/java/com/gitplex/server/web/component/diff/revision/RevisionDiffPanel.java@@ -57,7 +57,6 @@ import org.eclipse.jgit.lib.ObjectId;import com.gitplex.codeassist.InputCompletion;import com.gitplex.codeassist.InputStatus;import com.gitplex.codeassist.InputSuggestion;-import com.gitplex.jsymbol.Range;import com.gitplex.jsymbol.util.NoAntiCacheImage;import com.gitplex.server.GitPlex;import com.gitplex.server.git.Blob;@@ -74,11 +73,8 @@ import com.gitplex.server.model.support.MarkPos;import com.gitplex.server.model.support.ProjectAndRevision;import com.gitplex.server.search.IndexManager;import com.gitplex.server.security.SecurityUtils;-import com.gitplex.server.util.PathComparator;-import com.gitplex.server.util.StringUtils;import com.gitplex.server.util.diff.DiffUtils;import com.gitplex.server.util.diff.WhitespaceOption;-import com.gitplex.server.util.stringmatch.WildcardUtils;import com.gitplex.server.web.WebConstants;import com.gitplex.server.web.behavior.inputassist.InputAssistBehavior;import com.gitplex.server.web.component.comment.CodeCommentPanel;@@ -96,6 +92,10 @@ import com.gitplex.server.web.page.project.compare.RevisionComparePage;import com.gitplex.server.web.util.SuggestionUtils;import com.gitplex.server.web.util.ajaxlistener.ConfirmLeaveListener;import com.gitplex.server.web.websocket.PageDataChanged;+import com.gitplex.utils.PathComparator;+import com.gitplex.utils.Range;+import com.gitplex.utils.StringUtils;+import com.gitplex.utils.stringmatch.WildcardUtils;import com.google.common.base.Objects;import com.google.common.collect.Lists;diff --git a/web/src/main/java/com/gitplex/server/web/component/groupchoice/GroupChoiceProvider.java b/web/src/main/java/com/gitplex/server/web/component/groupchoice/GroupChoiceProvider.javaindex 260bab538f..cf4ccfd319 100644--- a/web/src/main/java/com/gitplex/server/web/component/groupchoice/GroupChoiceProvider.java+++ b/web/src/main/java/com/gitplex/server/web/component/groupchoice/GroupChoiceProvider.java@@ -7,11 +7,11 @@ import java.util.List;import com.gitplex.server.GitPlex;import com.gitplex.server.manager.CacheManager;import com.gitplex.server.util.facade.GroupFacade;-import com.gitplex.server.util.matchscore.MatchScoreProvider;-import com.gitplex.server.util.matchscore.MatchScoreUtils;import com.gitplex.server.web.WebConstants;import com.gitplex.server.web.component.select2.Response;import com.gitplex.server.web.component.select2.ResponseFiller;+import com.gitplex.utils.matchscore.MatchScoreProvider;+import com.gitplex.utils.matchscore.MatchScoreUtils;public class GroupChoiceProvider extends AbstractGroupChoiceProvider {diff --git a/web/src/main/java/com/gitplex/server/web/component/markdown/InsertUrlPanel.java b/web/src/main/java/com/gitplex/server/web/component/markdown/InsertUrlPanel.javaindex 45acdb7eb8..b986cbadd8 100644--- a/web/src/main/java/com/gitplex/server/web/component/markdown/InsertUrlPanel.java+++ b/web/src/main/java/com/gitplex/server/web/component/markdown/InsertUrlPanel.java@@ -40,13 +40,13 @@ import org.eclipse.jgit.lib.ObjectId;import com.gitplex.server.git.BlobIdent;import com.gitplex.server.git.BlobIdentFilter;import com.gitplex.server.model.Project;-import com.gitplex.server.util.FileUtils;-import com.gitplex.server.util.PathUtils;import com.gitplex.server.web.component.floating.FloatingPanel;import com.gitplex.server.web.component.link.DropdownLink;import com.gitplex.server.web.component.projectfilepicker.ProjectFilePicker;import com.gitplex.server.web.page.project.blob.ProjectBlobPage;import com.gitplex.server.web.page.project.blob.render.BlobRenderContext;+import com.gitplex.utils.FileUtils;+import com.gitplex.utils.PathUtils;import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;diff --git a/web/src/main/java/com/gitplex/server/web/component/markdown/MarkdownViewer.java b/web/src/main/java/com/gitplex/server/web/component/markdown/MarkdownViewer.javaindex 487534f295..39b75a7aa4 100644--- a/web/src/main/java/com/gitplex/server/web/component/markdown/MarkdownViewer.java+++ b/web/src/main/java/com/gitplex/server/web/component/markdown/MarkdownViewer.java@@ -18,8 +18,8 @@ import org.hibernate.StaleStateException;import com.gitplex.launcher.loader.AppLoader;import com.gitplex.server.manager.MarkdownManager;-import com.gitplex.server.util.StringUtils;import com.gitplex.server.web.behavior.AbstractPostAjaxBehavior;+import com.gitplex.utils.StringUtils;import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;diff --git a/web/src/main/java/com/gitplex/server/web/component/pathselector/PathSelector.java b/web/src/main/java/com/gitplex/server/web/component/pathselector/PathSelector.javaindex 5a64749fcc..5a371745e2 100644--- a/web/src/main/java/com/gitplex/server/web/component/pathselector/PathSelector.java+++ b/web/src/main/java/com/gitplex/server/web/component/pathselector/PathSelector.java@@ -30,9 +30,9 @@ import org.eclipse.jgit.treewalk.TreeWalk;import com.gitplex.server.git.BlobIdent;import com.gitplex.server.model.Project;-import com.gitplex.server.util.StringUtils;import com.gitplex.server.web.component.BlobIcon;import com.gitplex.server.web.component.link.PreventDefaultAjaxLink;+import com.gitplex.utils.StringUtils;@SuppressWarnings("serial")public abstract class PathSelector extends Panel {diff --git a/web/src/main/java/com/gitplex/server/web/component/projectselector/ProjectSelector.java b/web/src/main/java/com/gitplex/server/web/component/projectselector/ProjectSelector.javaindex 60b36a2881..32e4be8522 100644--- a/web/src/main/java/com/gitplex/server/web/component/projectselector/ProjectSelector.java+++ b/web/src/main/java/com/gitplex/server/web/component/projectselector/ProjectSelector.java@@ -28,12 +28,12 @@ import org.apache.wicket.request.mapper.parameter.PageParameters;import com.gitplex.server.GitPlex;import com.gitplex.server.manager.ProjectManager;import com.gitplex.server.model.Project;-import com.gitplex.server.util.matchscore.MatchScoreProvider;-import com.gitplex.server.util.matchscore.MatchScoreUtils;import com.gitplex.server.web.behavior.AbstractPostAjaxBehavior;import com.gitplex.server.web.behavior.InputChangeBehavior;import com.gitplex.server.web.component.link.PreventDefaultAjaxLink;import com.gitplex.server.web.page.project.blob.ProjectBlobPage;+import com.gitplex.utils.matchscore.MatchScoreProvider;+import com.gitplex.utils.matchscore.MatchScoreUtils;@SuppressWarnings("serial")public abstract class ProjectSelector extends Panel {diff --git a/web/src/main/java/com/gitplex/server/web/component/requestreviewer/ReviewerProvider.java b/web/src/main/java/com/gitplex/server/web/component/requestreviewer/ReviewerProvider.javaindex 367ac6e18a..56aba69263 100644--- a/web/src/main/java/com/gitplex/server/web/component/requestreviewer/ReviewerProvider.java+++ b/web/src/main/java/com/gitplex/server/web/component/requestreviewer/ReviewerProvider.java@@ -13,11 +13,11 @@ import com.gitplex.server.security.ProjectPrivilege;import com.gitplex.server.security.SecurityUtils;import com.gitplex.server.util.QualityCheckStatus;import com.gitplex.server.util.facade.UserFacade;-import com.gitplex.server.util.matchscore.MatchScoreProvider;-import com.gitplex.server.util.matchscore.MatchScoreUtils;import com.gitplex.server.web.WebConstants;import com.gitplex.server.web.component.select2.Response;import com.gitplex.server.web.component.userchoice.AbstractUserChoiceProvider;+import com.gitplex.utils.matchscore.MatchScoreProvider;+import com.gitplex.utils.matchscore.MatchScoreUtils;public class ReviewerProvider extends AbstractUserChoiceProvider {diff --git a/web/src/main/java/com/gitplex/server/web/component/userchoice/UserChoiceProvider.java b/web/src/main/java/com/gitplex/server/web/component/userchoice/UserChoiceProvider.javaindex 8e09ef74f7..2c40d2d703 100644--- a/web/src/main/java/com/gitplex/server/web/component/userchoice/UserChoiceProvider.java+++ b/web/src/main/java/com/gitplex/server/web/component/userchoice/UserChoiceProvider.java@@ -11,13 +11,13 @@ import com.gitplex.server.security.SecurityUtils;import com.gitplex.server.util.editable.annotation.UserChoice;import com.gitplex.server.util.facade.ProjectFacade;import com.gitplex.server.util.facade.UserFacade;-import com.gitplex.server.util.matchscore.MatchScoreProvider;-import com.gitplex.server.util.matchscore.MatchScoreUtils;import com.gitplex.server.web.WebConstants;import com.gitplex.server.web.component.select2.Response;import com.gitplex.server.web.component.select2.ResponseFiller;import com.gitplex.server.web.page.project.ProjectPage;import com.gitplex.server.web.util.WicketUtils;+import com.gitplex.utils.matchscore.MatchScoreProvider;+import com.gitplex.utils.matchscore.MatchScoreUtils;public class UserChoiceProvider extends AbstractUserChoiceProvider {diff --git a/web/src/main/java/com/gitplex/server/web/component/verification/VerificationDetailPanel.java b/web/src/main/java/com/gitplex/server/web/component/verification/VerificationDetailPanel.javaindex e84778d226..c6c0e09c5f 100644--- a/web/src/main/java/com/gitplex/server/web/component/verification/VerificationDetailPanel.java+++ b/web/src/main/java/com/gitplex/server/web/component/verification/VerificationDetailPanel.java@@ -19,9 +19,9 @@ import org.apache.wicket.markup.html.panel.GenericPanel;import org.apache.wicket.model.IModel;import org.apache.wicket.model.LoadableDetachableModel;-import com.gitplex.server.util.Pair;import com.gitplex.server.util.Verification;import com.gitplex.server.util.Verification.Status;+import com.gitplex.utils.Pair;@SuppressWarnings("serial")public class VerificationDetailPanel extends GenericPanel<Map<String, Verification>> {diff --git a/web/src/main/java/com/gitplex/server/web/component/wizard/ManualConfigStep.java b/web/src/main/java/com/gitplex/server/web/component/wizard/ManualConfigStep.javaindex f0bf8335f4..93738d0e49 100644--- a/web/src/main/java/com/gitplex/server/web/component/wizard/ManualConfigStep.java+++ b/web/src/main/java/com/gitplex/server/web/component/wizard/ManualConfigStep.java@@ -4,8 +4,8 @@ import java.io.Serializable;import org.apache.wicket.markup.html.form.FormComponent;-import com.gitplex.server.util.init.ManualConfig;import com.gitplex.server.web.editable.BeanContext;+import com.gitplex.utils.init.ManualConfig;@SuppressWarnings("serial")public class ManualConfigStep implements WizardStep {diff --git a/web/src/main/java/com/gitplex/server/web/editable/BeanContext.java b/web/src/main/java/com/gitplex/server/web/editable/BeanContext.javaindex cfc2c146be..6ca106d6bc 100644--- a/web/src/main/java/com/gitplex/server/web/editable/BeanContext.java+++ b/web/src/main/java/com/gitplex/server/web/editable/BeanContext.java@@ -9,7 +9,7 @@ import org.apache.wicket.model.IModel;import org.apache.wicket.model.Model;import com.gitplex.launcher.loader.AppLoader;-import com.gitplex.server.util.ClassUtils;+import com.gitplex.utils.ClassUtils;@SuppressWarnings("serial")public abstract class BeanContext<T> extends BeanDescriptor {diff --git a/web/src/main/java/com/gitplex/server/web/editable/BeanDescriptor.java b/web/src/main/java/com/gitplex/server/web/editable/BeanDescriptor.javaindex 1913b98795..797b8f34fd 100644--- a/web/src/main/java/com/gitplex/server/web/editable/BeanDescriptor.java+++ b/web/src/main/java/com/gitplex/server/web/editable/BeanDescriptor.java@@ -6,9 +6,9 @@ import java.util.ArrayList;import java.util.List;import java.util.Set;-import com.gitplex.server.util.BeanUtils;import com.gitplex.server.util.editable.EditableUtils;import com.gitplex.server.util.editable.annotation.Editable;+import com.gitplex.utils.BeanUtils;import com.google.common.collect.Sets;@SuppressWarnings("serial")diff --git a/web/src/main/java/com/gitplex/server/web/editable/DefaultEditSupportRegistry.java b/web/src/main/java/com/gitplex/server/web/editable/DefaultEditSupportRegistry.javaindex 6e7d1b33ac..677480f739 100644--- a/web/src/main/java/com/gitplex/server/web/editable/DefaultEditSupportRegistry.java+++ b/web/src/main/java/com/gitplex/server/web/editable/DefaultEditSupportRegistry.java@@ -8,8 +8,6 @@ import java.util.Set;import javax.inject.Inject;import javax.inject.Singleton;-import com.gitplex.server.util.GeneralException;-@Singletonpublic class DefaultEditSupportRegistry implements EditSupportRegistry {@@ -28,7 +26,7 @@ public class DefaultEditSupportRegistry implements EditSupportRegistry {if (editContext != null)return (BeanContext<Serializable>) editContext;}- throw new GeneralException(String.format("Unable to find edit context (bean: %s). "+ throw new RuntimeException(String.format("Unable to find edit context (bean: %s). "+ "Possible reason: forget to annotate the class with @Editable.", beanClass.getName()));}@@ -40,7 +38,7 @@ public class DefaultEditSupportRegistry implements EditSupportRegistry {if (editContext != null)return (PropertyContext<Serializable>) editContext;}- throw new GeneralException(String.format(+ throw new RuntimeException(String.format("Unable to find edit context (bean: %s, property: %s). Possible reason: forget to annotate "+ "return type of the method with @Editable.",beanClass.getName(), propertyName));diff --git a/web/src/main/java/com/gitplex/server/web/editable/PropertyDescriptor.java b/web/src/main/java/com/gitplex/server/web/editable/PropertyDescriptor.javaindex 46c0da6375..3ef3e9716a 100644--- a/web/src/main/java/com/gitplex/server/web/editable/PropertyDescriptor.java+++ b/web/src/main/java/com/gitplex/server/web/editable/PropertyDescriptor.java@@ -9,7 +9,7 @@ import javax.validation.constraints.Size;import org.hibernate.validator.constraints.NotEmpty;-import com.gitplex.server.util.BeanUtils;+import com.gitplex.utils.BeanUtils;public class PropertyDescriptor implements Serializable {diff --git a/web/src/main/java/com/gitplex/server/web/editable/filechoice/FileChoiceEditor.java b/web/src/main/java/com/gitplex/server/web/editable/filechoice/FileChoiceEditor.javaindex 0ba099831f..c23c2ae9c3 100644--- a/web/src/main/java/com/gitplex/server/web/editable/filechoice/FileChoiceEditor.java+++ b/web/src/main/java/com/gitplex/server/web/editable/filechoice/FileChoiceEditor.java@@ -11,8 +11,8 @@ import org.apache.wicket.util.convert.ConversionException;import com.gitplex.codeassist.InputCompletion;import com.gitplex.codeassist.InputStatus;import com.gitplex.codeassist.InputSuggestion;-import com.gitplex.jsymbol.Range;-import com.gitplex.server.util.ReflectionUtils;+import com.gitplex.utils.Range;+import com.gitplex.utils.ReflectionUtils;import com.gitplex.server.util.editable.annotation.FileChoice;import com.gitplex.server.web.behavior.inputassist.InputAssistBehavior;import com.gitplex.server.web.editable.ErrorContext;diff --git a/web/src/main/java/com/gitplex/server/web/editable/list/EnumListPropertyEditor.java b/web/src/main/java/com/gitplex/server/web/editable/list/EnumListPropertyEditor.javaindex 5114c940b8..458bcc3390 100644--- a/web/src/main/java/com/gitplex/server/web/editable/list/EnumListPropertyEditor.java+++ b/web/src/main/java/com/gitplex/server/web/editable/list/EnumListPropertyEditor.java@@ -17,7 +17,6 @@ import org.apache.wicket.util.convert.ConversionException;import org.json.JSONException;import org.json.JSONWriter;-import com.gitplex.server.util.WordUtils;import com.gitplex.server.util.editable.EditableUtils;import com.gitplex.server.util.editable.annotation.ExcludeValues;import com.gitplex.server.web.component.select2.ChoiceProvider;@@ -27,6 +26,7 @@ import com.gitplex.server.web.editable.ErrorContext;import com.gitplex.server.web.editable.PathSegment;import com.gitplex.server.web.editable.PropertyDescriptor;import com.gitplex.server.web.editable.PropertyEditor;+import com.gitplex.utils.WordUtils;@SuppressWarnings({"serial", "unchecked", "rawtypes"})public class EnumListPropertyEditor extends PropertyEditor<List<Enum<?>>> {diff --git a/web/src/main/java/com/gitplex/server/web/editable/list/StringListPropertyEditor.java b/web/src/main/java/com/gitplex/server/web/editable/list/StringListPropertyEditor.javaindex 786c6c6361..f7d76f2311 100644--- a/web/src/main/java/com/gitplex/server/web/editable/list/StringListPropertyEditor.java+++ b/web/src/main/java/com/gitplex/server/web/editable/list/StringListPropertyEditor.java@@ -12,7 +12,6 @@ import org.apache.wicket.util.convert.ConversionException;import org.json.JSONException;import org.json.JSONWriter;-import com.gitplex.server.util.ReflectionUtils;import com.gitplex.server.web.component.select2.ChoiceProvider;import com.gitplex.server.web.component.select2.Response;import com.gitplex.server.web.component.select2.Select2MultiChoice;@@ -20,6 +19,7 @@ import com.gitplex.server.web.editable.ErrorContext;import com.gitplex.server.web.editable.PathSegment;import com.gitplex.server.web.editable.PropertyDescriptor;import com.gitplex.server.web.editable.PropertyEditor;+import com.gitplex.utils.ReflectionUtils;import com.google.common.base.Preconditions;@SuppressWarnings("serial")diff --git a/web/src/main/java/com/gitplex/server/web/page/admin/authenticator/AuthenticatorPage.java b/web/src/main/java/com/gitplex/server/web/page/admin/authenticator/AuthenticatorPage.javaindex c7e9c7471b..a48f9264df 100644--- a/web/src/main/java/com/gitplex/server/web/page/admin/authenticator/AuthenticatorPage.java+++ b/web/src/main/java/com/gitplex/server/web/page/admin/authenticator/AuthenticatorPage.java@@ -21,7 +21,6 @@ import org.slf4j.LoggerFactory;import com.gitplex.server.GitPlex;import com.gitplex.server.manager.ConfigManager;import com.gitplex.server.security.authenticator.Authenticated;-import com.gitplex.server.util.ExceptionUtils;import com.gitplex.server.web.behavior.testform.TestFormBehavior;import com.gitplex.server.web.behavior.testform.TestResult;import com.gitplex.server.web.component.modal.ModalPanel;@@ -31,6 +30,7 @@ import com.gitplex.server.web.editable.EditorChanged;import com.gitplex.server.web.editable.PropertyContext;import com.gitplex.server.web.editable.PropertyEditor;import com.gitplex.server.web.page.admin.AdministrationPage;+import com.gitplex.utils.ExceptionUtils;import com.google.common.base.Joiner;@SuppressWarnings("serial")diff --git a/web/src/main/java/com/gitplex/server/web/page/admin/databasebackup/DatabaseBackupPage.java b/web/src/main/java/com/gitplex/server/web/page/admin/databasebackup/DatabaseBackupPage.javaindex e334fe7f52..2a895b334a 100644--- a/web/src/main/java/com/gitplex/server/web/page/admin/databasebackup/DatabaseBackupPage.java+++ b/web/src/main/java/com/gitplex/server/web/page/admin/databasebackup/DatabaseBackupPage.java@@ -8,13 +8,13 @@ import org.apache.wicket.markup.html.form.Form;import org.apache.wicket.markup.html.link.ResourceLink;import org.apache.wicket.request.resource.AbstractResource;-import com.gitplex.launcher.bootstrap.BootstrapUtils;import com.gitplex.server.GitPlex;import com.gitplex.server.manager.ConfigManager;import com.gitplex.server.persistence.PersistManager;-import com.gitplex.server.util.FileUtils;import com.gitplex.server.web.editable.BeanContext;import com.gitplex.server.web.page.admin.AdministrationPage;+import com.gitplex.utils.FileUtils;+import com.gitplex.utils.ZipUtils;@SuppressWarnings("serial")public class DatabaseBackupPage extends AdministrationPage {@@ -50,11 +50,11 @@ public class DatabaseBackupPage extends AdministrationPage {@Overridepublic void writeData(Attributes attributes) throws IOException {- File tempDir = BootstrapUtils.createTempDir("backup");+ File tempDir = FileUtils.createTempDir("backup");try {PersistManager persistManager = GitPlex.getInstance(PersistManager.class);persistManager.exportData(tempDir);- BootstrapUtils.zip(tempDir, attributes.getResponse().getOutputStream());+ ZipUtils.zip(tempDir, attributes.getResponse().getOutputStream());} finally {FileUtils.deleteDir(tempDir);}diff --git a/web/src/main/java/com/gitplex/server/web/page/admin/mailsetting/MailSettingPage.java b/web/src/main/java/com/gitplex/server/web/page/admin/mailsetting/MailSettingPage.javaindex 5a75271254..e2b9273932 100644--- a/web/src/main/java/com/gitplex/server/web/page/admin/mailsetting/MailSettingPage.java+++ b/web/src/main/java/com/gitplex/server/web/page/admin/mailsetting/MailSettingPage.java@@ -18,13 +18,13 @@ import com.gitplex.server.manager.UserManager;import com.gitplex.server.manager.ConfigManager;import com.gitplex.server.manager.MailManager;import com.gitplex.server.model.User;-import com.gitplex.server.util.ExceptionUtils;import com.gitplex.server.web.behavior.testform.TestFormBehavior;import com.gitplex.server.web.behavior.testform.TestResult;import com.gitplex.server.web.editable.BeanContext;import com.gitplex.server.web.editable.BeanEditor;import com.gitplex.server.web.editable.EditorChanged;import com.gitplex.server.web.page.admin.AdministrationPage;+import com.gitplex.utils.ExceptionUtils;@SuppressWarnings("serial")public class MailSettingPage extends AdministrationPage {diff --git a/web/src/main/java/com/gitplex/server/web/page/admin/serverinformation/ServerInformationPage.java b/web/src/main/java/com/gitplex/server/web/page/admin/serverinformation/ServerInformationPage.javaindex 571a228cad..95d7dc245e 100644--- a/web/src/main/java/com/gitplex/server/web/page/admin/serverinformation/ServerInformationPage.java+++ b/web/src/main/java/com/gitplex/server/web/page/admin/serverinformation/ServerInformationPage.java@@ -6,7 +6,7 @@ import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.link.Link;import org.apache.wicket.model.LoadableDetachableModel;-import com.gitplex.server.util.FileUtils;+import com.gitplex.utils.FileUtils;import com.gitplex.server.web.page.admin.AdministrationPage;import com.gitplex.server.web.util.DateUtils;diff --git a/web/src/main/java/com/gitplex/server/web/page/error/ExpectedExceptionPage.java b/web/src/main/java/com/gitplex/server/web/page/error/ExpectedExceptionPage.javaindex 864d216a11..762025ad6b 100644--- a/web/src/main/java/com/gitplex/server/web/page/error/ExpectedExceptionPage.java+++ b/web/src/main/java/com/gitplex/server/web/page/error/ExpectedExceptionPage.java@@ -7,10 +7,10 @@ import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.panel.Fragment;import org.apache.wicket.util.string.Strings;-import com.gitplex.server.util.WordUtils;import com.gitplex.server.web.component.MultilineLabel;import com.gitplex.server.web.component.link.ViewStateAwarePageLink;import com.gitplex.server.web.page.dashboard.DashboardPage;+import com.gitplex.utils.WordUtils;@SuppressWarnings("serial")public class ExpectedExceptionPage extends BaseErrorPage {diff --git a/web/src/main/java/com/gitplex/server/web/page/error/UnexpectedExceptionPage.java b/web/src/main/java/com/gitplex/server/web/page/error/UnexpectedExceptionPage.javaindex 8c38d871a0..5dac7e620f 100644--- a/web/src/main/java/com/gitplex/server/web/page/error/UnexpectedExceptionPage.java+++ b/web/src/main/java/com/gitplex/server/web/page/error/UnexpectedExceptionPage.java@@ -36,10 +36,10 @@ import org.apache.wicket.util.string.Strings;import com.gitplex.server.GitPlex;import com.gitplex.server.manager.ConfigManager;import com.gitplex.server.model.User;-import com.gitplex.server.util.FileUtils;-import com.gitplex.server.util.StringUtils;+import com.gitplex.utils.FileUtils;import com.gitplex.server.web.page.dashboard.DashboardPage;import com.gitplex.server.web.util.DateUtils;+import com.gitplex.utils.StringUtils;@SuppressWarnings("serial")public class UnexpectedExceptionPage extends BaseErrorPage {diff --git a/web/src/main/java/com/gitplex/server/web/page/group/GroupAuthorizationsPage.java b/web/src/main/java/com/gitplex/server/web/page/group/GroupAuthorizationsPage.javaindex beaf0c5215..d8e93399fe 100644--- a/web/src/main/java/com/gitplex/server/web/page/group/GroupAuthorizationsPage.java+++ b/web/src/main/java/com/gitplex/server/web/page/group/GroupAuthorizationsPage.java@@ -42,8 +42,6 @@ import com.gitplex.server.persistence.dao.EntityCriteria;import com.gitplex.server.security.ProjectPrivilege;import com.gitplex.server.util.facade.GroupAuthorizationFacade;import com.gitplex.server.util.facade.ProjectFacade;-import com.gitplex.server.util.matchscore.MatchScoreProvider;-import com.gitplex.server.util.matchscore.MatchScoreUtils;import com.gitplex.server.web.WebConstants;import com.gitplex.server.web.behavior.OnTypingDoneBehavior;import com.gitplex.server.web.component.datatable.HistoryAwareDataTable;@@ -58,6 +56,8 @@ import com.gitplex.server.web.component.select2.ResponseFiller;import com.gitplex.server.web.component.select2.SelectToAddChoice;import com.gitplex.server.web.page.project.blob.ProjectBlobPage;import com.gitplex.server.web.util.PagingHistorySupport;+import com.gitplex.utils.matchscore.MatchScoreProvider;+import com.gitplex.utils.matchscore.MatchScoreUtils;@SuppressWarnings("serial")public class GroupAuthorizationsPage extends GroupPage {diff --git a/web/src/main/java/com/gitplex/server/web/page/group/GroupMembershipsPage.java b/web/src/main/java/com/gitplex/server/web/page/group/GroupMembershipsPage.javaindex 058cd7ee1f..8047b9084b 100644--- a/web/src/main/java/com/gitplex/server/web/page/group/GroupMembershipsPage.java+++ b/web/src/main/java/com/gitplex/server/web/page/group/GroupMembershipsPage.java@@ -39,8 +39,6 @@ import com.gitplex.server.persistence.dao.EntityCriteria;import com.gitplex.server.security.SecurityUtils;import com.gitplex.server.util.facade.MembershipFacade;import com.gitplex.server.util.facade.UserFacade;-import com.gitplex.server.util.matchscore.MatchScoreProvider;-import com.gitplex.server.util.matchscore.MatchScoreUtils;import com.gitplex.server.web.WebConstants;import com.gitplex.server.web.behavior.OnTypingDoneBehavior;import com.gitplex.server.web.component.avatar.AvatarLink;@@ -53,6 +51,8 @@ import com.gitplex.server.web.component.select2.SelectToAddChoice;import com.gitplex.server.web.component.userchoice.AbstractUserChoiceProvider;import com.gitplex.server.web.component.userchoice.UserChoiceResourceReference;import com.gitplex.server.web.util.PagingHistorySupport;+import com.gitplex.utils.matchscore.MatchScoreProvider;+import com.gitplex.utils.matchscore.MatchScoreUtils;@SuppressWarnings("serial")public class GroupMembershipsPage extends GroupPage {diff --git a/web/src/main/java/com/gitplex/server/web/page/init/ServerInitPage.java b/web/src/main/java/com/gitplex/server/web/page/init/ServerInitPage.javaindex 933f40c9c2..2a310b7c06 100644--- a/web/src/main/java/com/gitplex/server/web/page/init/ServerInitPage.java+++ b/web/src/main/java/com/gitplex/server/web/page/init/ServerInitPage.java@@ -15,14 +15,14 @@ import com.gitplex.server.GitPlex;import com.gitplex.server.manager.UserManager;import com.gitplex.server.model.User;import com.gitplex.server.security.SecurityUtils;-import com.gitplex.server.util.init.InitStage;-import com.gitplex.server.util.init.ManualConfig;-import com.gitplex.server.util.init.Skippable;import com.gitplex.server.web.WebSession;import com.gitplex.server.web.component.wizard.ManualConfigStep;import com.gitplex.server.web.component.wizard.Wizard;import com.gitplex.server.web.page.base.BasePage;import com.gitplex.server.web.page.dashboard.DashboardPage;+import com.gitplex.utils.init.InitStage;+import com.gitplex.utils.init.ManualConfig;+import com.gitplex.utils.init.Skippable;@SuppressWarnings("serial")public class ServerInitPage extends BasePage {diff --git a/web/src/main/java/com/gitplex/server/web/page/project/ProjectListPage.java b/web/src/main/java/com/gitplex/server/web/page/project/ProjectListPage.javaindex 66619f51b2..e491bf48b8 100644--- a/web/src/main/java/com/gitplex/server/web/page/project/ProjectListPage.java+++ b/web/src/main/java/com/gitplex/server/web/page/project/ProjectListPage.java@@ -29,14 +29,14 @@ import com.gitplex.server.security.SecurityUtils;import com.gitplex.server.util.facade.GroupAuthorizationFacade;import com.gitplex.server.util.facade.ProjectFacade;import com.gitplex.server.util.facade.UserAuthorizationFacade;-import com.gitplex.server.util.matchscore.MatchScoreProvider;-import com.gitplex.server.util.matchscore.MatchScoreUtils;import com.gitplex.server.web.ComponentRenderer;import com.gitplex.server.web.behavior.OnTypingDoneBehavior;import com.gitplex.server.web.component.link.ViewStateAwarePageLink;import com.gitplex.server.web.component.projectlist.ProjectListPanel;import com.gitplex.server.web.page.layout.LayoutPage;import com.gitplex.server.web.util.PagingHistorySupport;+import com.gitplex.utils.matchscore.MatchScoreProvider;+import com.gitplex.utils.matchscore.MatchScoreUtils;@SuppressWarnings("serial")public class ProjectListPage extends LayoutPage {diff --git a/web/src/main/java/com/gitplex/server/web/page/project/blob/navigator/BlobNavigator.java b/web/src/main/java/com/gitplex/server/web/page/project/blob/navigator/BlobNavigator.javaindex 1b16e840e4..127af5a426 100644--- a/web/src/main/java/com/gitplex/server/web/page/project/blob/navigator/BlobNavigator.java+++ b/web/src/main/java/com/gitplex/server/web/page/project/blob/navigator/BlobNavigator.java@@ -39,7 +39,6 @@ import org.eclipse.jgit.lib.FileMode;import com.gitplex.server.git.BlobIdent;import com.gitplex.server.git.BlobIdentFilter;import com.gitplex.server.git.GitUtils;-import com.gitplex.server.util.StringUtils;import com.gitplex.server.web.component.BlobIcon;import com.gitplex.server.web.component.floating.AlignPlacement;import com.gitplex.server.web.component.floating.FloatingPanel;@@ -49,6 +48,7 @@ import com.gitplex.server.web.page.project.blob.ProjectBlobPage;import com.gitplex.server.web.page.project.blob.render.BlobRenderContext;import com.gitplex.server.web.page.project.blob.render.BlobRenderContext.Mode;import com.gitplex.server.web.util.ajaxlistener.ConfirmLeaveListener;+import com.gitplex.utils.StringUtils;import com.google.common.base.Splitter;@SuppressWarnings("serial")diff --git a/web/src/main/java/com/gitplex/server/web/page/project/blob/render/commitoption/CommitOptionPanel.java b/web/src/main/java/com/gitplex/server/web/page/project/blob/render/commitoption/CommitOptionPanel.javaindex ebcc9521f9..d9a062e48d 100644--- a/web/src/main/java/com/gitplex/server/web/page/project/blob/render/commitoption/CommitOptionPanel.java+++ b/web/src/main/java/com/gitplex/server/web/page/project/blob/render/commitoption/CommitOptionPanel.java@@ -54,7 +54,6 @@ import com.gitplex.server.model.Project;import com.gitplex.server.model.PullRequest;import com.gitplex.server.model.User;import com.gitplex.server.security.SecurityUtils;-import com.gitplex.server.util.Provider;import com.gitplex.server.util.diff.WhitespaceOption;import com.gitplex.server.web.component.diff.blob.BlobDiffPanel;import com.gitplex.server.web.component.diff.revision.DiffViewMode;@@ -65,6 +64,7 @@ import com.gitplex.server.web.page.project.blob.render.BlobRenderContext;import com.gitplex.server.web.page.project.blob.render.BlobRenderContext.Mode;import com.gitplex.server.web.util.ajaxlistener.ConfirmLeaveListener;import com.gitplex.server.web.util.ajaxlistener.TrackViewStateListener;+import com.gitplex.utils.Provider;import com.google.common.base.Objects;import com.google.common.base.Preconditions;diff --git a/web/src/main/java/com/gitplex/server/web/page/project/blob/render/edit/BlobEditPanel.java b/web/src/main/java/com/gitplex/server/web/page/project/blob/render/edit/BlobEditPanel.javaindex 54dd12fa4e..820f2a140d 100644--- a/web/src/main/java/com/gitplex/server/web/page/project/blob/render/edit/BlobEditPanel.java+++ b/web/src/main/java/com/gitplex/server/web/page/project/blob/render/edit/BlobEditPanel.java@@ -15,13 +15,13 @@ import org.apache.wicket.markup.html.form.FormComponentPanel;import org.apache.wicket.markup.html.panel.Panel;import org.apache.wicket.request.cycle.RequestCycle;-import com.gitplex.server.util.Provider;import com.gitplex.server.web.component.link.ViewStateAwareAjaxLink;import com.gitplex.server.web.page.project.blob.navigator.BlobNameChanging;import com.gitplex.server.web.page.project.blob.render.BlobRenderContext;import com.gitplex.server.web.page.project.blob.render.BlobRenderContext.Mode;import com.gitplex.server.web.page.project.blob.render.commitoption.CommitOptionPanel;import com.gitplex.server.web.util.ajaxlistener.ConfirmLeaveListener;+import com.gitplex.utils.Provider;import com.google.common.base.Preconditions;@SuppressWarnings("serial")diff --git a/web/src/main/java/com/gitplex/server/web/page/project/blob/render/renderers/markdown/MarkdownBlobEditor.java b/web/src/main/java/com/gitplex/server/web/page/project/blob/render/renderers/markdown/MarkdownBlobEditor.javaindex a585b46672..c62cd7d281 100644--- a/web/src/main/java/com/gitplex/server/web/page/project/blob/render/renderers/markdown/MarkdownBlobEditor.java+++ b/web/src/main/java/com/gitplex/server/web/page/project/blob/render/renderers/markdown/MarkdownBlobEditor.java@@ -1,81 +1,81 @@-package com.gitplex.server.web.page.project.blob.render.renderers.markdown;--import java.nio.charset.Charset;--import org.apache.wicket.behavior.AttributeAppender;-import org.apache.wicket.markup.head.IHeaderResponse;-import org.apache.wicket.markup.head.OnDomReadyHeaderItem;-import org.apache.wicket.markup.html.form.FormComponentPanel;-import org.apache.wicket.model.Model;--import com.gitplex.server.util.ContentDetector;-import com.gitplex.server.util.StringUtils;-import com.gitplex.server.web.component.markdown.MarkdownEditor;-import com.gitplex.server.web.page.project.blob.render.BlobRenderContext;-import com.gitplex.server.web.page.project.blob.render.BlobRenderContext.Mode;--@SuppressWarnings("serial")-abstract class MarkdownBlobEditor extends FormComponentPanel<byte[]> {-- private final BlobRenderContext context;-- private final String charset;-- private MarkdownEditor input;-- public MarkdownBlobEditor(String id, BlobRenderContext context, byte[] initialContent) {- super(id, Model.of(initialContent));-- this.context = context;-- Charset detectedCharset = ContentDetector.detectCharset(getModelObject());- charset = (detectedCharset!=null?detectedCharset:Charset.defaultCharset()).name();- }-- @Override- protected void onInitialize() {- super.onInitialize();-- add(input = new MarkdownEditor("input", Model.of(new String(getModelObject(), Charset.forName(charset))),- false, context) {-- @Override- protected String getAutosaveKey() {- return MarkdownBlobEditor.this.getAutosaveKey();- }-- });- if (context.getMode() != Mode.EDIT) {- input.add(AttributeAppender.append("class", "no-autofocus"));- }- input.setOutputMarkupId(true);- }-- @Override- public void convertInput() {- String content = input.getConvertedInput();- if (content != null) {- /*- * Textarea always uses CRLF as line ending, and below we change back to original EOL- */- String initialContent = input.getModelObject();- if (initialContent == null || !initialContent.contains("\r\n"))- content = StringUtils.replace(content, "\r\n", "\n");- setConvertedInput(content.getBytes(Charset.forName(charset)));- } else {- setConvertedInput(new byte[0]);- }- }-- @Override- public void renderHead(IHeaderResponse response) {- super.renderHead(response);- if (context.getMode() == Mode.EDIT) {- String script = String.format("$('#%s textarea').focus();", input.getMarkupId());- response.render(OnDomReadyHeaderItem.forScript(script));- }- }-- protected abstract String getAutosaveKey();--}+package com.gitplex.server.web.page.project.blob.render.renderers.markdown;++import java.nio.charset.Charset;++import org.apache.wicket.behavior.AttributeAppender;+import org.apache.wicket.markup.head.IHeaderResponse;+import org.apache.wicket.markup.head.OnDomReadyHeaderItem;+import org.apache.wicket.markup.html.form.FormComponentPanel;+import org.apache.wicket.model.Model;++import com.gitplex.server.util.ContentDetector;+import com.gitplex.server.web.component.markdown.MarkdownEditor;+import com.gitplex.server.web.page.project.blob.render.BlobRenderContext;+import com.gitplex.server.web.page.project.blob.render.BlobRenderContext.Mode;+import com.gitplex.utils.StringUtils;++@SuppressWarnings("serial")+abstract class MarkdownBlobEditor extends FormComponentPanel<byte[]> {++ private final BlobRenderContext context;++ private final String charset;++ private MarkdownEditor input;++ public MarkdownBlobEditor(String id, BlobRenderContext context, byte[] initialContent) {+ super(id, Model.of(initialContent));++ this.context = context;++ Charset detectedCharset = ContentDetector.detectCharset(getModelObject());+ charset = (detectedCharset!=null?detectedCharset:Charset.defaultCharset()).name();+ }++ @Override+ protected void onInitialize() {+ super.onInitialize();++ add(input = new MarkdownEditor("input", Model.of(new String(getModelObject(), Charset.forName(charset))),+ false, context) {++ @Override+ protected String getAutosaveKey() {+ return MarkdownBlobEditor.this.getAutosaveKey();+ }++ });+ if (context.getMode() != Mode.EDIT) {+ input.add(AttributeAppender.append("class", "no-autofocus"));+ }+ input.setOutputMarkupId(true);+ }++ @Override+ public void convertInput() {+ String content = input.getConvertedInput();+ if (content != null) {+ /*+ * Textarea always uses CRLF as line ending, and below we change back to original EOL+ */+ String initialContent = input.getModelObject();+ if (initialContent == null || !initialContent.contains("\r\n"))+ content = StringUtils.replace(content, "\r\n", "\n");+ setConvertedInput(content.getBytes(Charset.forName(charset)));+ } else {+ setConvertedInput(new byte[0]);+ }+ }++ @Override+ public void renderHead(IHeaderResponse response) {+ super.renderHead(response);+ if (context.getMode() == Mode.EDIT) {+ String script = String.format("$('#%s textarea').focus();", input.getMarkupId());+ response.render(OnDomReadyHeaderItem.forScript(script));+ }+ }++ protected abstract String getAutosaveKey();++}diff --git a/web/src/main/java/com/gitplex/server/web/page/project/blob/render/renderers/source/SourceFormComponent.java b/web/src/main/java/com/gitplex/server/web/page/project/blob/render/renderers/source/SourceFormComponent.javaindex e93ac9266b..2a3ebb8d11 100644--- a/web/src/main/java/com/gitplex/server/web/page/project/blob/render/renderers/source/SourceFormComponent.java+++ b/web/src/main/java/com/gitplex/server/web/page/project/blob/render/renderers/source/SourceFormComponent.java@@ -1,59 +1,59 @@-package com.gitplex.server.web.page.project.blob.render.renderers.source;--import java.nio.charset.Charset;--import org.apache.wicket.markup.html.form.FormComponentPanel;-import org.apache.wicket.markup.html.form.TextArea;-import org.apache.wicket.model.Model;--import com.gitplex.server.util.ContentDetector;-import com.gitplex.server.util.StringUtils;-import com.google.common.base.Charsets;--@SuppressWarnings("serial")-class SourceFormComponent extends FormComponentPanel<byte[]> {-- private TextArea<String> input;-- private final String charset;-- public SourceFormComponent(String id, byte[] initialContent) {- super(id, Model.of(initialContent));-- Charset detectedCharset = ContentDetector.detectCharset(getModelObject());- charset = (detectedCharset!=null?detectedCharset:Charset.defaultCharset()).name();- }-- @Override- protected void onInitialize() {- super.onInitialize();-- String source = new String(getModelObject(), Charset.forName(charset));- add(input = new TextArea<String>("input", Model.of(source)) {-- @Override- protected boolean shouldTrimInput() {- return false;- }-- });- setOutputMarkupId(true);- }-- @Override- public void convertInput() {- String content = input.getConvertedInput();- if (content != null) {- /*- * Textarea always uses CRLF as line ending, and below we change back to original EOL- */- String initialContent = input.getModelObject();- if (initialContent == null || !initialContent.contains("\r\n"))- content = StringUtils.replace(content, "\r\n", "\n");- setConvertedInput(content.getBytes(Charsets.UTF_8));- } else {- setConvertedInput(new byte[0]);- }- }--}+package com.gitplex.server.web.page.project.blob.render.renderers.source;++import java.nio.charset.Charset;++import org.apache.wicket.markup.html.form.FormComponentPanel;+import org.apache.wicket.markup.html.form.TextArea;+import org.apache.wicket.model.Model;++import com.gitplex.server.util.ContentDetector;+import com.gitplex.utils.StringUtils;+import com.google.common.base.Charsets;++@SuppressWarnings("serial")+class SourceFormComponent extends FormComponentPanel<byte[]> {++ private TextArea<String> input;++ private final String charset;++ public SourceFormComponent(String id, byte[] initialContent) {+ super(id, Model.of(initialContent));++ Charset detectedCharset = ContentDetector.detectCharset(getModelObject());+ charset = (detectedCharset!=null?detectedCharset:Charset.defaultCharset()).name();+ }++ @Override+ protected void onInitialize() {+ super.onInitialize();++ String source = new String(getModelObject(), Charset.forName(charset));+ add(input = new TextArea<String>("input", Model.of(source)) {++ @Override+ protected boolean shouldTrimInput() {+ return false;+ }++ });+ setOutputMarkupId(true);+ }++ @Override+ public void convertInput() {+ String content = input.getConvertedInput();+ if (content != null) {+ /*+ * Textarea always uses CRLF as line ending, and below we change back to original EOL+ */+ String initialContent = input.getModelObject();+ if (initialContent == null || !initialContent.contains("\r\n"))+ content = StringUtils.replace(content, "\r\n", "\n");+ setConvertedInput(content.getBytes(Charsets.UTF_8));+ } else {+ setConvertedInput(new byte[0]);+ }+ }++}diff --git a/web/src/main/java/com/gitplex/server/web/page/project/blob/render/renderers/source/SourceViewPanel.java b/web/src/main/java/com/gitplex/server/web/page/project/blob/render/renderers/source/SourceViewPanel.javaindex b866de7441..2973f4d35f 100644--- a/web/src/main/java/com/gitplex/server/web/page/project/blob/render/renderers/source/SourceViewPanel.java+++ b/web/src/main/java/com/gitplex/server/web/page/project/blob/render/renderers/source/SourceViewPanel.java@@ -53,7 +53,10 @@ import org.unbescape.javascript.JavaScriptEscape;import com.fasterxml.jackson.core.JsonProcessingException;import com.fasterxml.jackson.databind.ObjectMapper;-import com.gitplex.jsymbol.Range;+import com.gitplex.utils.Range;+import com.gitplex.utils.StringUtils;+import com.gitplex.utils.matchscore.MatchScoreProvider;+import com.gitplex.utils.matchscore.MatchScoreUtils;import com.gitplex.jsymbol.Symbol;import com.gitplex.jsymbol.SymbolExtractor;import com.gitplex.jsymbol.SymbolExtractorRegistry;@@ -76,9 +79,6 @@ import com.gitplex.server.model.support.TextRange;import com.gitplex.server.search.SearchManager;import com.gitplex.server.search.hit.QueryHit;import com.gitplex.server.security.SecurityUtils;-import com.gitplex.server.util.StringUtils;-import com.gitplex.server.util.matchscore.MatchScoreProvider;-import com.gitplex.server.util.matchscore.MatchScoreUtils;import com.gitplex.server.web.behavior.AbstractPostAjaxBehavior;import com.gitplex.server.web.behavior.blamemessage.BlameMessageBehavior;import com.gitplex.server.web.component.comment.CodeCommentPanel;diff --git a/web/src/main/java/com/gitplex/server/web/page/project/blob/render/renderers/symbollink/SymbolLinkPanel.java b/web/src/main/java/com/gitplex/server/web/page/project/blob/render/renderers/symbollink/SymbolLinkPanel.javaindex 822438656d..cf294ef34c 100644--- a/web/src/main/java/com/gitplex/server/web/page/project/blob/render/renderers/symbollink/SymbolLinkPanel.java+++ b/web/src/main/java/com/gitplex/server/web/page/project/blob/render/renderers/symbollink/SymbolLinkPanel.java@@ -16,11 +16,11 @@ import org.eclipse.jgit.treewalk.TreeWalk;import com.gitplex.server.git.Blob;import com.gitplex.server.git.BlobIdent;-import com.gitplex.server.util.PathUtils;import com.gitplex.server.web.component.link.ViewStateAwarePageLink;import com.gitplex.server.web.page.project.blob.ProjectBlobPage;import com.gitplex.server.web.page.project.blob.render.BlobRenderContext;import com.gitplex.server.web.page.project.blob.render.view.BlobViewPanel;+import com.gitplex.utils.PathUtils;@SuppressWarnings("serial")public class SymbolLinkPanel extends BlobViewPanel {diff --git a/web/src/main/java/com/gitplex/server/web/page/project/blob/render/view/BlobViewPanel.java b/web/src/main/java/com/gitplex/server/web/page/project/blob/render/view/BlobViewPanel.javaindex a5e787e17f..63bd52d283 100644--- a/web/src/main/java/com/gitplex/server/web/page/project/blob/render/view/BlobViewPanel.java+++ b/web/src/main/java/com/gitplex/server/web/page/project/blob/render/view/BlobViewPanel.java@@ -22,7 +22,6 @@ import org.apache.wicket.model.Model;import com.gitplex.server.git.BlobIdent;import com.gitplex.server.security.SecurityUtils;-import com.gitplex.server.util.FileUtils;import com.gitplex.server.web.component.link.ViewStateAwareAjaxLink;import com.gitplex.server.web.page.project.blob.render.BlobRenderContext;import com.gitplex.server.web.page.project.blob.render.BlobRenderContext.Mode;@@ -30,6 +29,7 @@ import com.gitplex.server.web.util.ajaxlistener.ConfirmLeaveListener;import com.gitplex.server.web.util.ajaxlistener.TrackViewStateListener;import com.gitplex.server.web.util.resource.RawBlobResource;import com.gitplex.server.web.util.resource.RawBlobResourceReference;+import com.gitplex.utils.FileUtils;import com.google.common.base.Preconditions;@SuppressWarnings("serial")diff --git a/web/src/main/java/com/gitplex/server/web/page/project/blob/search/advanced/AdvancedSearchPanel.java b/web/src/main/java/com/gitplex/server/web/page/project/blob/search/advanced/AdvancedSearchPanel.javaindex c88d93284f..6dfeafd94d 100644--- a/web/src/main/java/com/gitplex/server/web/page/project/blob/search/advanced/AdvancedSearchPanel.java+++ b/web/src/main/java/com/gitplex/server/web/page/project/blob/search/advanced/AdvancedSearchPanel.java@@ -47,12 +47,12 @@ import com.gitplex.server.search.query.FileQuery;import com.gitplex.server.search.query.SymbolQuery;import com.gitplex.server.search.query.TextQuery;import com.gitplex.server.search.query.TooGeneralQueryException;-import com.gitplex.server.util.StringUtils;import com.gitplex.server.web.behavior.RunTaskBehavior;import com.gitplex.server.web.component.tabbable.AjaxActionTab;import com.gitplex.server.web.component.tabbable.Tab;import com.gitplex.server.web.component.tabbable.Tabbable;import com.gitplex.server.web.page.project.blob.search.result.SearchResultPanel;+import com.gitplex.utils.StringUtils;import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;diff --git a/web/src/main/java/com/gitplex/server/web/page/project/blob/search/quick/QuickSearchPanel.java b/web/src/main/java/com/gitplex/server/web/page/project/blob/search/quick/QuickSearchPanel.javaindex dcda0e09a5..24483141d2 100644--- a/web/src/main/java/com/gitplex/server/web/page/project/blob/search/quick/QuickSearchPanel.java+++ b/web/src/main/java/com/gitplex/server/web/page/project/blob/search/quick/QuickSearchPanel.java@@ -42,13 +42,13 @@ import com.gitplex.server.search.query.BlobQuery;import com.gitplex.server.search.query.FileQuery;import com.gitplex.server.search.query.SymbolQuery;import com.gitplex.server.search.query.TooGeneralQueryException;-import com.gitplex.server.util.StringUtils;import com.gitplex.server.web.behavior.AbstractPostAjaxBehavior;import com.gitplex.server.web.behavior.RunTaskBehavior;import com.gitplex.server.web.component.link.ViewStateAwareAjaxLink;import com.gitplex.server.web.page.project.blob.ProjectBlobPage;import com.gitplex.server.web.page.project.blob.search.result.SearchResultPanel;import com.gitplex.server.web.util.ajaxlistener.ConfirmLeaveListener;+import com.gitplex.utils.StringUtils;@SuppressWarnings("serial")public abstract class QuickSearchPanel extends Panel {diff --git a/web/src/main/java/com/gitplex/server/web/page/project/blob/search/result/MatchedBlob.java b/web/src/main/java/com/gitplex/server/web/page/project/blob/search/result/MatchedBlob.javaindex 4fc9419a89..6d296d79f1 100644--- a/web/src/main/java/com/gitplex/server/web/page/project/blob/search/result/MatchedBlob.java+++ b/web/src/main/java/com/gitplex/server/web/page/project/blob/search/result/MatchedBlob.java@@ -4,7 +4,7 @@ import java.io.Serializable;import java.util.List;import com.gitplex.server.search.hit.QueryHit;-import com.gitplex.jsymbol.Range;+import com.gitplex.utils.Range;public class MatchedBlob implements Serializable {diff --git a/web/src/main/java/com/gitplex/server/web/page/project/blob/search/result/SearchResultPanel.java b/web/src/main/java/com/gitplex/server/web/page/project/blob/search/result/SearchResultPanel.javaindex 71be7f5e03..9d7b020ef7 100644--- a/web/src/main/java/com/gitplex/server/web/page/project/blob/search/result/SearchResultPanel.java+++ b/web/src/main/java/com/gitplex/server/web/page/project/blob/search/result/SearchResultPanel.java@@ -35,7 +35,7 @@ import com.gitplex.server.search.hit.TextHit;import com.gitplex.server.web.component.link.ViewStateAwareAjaxLink;import com.gitplex.server.web.page.project.blob.ProjectBlobPage;import com.gitplex.server.web.page.project.blob.render.BlobRenderContext;-import com.gitplex.jsymbol.Range;+import com.gitplex.utils.Range;import com.gitplex.jsymbol.util.HighlightableLabel;@SuppressWarnings("serial")diff --git a/web/src/main/java/com/gitplex/server/web/page/project/branches/ProjectBranchesPage.java b/web/src/main/java/com/gitplex/server/web/page/project/branches/ProjectBranchesPage.javaindex a32a01e1f4..29aba11645 100644--- a/web/src/main/java/com/gitplex/server/web/page/project/branches/ProjectBranchesPage.java+++ b/web/src/main/java/com/gitplex/server/web/page/project/branches/ProjectBranchesPage.java@@ -62,7 +62,6 @@ import com.gitplex.server.model.Project;import com.gitplex.server.model.PullRequest;import com.gitplex.server.model.support.ProjectAndBranch;import com.gitplex.server.security.SecurityUtils;-import com.gitplex.server.util.StringUtils;import com.gitplex.server.util.Verification;import com.gitplex.server.web.behavior.OnTypingDoneBehavior;import com.gitplex.server.web.component.branchchoice.BranchChoiceProvider;@@ -85,6 +84,7 @@ import com.gitplex.server.web.page.project.pullrequest.requestlist.SearchOption;import com.gitplex.server.web.page.project.pullrequest.requestlist.SearchOption.Status;import com.gitplex.server.web.page.project.pullrequest.requestlist.SortOption;import com.gitplex.server.web.util.PagingHistorySupport;+import com.gitplex.utils.StringUtils;import com.google.common.base.Preconditions;import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;diff --git a/web/src/main/java/com/gitplex/server/web/page/project/commit/CommitQueryBehavior.java b/web/src/main/java/com/gitplex/server/web/page/project/commit/CommitQueryBehavior.javaindex 720a00a990..6e562e5bd2 100644--- a/web/src/main/java/com/gitplex/server/web/page/project/commit/CommitQueryBehavior.java+++ b/web/src/main/java/com/gitplex/server/web/page/project/commit/CommitQueryBehavior.java@@ -13,14 +13,14 @@ import com.gitplex.codeassist.InputSuggestion;import com.gitplex.codeassist.ParentedElement;import com.gitplex.codeassist.grammar.ElementSpec;import com.gitplex.codeassist.grammar.LexerRuleRefElementSpec;-import com.gitplex.jsymbol.Range;+import com.gitplex.utils.Range;+import com.gitplex.utils.StringUtils;+import com.gitplex.utils.stringmatch.PatternApplied;+import com.gitplex.utils.stringmatch.WildcardUtils;import com.gitplex.server.GitPlex;import com.gitplex.server.git.NameAndEmail;import com.gitplex.server.manager.CommitInfoManager;import com.gitplex.server.model.Project;-import com.gitplex.server.util.StringUtils;-import com.gitplex.server.util.stringmatch.PatternApplied;-import com.gitplex.server.util.stringmatch.WildcardUtils;import com.gitplex.server.web.WebConstants;import com.gitplex.server.web.behavior.inputassist.ANTLRAssistBehavior;import com.gitplex.server.web.page.project.commit.CommitQueryParser;diff --git a/web/src/main/java/com/gitplex/server/web/page/project/commit/ProjectCommitsPage.java b/web/src/main/java/com/gitplex/server/web/page/project/commit/ProjectCommitsPage.javaindex e57f3470c9..b0b3da9c7d 100644--- a/web/src/main/java/com/gitplex/server/web/page/project/commit/ProjectCommitsPage.java+++ b/web/src/main/java/com/gitplex/server/web/page/project/commit/ProjectCommitsPage.java@@ -53,7 +53,6 @@ import com.gitplex.server.git.command.RevListCommand;import com.gitplex.server.manager.VerificationManager;import com.gitplex.server.model.Project;import com.gitplex.server.model.support.ProjectAndRevision;-import com.gitplex.server.util.StringUtils;import com.gitplex.server.util.Verification;import com.gitplex.server.web.WebConstants;import com.gitplex.server.web.behavior.clipboard.CopyClipboardBehavior;@@ -72,6 +71,7 @@ import com.gitplex.server.web.page.project.commit.CommitQueryParser.QueryContextimport com.gitplex.server.web.page.project.compare.RevisionComparePage;import com.gitplex.server.web.util.ajaxlistener.IndicateLoadingListener;import com.gitplex.server.web.util.model.CommitRefsModel;+import com.gitplex.utils.StringUtils;import com.google.common.base.Joiner;import com.google.common.base.Optional;import com.google.common.base.Throwables;diff --git a/web/src/main/java/com/gitplex/server/web/page/project/pullrequest/requestlist/SortOption.java b/web/src/main/java/com/gitplex/server/web/page/project/pullrequest/requestlist/SortOption.javaindex 9571038bfc..0f44365f50 100644--- a/web/src/main/java/com/gitplex/server/web/page/project/pullrequest/requestlist/SortOption.java+++ b/web/src/main/java/com/gitplex/server/web/page/project/pullrequest/requestlist/SortOption.java@@ -7,7 +7,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;import org.apache.wicket.request.mapper.parameter.PageParameters;import org.hibernate.criterion.Order;-import com.gitplex.server.util.WordUtils;+import com.gitplex.utils.WordUtils;public class SortOption implements Serializable {diff --git a/web/src/main/java/com/gitplex/server/web/page/project/setting/authorization/ProjectAuthorizationsPage.java b/web/src/main/java/com/gitplex/server/web/page/project/setting/authorization/ProjectAuthorizationsPage.javaindex 2145c091d8..a868ce22f9 100644--- a/web/src/main/java/com/gitplex/server/web/page/project/setting/authorization/ProjectAuthorizationsPage.java+++ b/web/src/main/java/com/gitplex/server/web/page/project/setting/authorization/ProjectAuthorizationsPage.java@@ -49,8 +49,6 @@ import com.gitplex.server.util.facade.GroupFacade;import com.gitplex.server.util.facade.MembershipFacade;import com.gitplex.server.util.facade.UserAuthorizationFacade;import com.gitplex.server.util.facade.UserFacade;-import com.gitplex.server.util.matchscore.MatchScoreProvider;-import com.gitplex.server.util.matchscore.MatchScoreUtils;import com.gitplex.server.web.WebConstants;import com.gitplex.server.web.behavior.OnTypingDoneBehavior;import com.gitplex.server.web.component.avatar.AvatarLink;@@ -68,6 +66,8 @@ import com.gitplex.server.web.component.userchoice.AbstractUserChoiceProvider;import com.gitplex.server.web.component.userchoice.UserChoiceResourceReference;import com.gitplex.server.web.page.project.setting.ProjectSettingPage;import com.gitplex.server.web.util.PagingHistorySupport;+import com.gitplex.utils.matchscore.MatchScoreProvider;+import com.gitplex.utils.matchscore.MatchScoreUtils;@SuppressWarnings("serial")public class ProjectAuthorizationsPage extends ProjectSettingPage {diff --git a/web/src/main/java/com/gitplex/server/web/page/project/tags/ProjectTagsPage.java b/web/src/main/java/com/gitplex/server/web/page/project/tags/ProjectTagsPage.javaindex 9d943b8beb..1678c831c8 100644--- a/web/src/main/java/com/gitplex/server/web/page/project/tags/ProjectTagsPage.java+++ b/web/src/main/java/com/gitplex/server/web/page/project/tags/ProjectTagsPage.java@@ -39,7 +39,6 @@ import com.gitplex.server.git.GitUtils;import com.gitplex.server.git.RefInfo;import com.gitplex.server.manager.VerificationManager;import com.gitplex.server.security.SecurityUtils;-import com.gitplex.server.util.StringUtils;import com.gitplex.server.util.Verification;import com.gitplex.server.web.behavior.OnTypingDoneBehavior;import com.gitplex.server.web.component.contributorpanel.ContributorPanel;@@ -57,6 +56,7 @@ import com.gitplex.server.web.page.project.blob.ProjectBlobPage;import com.gitplex.server.web.page.project.commit.CommitDetailPage;import com.gitplex.server.web.util.PagingHistorySupport;import com.gitplex.server.web.util.ajaxlistener.ConfirmListener;+import com.gitplex.utils.StringUtils;import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;diff --git a/web/src/main/java/com/gitplex/server/web/page/user/AvatarEditPage.java b/web/src/main/java/com/gitplex/server/web/page/user/AvatarEditPage.javaindex 5859507584..9442e43d24 100644--- a/web/src/main/java/com/gitplex/server/web/page/user/AvatarEditPage.java+++ b/web/src/main/java/com/gitplex/server/web/page/user/AvatarEditPage.java@@ -12,9 +12,9 @@ import org.apache.wicket.request.mapper.parameter.PageParameters;import com.gitplex.server.GitPlex;import com.gitplex.server.security.SecurityUtils;-import com.gitplex.server.util.FileUtils;import com.gitplex.server.web.component.avatar.AvatarChanged;import com.gitplex.server.web.util.avatar.AvatarManager;+import com.gitplex.utils.FileUtils;import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;diff --git a/web/src/main/java/com/gitplex/server/web/page/user/UserAuthorizationsPage.java b/web/src/main/java/com/gitplex/server/web/page/user/UserAuthorizationsPage.javaindex d9c78a382c..39db99f8eb 100644--- a/web/src/main/java/com/gitplex/server/web/page/user/UserAuthorizationsPage.java+++ b/web/src/main/java/com/gitplex/server/web/page/user/UserAuthorizationsPage.java@@ -47,8 +47,6 @@ import com.gitplex.server.util.facade.GroupAuthorizationFacade;import com.gitplex.server.util.facade.MembershipFacade;import com.gitplex.server.util.facade.ProjectFacade;import com.gitplex.server.util.facade.UserAuthorizationFacade;-import com.gitplex.server.util.matchscore.MatchScoreProvider;-import com.gitplex.server.util.matchscore.MatchScoreUtils;import com.gitplex.server.web.WebConstants;import com.gitplex.server.web.behavior.OnTypingDoneBehavior;import com.gitplex.server.web.component.datatable.HistoryAwareDataTable;@@ -64,6 +62,8 @@ import com.gitplex.server.web.component.select2.ResponseFiller;import com.gitplex.server.web.component.select2.SelectToAddChoice;import com.gitplex.server.web.page.project.blob.ProjectBlobPage;import com.gitplex.server.web.util.PagingHistorySupport;+import com.gitplex.utils.matchscore.MatchScoreProvider;+import com.gitplex.utils.matchscore.MatchScoreUtils;@SuppressWarnings("serial")public class UserAuthorizationsPage extends UserPage {diff --git a/web/src/main/java/com/gitplex/server/web/page/user/UserMembershipsPage.java b/web/src/main/java/com/gitplex/server/web/page/user/UserMembershipsPage.javaindex fa91025edf..73fb7fbd59 100644--- a/web/src/main/java/com/gitplex/server/web/page/user/UserMembershipsPage.java+++ b/web/src/main/java/com/gitplex/server/web/page/user/UserMembershipsPage.java@@ -41,8 +41,6 @@ import com.gitplex.server.persistence.dao.EntityCriteria;import com.gitplex.server.security.SecurityUtils;import com.gitplex.server.util.facade.GroupFacade;import com.gitplex.server.util.facade.MembershipFacade;-import com.gitplex.server.util.matchscore.MatchScoreProvider;-import com.gitplex.server.util.matchscore.MatchScoreUtils;import com.gitplex.server.web.WebConstants;import com.gitplex.server.web.behavior.OnTypingDoneBehavior;import com.gitplex.server.web.component.datatable.HistoryAwareDataTable;@@ -54,6 +52,8 @@ import com.gitplex.server.web.component.select2.ResponseFiller;import com.gitplex.server.web.component.select2.SelectToAddChoice;import com.gitplex.server.web.page.group.GroupProfilePage;import com.gitplex.server.web.util.PagingHistorySupport;+import com.gitplex.utils.matchscore.MatchScoreProvider;+import com.gitplex.utils.matchscore.MatchScoreUtils;@SuppressWarnings("serial")public class UserMembershipsPage extends UserPage {diff --git a/web/src/main/java/com/gitplex/server/web/page/user/UserPage.java b/web/src/main/java/com/gitplex/server/web/page/user/UserPage.javaindex 1db9855ebc..899ac0afac 100644--- a/web/src/main/java/com/gitplex/server/web/page/user/UserPage.java+++ b/web/src/main/java/com/gitplex/server/web/page/user/UserPage.java@@ -16,7 +16,6 @@ import com.gitplex.server.GitPlex;import com.gitplex.server.manager.UserManager;import com.gitplex.server.model.User;import com.gitplex.server.security.SecurityUtils;-import com.gitplex.server.util.StringUtils;import com.gitplex.server.web.ComponentRenderer;import com.gitplex.server.web.component.avatar.Avatar;import com.gitplex.server.web.component.link.ViewStateAwarePageLink;@@ -24,6 +23,7 @@ import com.gitplex.server.web.component.tabbable.PageTab;import com.gitplex.server.web.component.tabbable.Tabbable;import com.gitplex.server.web.page.layout.LayoutPage;import com.gitplex.server.web.util.model.EntityModel;+import com.gitplex.utils.StringUtils;@SuppressWarnings("serial")public abstract class UserPage extends LayoutPage {diff --git a/web/src/main/java/com/gitplex/server/web/util/SuggestionUtils.java b/web/src/main/java/com/gitplex/server/web/util/SuggestionUtils.javaindex 1058a439b2..5806d8b3a7 100644--- a/web/src/main/java/com/gitplex/server/web/util/SuggestionUtils.java+++ b/web/src/main/java/com/gitplex/server/web/util/SuggestionUtils.java@@ -9,7 +9,9 @@ import java.util.Map;import java.util.Set;import com.gitplex.codeassist.InputSuggestion;-import com.gitplex.jsymbol.Range;+import com.gitplex.utils.Range;+import com.gitplex.utils.stringmatch.PatternApplied;+import com.gitplex.utils.stringmatch.WildcardUtils;import com.gitplex.server.GitPlex;import com.gitplex.server.git.GitUtils;import com.gitplex.server.git.RefInfo;@@ -21,8 +23,6 @@ import com.gitplex.server.model.Project;import com.gitplex.server.security.ProjectPrivilege;import com.gitplex.server.security.SecurityUtils;import com.gitplex.server.util.facade.UserFacade;-import com.gitplex.server.util.stringmatch.PatternApplied;-import com.gitplex.server.util.stringmatch.WildcardUtils;import com.gitplex.server.web.behavior.inputassist.InputAssistBehavior;import com.google.common.base.Preconditions;diff --git a/web/src/main/java/com/gitplex/server/web/util/avatar/DefaultAvatarManager.java b/web/src/main/java/com/gitplex/server/web/util/avatar/DefaultAvatarManager.javaindex 323a0999cb..5b49218163 100644--- a/web/src/main/java/com/gitplex/server/web/util/avatar/DefaultAvatarManager.java+++ b/web/src/main/java/com/gitplex/server/web/util/avatar/DefaultAvatarManager.java@@ -20,10 +20,10 @@ import com.gitplex.server.GitPlex;import com.gitplex.server.manager.ConfigManager;import com.gitplex.server.model.User;import com.gitplex.server.persistence.annotation.Sessional;-import com.gitplex.server.util.FileUtils;-import com.gitplex.server.util.LockUtils;-import com.gitplex.server.util.StringUtils;import com.gitplex.server.util.facade.UserFacade;+import com.gitplex.utils.FileUtils;+import com.gitplex.utils.LockUtils;+import com.gitplex.utils.StringUtils;import com.google.common.base.Splitter;import com.google.common.base.Throwables;import com.google.common.collect.Iterables;diff --git a/web/src/main/java/com/gitplex/server/web/util/model/EntityModel.java b/web/src/main/java/com/gitplex/server/web/util/model/EntityModel.javaindex 50cbddcda2..9161df37bf 100644--- a/web/src/main/java/com/gitplex/server/web/util/model/EntityModel.java+++ b/web/src/main/java/com/gitplex/server/web/util/model/EntityModel.java@@ -7,7 +7,7 @@ import org.apache.wicket.model.LoadableDetachableModel;import com.gitplex.launcher.loader.AppLoader;import com.gitplex.server.model.AbstractEntity;import com.gitplex.server.persistence.dao.Dao;-import com.gitplex.server.util.ClassUtils;+import com.gitplex.utils.ClassUtils;public class EntityModel<T extends AbstractEntity> extends LoadableDetachableModel<T> {diff --git a/web/src/main/java/com/gitplex/server/web/util/resource/ServerLogResource.java b/web/src/main/java/com/gitplex/server/web/util/resource/ServerLogResource.javaindex 6b1589b84d..dc0e3aa036 100644--- a/web/src/main/java/com/gitplex/server/web/util/resource/ServerLogResource.java+++ b/web/src/main/java/com/gitplex/server/web/util/resource/ServerLogResource.java@@ -13,7 +13,7 @@ import org.apache.wicket.request.resource.AbstractResource;import com.gitplex.launcher.bootstrap.Bootstrap;import com.gitplex.server.security.SecurityUtils;-import com.gitplex.server.util.FileUtils;+import com.gitplex.utils.FileUtils;import com.google.common.base.Charsets;import com.google.common.base.Joiner;diff --git a/web/src/main/java/com/gitplex/server/web/util/resourcebundle/BundleAwareResourceReferenceFactory.java b/web/src/main/java/com/gitplex/server/web/util/resourcebundle/BundleAwareResourceReferenceFactory.javaindex ed935bfd43..2aeed1a582 100644--- a/web/src/main/java/com/gitplex/server/web/util/resourcebundle/BundleAwareResourceReferenceFactory.java+++ b/web/src/main/java/com/gitplex/server/web/util/resourcebundle/BundleAwareResourceReferenceFactory.java@@ -15,7 +15,7 @@ import org.apache.wicket.request.resource.ResourceReference;import org.apache.wicket.request.resource.ResourceReference.Key;import org.apache.wicket.resource.bundles.ConcatResourceBundleReference;-import com.gitplex.server.util.PathUtils;+import com.gitplex.utils.PathUtils;/** When css is bundled, and its access url can be changed (unless its resource is annotated with @ResourceBundle),diff --git a/web/src/main/java/com/gitplex/server/web/util/resourcebundle/ResourceBundleReferences.java b/web/src/main/java/com/gitplex/server/web/util/resourcebundle/ResourceBundleReferences.javaindex 43ba866182..8ef50f1760 100644--- a/web/src/main/java/com/gitplex/server/web/util/resourcebundle/ResourceBundleReferences.java+++ b/web/src/main/java/com/gitplex/server/web/util/resourcebundle/ResourceBundleReferences.java@@ -27,8 +27,8 @@ import org.apache.wicket.request.resource.ResourceReference;import org.apache.wicket.resource.bundles.ConcatResourceBundleReference;import com.gitplex.launcher.loader.LoaderUtils;-import com.gitplex.server.util.DependencyAware;-import com.gitplex.server.util.DependencyUtils;+import com.gitplex.utils.DependencyAware;+import com.gitplex.utils.DependencyUtils;public class ResourceBundleReferences {