mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 01:15:44 +01:00
util classes should be final with a private constructor
This commit is contained in:
@@ -50,9 +50,17 @@ import java.util.List;
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.15
|
||||
*/
|
||||
public class EscapeUtil
|
||||
public final class EscapeUtil
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private EscapeUtil() {}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
@@ -58,7 +58,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class PermissionUtil
|
||||
public final class PermissionUtil
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -67,6 +67,14 @@ public class PermissionUtil
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(PermissionUtil.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private PermissionUtil() {}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -105,7 +113,6 @@ public class PermissionUtil
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
* @param securityContextProvider
|
||||
* @param pt
|
||||
*
|
||||
* @since 1.21
|
||||
@@ -238,7 +245,6 @@ public class PermissionUtil
|
||||
*
|
||||
* @param configuration SCM-Manager main configuration
|
||||
* @param repository repository to check
|
||||
* @param securityContext current user security context
|
||||
*
|
||||
* @return true if the repository is writable
|
||||
* @since 1.21
|
||||
|
||||
@@ -59,13 +59,21 @@ import javax.servlet.http.HttpServletRequest;
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.11
|
||||
*/
|
||||
public class RepositoryUtil
|
||||
public final class RepositoryUtil
|
||||
{
|
||||
|
||||
/** the logger for RepositoryUtil */
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(RepositoryUtil.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private RepositoryUtil() {}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -79,8 +87,7 @@ public class RepositoryUtil
|
||||
* @since 1.16
|
||||
*/
|
||||
public static void appendUrl(ScmConfiguration configuration,
|
||||
RepositoryManager repositoryManager,
|
||||
Repository repository)
|
||||
RepositoryManager repositoryManager, Repository repository)
|
||||
{
|
||||
RepositoryHandler handler =
|
||||
repositoryManager.getHandler(repository.getType());
|
||||
@@ -106,8 +113,7 @@ public class RepositoryUtil
|
||||
* @since 1.16
|
||||
*/
|
||||
public static void appendUrl(HttpServletRequest request,
|
||||
RepositoryManager repositoryManager,
|
||||
Repository repository)
|
||||
RepositoryManager repositoryManager, Repository repository)
|
||||
{
|
||||
RepositoryHandler handler =
|
||||
repositoryManager.getHandler(repository.getType());
|
||||
@@ -131,7 +137,7 @@ public class RepositoryUtil
|
||||
* @return
|
||||
*/
|
||||
public static List<File> searchRepositoryDirectories(File directory,
|
||||
String... names)
|
||||
String... names)
|
||||
{
|
||||
List<File> repositories = new ArrayList<File>();
|
||||
|
||||
@@ -154,11 +160,11 @@ public class RepositoryUtil
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String getRepositoryName(AbstractRepositoryHandler handler,
|
||||
String directoryPath)
|
||||
throws IOException
|
||||
String directoryPath)
|
||||
throws IOException
|
||||
{
|
||||
return getRepositoryName(handler.getConfig().getRepositoryDirectory(),
|
||||
new File(directoryPath));
|
||||
new File(directoryPath));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,11 +179,11 @@ public class RepositoryUtil
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String getRepositoryName(SimpleRepositoryConfig config,
|
||||
String directoryPath)
|
||||
throws IOException
|
||||
String directoryPath)
|
||||
throws IOException
|
||||
{
|
||||
return getRepositoryName(config.getRepositoryDirectory(),
|
||||
new File(directoryPath));
|
||||
new File(directoryPath));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,11 +198,11 @@ public class RepositoryUtil
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String getRepositoryName(AbstractRepositoryHandler handler,
|
||||
File directory)
|
||||
throws IOException
|
||||
File directory)
|
||||
throws IOException
|
||||
{
|
||||
return getRepositoryName(handler.getConfig().getRepositoryDirectory(),
|
||||
directory);
|
||||
directory);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -211,8 +217,8 @@ public class RepositoryUtil
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String getRepositoryName(SimpleRepositoryConfig config,
|
||||
File directory)
|
||||
throws IOException
|
||||
File directory)
|
||||
throws IOException
|
||||
{
|
||||
return getRepositoryName(config.getRepositoryDirectory(), directory);
|
||||
}
|
||||
@@ -229,7 +235,7 @@ public class RepositoryUtil
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String getRepositoryName(File baseDirectory, File directory)
|
||||
throws IOException
|
||||
throws IOException
|
||||
{
|
||||
String name = null;
|
||||
String path = directory.getCanonicalPath();
|
||||
@@ -262,8 +268,8 @@ public class RepositoryUtil
|
||||
* @throws IOException
|
||||
*/
|
||||
public static List<String> getRepositoryNames(
|
||||
AbstractRepositoryHandler handler, String... directoryNames)
|
||||
throws IOException
|
||||
AbstractRepositoryHandler handler, String... directoryNames)
|
||||
throws IOException
|
||||
{
|
||||
return getRepositoryNames(handler.getConfig(), directoryNames);
|
||||
}
|
||||
@@ -280,8 +286,8 @@ public class RepositoryUtil
|
||||
* @throws IOException
|
||||
*/
|
||||
public static List<String> getRepositoryNames(SimpleRepositoryConfig config,
|
||||
String... directoryNames)
|
||||
throws IOException
|
||||
String... directoryNames)
|
||||
throws IOException
|
||||
{
|
||||
return getRepositoryNames(config.getRepositoryDirectory(), directoryNames);
|
||||
}
|
||||
@@ -298,8 +304,8 @@ public class RepositoryUtil
|
||||
* @throws IOException
|
||||
*/
|
||||
public static List<String> getRepositoryNames(File baseDirectory,
|
||||
String... directoryNames)
|
||||
throws IOException
|
||||
String... directoryNames)
|
||||
throws IOException
|
||||
{
|
||||
List<String> repositories = new ArrayList<String>();
|
||||
List<File> repositoryFiles = searchRepositoryDirectories(baseDirectory,
|
||||
@@ -329,7 +335,7 @@ public class RepositoryUtil
|
||||
* @param names
|
||||
*/
|
||||
private static void searchRepositoryDirectories(List<File> repositories,
|
||||
File directory, List<String> names)
|
||||
File directory, List<String> names)
|
||||
{
|
||||
boolean found = false;
|
||||
|
||||
|
||||
@@ -50,9 +50,17 @@ import java.util.Locale;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class SearchUtil
|
||||
public final class SearchUtil
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private SearchUtil() {}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -64,7 +72,7 @@ public class SearchUtil
|
||||
* @return
|
||||
*/
|
||||
public static boolean matchesAll(SearchRequest request, String value,
|
||||
String... other)
|
||||
String... other)
|
||||
{
|
||||
boolean result = false;
|
||||
String query = createStringQuery(request);
|
||||
@@ -101,7 +109,7 @@ public class SearchUtil
|
||||
* @return
|
||||
*/
|
||||
public static boolean matchesOne(SearchRequest request, String value,
|
||||
String... other)
|
||||
String... other)
|
||||
{
|
||||
boolean result = false;
|
||||
String query = createStringQuery(request);
|
||||
@@ -141,7 +149,7 @@ public class SearchUtil
|
||||
* @return
|
||||
*/
|
||||
public static <T> Collection<T> search(SearchRequest searchRequest,
|
||||
Collection<T> collection, TransformFilter<T> filter)
|
||||
Collection<T> collection, TransformFilter<T> filter)
|
||||
{
|
||||
List<T> items = new ArrayList<T>();
|
||||
int index = 0;
|
||||
|
||||
@@ -43,7 +43,7 @@ import sonia.scm.util.ServiceUtil;
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.7
|
||||
*/
|
||||
public class CipherUtil
|
||||
public final class CipherUtil
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
@@ -51,8 +51,6 @@ public class CipherUtil
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
private KeyGenerator keyGenerator;
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
@@ -71,17 +69,10 @@ public class CipherUtil
|
||||
if (cipherHandler == null)
|
||||
{
|
||||
cipherHandler = new DefaultCipherHandler(SCMContext.getContext(),
|
||||
keyGenerator);
|
||||
keyGenerator);
|
||||
}
|
||||
}
|
||||
|
||||
public KeyGenerator getKeyGenerator()
|
||||
{
|
||||
return keyGenerator;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -147,8 +138,22 @@ public class CipherUtil
|
||||
return cipherHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public KeyGenerator getKeyGenerator()
|
||||
{
|
||||
return keyGenerator;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private CipherHandler cipherHandler;
|
||||
|
||||
/** Field description */
|
||||
private KeyGenerator keyGenerator;
|
||||
}
|
||||
|
||||
@@ -42,9 +42,17 @@ import sonia.scm.util.Util;
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.11
|
||||
*/
|
||||
public class UrlUtil
|
||||
public final class UrlUtil
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private UrlUtil() {}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
@@ -35,7 +35,6 @@ package sonia.scm.util;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.ArgumentIsInvalidException;
|
||||
import sonia.scm.Validateable;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
@@ -46,9 +45,17 @@ import java.util.Collection;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class AssertUtil
|
||||
public final class AssertUtil
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private AssertUtil() {}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
@@ -48,12 +48,20 @@ import java.security.NoSuchAlgorithmException;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class ChecksumUtil
|
||||
public final class ChecksumUtil
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final String DIGEST_TYPE = "SHA-1";
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private ChecksumUtil() {}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -143,7 +151,7 @@ public class ChecksumUtil
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*
|
||||
*
|
||||
* @since 1.12
|
||||
*/
|
||||
public static String createChecksum(byte[] content) throws IOException
|
||||
|
||||
@@ -40,9 +40,15 @@ package sonia.scm.util;
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.8
|
||||
*/
|
||||
public class GlobUtil
|
||||
public final class GlobUtil
|
||||
{
|
||||
|
||||
private GlobUtil()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Converts the given glob string to a regular expression string.
|
||||
*
|
||||
|
||||
@@ -61,7 +61,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class HttpUtil
|
||||
public final class HttpUtil
|
||||
{
|
||||
|
||||
/** authentication realm for basic authentication */
|
||||
@@ -160,10 +160,21 @@ public class HttpUtil
|
||||
/** the logger for HttpUtil */
|
||||
private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
|
||||
|
||||
/** Field description */
|
||||
/**
|
||||
* Pattern for url normalization
|
||||
* @sincee 1.26
|
||||
*/
|
||||
private static final Pattern PATTERN_URLNORMALIZE =
|
||||
Pattern.compile("(?:(http://[^:]+):80(/.+)?|(https://[^:]+):443(/.+)?)");
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private HttpUtil() {}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,7 +65,7 @@ import java.util.Locale;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class IOUtil
|
||||
public final class IOUtil
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
@@ -93,16 +93,24 @@ public class IOUtil
|
||||
|
||||
/** Field description */
|
||||
private static final String[] EXTENSION_SCRIPT_UNIX = { ".sh", ".csh",
|
||||
".bsh" };
|
||||
".bsh" };
|
||||
|
||||
/** Field description */
|
||||
private static final String[] EXTENSION_SCRIPT_WINDOWS = { ".bat", ".cmd",
|
||||
".exe" };
|
||||
".exe" };
|
||||
|
||||
/** Field description */
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(IOUtil.class.getName());
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private IOUtil() {}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -137,7 +145,7 @@ public class IOUtil
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void copy(Reader reader, Writer writer, int bufferSize)
|
||||
throws IOException
|
||||
throws IOException
|
||||
{
|
||||
char[] buffer = new char[bufferSize];
|
||||
|
||||
@@ -186,7 +194,7 @@ public class IOUtil
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void copy(InputStream in, OutputStream out, int bufferSize)
|
||||
throws IOException
|
||||
throws IOException
|
||||
{
|
||||
byte[] buffer = new byte[bufferSize];
|
||||
|
||||
@@ -210,8 +218,8 @@ public class IOUtil
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void copy(InputStream in, OutputStream out, int bufferSize,
|
||||
int byteCount)
|
||||
throws IOException
|
||||
int byteCount)
|
||||
throws IOException
|
||||
{
|
||||
byte buffer[] = new byte[bufferSize];
|
||||
int len = bufferSize;
|
||||
@@ -221,8 +229,8 @@ public class IOUtil
|
||||
while (byteCount > 0)
|
||||
{
|
||||
int max = (byteCount < bufferSize)
|
||||
? (int) byteCount
|
||||
: bufferSize;
|
||||
? (int) byteCount
|
||||
: bufferSize;
|
||||
|
||||
len = in.read(buffer, 0, max);
|
||||
|
||||
@@ -343,7 +351,7 @@ public class IOUtil
|
||||
* @param bufferSize
|
||||
*/
|
||||
public static void copyThread(InputStream input, OutputStream output,
|
||||
int bufferSize)
|
||||
int bufferSize)
|
||||
{
|
||||
new Thread(new IOStreamCopyThread(input, output, bufferSize)).start();
|
||||
}
|
||||
@@ -410,7 +418,7 @@ public class IOUtil
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void extract(File archive, File outputDirectory)
|
||||
throws IOException
|
||||
throws IOException
|
||||
{
|
||||
String name = archive.getName().toLowerCase(Locale.ENGLISH);
|
||||
|
||||
@@ -428,7 +436,7 @@ public class IOUtil
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void extract(File archive, File outputDirectory, String type)
|
||||
throws IOException
|
||||
throws IOException
|
||||
{
|
||||
if (type.endsWith(ZipUnArchiver.EXTENSION))
|
||||
{
|
||||
@@ -451,7 +459,7 @@ public class IOUtil
|
||||
if (!directory.exists() &&!directory.mkdirs())
|
||||
{
|
||||
throw new IllegalStateException(
|
||||
"could not create directory ".concat(directory.getPath()));
|
||||
"could not create directory ".concat(directory.getPath()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,7 +577,7 @@ public class IOUtil
|
||||
* @return
|
||||
*/
|
||||
public static List<String> searchAll(String[] path, String cmd,
|
||||
String checkParameter)
|
||||
String checkParameter)
|
||||
{
|
||||
List<String> cmds = new ArrayList<String>();
|
||||
|
||||
@@ -737,7 +745,7 @@ public class IOUtil
|
||||
* @return
|
||||
*/
|
||||
private static File findFileByExtension(String parentPath, String cmd,
|
||||
List<String> potentialExtensions)
|
||||
List<String> potentialExtensions)
|
||||
{
|
||||
File file = null;
|
||||
|
||||
@@ -942,7 +950,7 @@ public class IOUtil
|
||||
* @param bufferSize
|
||||
*/
|
||||
public IOStreamCopyThread(InputStream input, OutputStream output,
|
||||
int bufferSize)
|
||||
int bufferSize)
|
||||
{
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
|
||||
@@ -51,13 +51,21 @@ import java.util.Scanner;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class RegistryUtil
|
||||
public final class RegistryUtil
|
||||
{
|
||||
|
||||
/** the logger for RegistryUtil */
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(RegistryUtil.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private RegistryUtil() {}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -98,7 +106,7 @@ public class RegistryUtil
|
||||
* @return
|
||||
*/
|
||||
public static String getRegistryValue(String key, String subKey,
|
||||
String defaultValue)
|
||||
String defaultValue)
|
||||
{
|
||||
String value = defaultValue;
|
||||
SimpleCommand command = null;
|
||||
|
||||
@@ -50,9 +50,17 @@ import sonia.scm.user.User;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class SecurityUtil
|
||||
public final class SecurityUtil
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private SecurityUtil() {}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
@@ -44,9 +44,17 @@ import java.util.ServiceLoader;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class ServiceUtil
|
||||
public final class ServiceUtil
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private ServiceUtil() {}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
@@ -43,7 +43,7 @@ import sonia.scm.ServletContainerDetector;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class SystemUtil
|
||||
public final class SystemUtil
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
@@ -58,13 +58,20 @@ public class SystemUtil
|
||||
/** Field description */
|
||||
private static Platform platform =
|
||||
new Platform(System.getProperty(PROPERTY_OSNAME),
|
||||
System.getProperty(PROPERTY_ARCH),
|
||||
System.getProperty(PROPERTY_OSARCH));
|
||||
System.getProperty(PROPERTY_ARCH), System.getProperty(PROPERTY_OSARCH));
|
||||
|
||||
/** Field description */
|
||||
private static ServletContainer servletContainer =
|
||||
ServletContainerDetector.detect();
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private SystemUtil() {}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@@ -55,7 +55,7 @@ import java.util.TimeZone;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class Util
|
||||
public final class Util
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
@@ -64,6 +64,14 @@ public class Util
|
||||
/** Field description */
|
||||
public static final String EMPTY_STRING = "";
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private Util() {}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -107,7 +115,7 @@ public class Util
|
||||
* @return
|
||||
*/
|
||||
public static <T> boolean containsOne(Collection<T> collection,
|
||||
Collection<T> other)
|
||||
Collection<T> other)
|
||||
{
|
||||
boolean result = false;
|
||||
|
||||
@@ -198,7 +206,7 @@ public class Util
|
||||
* @since 1.4
|
||||
*/
|
||||
public static <T> Collection<T> createSubCollection(Collection<T> values,
|
||||
Comparator<T> comparator, int start, int limit)
|
||||
Comparator<T> comparator, int start, int limit)
|
||||
{
|
||||
return createSubCollection(values, comparator, null, start, limit);
|
||||
}
|
||||
@@ -216,7 +224,7 @@ public class Util
|
||||
* @since 1.4
|
||||
*/
|
||||
public static <T> Collection<T> createSubCollection(Collection<T> values,
|
||||
int start, int limit)
|
||||
int start, int limit)
|
||||
{
|
||||
return createSubCollection(values, null, null, start, limit);
|
||||
}
|
||||
@@ -235,7 +243,7 @@ public class Util
|
||||
* @since 1.4
|
||||
*/
|
||||
public static <T> Collection<T> createSubCollection(Collection<T> values,
|
||||
CollectionAppender<T> appender, int start, int limit)
|
||||
CollectionAppender<T> appender, int start, int limit)
|
||||
{
|
||||
return createSubCollection(values, null, appender, start, limit);
|
||||
}
|
||||
@@ -256,8 +264,8 @@ public class Util
|
||||
* @since 1.4
|
||||
*/
|
||||
public static <T> Collection<T> createSubCollection(Collection<T> values,
|
||||
Comparator<T> comparator, CollectionAppender<T> appender, int start,
|
||||
int limit)
|
||||
Comparator<T> comparator, CollectionAppender<T> appender, int start,
|
||||
int limit)
|
||||
{
|
||||
List<T> result = new ArrayList<T>();
|
||||
List<T> valueList = new ArrayList(values);
|
||||
@@ -356,8 +364,8 @@ public class Util
|
||||
public static String nonNull(Object value)
|
||||
{
|
||||
return (value != null)
|
||||
? value.toString()
|
||||
: "";
|
||||
? value.toString()
|
||||
: "";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -372,7 +380,7 @@ public class Util
|
||||
* @throws ParseException
|
||||
*/
|
||||
public static Date parseDate(String dateString, TimeZone tz)
|
||||
throws ParseException
|
||||
throws ParseException
|
||||
{
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(DATE_PATTERN);
|
||||
|
||||
@@ -407,13 +415,13 @@ public class Util
|
||||
* @param start
|
||||
*
|
||||
* @return
|
||||
*
|
||||
*
|
||||
* @since 1.17
|
||||
*/
|
||||
public static boolean startWithIgnoreCase(String value, String start)
|
||||
{
|
||||
return (value != null) && (start != null)
|
||||
&& value.toUpperCase(Locale.ENGLISH).startsWith(start);
|
||||
&& value.toUpperCase(Locale.ENGLISH).startsWith(start);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -584,8 +592,8 @@ public class Util
|
||||
public static boolean isEquals(Object object, Object other)
|
||||
{
|
||||
return (object == null)
|
||||
? other == null
|
||||
: object.equals(other);
|
||||
? other == null
|
||||
: object.equals(other);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,7 +47,7 @@ import java.util.regex.Pattern;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class ValidationUtil
|
||||
public final class ValidationUtil
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
@@ -65,6 +65,14 @@ public class ValidationUtil
|
||||
private static final String REGEX_USERNAME =
|
||||
"^[A-z0-9\\.\\-_@]|[^ ]([A-z0-9\\.\\-_@ ]*[A-z0-9\\.\\-_@]|[^ ])?$";
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private ValidationUtil() {}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -116,7 +124,7 @@ public class ValidationUtil
|
||||
* @return
|
||||
*/
|
||||
public static boolean isNotContaining(String value,
|
||||
String... notAllowedStrings)
|
||||
String... notAllowedStrings)
|
||||
{
|
||||
boolean result = Util.isNotEmpty(value);
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.util;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
@@ -56,7 +58,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.15
|
||||
*/
|
||||
public class WebUtil
|
||||
public final class WebUtil
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
@@ -110,6 +112,14 @@ public class WebUtil
|
||||
/** Field description */
|
||||
private static final Logger logger = LoggerFactory.getLogger(WebUtil.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private WebUtil() {}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -146,7 +156,7 @@ public class WebUtil
|
||||
* @param seconds
|
||||
*/
|
||||
public static void addStaticCacheControls(HttpServletResponse response,
|
||||
long seconds)
|
||||
long seconds)
|
||||
{
|
||||
long time = new Date().getTime();
|
||||
|
||||
@@ -199,7 +209,7 @@ public class WebUtil
|
||||
public static String getETag(File file)
|
||||
{
|
||||
return new StringBuilder("W/\"").append(file.length()).append(
|
||||
file.lastModified()).append("\"").toString();
|
||||
file.lastModified()).append("\"").toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -280,7 +290,7 @@ public class WebUtil
|
||||
Date modifiedSince = getIfModifiedSinceDate(request);
|
||||
|
||||
if ((modifiedSince != null)
|
||||
&& (modifiedSince.getTime() == file.lastModified()))
|
||||
&& (modifiedSince.getTime() == file.lastModified()))
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
@@ -290,7 +300,7 @@ public class WebUtil
|
||||
String inmEtag = request.getHeader(HEADER_INM);
|
||||
|
||||
if ((inmEtag != null) && (inmEtag.length() > 0)
|
||||
&& inmEtag.equals(getETag(file)))
|
||||
&& inmEtag.equals(getETag(file)))
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user