util classes should be final with a private constructor

This commit is contained in:
Sebastian Sdorra
2013-01-31 10:26:16 +01:00
parent 2d5fa22ca4
commit 9adc65d9e5
34 changed files with 393 additions and 134 deletions

View File

@@ -48,9 +48,17 @@ import java.util.zip.ZipFile;
*
* @author Sebastian Sdorra
*/
public class Util
public final class Util
{
/**
* Constructs ...
*
*/
private Util() {}
//~--- methods --------------------------------------------------------------
/**
* Method description
*

View File

@@ -50,9 +50,17 @@ import java.util.List;
*
* @author Sebastian Sdorra
*/
public class WrapperUtil
public final class WrapperUtil
{
/**
* Constructs ...
*
*/
private WrapperUtil() {}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
@@ -78,7 +86,6 @@ public class WrapperUtil
*
*
*
* @param baseUrl
*
* @param config
* @param repositories
@@ -86,7 +93,7 @@ public class WrapperUtil
* @return
*/
public static List<RepositoryWrapper> wrapRepositories(ServerConfig config,
Collection<Repository> repositories)
Collection<Repository> repositories)
{
List<RepositoryWrapper> wrappers = new ArrayList<RepositoryWrapper>();

View File

@@ -49,13 +49,21 @@ import com.sun.jersey.api.client.filter.LoggingFilter;
*
* @author Sebastian Sdorra
*/
public class ClientUtil
public final class ClientUtil
{
/** the logger for ClientUtil */
private static final Logger logger =
LoggerFactory.getLogger(ClientUtil.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private ClientUtil() {}
//~--- methods --------------------------------------------------------------
/**

View File

@@ -50,7 +50,7 @@ import com.sun.jersey.api.client.WebResource;
*
* @author Sebastian Sdorra
*/
public class ClientTestUtil
public final class ClientTestUtil
{
/** Field description */
@@ -68,6 +68,13 @@ public class ClientTestUtil
/** Field description */
public static final boolean REQUEST_LOGGING = false;
private ClientTestUtil()
{
}
//~--- methods --------------------------------------------------------------
/**

View File

@@ -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
*

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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

View File

@@ -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.
*

View File

@@ -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 --------------------------------------------------------------
/**

View File

@@ -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;

View File

@@ -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;

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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 --------------------------------------------------------------
/**

View File

@@ -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);
}
/**

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -30,6 +30,7 @@
*/
package sonia.scm.orientdb;
//~--- non-JDK imports --------------------------------------------------------
@@ -54,7 +55,7 @@ import java.util.List;
*
* @author Sebastian Sdorra
*/
public class OrientDBUtil
public final class OrientDBUtil
{
/** Field description */
@@ -66,6 +67,14 @@ public class OrientDBUtil
private static final Logger logger =
LoggerFactory.getLogger(OrientDBUtil.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private OrientDBUtil() {}
//~--- methods --------------------------------------------------------------
/**
@@ -93,7 +102,7 @@ public class OrientDBUtil
* @return
*/
public static List<ODocument> executeListResultQuery(
ODatabaseDocumentTx connection, String query, Object... parameters)
ODatabaseDocumentTx connection, String query, Object... parameters)
{
if (logger.isTraceEnabled())
{
@@ -118,7 +127,7 @@ public class OrientDBUtil
* @return
*/
public static ODocument executeSingleResultQuery(
ODatabaseDocumentTx connection, String query, Object... parameters)
ODatabaseDocumentTx connection, String query, Object... parameters)
{
if (logger.isTraceEnabled())
{
@@ -152,7 +161,7 @@ public class OrientDBUtil
* @return
*/
public static <T> List<ODocument> transformToDocuments(
Converter<T> converter, List<T> items)
Converter<T> converter, List<T> items)
{
List<ODocument> docs = null;
@@ -175,14 +184,14 @@ public class OrientDBUtil
* @return
*/
public static <T> List<T> transformToItems(Converter<T> converter,
List<ODocument> docs)
List<ODocument> docs)
{
List<T> items = null;
if (Util.isNotEmpty(docs))
{
items = Lists.transform(docs,
new DocumentConverterFunction<T>(converter));
new DocumentConverterFunction<T>(converter));
}
return items;
@@ -200,7 +209,7 @@ public class OrientDBUtil
* @author Enter your name here...
*/
private static class DocumentConverterFunction<T>
implements Function<ODocument, T>
implements Function<ODocument, T>
{
/**
@@ -248,7 +257,7 @@ public class OrientDBUtil
* @author Enter your name here...
*/
private static class ItemConverterFunction<F>
implements Function<F, ODocument>
implements Function<F, ODocument>
{
/**

View File

@@ -48,9 +48,17 @@ import java.util.List;
*
* @author Sebastian Sdorra
*/
public class PluginUtil
public final class PluginUtil
{
/**
* Constructs ...
*
*/
private PluginUtil() {}
//~--- methods --------------------------------------------------------------
/**
* Method description
*

View File

@@ -63,7 +63,7 @@ import java.util.Map;
*
* @author Sebastian Sdorra
*/
public class GitUtil
public final class GitUtil
{
/** Field description */
@@ -84,6 +84,14 @@ public class GitUtil
/** the logger for GitUtil */
private static final Logger logger = LoggerFactory.getLogger(GitUtil.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private GitUtil() {}
//~--- methods --------------------------------------------------------------
/**

View File

@@ -48,12 +48,20 @@ import java.io.File;
*
* @author Sebastian Sdorra
*/
public class HgUtil
public final class HgUtil
{
/** Field description */
public static final String REVISION_TIP = "tip";
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private HgUtil() {}
//~--- get methods ----------------------------------------------------------
/**

View File

@@ -30,6 +30,7 @@
*/
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
@@ -40,9 +41,17 @@ import org.junit.Assume;
*
* @author Sebastian Sdorra
*/
public class HgTestUtil
public final class HgTestUtil
{
/**
* Constructs ...
*
*/
private HgTestUtil() {}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
@@ -51,6 +60,7 @@ public class HgTestUtil
*/
public static void checkForSkip(HgRepositoryHandler handler)
{
// skip tests if hg not in path
if (!handler.isConfigured())
{

View File

@@ -57,7 +57,7 @@ import java.util.Map;
*
* @author Sebastian Sdorra
*/
public class SvnUtil
public final class SvnUtil
{
/**
@@ -65,6 +65,14 @@ public class SvnUtil
*/
private static final Logger logger = LoggerFactory.getLogger(SvnUtil.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private SvnUtil() {}
//~--- methods --------------------------------------------------------------
/**

View File

@@ -67,13 +67,21 @@ import javax.servlet.http.HttpServletResponse;
*
* @author Sebastian Sdorra
*/
public class MockUtil
public final class MockUtil
{
/** Field description */
private static final User ADMIN = new User("scmadmin", "SCM Admin",
"scmadmin@scm.org");
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private MockUtil() {}
//~--- methods --------------------------------------------------------------
/**

View File

@@ -46,7 +46,7 @@ import javax.servlet.ServletContext;
*
* @author Sebastian Sdorra
*/
public class BootstrapUtil
public final class BootstrapUtil
{
/** Field description */
@@ -56,6 +56,14 @@ public class BootstrapUtil
private static final Logger logger =
LoggerFactory.getLogger(BootstrapUtil.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private BootstrapUtil() {}
//~--- methods --------------------------------------------------------------
/**
@@ -96,7 +104,7 @@ public class BootstrapUtil
* @return
*/
public static <T> T loadClass(ClassLoader classLoader, Class<T> clazz,
String className)
String className)
{
T instance = null;
@@ -164,7 +172,7 @@ public class BootstrapUtil
* @param classLoader
*/
public static void setClassLoader(ServletContext context,
ClassLoader classLoader)
ClassLoader classLoader)
{
context.setAttribute(CLASSLOADER, classLoader);
}

View File

@@ -56,7 +56,7 @@ import javax.xml.bind.Unmarshaller;
*
* @author Sebastian Sdorra
*/
public class ScmConfigurationUtil
public final class ScmConfigurationUtil
{
/** Field description */
@@ -72,13 +72,13 @@ public class ScmConfigurationUtil
* Constructs ...
*
*/
public ScmConfigurationUtil()
private ScmConfigurationUtil()
{
try
{
context = JAXBContext.newInstance(ScmConfiguration.class);
file = new File(SCMContext.getContext().getBaseDirectory(),
ScmConfiguration.PATH);
ScmConfiguration.PATH);
}
catch (JAXBException ex)
{

View File

@@ -42,12 +42,20 @@ import sonia.scm.SCMContext;
/**
*
* @author Sebastian Sdorra
* @deprecated
* @deprecated
*/
@Deprecated
public class SecurityUtil
public final class SecurityUtil
{
/**
* Constructs ...
*
*/
private SecurityUtil() {}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
@@ -57,7 +65,7 @@ public class SecurityUtil
* @return
*/
public static String getUsername(
Provider<WebSecurityContext> securityContextProvider)
Provider<WebSecurityContext> securityContextProvider)
{
return getUsername(securityContextProvider.get());
}

View File

@@ -68,7 +68,7 @@ import javax.ws.rs.core.MultivaluedMap;
*
* @author Sebastian Sdorra
*/
public class IntegrationTestUtil
public final class IntegrationTestUtil
{
/** Field description */
@@ -83,6 +83,14 @@ public class IntegrationTestUtil
/** Field description */
public static final String EXTENSION = ".xml";
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private IntegrationTestUtil() {}
//~--- methods --------------------------------------------------------------
/**
@@ -96,7 +104,7 @@ public class IntegrationTestUtil
* @return
*/
public static ClientResponse authenticate(Client client, String username,
String password)
String password)
{
WebResource wr = createResource(client, "authentication/login");
MultivaluedMap<String, String> formData = new MultivaluedMapImpl();
@@ -105,7 +113,7 @@ public class IntegrationTestUtil
formData.add("password", password);
return wr.type("application/x-www-form-urlencoded").post(
ClientResponse.class, formData);
ClientResponse.class, formData);
}
/**
@@ -165,7 +173,7 @@ public class IntegrationTestUtil
DefaultApacheHttpClientConfig config = new DefaultApacheHttpClientConfig();
config.getProperties().put(ApacheHttpClientConfig.PROPERTY_HANDLE_COOKIES,
true);
true);
return ApacheHttpClient.create(config);
}
@@ -181,7 +189,7 @@ public class IntegrationTestUtil
* @throws RepositoryClientException
*/
public static void createRandomFile(RepositoryClient client)
throws IOException, RepositoryClientException
throws IOException, RepositoryClientException
{
String uuid = UUID.randomUUID().toString();
String name = "file-" + uuid + ".uuid";
@@ -257,7 +265,7 @@ public class IntegrationTestUtil
public static File createTempDirectory()
{
File directory = new File(System.getProperty("java.io.tmpdir"),
UUID.randomUUID().toString());
UUID.randomUUID().toString());
IOUtil.mkdirs(directory);

View File

@@ -51,9 +51,17 @@ import com.sun.jersey.api.client.WebResource;
*
* @author Sebastian Sdorra
*/
public class RepositoryITUtil
public final class RepositoryITUtil
{
/**
* Constructs ...
*
*/
private RepositoryITUtil() {}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
@@ -62,7 +70,7 @@ public class RepositoryITUtil
* @param other
*/
public static void assertRepositoriesEquals(Repository repository,
Repository other)
Repository other)
{
assertEquals(repository.getName(), other.getName());
assertEquals(repository.getDescription(), other.getDescription());
@@ -82,7 +90,7 @@ public class RepositoryITUtil
* @return
*/
public static Repository createRepository(Client client,
Repository repository)
Repository repository)
{
WebResource wr = createResource(client, "repositories");
ClientResponse response = wr.post(ClientResponse.class, repository);