mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-02-26 00:10:50 +01:00
Cleanup Code
Pushed-by: Rene Pfeuffer<rene.pfeuffer@cloudogu.com> Co-authored-by: René Pfeuffer<rene.pfeuffer@cloudogu.com>
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.annotation;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.w3c.dom.Document;
|
||||
@@ -33,11 +32,7 @@ import org.w3c.dom.Element;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class ClassSetElement implements DescriptorElement {
|
||||
|
||||
private static final String EL_CLASS = "class";
|
||||
|
||||
@@ -24,24 +24,14 @@
|
||||
|
||||
package sonia.scm.annotation;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
public interface DescriptorElement
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param doc
|
||||
* @param root
|
||||
*/
|
||||
|
||||
public void append(Document doc, Element root);
|
||||
}
|
||||
|
||||
@@ -81,9 +81,7 @@ import java.util.Set;
|
||||
import static javax.lang.model.util.ElementFilter.methodsIn;
|
||||
|
||||
|
||||
/**
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@SupportedAnnotationTypes("*")
|
||||
@MetaInfServices(Processor.class)
|
||||
@SuppressWarnings({"Since16"})
|
||||
|
||||
@@ -24,42 +24,30 @@
|
||||
|
||||
package sonia.scm.annotation;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
public class SubscriberElement implements DescriptorElement
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final String EL_CLASS = "class";
|
||||
|
||||
/** Field description */
|
||||
private static final String EL_DESCRIPTION = "description";
|
||||
|
||||
/** Field description */
|
||||
private static final String EL_EVENT = "event";
|
||||
|
||||
/** Field description */
|
||||
private static final String EL_SUBSCRIBER = "subscriber";
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
private final String description;
|
||||
|
||||
private final String eventType;
|
||||
|
||||
private final String subscriberType;
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param subscriberType
|
||||
* @param eventType
|
||||
* @param description
|
||||
*/
|
||||
public SubscriberElement(String subscriberType, String eventType,
|
||||
String description)
|
||||
{
|
||||
@@ -68,15 +56,8 @@ public class SubscriberElement implements DescriptorElement
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param doc
|
||||
* @param root
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void append(Document doc, Element root)
|
||||
{
|
||||
@@ -102,14 +83,4 @@ public class SubscriberElement implements DescriptorElement
|
||||
root.appendChild(subscriberEl);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final String description;
|
||||
|
||||
/** Field description */
|
||||
private final String eventType;
|
||||
|
||||
/** Field description */
|
||||
private final String subscriberType;
|
||||
}
|
||||
|
||||
@@ -24,12 +24,9 @@
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.BindingAnnotation;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -40,7 +37,6 @@ import java.lang.annotation.Target;
|
||||
* The default annotation can be used to inject the default implementation of
|
||||
* service. The annotation is mainly used to inject the ServletContext.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Documented
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -34,7 +32,6 @@ import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Documented
|
||||
|
||||
@@ -33,7 +33,6 @@ import java.lang.annotation.Target;
|
||||
/**
|
||||
* Annotation to specify the source of an enricher.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Documented
|
||||
|
||||
@@ -24,12 +24,9 @@
|
||||
|
||||
package sonia.scm.event;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.plugin.PluginAnnotation;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -40,7 +37,6 @@ import java.lang.annotation.Target;
|
||||
* This annotation marks classes which are receivable over the event bus of
|
||||
* scm-manager.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.33
|
||||
*/
|
||||
@Documented
|
||||
|
||||
@@ -24,12 +24,9 @@
|
||||
|
||||
package sonia.scm.filter;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.plugin.PluginAnnotation;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -40,7 +37,6 @@ import java.lang.annotation.Target;
|
||||
* Annotation to register servlets and filters. The annotation is automatically
|
||||
* picked up by the plugin registration processor of SCM-Manager.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Documented
|
||||
@@ -69,14 +65,11 @@ public @interface WebElement
|
||||
* Returns {@code true} if the path patterns are specified as regex patterns.
|
||||
* Default is {@code false}.
|
||||
*
|
||||
* @return {@code true} if the path patterns are specified as regex patterns
|
||||
*/
|
||||
public boolean regex() default false;
|
||||
|
||||
/**
|
||||
* Returns an array of init params.
|
||||
*
|
||||
* @return array of init params
|
||||
*/
|
||||
public WebInitParam[] initParams() default {};
|
||||
}
|
||||
|
||||
@@ -34,24 +34,13 @@ import java.lang.annotation.Target;
|
||||
* Init param for servlet of filter registration. This annotation can only be
|
||||
* used with {@link WebElement}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Documented
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface WebInitParam
|
||||
{
|
||||
/**
|
||||
* Name of the init parameter.
|
||||
*
|
||||
* @return name of init parameter
|
||||
*/
|
||||
public String name();
|
||||
|
||||
/**
|
||||
* Value of the init parameter.
|
||||
*
|
||||
* @return value of init parameter
|
||||
*/
|
||||
public String value();
|
||||
}
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
package sonia.scm.i18n;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -36,7 +34,6 @@ import java.lang.annotation.Target;
|
||||
* The I18n annotation is used by the I18nMessages class to define the
|
||||
* resource bundle key.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.37
|
||||
*/
|
||||
@Documented
|
||||
@@ -46,8 +43,6 @@ public @interface I18n
|
||||
{
|
||||
/**
|
||||
* Returns the key for the resource bundle.
|
||||
*
|
||||
* @return resource bundle key
|
||||
*/
|
||||
String value();
|
||||
}
|
||||
|
||||
@@ -24,18 +24,13 @@
|
||||
|
||||
package sonia.scm.plugin;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@Documented
|
||||
@Target({ ElementType.TYPE })
|
||||
@PluginAnnotation("extension")
|
||||
|
||||
@@ -30,10 +30,7 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@Documented
|
||||
@Target({ ElementType.TYPE })
|
||||
@PluginAnnotation("extension-point")
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
package sonia.scm.plugin;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -34,7 +32,6 @@ import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Documented
|
||||
|
||||
@@ -59,8 +59,6 @@ public @interface Indexed {
|
||||
|
||||
/**
|
||||
* {@code true} if this field should be part of default query for this type of object.
|
||||
*
|
||||
* @return {@code true} if field is part of default query
|
||||
*/
|
||||
boolean defaultQuery() default false;
|
||||
|
||||
@@ -76,7 +74,6 @@ public @interface Indexed {
|
||||
/**
|
||||
* {@code true} to search the field value for matches and returns fragments with those matches instead of the whole value.
|
||||
*
|
||||
* @return {@code true} to return matched fragments
|
||||
*/
|
||||
boolean highlighted() default false;
|
||||
|
||||
@@ -150,9 +147,6 @@ public @interface Indexed {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the field is tokenized.
|
||||
*
|
||||
* @return {@code true} if tokenized
|
||||
* @see #TOKENIZED
|
||||
*/
|
||||
public boolean isTokenized() {
|
||||
@@ -160,19 +154,12 @@ public @interface Indexed {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the field is searchable.
|
||||
*
|
||||
* @return {@code true} if searchable
|
||||
* @see #SEARCHABLE
|
||||
*/
|
||||
public boolean isSearchable() {
|
||||
return searchable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the field is stored.
|
||||
* @return {@code true} if stored
|
||||
*/
|
||||
public boolean isStored() {
|
||||
return stored;
|
||||
}
|
||||
|
||||
@@ -28,55 +28,27 @@ package sonia.scm;
|
||||
* This type of exception is only thrown by scm-manager backend implementation,
|
||||
* such as the xml or jdbc backend.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.14
|
||||
*/
|
||||
public class BackendException extends RuntimeException
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final long serialVersionUID = -6885276113482167556L;
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
public BackendException()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
public BackendException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param cause
|
||||
*/
|
||||
public BackendException(Throwable cause)
|
||||
{
|
||||
super(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param message
|
||||
* @param cause
|
||||
*/
|
||||
public BackendException(String message, Throwable cause)
|
||||
{
|
||||
super(message, cause);
|
||||
|
||||
@@ -70,8 +70,6 @@ final class BaseDirectory {
|
||||
|
||||
/**
|
||||
* Returns the determined base directory.
|
||||
*
|
||||
* @return base directory
|
||||
*/
|
||||
@SuppressWarnings("java:S5304") // it is safe to use environment in this case
|
||||
static Path get() {
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Strings;
|
||||
@@ -40,12 +39,9 @@ import java.nio.file.Path;
|
||||
import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The default implementation of {@link SCMContextProvider}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@SuppressWarnings("java:S106") // we can not use logger until base directory is not determined
|
||||
public class BasicContextProvider implements SCMContextProvider
|
||||
@@ -67,10 +63,22 @@ public class BasicContextProvider implements SCMContextProvider
|
||||
/** Maven property for the version of the artifact */
|
||||
public static final String MAVEN_PROPERTY_VERSION = "version";
|
||||
|
||||
|
||||
public static final String DEVELOPMENT_INSTANCE_ID = "00000000-0000-0000-0000-000000000000";
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
/** The base directory of the SCM-Manager */
|
||||
private File baseDirectory;
|
||||
|
||||
/** stage of the current SCM-Manager instance */
|
||||
private Stage stage;
|
||||
|
||||
/** startup exception */
|
||||
private Throwable startupError;
|
||||
|
||||
/** the version of the SCM-Manager */
|
||||
private String version;
|
||||
|
||||
/** the instance id of the SCM-Manager */
|
||||
private String instanceId;
|
||||
|
||||
/**
|
||||
* Constructs a new {@link BasicContextProvider} object.
|
||||
@@ -101,9 +109,6 @@ public class BasicContextProvider implements SCMContextProvider
|
||||
this.stage = stage;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
|
||||
@Override
|
||||
public Path resolve(Path path) {
|
||||
if (path.isAbsolute()) {
|
||||
@@ -113,29 +118,22 @@ public class BasicContextProvider implements SCMContextProvider
|
||||
return baseDirectory.toPath().resolve(path);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public File getBaseDirectory()
|
||||
{
|
||||
return baseDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Stage getStage()
|
||||
{
|
||||
return stage;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Throwable getStartupError()
|
||||
{
|
||||
@@ -145,9 +143,6 @@ public class BasicContextProvider implements SCMContextProvider
|
||||
/**
|
||||
* Returns the version of the SCM-Manager. If the version is not set, the
|
||||
* {@link #VERSION_DEFAULT} is returned.
|
||||
*
|
||||
*
|
||||
* @return the version of the SCM-Manager
|
||||
*/
|
||||
@Override
|
||||
public String getVersion()
|
||||
@@ -160,7 +155,6 @@ public class BasicContextProvider implements SCMContextProvider
|
||||
return instanceId;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Find the base directory of SCM-Manager.
|
||||
@@ -201,9 +195,6 @@ public class BasicContextProvider implements SCMContextProvider
|
||||
|
||||
/**
|
||||
* Loads the version of the SCM-Manager from maven properties file.
|
||||
*
|
||||
*
|
||||
* @return the version of the SCM-Manager
|
||||
*/
|
||||
private String loadVersion()
|
||||
{
|
||||
@@ -255,20 +246,5 @@ public class BasicContextProvider implements SCMContextProvider
|
||||
return uuid;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** The base directory of the SCM-Manager */
|
||||
private File baseDirectory;
|
||||
|
||||
/** stage of the current SCM-Manager instance */
|
||||
private Stage stage;
|
||||
|
||||
/** startup exception */
|
||||
private Throwable startupError;
|
||||
|
||||
/** the version of the SCM-Manager */
|
||||
private String version;
|
||||
|
||||
/** the instance id of the SCM-Manager */
|
||||
private String instanceId;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Maps;
|
||||
@@ -36,26 +35,20 @@ import sonia.scm.xml.XmlMapStringAdapter;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Default implementation of {@link PropertiesAware} interface.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class BasicPropertiesAware implements PropertiesAware, Serializable
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final long serialVersionUID = -536608122577385802L;
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
/** map to hold the properties */
|
||||
@XmlJavaTypeAdapter(XmlMapStringAdapter.class)
|
||||
protected Map<String, String> properties;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
@@ -74,32 +67,22 @@ public class BasicPropertiesAware implements PropertiesAware, Serializable
|
||||
return Objects.equal(properties, other.properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hashCode(properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void removeProperty(String key)
|
||||
{
|
||||
getProperties().remove(key);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Map<String, String> getProperties()
|
||||
{
|
||||
@@ -111,41 +94,26 @@ public class BasicPropertiesAware implements PropertiesAware, Serializable
|
||||
return properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*/
|
||||
|
||||
@Override
|
||||
public String getProperty(String key)
|
||||
{
|
||||
return getProperties().get(key);
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void setProperties(Map<String, String> properties)
|
||||
{
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void setProperty(String key, String value)
|
||||
{
|
||||
getProperties().put(key, value);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** map to hold the properties */
|
||||
@XmlJavaTypeAdapter(XmlMapStringAdapter.class)
|
||||
protected Map<String, String> properties;
|
||||
}
|
||||
|
||||
@@ -24,22 +24,20 @@
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import sonia.scm.i18n.I18nMessages;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* I18n messages which are send back to client.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.37
|
||||
*/
|
||||
public final class ClientMessages
|
||||
{
|
||||
private String failedAuthentication;
|
||||
private String notEnoughPrivileges;
|
||||
|
||||
/**
|
||||
* Constructs a new instance of ClientMessages. This constructor should not be
|
||||
@@ -48,13 +46,9 @@ public final class ClientMessages
|
||||
*/
|
||||
public ClientMessages() {}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the localized string for a failed authentication.
|
||||
*
|
||||
*
|
||||
* @return localized string
|
||||
*/
|
||||
public String failedAuthentication()
|
||||
{
|
||||
@@ -62,35 +56,21 @@ public final class ClientMessages
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the localized string for "not enough privileges.
|
||||
*
|
||||
*
|
||||
* @return localized string
|
||||
* Returns the localized string for not enough privileges.
|
||||
*/
|
||||
public String notEnoughPrivileges()
|
||||
{
|
||||
return notEnoughPrivileges;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns an instance {@link ClientMessages}.
|
||||
*
|
||||
* @param request servlet request
|
||||
*
|
||||
* @return instance of client messages
|
||||
*/
|
||||
public static ClientMessages get(HttpServletRequest request)
|
||||
{
|
||||
return I18nMessages.get(ClientMessages.class, request);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** failed authentication */
|
||||
private String failedAuthentication;
|
||||
|
||||
/** not enough privileges */
|
||||
private String notEnoughPrivileges;
|
||||
}
|
||||
|
||||
@@ -27,54 +27,28 @@ package sonia.scm;
|
||||
/**
|
||||
* Exception for problems with the SCM-Manager configuration.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class ConfigurationException extends RuntimeException
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final long serialVersionUID = 3462977946341972841L;
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs a {@link ConfigurationException}
|
||||
*
|
||||
*/
|
||||
public ConfigurationException()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@link ConfigurationException}
|
||||
*
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
public ConfigurationException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@link ConfigurationException}
|
||||
*
|
||||
*
|
||||
* @param cause
|
||||
*/
|
||||
public ConfigurationException(Throwable cause)
|
||||
{
|
||||
super(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@link ConfigurationException}
|
||||
*
|
||||
*
|
||||
* @param message
|
||||
* @param cause
|
||||
*/
|
||||
public ConfigurationException(String message, Throwable cause)
|
||||
{
|
||||
super(message, cause);
|
||||
|
||||
@@ -27,16 +27,12 @@ package sonia.scm;
|
||||
/**
|
||||
* Base interface of all objects which have a creation time.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.14
|
||||
*/
|
||||
public interface CreationTimeAware
|
||||
{
|
||||
/**
|
||||
* Returns a timestamp of object creation.
|
||||
*
|
||||
*
|
||||
* @return timestamp of object creation
|
||||
*/
|
||||
public Long getCreationTime();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ package sonia.scm;
|
||||
/**
|
||||
* Factory for decorated objects.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.23
|
||||
*
|
||||
* @param <T>
|
||||
@@ -35,13 +34,5 @@ package sonia.scm;
|
||||
public interface DecoratorFactory<T>
|
||||
{
|
||||
|
||||
/**
|
||||
* Create a decorator for the given object.
|
||||
*
|
||||
*
|
||||
* @param object object to decorate
|
||||
*
|
||||
* @return decorated object
|
||||
*/
|
||||
public T createDecorator(T object);
|
||||
}
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -34,7 +32,6 @@ import java.lang.annotation.Target;
|
||||
/**
|
||||
* Eager singleton scope for injection.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.23
|
||||
*/
|
||||
@Target({ ElementType.TYPE, ElementType.METHOD })
|
||||
|
||||
@@ -65,9 +65,8 @@ public abstract class ExceptionWithContext extends RuntimeException {
|
||||
|
||||
/**
|
||||
* Returns an url which gives more information about the exception or an empty optional.
|
||||
* The methods returns an empty optional by default and can be overwritten.
|
||||
* The method returns an empty optional by default and can be overwritten.
|
||||
*
|
||||
* @return information url or empty
|
||||
* @since 2.5.0
|
||||
*/
|
||||
public Optional<String> getUrl() {
|
||||
|
||||
@@ -28,7 +28,6 @@ import java.util.Collections;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @version 1.6
|
||||
*/
|
||||
@SuppressWarnings("squid:MaximumInheritanceDepth") // exceptions have a deep inheritance depth themselves; therefore we accept this here
|
||||
|
||||
@@ -21,18 +21,15 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
package sonia.scm;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Generic data access object. A DAO does not check the permission of the
|
||||
* current user. A DAO should only used by a {@link Manager} class.
|
||||
* current user. A DAO should only be used by a {@link Manager} class.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.14
|
||||
*
|
||||
* @param <T> type of object
|
||||
@@ -44,7 +41,6 @@ public interface GenericDAO<T>
|
||||
/**
|
||||
* Persists a new item.
|
||||
*
|
||||
*
|
||||
* @param item item to persist
|
||||
*/
|
||||
public void add(T item);
|
||||
@@ -52,10 +48,7 @@ public interface GenericDAO<T>
|
||||
/**
|
||||
* Returns true if the item already exists in the backend.
|
||||
*
|
||||
*
|
||||
* @param item item to check
|
||||
*
|
||||
* @return true if the item already exists
|
||||
*/
|
||||
public boolean contains(T item);
|
||||
|
||||
@@ -63,17 +56,13 @@ public interface GenericDAO<T>
|
||||
* Returns true if the item with the specified id
|
||||
* already exists in the backend.
|
||||
*
|
||||
*
|
||||
* @param id id of the item to check
|
||||
*
|
||||
* @return true if the item already exists
|
||||
*/
|
||||
public boolean contains(String id);
|
||||
|
||||
/**
|
||||
* Updates an existing item.
|
||||
*
|
||||
*
|
||||
* @param item item to update
|
||||
*/
|
||||
public void modify(T item);
|
||||
@@ -81,29 +70,20 @@ public interface GenericDAO<T>
|
||||
/**
|
||||
* Removes the specified item from the backend.
|
||||
*
|
||||
*
|
||||
* @param item item to remove
|
||||
*/
|
||||
public void delete(T item);
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the item by its id or returns null if no item with
|
||||
* the specified id exists in the backend.
|
||||
*
|
||||
*
|
||||
* @param id id of the item
|
||||
*
|
||||
* @return item with the specified id or null
|
||||
*/
|
||||
public T get(String id);
|
||||
|
||||
/**
|
||||
* Returns all items stored in the backend.
|
||||
*
|
||||
*
|
||||
* @return all items
|
||||
*/
|
||||
public Collection<T> getAll();
|
||||
|
||||
|
||||
@@ -21,13 +21,12 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
/**
|
||||
* Base interface for all handler objects.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*
|
||||
* @param <T> a typed object
|
||||
*/
|
||||
@@ -35,17 +34,11 @@ public interface Handler<T extends TypedObject> extends HandlerBase<T> {
|
||||
|
||||
/**
|
||||
* Returns the type object of the handler.
|
||||
*
|
||||
*
|
||||
* @return type object of the handler
|
||||
*/
|
||||
Type getType();
|
||||
|
||||
/**
|
||||
* Returns true if the hanlder is configured.
|
||||
*
|
||||
*
|
||||
* @return true if the hanlder is configured
|
||||
*/
|
||||
boolean isConfigured();
|
||||
}
|
||||
|
||||
@@ -21,17 +21,14 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
package sonia.scm;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
/**
|
||||
* The base class of all handlers.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*
|
||||
* @param <T> type object of the handler
|
||||
*/
|
||||
@@ -41,24 +38,16 @@ public interface HandlerBase<T extends TypedObject>
|
||||
|
||||
/**
|
||||
* Persists a new object.
|
||||
*
|
||||
* @return The persisted object.
|
||||
*/
|
||||
T create(T object);
|
||||
|
||||
/**
|
||||
* Removes a persistent object.
|
||||
*
|
||||
*
|
||||
* @param object to delete
|
||||
*/
|
||||
void delete(T object);
|
||||
|
||||
/**
|
||||
* Modifies a persistent object.
|
||||
*
|
||||
*
|
||||
* @param object to modify
|
||||
*/
|
||||
void modify(T object);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ package sonia.scm;
|
||||
/**
|
||||
* Handler event type.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public enum HandlerEventType
|
||||
{
|
||||
@@ -38,12 +37,12 @@ public enum HandlerEventType
|
||||
CREATE(true),
|
||||
|
||||
/**
|
||||
* After a object is modified by a handler.
|
||||
* After an object is modified by a handler.
|
||||
*/
|
||||
MODIFY(true),
|
||||
|
||||
/**
|
||||
* After a object is removed by a handler.
|
||||
* After an object is removed by a handler.
|
||||
*/
|
||||
DELETE(true),
|
||||
|
||||
@@ -54,35 +53,25 @@ public enum HandlerEventType
|
||||
BEFORE_CREATE(false),
|
||||
|
||||
/**
|
||||
* Before a object is modified by a handler.
|
||||
* Before an object is modified by a handler.
|
||||
* @since 1.16
|
||||
*/
|
||||
BEFORE_MODIFY(false),
|
||||
|
||||
/**
|
||||
* Before a object is removed by a handler.
|
||||
* Before an object is removed by a handler.
|
||||
* @since 1.16
|
||||
*/
|
||||
BEFORE_DELETE(false);
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param post
|
||||
*/
|
||||
private HandlerEventType(boolean post)
|
||||
{
|
||||
this.post = post;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns true if the event is fired after the action is occurred.
|
||||
*
|
||||
*
|
||||
* @return true if the event is fired after the action is occurred
|
||||
* @since 1.21
|
||||
*/
|
||||
public boolean isPost()
|
||||
@@ -93,8 +82,6 @@ public enum HandlerEventType
|
||||
/**
|
||||
* Returns true if the event is fired before the action is occurred.
|
||||
*
|
||||
*
|
||||
* @return true if the event is fired before the action is occurred
|
||||
* @since 1.21
|
||||
*/
|
||||
public boolean isPre()
|
||||
@@ -102,8 +89,5 @@ public enum HandlerEventType
|
||||
return !post;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final boolean post;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ package sonia.scm;
|
||||
/**
|
||||
* Base interface for all initable objects.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public interface Initable
|
||||
{
|
||||
|
||||
@@ -27,16 +27,12 @@ package sonia.scm;
|
||||
/**
|
||||
* Base interface of all objects which have a last modified date.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public interface LastModifiedAware
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns a timestamp of the last modified date.
|
||||
*
|
||||
*
|
||||
* @return timestamp of the last modified date
|
||||
*/
|
||||
public Long getLastModified();
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import java.util.function.Predicate;
|
||||
/**
|
||||
* Base interface for all manager classes.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*
|
||||
* @param <T> type of the model object
|
||||
*/
|
||||
@@ -41,7 +40,7 @@ public interface Manager<T extends ModelObject>
|
||||
|
||||
|
||||
/**
|
||||
* Reloads a object from store and overwrites all changes.
|
||||
* Reloads an object from store and overwrites all changes.
|
||||
*
|
||||
*
|
||||
* @param object to refresh
|
||||
@@ -50,7 +49,6 @@ public interface Manager<T extends ModelObject>
|
||||
*/
|
||||
void refresh(T object);
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the object with the given id.
|
||||
@@ -64,9 +62,6 @@ public interface Manager<T extends ModelObject>
|
||||
|
||||
/**
|
||||
* Returns a {@link java.util.Collection} of all objects in the store.
|
||||
*
|
||||
*
|
||||
* @return all object in the store
|
||||
*/
|
||||
Collection<T> getAll();
|
||||
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
@@ -34,19 +32,12 @@ import java.util.function.Predicate;
|
||||
/**
|
||||
* Basic decorator for manager classes.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.23
|
||||
*
|
||||
* @param <T> model type
|
||||
*/
|
||||
public class ManagerDecorator<T extends ModelObject> implements Manager<T> {
|
||||
|
||||
/**
|
||||
* Constructs a new ManagerDecorator.
|
||||
*
|
||||
*
|
||||
* @param decorated manager implementation
|
||||
*/
|
||||
public ManagerDecorator(Manager<T> decorated)
|
||||
{
|
||||
this.decorated = decorated;
|
||||
|
||||
@@ -24,14 +24,11 @@
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Base interface for all model objects.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public interface ModelObject
|
||||
extends TypedObject, LastModifiedAware, Cloneable, Validateable,
|
||||
@@ -40,9 +37,6 @@ public interface ModelObject
|
||||
|
||||
/**
|
||||
* Returns the unique id of the model object
|
||||
*
|
||||
*
|
||||
* @return unique id
|
||||
*/
|
||||
String getId();
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
import sonia.scm.event.HandlerEvent;
|
||||
@@ -30,16 +30,13 @@ import sonia.scm.event.HandlerEvent;
|
||||
* Extension to the {@link ModificationHandlerEvent}.
|
||||
*
|
||||
* @param <T> type of changed item
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*
|
||||
* @since 1.48
|
||||
*/
|
||||
public interface ModificationHandlerEvent<T> extends HandlerEvent<T>
|
||||
{
|
||||
/**
|
||||
* Returns item, before it was modified.
|
||||
*
|
||||
* @return item before modification
|
||||
*/
|
||||
public T getItemBeforeModification();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ package sonia.scm;
|
||||
/**
|
||||
* Interface for objects using a password.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.13
|
||||
*/
|
||||
public interface PasswordAware
|
||||
@@ -35,19 +34,12 @@ public interface PasswordAware
|
||||
|
||||
/**
|
||||
* Returns the encrypted password.
|
||||
*
|
||||
*
|
||||
* @return encrypted password
|
||||
*/
|
||||
public String getPassword();
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Sets the encrypted password
|
||||
*
|
||||
*
|
||||
* @param password encrypted password
|
||||
*/
|
||||
public void setPassword(String password);
|
||||
}
|
||||
|
||||
@@ -21,32 +21,35 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Represents the platform on which the SCM manager running.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class Platform
|
||||
{
|
||||
|
||||
private String arch;
|
||||
|
||||
private String name;
|
||||
|
||||
private PlatformType type;
|
||||
|
||||
private boolean x64;
|
||||
/**
|
||||
* Constructs a {@link Platform} object
|
||||
*
|
||||
*
|
||||
* @param osName - name of the operation system
|
||||
* @param osName - name of the operating system
|
||||
* @param archModel - name of the host architecture model
|
||||
* @param osArch - name of the operation system architecture
|
||||
* @param osArch - name of the operating system architecture
|
||||
*/
|
||||
public Platform(String osName, String archModel, String osArch)
|
||||
{
|
||||
@@ -67,13 +70,9 @@ public class Platform
|
||||
type = PlatformType.createPlatformType(osName);
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns true if the operating system is a 32 bit operating system.
|
||||
*
|
||||
*
|
||||
* @return true if the operating system is a 32 bit operating system
|
||||
* Returns true if the operating system is a 32-bit operating system.
|
||||
*/
|
||||
public boolean is32Bit()
|
||||
{
|
||||
@@ -82,22 +81,15 @@ public class Platform
|
||||
|
||||
/**
|
||||
* Returns true if the operating system is a 64 a bit operating system.
|
||||
*
|
||||
*
|
||||
* @return true if the operating system is a 64 a bit operating system
|
||||
*/
|
||||
public boolean is64Bit()
|
||||
{
|
||||
return x64;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the architecture of the platform.
|
||||
*
|
||||
*
|
||||
* @return the architecture of the platform
|
||||
*/
|
||||
public String getArch()
|
||||
{
|
||||
@@ -106,9 +98,6 @@ public class Platform
|
||||
|
||||
/**
|
||||
* Returns the name of the platform.
|
||||
*
|
||||
*
|
||||
* @return name of the platform
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
@@ -117,9 +106,6 @@ public class Platform
|
||||
|
||||
/**
|
||||
* Returns the type of the platform.
|
||||
*
|
||||
*
|
||||
* @return type of the platform
|
||||
*/
|
||||
public PlatformType getType()
|
||||
{
|
||||
@@ -128,9 +114,6 @@ public class Platform
|
||||
|
||||
/**
|
||||
* Returns true if the operating system is a FreeBSD.
|
||||
*
|
||||
*
|
||||
* @return true if the operating system is a FreeBSD
|
||||
*/
|
||||
public boolean isFreeBSD()
|
||||
{
|
||||
@@ -139,9 +122,6 @@ public class Platform
|
||||
|
||||
/**
|
||||
* Returns true if the operating system is a Linux.
|
||||
*
|
||||
*
|
||||
* @return true if the operating system is a Linux
|
||||
*/
|
||||
public boolean isLinux()
|
||||
{
|
||||
@@ -150,9 +130,6 @@ public class Platform
|
||||
|
||||
/**
|
||||
* Returns true if the operating system is a Mac OS.
|
||||
*
|
||||
*
|
||||
* @return true if the operating system is a Mac OS
|
||||
*/
|
||||
public boolean isMac()
|
||||
{
|
||||
@@ -161,9 +138,6 @@ public class Platform
|
||||
|
||||
/**
|
||||
* Returns true if the operating system is a OpenBSD.
|
||||
*
|
||||
*
|
||||
* @return true if the operating system is a OpenBSD
|
||||
*/
|
||||
public boolean isOpenBSD()
|
||||
{
|
||||
@@ -172,9 +146,6 @@ public class Platform
|
||||
|
||||
/**
|
||||
* Returns true if the operating system has posix support.
|
||||
*
|
||||
*
|
||||
* @return true if the operating system has posix support
|
||||
*/
|
||||
public boolean isPosix()
|
||||
{
|
||||
@@ -183,9 +154,6 @@ public class Platform
|
||||
|
||||
/**
|
||||
* Returns true if the operating system is a Solaris.
|
||||
*
|
||||
*
|
||||
* @return true if the operating system is a Solaris
|
||||
*/
|
||||
public boolean isSolaris()
|
||||
{
|
||||
@@ -194,9 +162,6 @@ public class Platform
|
||||
|
||||
/**
|
||||
* Returns true if the operating system is a Unix system.
|
||||
*
|
||||
*
|
||||
* @return true if the operating system is a Unix system
|
||||
*/
|
||||
public boolean isUnix()
|
||||
{
|
||||
@@ -205,26 +170,10 @@ public class Platform
|
||||
|
||||
/**
|
||||
* Returns true if the operating system is a Windows.
|
||||
*
|
||||
*
|
||||
* @return true if the operating system is a Windows
|
||||
*/
|
||||
public boolean isWindows()
|
||||
{
|
||||
return PlatformType.WINDOWS == type;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private String arch;
|
||||
|
||||
/** Field description */
|
||||
private String name;
|
||||
|
||||
/** Field description */
|
||||
private PlatformType type;
|
||||
|
||||
/** Field description */
|
||||
private boolean x64;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import java.util.Locale;
|
||||
/**
|
||||
* Type of the SCM-Manager host platform.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public enum PlatformType
|
||||
{
|
||||
@@ -37,6 +36,12 @@ public enum PlatformType
|
||||
WINDOWS(false, false), SOLARIS(true, true), FREEBSD(true, true),
|
||||
OPENBSD(true, true);
|
||||
|
||||
/** has the platform support for posix */
|
||||
private boolean posix;
|
||||
|
||||
/** is the platform a unix system */
|
||||
private boolean unix;
|
||||
|
||||
/**
|
||||
* Constructs {@link PlatformType} object.
|
||||
*
|
||||
@@ -50,15 +55,12 @@ public enum PlatformType
|
||||
this.posix = posix;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns {@link PlatformType} object for the given operating system name.
|
||||
*
|
||||
*
|
||||
* @param osName - name of the operating system
|
||||
*
|
||||
* @return {@link PlatformType} object for the given operating system name
|
||||
*/
|
||||
public static PlatformType createPlatformType(String osName)
|
||||
{
|
||||
@@ -94,7 +96,6 @@ public enum PlatformType
|
||||
return type;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns true if the platform has support for posix.
|
||||
@@ -118,11 +119,4 @@ public enum PlatformType
|
||||
return unix;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** has the platform support for posix */
|
||||
private boolean posix;
|
||||
|
||||
/** is the platform is a unix system */
|
||||
private boolean unix;
|
||||
}
|
||||
|
||||
@@ -24,37 +24,26 @@
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.common.primitives.Ints;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Priority constants and util methods to sort classes by {@link Priority}
|
||||
* annotation.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public final class Priorities
|
||||
{
|
||||
|
||||
/** default priority */
|
||||
public static final int DEFAULT = 9999;
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private Priorities() {}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns a list sorted by priority.
|
||||
@@ -83,7 +72,6 @@ public final class Priorities
|
||||
}
|
||||
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the priority of the given class.
|
||||
@@ -106,8 +94,6 @@ public final class Priorities
|
||||
return priority;
|
||||
}
|
||||
|
||||
//~--- inner classes --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@link Ordering} which orders classes by priority.
|
||||
*
|
||||
|
||||
@@ -24,45 +24,32 @@
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Base interface of all objects which have properties.
|
||||
*
|
||||
* @since 1.6
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public interface PropertiesAware
|
||||
{
|
||||
|
||||
/**
|
||||
* Removes a existing property.
|
||||
*
|
||||
* @param key - the key of the property
|
||||
*/
|
||||
public void removeProperty(String key);
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns all properties.
|
||||
*
|
||||
* @return all properties
|
||||
*/
|
||||
public Map<String, String> getProperties();
|
||||
|
||||
/**
|
||||
* Returns the property value for the given key
|
||||
* or null if the key does not exists.
|
||||
* or null if the key does not exist.
|
||||
*
|
||||
* @param key - the key of the property
|
||||
* @return the value of the property
|
||||
*/
|
||||
public String getProperty(String key);
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Sets all properties and overwrites existing ones.
|
||||
|
||||
@@ -28,8 +28,6 @@ package sonia.scm;
|
||||
/**
|
||||
* This is a reduced form of a model object.
|
||||
* It can be used as search result to avoid returning the whole object properties.
|
||||
*
|
||||
* @author Mohamed Karray
|
||||
*/
|
||||
public interface ReducedModelObject {
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.net.URL;
|
||||
|
||||
/**
|
||||
* RootURL is able to return the root url of the SCM-Manager instance,
|
||||
* regardless of the scope (web request, async hook, ssh command, etc).
|
||||
* regardless of the scope (web request, async hook, ssh command, etc.).
|
||||
*
|
||||
* @since 2.3.1
|
||||
*/
|
||||
@@ -43,8 +43,6 @@ public interface RootURL {
|
||||
|
||||
/**
|
||||
* Returns the root url of the SCM-Manager instance as string.
|
||||
*
|
||||
* @return root url as string
|
||||
*/
|
||||
default String getAsString() {
|
||||
return get().toExternalForm();
|
||||
|
||||
@@ -24,17 +24,15 @@
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.security.CipherUtil;
|
||||
import sonia.scm.user.User;
|
||||
import sonia.scm.util.ServiceUtil;
|
||||
|
||||
/**
|
||||
* The SCMContext searches a implementation of {@link SCMContextProvider} and
|
||||
* The SCMContext searches an implementation of {@link SCMContextProvider} and
|
||||
* holds a singleton instance of this implementation.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public final class SCMContext {
|
||||
|
||||
@@ -67,20 +65,13 @@ public final class SCMContext {
|
||||
*/
|
||||
private static SCMContextProvider provider = null;
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*/
|
||||
private SCMContext() {
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the singleton instance of {@link SCMContextProvider}
|
||||
*
|
||||
* @return singleton instance of {@link SCMContextProvider}
|
||||
*/
|
||||
public static SCMContextProvider getContext() {
|
||||
synchronized (SCMContext.class) {
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import sonia.scm.version.Version;
|
||||
|
||||
import java.io.File;
|
||||
@@ -39,14 +37,10 @@ import static java.lang.String.format;
|
||||
* This class is a singleton which can be retrieved via injection
|
||||
* or with the static {@link SCMContext#getContext()} method.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public interface SCMContextProvider {
|
||||
/**
|
||||
* Returns the base directory of the SCM-Manager.
|
||||
*
|
||||
*
|
||||
* @return base directory of the SCM-Manager
|
||||
*/
|
||||
File getBaseDirectory();
|
||||
|
||||
@@ -64,14 +58,12 @@ public interface SCMContextProvider {
|
||||
/**
|
||||
* Returns the current stage of SCM-Manager.
|
||||
*
|
||||
*
|
||||
* @return stage of SCM-Manager
|
||||
* @since 1.12
|
||||
*/
|
||||
Stage getStage();
|
||||
|
||||
/**
|
||||
* Returns a exception which is occurred on context startup.
|
||||
* Returns an exception which is occurred on context startup.
|
||||
* The method returns null if the start was successful.
|
||||
*
|
||||
*
|
||||
@@ -82,18 +74,14 @@ public interface SCMContextProvider {
|
||||
|
||||
/**
|
||||
* Returns the version of the SCM-Manager.
|
||||
*
|
||||
*
|
||||
* @return version of the SCM-Manager
|
||||
*/
|
||||
String getVersion();
|
||||
|
||||
/**
|
||||
* Returns the version of the SCM-Manager used in documentation urls (eg. version 2.17.0 and 2.17.1 will all result
|
||||
* Returns the version of the SCM-Manager used in documentation urls (e.g. version 2.17.0 and 2.17.1 will all result
|
||||
* in 2.17.x). The default implementation works for versions with three parts (major version, minor version,
|
||||
* and patch version, where the patch version will be replaces with an 'x').
|
||||
* and patch version, where the patch version will be replaced with an 'x').
|
||||
*
|
||||
* @return version of the SCM-Manager used in documentation urls
|
||||
* @since 2.17.0
|
||||
*/
|
||||
default String getDocumentationVersion() {
|
||||
@@ -104,7 +92,6 @@ public interface SCMContextProvider {
|
||||
/**
|
||||
* Returns the instance id of the SCM-Manager used.
|
||||
*
|
||||
* @return instance id of the SCM-Manager
|
||||
* @since 2.30.0
|
||||
*/
|
||||
default String getInstanceId() {
|
||||
|
||||
@@ -67,7 +67,7 @@ public class ScmConstraintViolationException extends RuntimeException implements
|
||||
}
|
||||
|
||||
/**
|
||||
* An optional URL for more informations about this constraint violation.
|
||||
* An optional URL for more information about this constraint violation.
|
||||
*/
|
||||
public String getUrl() {
|
||||
return furtherInformation;
|
||||
@@ -102,7 +102,7 @@ public class ScmConstraintViolationException extends RuntimeException implements
|
||||
* you can call this method multiple times.
|
||||
* @param message The message describing the violation.
|
||||
* @param pathElements The affected property denoted by the path to reach this property,
|
||||
* eg. "someParameter", "complexProperty", "attribute"
|
||||
* e.g. "someParameter", "complexProperty", "attribute"
|
||||
* @return this builder instance.
|
||||
*/
|
||||
public Builder violation(String message, String... pathElements) {
|
||||
@@ -121,7 +121,7 @@ public class ScmConstraintViolationException extends RuntimeException implements
|
||||
}
|
||||
|
||||
/**
|
||||
* When the given condition is <code>true</code>, a exception will be thrown. Otherwise this simply resets this
|
||||
* When the given condition is <code>true</code>, an exception will be thrown. Otherwise, this simply resets this
|
||||
* builder and does nothing else.
|
||||
* @param condition The condition that indicates a violation of this constraint.
|
||||
* @return this builder instance.
|
||||
|
||||
@@ -25,9 +25,8 @@
|
||||
package sonia.scm;
|
||||
|
||||
/**
|
||||
* Type of a servlet container.
|
||||
* Type of servlet container.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public enum ServletContainer
|
||||
{
|
||||
|
||||
@@ -21,10 +21,9 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import jakarta.servlet.RequestDispatcher;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
@@ -36,16 +35,16 @@ import org.slf4j.LoggerFactory;
|
||||
* This class is inspired by
|
||||
* com.liferay.portal.kernel.util.ServerDetector of liferay.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class ServletContainerDetector
|
||||
{
|
||||
/** Servlet request for alternate detection method. */
|
||||
private HttpServletRequest request = null;
|
||||
|
||||
/** Make usage of the logging framework. */
|
||||
private static final Logger LOGGER =
|
||||
LoggerFactory.getLogger(ServletContainerDetector.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs a new ServletContainerDetector depending on the ServletRequest.
|
||||
@@ -56,13 +55,11 @@ public class ServletContainerDetector
|
||||
request = req;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Detects the ServletContainer.
|
||||
*
|
||||
* @param req The used Servlet instance.
|
||||
* @return the detected ServletContainer.
|
||||
* @since 1.32
|
||||
*/
|
||||
public static ServletContainer detect(final HttpServletRequest req)
|
||||
@@ -72,9 +69,6 @@ public class ServletContainerDetector
|
||||
|
||||
/**
|
||||
* Detects the ServletContainer.
|
||||
*
|
||||
*
|
||||
* @return the detected ServletContainer
|
||||
*/
|
||||
public ServletContainer detectContainer()
|
||||
{
|
||||
@@ -139,13 +133,11 @@ public class ServletContainerDetector
|
||||
return container;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns true if the ServletContainer is a Eclipse Jetty.
|
||||
*
|
||||
* @since 1.32
|
||||
* @return true if the ServletContainer is a Eclipse Jetty
|
||||
*/
|
||||
public boolean isEclipseJetty()
|
||||
{
|
||||
@@ -161,9 +153,6 @@ public class ServletContainerDetector
|
||||
|
||||
/**
|
||||
* Returns true if the ServletContainer is a Geronimo.
|
||||
*
|
||||
*
|
||||
* @return true if the ServletContainer is a Geronimo
|
||||
*/
|
||||
public boolean isGeronimo()
|
||||
{
|
||||
@@ -172,9 +161,6 @@ public class ServletContainerDetector
|
||||
|
||||
/**
|
||||
* Returns true if the ServletContainer is a Glassfish.
|
||||
*
|
||||
*
|
||||
* @return true if the ServletContainer is a Glassfish
|
||||
*/
|
||||
public boolean isGlassfish()
|
||||
{
|
||||
@@ -185,9 +171,6 @@ public class ServletContainerDetector
|
||||
|
||||
/**
|
||||
* Returns true if the ServletContainer is a JBoss.
|
||||
*
|
||||
*
|
||||
* @return true if the ServletContainer is a JBos
|
||||
*/
|
||||
public boolean isJBoss()
|
||||
{
|
||||
@@ -196,9 +179,6 @@ public class ServletContainerDetector
|
||||
|
||||
/**
|
||||
* Returns true if the ServletContainer is a JOnAS.
|
||||
*
|
||||
*
|
||||
* @return true if the ServletContainer is a JOnAS
|
||||
*/
|
||||
public boolean isJOnAS()
|
||||
{
|
||||
@@ -214,9 +194,6 @@ public class ServletContainerDetector
|
||||
|
||||
/**
|
||||
* Returns true if the ServletContainer is a Jetty.
|
||||
*
|
||||
*
|
||||
* @return true if the ServletContainer is a Jetty
|
||||
*/
|
||||
public boolean isJetty()
|
||||
{
|
||||
@@ -225,9 +202,6 @@ public class ServletContainerDetector
|
||||
|
||||
/**
|
||||
* Returns true if the ServletContainer is a OC4J.
|
||||
*
|
||||
*
|
||||
* @return true if the ServletContainer is a OC4J
|
||||
*/
|
||||
public boolean isOC4J()
|
||||
{
|
||||
@@ -236,9 +210,6 @@ public class ServletContainerDetector
|
||||
|
||||
/**
|
||||
* Returns true if the ServletContainer is a Resin.
|
||||
*
|
||||
*
|
||||
* @return true if the ServletContainer is a Resin
|
||||
*/
|
||||
public boolean isResin()
|
||||
{
|
||||
@@ -247,9 +218,6 @@ public class ServletContainerDetector
|
||||
|
||||
/**
|
||||
* Returns true if the ServletContainer is a SCM-Server.
|
||||
*
|
||||
*
|
||||
* @return true if the ServletContainer is a SCM-Server
|
||||
*/
|
||||
public boolean isScmServer()
|
||||
{
|
||||
@@ -260,9 +228,6 @@ public class ServletContainerDetector
|
||||
|
||||
/**
|
||||
* Returns true if the ServletContainer is a Tomcat.
|
||||
*
|
||||
*
|
||||
* @return true if the ServletContainer is a Tomcat
|
||||
*/
|
||||
public boolean isTomcat()
|
||||
{
|
||||
@@ -278,9 +243,6 @@ public class ServletContainerDetector
|
||||
|
||||
/**
|
||||
* Returns true if the ServletContainer is a WebLogic.
|
||||
*
|
||||
*
|
||||
* @return true if the ServletContainer is a WebLogic
|
||||
*/
|
||||
public boolean isWebLogic()
|
||||
{
|
||||
@@ -289,24 +251,18 @@ public class ServletContainerDetector
|
||||
|
||||
/**
|
||||
* Returns true if the ServletContainer is a WebSphere.
|
||||
*
|
||||
*
|
||||
* @return true if the ServletContainer is a WebSpere
|
||||
*/
|
||||
public boolean isWebSphere()
|
||||
{
|
||||
return detect("/com/ibm/websphere/product/VersionInfo.class");
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns true if the given class exists in the system classpath.
|
||||
*
|
||||
*
|
||||
* @param clazz class name to search in classpath
|
||||
*
|
||||
* @return true if class exists in system classpath
|
||||
*/
|
||||
private boolean detect(final String clazz)
|
||||
{
|
||||
@@ -332,18 +288,16 @@ public class ServletContainerDetector
|
||||
}
|
||||
|
||||
/**
|
||||
* An alternate detection. The default servlet that must be implemented by each application, so we can get it's
|
||||
* An alternate detection. The default servlet that must be implemented by each application, so we can get its
|
||||
* class name and compare against our suggestion.
|
||||
*
|
||||
* @since 1.32
|
||||
* @param keyword Part of the class path that is needed at the implementation class.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean detectDefaultServlet(final String keyword)
|
||||
{
|
||||
|
||||
// Request the default servlet (its pretty safe to say it will always be there)
|
||||
// Request the default servlet (It's pretty safe to say it will always be there)
|
||||
final RequestDispatcher dispatcher =
|
||||
request.getServletContext().getNamedDispatcher("default");
|
||||
|
||||
@@ -356,8 +310,4 @@ public class ServletContainerDetector
|
||||
return dispatcher.getClass().getName().contains(keyword);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Servlet request for alternate detection method. */
|
||||
private HttpServletRequest request = null;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
/**
|
||||
@@ -29,11 +29,9 @@ package sonia.scm;
|
||||
* SCM_Manager instance. The stage can be queried by calling
|
||||
* {@link SCMContextProvider#getStage()}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.12
|
||||
*/
|
||||
public enum Stage
|
||||
{
|
||||
public enum Stage {
|
||||
|
||||
/**
|
||||
* This value indicates SCM-Manager is right now in development.
|
||||
@@ -47,38 +45,24 @@ public enum Stage
|
||||
|
||||
/**
|
||||
* This value indicates SCM-Manager is right now in development but specifically configured for testing.
|
||||
*
|
||||
* @since 2.47.0
|
||||
*/
|
||||
TESTING(com.google.inject.Stage.DEVELOPMENT);
|
||||
|
||||
/**
|
||||
* Constructs a new Stage
|
||||
*
|
||||
*
|
||||
* @param injectionStage injection stage
|
||||
*/
|
||||
private Stage(com.google.inject.Stage injectionStage)
|
||||
{
|
||||
private final com.google.inject.Stage injectionStage;
|
||||
|
||||
private Stage(com.google.inject.Stage injectionStage) {
|
||||
this.injectionStage = injectionStage;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the injection stage
|
||||
*
|
||||
*
|
||||
* @return injection stage
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public com.google.inject.Stage getInjectionStage()
|
||||
{
|
||||
public com.google.inject.Stage getInjectionStage() {
|
||||
return injectionStage;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** injection stage */
|
||||
private final com.google.inject.Stage injectionStage;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ package sonia.scm;
|
||||
/**
|
||||
* Util class to transform multiple objects.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*
|
||||
* @param <T> type of objects to transform
|
||||
* @param <R> result type of the transformation
|
||||
@@ -43,7 +42,7 @@ public interface TransformFilter<T, R>
|
||||
*
|
||||
* @param item
|
||||
*
|
||||
* @return tranformed object
|
||||
* @return transformed object
|
||||
*/
|
||||
R accept(T item);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import sonia.scm.util.AssertUtil;
|
||||
@@ -33,11 +32,15 @@ import sonia.scm.util.Util;
|
||||
/**
|
||||
* Base class for all objects which supports different types.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@XmlRootElement
|
||||
public class Type
|
||||
{
|
||||
/** display name of the type */
|
||||
private String displayName;
|
||||
|
||||
/** unique name of the type */
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Constructs {@link Type} object.
|
||||
@@ -68,15 +71,12 @@ public class Type
|
||||
}
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns true if the given ovject is equals.
|
||||
* Returns true if the given object is equals.
|
||||
*
|
||||
*
|
||||
* @param obj
|
||||
*
|
||||
* @return true if the given ovject is equals
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
@@ -112,9 +112,6 @@ public class Type
|
||||
|
||||
/**
|
||||
* Returns the hash code of the object.
|
||||
*
|
||||
*
|
||||
* @return hash code of the object
|
||||
*/
|
||||
@Override
|
||||
public int hashCode()
|
||||
@@ -131,12 +128,6 @@ public class Type
|
||||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link String} representation of the type.
|
||||
*
|
||||
*
|
||||
* @return {@link String} representation of the type
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
@@ -147,13 +138,9 @@ public class Type
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the display name of the type.
|
||||
*
|
||||
*
|
||||
* @return display name of the type
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
@@ -162,16 +149,12 @@ public class Type
|
||||
|
||||
/**
|
||||
* Returns the unique name of the type.
|
||||
*
|
||||
*
|
||||
* @return unique name of the type
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Setter for the display name of the type
|
||||
@@ -196,11 +179,4 @@ public class Type
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** display name of the type */
|
||||
private String displayName;
|
||||
|
||||
/** unique name of the type */
|
||||
private String name;
|
||||
}
|
||||
|
||||
@@ -24,14 +24,11 @@
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Base interface for all type manager classes.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*
|
||||
* @param <T> type of the model object
|
||||
* @param <H> type of the handler
|
||||
@@ -44,16 +41,12 @@ public interface TypeManager<T extends ModelObject, H extends Handler<T>> extend
|
||||
* null if no handler of that type is available.
|
||||
*
|
||||
* @param type name of the handler
|
||||
*
|
||||
* @return the handler for given type
|
||||
*/
|
||||
H getHandler(String type);
|
||||
|
||||
/**
|
||||
* Returns a {@link java.util.Collection} of all
|
||||
* available and configured types.
|
||||
*
|
||||
* @return all available types
|
||||
*/
|
||||
Collection<Type> getTypes();
|
||||
}
|
||||
|
||||
@@ -21,22 +21,18 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
/**
|
||||
* Base interface for all objects of specific type.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public interface TypedObject
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns the type of the object.
|
||||
*
|
||||
*
|
||||
* @return type of the object
|
||||
*/
|
||||
public String getType();
|
||||
String getType();
|
||||
}
|
||||
|
||||
@@ -27,16 +27,12 @@ package sonia.scm;
|
||||
/**
|
||||
* Base interface for all validateable objects.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public interface Validateable
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns true if the object is valid.
|
||||
*
|
||||
*
|
||||
* @return true if the object is valid
|
||||
*/
|
||||
public boolean isValid();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ public interface BranchLinkProvider {
|
||||
*
|
||||
* @param namespaceAndName The namespace and name of the repository.
|
||||
* @param branch The name of the branch.
|
||||
* @return Internal api link for the given branch.
|
||||
*/
|
||||
String get(NamespaceAndName namespaceAndName, String branch);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.api.v2.resources;
|
||||
|
||||
import de.otto.edison.hal.HalRepresentation;
|
||||
@@ -31,7 +31,6 @@ import java.util.List;
|
||||
/**
|
||||
* The {@link HalAppender} can be used within an {@link HalEnricher} to append hateoas links to a json response.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public interface HalAppender {
|
||||
|
||||
@@ -33,7 +33,6 @@ import sonia.scm.plugin.ExtensionPoint;
|
||||
*
|
||||
* <b>Warning:</b> enrichers are always registered as singletons.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@ExtensionPoint
|
||||
|
||||
@@ -34,7 +34,6 @@ import java.util.Optional;
|
||||
* Context object for the {@link HalEnricher}. The context holds the source object for the json and all related
|
||||
* objects, which can be useful for the enrichment.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public final class HalEnricherContext {
|
||||
@@ -49,8 +48,6 @@ public final class HalEnricherContext {
|
||||
* Creates a context with the given entries
|
||||
*
|
||||
* @param instances entries of the context
|
||||
*
|
||||
* @return context of given entries
|
||||
*/
|
||||
public static HalEnricherContext of(Object... instances) {
|
||||
ImmutableMap.Builder<Class<?>, Object> builder = ImmutableMap.builder();
|
||||
@@ -62,7 +59,6 @@ public final class HalEnricherContext {
|
||||
|
||||
/**
|
||||
* Return builder for {@link HalEnricherContext}.
|
||||
* @return builder
|
||||
* @since 2.23.0
|
||||
*/
|
||||
public static Builder builder() {
|
||||
@@ -125,7 +121,6 @@ public final class HalEnricherContext {
|
||||
|
||||
/**
|
||||
* Returns the {@link HalEnricherContext}.
|
||||
* @return context
|
||||
*/
|
||||
public HalEnricherContext build() {
|
||||
return new HalEnricherContext(mapBuilder.build());
|
||||
|
||||
@@ -32,7 +32,6 @@ import sonia.scm.plugin.Extension;
|
||||
/**
|
||||
* The {@link HalEnricherRegistry} is responsible for binding {@link HalEnricher} instances to their source types.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Extension
|
||||
@@ -55,7 +54,6 @@ public final class HalEnricherRegistry {
|
||||
* Returns all registered {@link HalEnricher} for the given type.
|
||||
*
|
||||
* @param sourceType type of json mapping source
|
||||
* @return all registered enrichers
|
||||
*/
|
||||
public Iterable<HalEnricher> allByType(Class sourceType) {
|
||||
return enrichers.get(sourceType);
|
||||
|
||||
@@ -27,7 +27,6 @@ package sonia.scm.api.v2.resources;
|
||||
/**
|
||||
* The {@link Index} object can be used to register a {@link HalEnricher} for the index resource.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public final class Index {
|
||||
|
||||
@@ -27,7 +27,6 @@ package sonia.scm.api.v2.resources;
|
||||
/**
|
||||
* The {@link Me} object can be used to register a {@link HalEnricher} for the me resource.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public final class Me {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.api.v2.resources;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -32,7 +32,6 @@ public interface RepositoryLinkProvider {
|
||||
* Returns the internal api link for the given repository.
|
||||
*
|
||||
* @param namespaceAndName The namespace and name of the repository.
|
||||
* @return Internal api link for the given repository.
|
||||
*/
|
||||
String get(NamespaceAndName namespaceAndName);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.cache;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
@@ -32,7 +31,6 @@ import com.google.common.base.Predicate;
|
||||
* The main interface for the cache.
|
||||
* Provides methods to add, access, and remove entries from a cache.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*
|
||||
* @param <K> type of the keys for the cache
|
||||
* @param <V> type of cached elements
|
||||
@@ -42,17 +40,13 @@ public interface Cache<K, V> extends org.apache.shiro.cache.Cache<K, V> {
|
||||
|
||||
/**
|
||||
* Remove all elements from this cache.
|
||||
*
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Returns true if this cache contains an element with the specified key.
|
||||
*
|
||||
*
|
||||
* @param key key of the cached element
|
||||
*
|
||||
* @return true if this cache contains an element with the specified key
|
||||
*/
|
||||
boolean contains(K key);
|
||||
|
||||
@@ -84,8 +78,6 @@ public interface Cache<K, V> extends org.apache.shiro.cache.Cache<K, V> {
|
||||
* @since 1.9
|
||||
*
|
||||
* @param predicate predicate to match cache keys
|
||||
*
|
||||
* @return all previous cached values
|
||||
*/
|
||||
@SuppressWarnings("java:S4738") // we have to use guava predicate for compatibility
|
||||
Iterable<V> removeAll(Predicate<K> predicate);
|
||||
@@ -93,13 +85,10 @@ public interface Cache<K, V> extends org.apache.shiro.cache.Cache<K, V> {
|
||||
/**
|
||||
* Returns the number of entries in the cache.
|
||||
*
|
||||
* @return number of entries in the cache
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
int size();
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the element with the specified key.
|
||||
@@ -116,8 +105,6 @@ public interface Cache<K, V> extends org.apache.shiro.cache.Cache<K, V> {
|
||||
* support statistics. The returned statistic is a snapshot of the current
|
||||
* performance.
|
||||
*
|
||||
* @return performance statistics or null
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
CacheStatistics getStatistics();
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
package sonia.scm.cache;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
/**
|
||||
@@ -33,7 +31,6 @@ import java.io.Closeable;
|
||||
* and manages their creation.
|
||||
* This class is a singleton which can be retrieved via injection.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public interface CacheManager extends Closeable {
|
||||
|
||||
|
||||
@@ -31,11 +31,19 @@ import com.google.common.base.Objects;
|
||||
* Statistics about the performance of a {@link Cache}.
|
||||
* Instances of this class are immutable.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public final class CacheStatistics {
|
||||
|
||||
private final long hitCount;
|
||||
|
||||
private final long missCount;
|
||||
|
||||
/**
|
||||
* name of cache
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Constructs a new performance statistic for a {@link Cache}.
|
||||
*
|
||||
@@ -49,11 +57,8 @@ public final class CacheStatistics {
|
||||
this.missCount = missCount;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
@@ -71,17 +76,13 @@ public final class CacheStatistics {
|
||||
&& Objects.equal(missCount, other.missCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(name, hitCount, missCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
//J-
|
||||
@@ -93,7 +94,6 @@ public final class CacheStatistics {
|
||||
//J+
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns number of times requested elements were found in the cache.
|
||||
@@ -106,8 +106,6 @@ public final class CacheStatistics {
|
||||
|
||||
/**
|
||||
* Returns the ratio of cache requests which were hits.
|
||||
*
|
||||
* @return ratio of cache hits
|
||||
*/
|
||||
public double getHitRate() {
|
||||
return ratio(hitCount);
|
||||
@@ -115,8 +113,6 @@ public final class CacheStatistics {
|
||||
|
||||
/**
|
||||
* Returns number of times a requested element was not found in the cache.
|
||||
*
|
||||
* @return number of cache misses
|
||||
*/
|
||||
public long getMissCount() {
|
||||
return missCount;
|
||||
@@ -124,8 +120,6 @@ public final class CacheStatistics {
|
||||
|
||||
/**
|
||||
* Returns the ratio of cache requests which were misses.
|
||||
*
|
||||
* @return ratio of cache misses
|
||||
*/
|
||||
public double getMissRate() {
|
||||
return ratio(missCount);
|
||||
@@ -133,8 +127,6 @@ public final class CacheStatistics {
|
||||
|
||||
/**
|
||||
* Returns name of the cache.
|
||||
*
|
||||
* @return name of the cache
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
@@ -142,8 +134,6 @@ public final class CacheStatistics {
|
||||
|
||||
/**
|
||||
* Returns the total number of requests, this includes hits and misses.
|
||||
*
|
||||
* @return numer of requests
|
||||
*/
|
||||
public long getRequestCount() {
|
||||
return hitCount + missCount;
|
||||
@@ -163,18 +153,5 @@ public final class CacheStatistics {
|
||||
: (double) counter / requestCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* hit count
|
||||
*/
|
||||
private final long hitCount;
|
||||
|
||||
/**
|
||||
* miss count
|
||||
*/
|
||||
private final long missCount;
|
||||
|
||||
/**
|
||||
* name of cache
|
||||
*/
|
||||
private final String name;
|
||||
}
|
||||
|
||||
@@ -61,13 +61,11 @@ public interface CliContext {
|
||||
|
||||
/**
|
||||
* Returns the {@link Locale} of the client terminal.
|
||||
* @return locale of the client terminal
|
||||
*/
|
||||
Locale getLocale();
|
||||
|
||||
/**
|
||||
* Returns the client.
|
||||
* @return client
|
||||
*/
|
||||
Client getClient();
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ import java.lang.annotation.Target;
|
||||
* Defines a custom resource bundle for the CLI command
|
||||
*
|
||||
* We need to use this workaround instead the picocli way because we cannot ensure that the resource bundles can be found by the classloader.
|
||||
* Currently there is no solution for picocli to chose which classloader should be used to load command-related resource bundle.
|
||||
* Currently, there is no solution for picocli to chose which classloader should be used to load command-related resource bundle.
|
||||
*
|
||||
* @since 2.35.0
|
||||
*/
|
||||
|
||||
@@ -24,15 +24,12 @@
|
||||
|
||||
package sonia.scm.collect;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@@ -40,7 +37,6 @@ import java.util.concurrent.Callable;
|
||||
* A {@link Callable} which consumes all items from a {@link QueueIterator} and
|
||||
* returns a list with all items from the queue.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*
|
||||
* @since 1.29
|
||||
*
|
||||
@@ -49,13 +45,9 @@ import java.util.concurrent.Callable;
|
||||
public class CallableQueueCollector<T> implements Callable<List<T>>
|
||||
{
|
||||
|
||||
/**
|
||||
* the logger for CallableListComsumer
|
||||
*/
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(CallableQueueCollector.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs a new {@link CallableQueueCollector} from the given
|
||||
@@ -68,7 +60,6 @@ public class CallableQueueCollector<T> implements Callable<List<T>>
|
||||
this.queue = queue;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Creates a {@link List} from all items of the queue.
|
||||
|
||||
@@ -21,10 +21,9 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.collect;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -32,37 +31,34 @@ import com.google.common.collect.Lists;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A iterable queue. The queue can have multiple parallel consumer
|
||||
* {@link Iterator}s, which can iterate over all items of the queue until the
|
||||
* end of the queue is reached. The end of the queue if reached, if a producer
|
||||
* An iterable queue. The queue can have multiple parallel consumer
|
||||
* {@link Iterator}s, which can iterate over all items of the queue until the
|
||||
* end of the queue is reached. The end of the queue if reached, if a producer
|
||||
* call the method {@link #endReached()} and the iterator has consumed all items
|
||||
* of the backend list. <strong>Warning: </strong> The queue iterator blocks
|
||||
* of the backend list. <strong>Warning: </strong> The queue iterator blocks
|
||||
* forever if the producer never call {@link #endReached()}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*
|
||||
* @since 1.29
|
||||
* @param <T> type of the queued items
|
||||
*/
|
||||
public final class IterableQueue<T> implements Iterable<T>
|
||||
{
|
||||
private boolean endReached = false;
|
||||
|
||||
/** backend list of the queue */
|
||||
private List<T> list;
|
||||
|
||||
/**
|
||||
* the logger for IterableQueue
|
||||
*/
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(IterableQueue.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs a new {@link IterableQueue} with the default implementation
|
||||
* Constructs a new {@link IterableQueue} with the default implementation
|
||||
* of the backing list.
|
||||
*
|
||||
*/
|
||||
@@ -82,10 +78,9 @@ public final class IterableQueue<T> implements Iterable<T>
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Mark that the end of the queue is reached and notify all consuming
|
||||
* Mark that the end of the queue is reached and notify all consuming
|
||||
* iterators.
|
||||
*
|
||||
* @throws IllegalStateException if the end of the queue if already reached
|
||||
@@ -102,11 +97,11 @@ public final class IterableQueue<T> implements Iterable<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new consuming iterator for the queue. The methods
|
||||
* {@link Iterator#hasNext()} and {@link Iterator#next()} of the
|
||||
* {@link Iterator} will block until the next item is pushed to the queue, if
|
||||
* the queue is empty and the end is not reached. The
|
||||
* {@link Iterator#remove()} method of the {@link Iterator} is not implemented
|
||||
* Returns a new consuming iterator for the queue. The methods
|
||||
* {@link Iterator#hasNext()} and {@link Iterator#next()} of the
|
||||
* {@link Iterator} will block until the next item is pushed to the queue, if
|
||||
* the queue is empty and the end is not reached. The
|
||||
* {@link Iterator#remove()} method of the {@link Iterator} is not implemented
|
||||
* and will throw a {@link UnsupportedOperationException}.
|
||||
*
|
||||
*
|
||||
@@ -151,24 +146,15 @@ public final class IterableQueue<T> implements Iterable<T>
|
||||
|
||||
/**
|
||||
* Returns the current size of the queue.
|
||||
*
|
||||
*
|
||||
* @return current size
|
||||
*/
|
||||
int size()
|
||||
{
|
||||
return list.size();
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the item at the specified index in this queue.
|
||||
*
|
||||
*
|
||||
* @param index index of the item in the queue
|
||||
*
|
||||
* @return item at the current index
|
||||
*/
|
||||
T get(int index)
|
||||
{
|
||||
@@ -177,20 +163,10 @@ public final class IterableQueue<T> implements Iterable<T>
|
||||
|
||||
/**
|
||||
* Returns true if the end of the queue is reached.
|
||||
*
|
||||
*
|
||||
* @return true if the end is reached
|
||||
*/
|
||||
boolean isEndReached()
|
||||
{
|
||||
return endReached;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** marker for the end of the queue */
|
||||
private boolean endReached = false;
|
||||
|
||||
/** backend list of the queue */
|
||||
private List<T> list;
|
||||
}
|
||||
|
||||
@@ -21,16 +21,13 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.collect;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.collect.ForwardingSortedSet;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.SortedSet;
|
||||
@@ -40,13 +37,16 @@ import java.util.TreeSet;
|
||||
* A sorted set which is limited to a specified maximum size. If the maximum
|
||||
* size is reached the last element is removed from the set.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*
|
||||
* @param <E>
|
||||
* @since 1.32
|
||||
*/
|
||||
public class LimitedSortedSet<E> extends ForwardingSortedSet<E>
|
||||
{
|
||||
private int maxSize;
|
||||
|
||||
/** delegate set */
|
||||
private SortedSet<E> sortedSet;
|
||||
|
||||
/**
|
||||
* Constructs a new set with the specified maximum.
|
||||
@@ -74,11 +74,8 @@ public class LimitedSortedSet<E> extends ForwardingSortedSet<E>
|
||||
this.maxSize = maxSize;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean add(E o)
|
||||
{
|
||||
@@ -89,9 +86,7 @@ public class LimitedSortedSet<E> extends ForwardingSortedSet<E>
|
||||
return added;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends E> c)
|
||||
{
|
||||
@@ -116,7 +111,6 @@ public class LimitedSortedSet<E> extends ForwardingSortedSet<E>
|
||||
|
||||
/**
|
||||
* Remove the last entries, if the maximum size is reached.
|
||||
*
|
||||
*/
|
||||
private void cleanUp()
|
||||
{
|
||||
@@ -126,11 +120,4 @@ public class LimitedSortedSet<E> extends ForwardingSortedSet<E>
|
||||
}
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** maximum size of the set */
|
||||
private int maxSize;
|
||||
|
||||
/** delegate set */
|
||||
private SortedSet<E> sortedSet;
|
||||
}
|
||||
|
||||
@@ -24,12 +24,9 @@
|
||||
|
||||
package sonia.scm.collect;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.collect.UnmodifiableIterator;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -38,13 +35,15 @@ import java.util.concurrent.TimeUnit;
|
||||
* only be created from the {@link IterableQueue} by calling the
|
||||
* {@link IterableQueue#iterator()}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*
|
||||
* @since 1.29
|
||||
* @param <T> type of the queued items
|
||||
*/
|
||||
public final class QueueIterator<T> extends UnmodifiableIterator<T>
|
||||
{
|
||||
private final IterableQueue<T> queue;
|
||||
|
||||
private int index = 0;
|
||||
|
||||
/**
|
||||
* Constructs a new {@link QueueIterator} for the given {@link IterableQueue}.
|
||||
@@ -57,7 +56,6 @@ public final class QueueIterator<T> extends UnmodifiableIterator<T>
|
||||
this.queue = queue;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the next item in the queue. This method will block until the next
|
||||
@@ -79,16 +77,11 @@ public final class QueueIterator<T> extends UnmodifiableIterator<T>
|
||||
return queue.get(index++);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns {@code true} {@code true} if the queue has more items.
|
||||
* Returns {@code true} if the queue has more items.
|
||||
* This method will block until the next item is pushed to the queue, if the
|
||||
* queue is empty and the end is not
|
||||
* reached.
|
||||
*
|
||||
*
|
||||
* @return {@code true} {@code true} if the queue has more items
|
||||
* queue is empty and the end is not reached.
|
||||
*/
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
@@ -118,11 +111,4 @@ public final class QueueIterator<T> extends UnmodifiableIterator<T>
|
||||
return result;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** queue for the iterator */
|
||||
private final IterableQueue<T> queue;
|
||||
|
||||
/** current index */
|
||||
private int index = 0;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@ import java.util.concurrent.TimeUnit;
|
||||
/**
|
||||
* The main configuration object for SCM-Manager.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@Singleton
|
||||
|
||||
@@ -30,7 +30,6 @@ import sonia.scm.event.Event;
|
||||
* The {@link ScmConfigurationChangedEvent} is fired whenever the
|
||||
* {@link ScmConfiguration} changes.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.34
|
||||
*/
|
||||
@Event
|
||||
|
||||
@@ -21,10 +21,9 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.event;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Objects;
|
||||
@@ -33,7 +32,6 @@ import sonia.scm.HandlerEventType;
|
||||
/**
|
||||
* Abstract base class for {@link HandlerEvent}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param <T>
|
||||
@@ -41,26 +39,18 @@ import sonia.scm.HandlerEventType;
|
||||
public class AbstractHandlerEvent<T> implements HandlerEvent<T>
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param eventType
|
||||
* @param item
|
||||
*/
|
||||
private final HandlerEventType eventType;
|
||||
|
||||
/** changed item */
|
||||
private final T item;
|
||||
|
||||
private final T oldItem;
|
||||
|
||||
public AbstractHandlerEvent(HandlerEventType eventType, T item)
|
||||
{
|
||||
this(eventType, item, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param eventType
|
||||
* @param item
|
||||
* @param oldItem
|
||||
*/
|
||||
public AbstractHandlerEvent(HandlerEventType eventType, T item, T oldItem)
|
||||
{
|
||||
this.eventType = eventType;
|
||||
@@ -68,16 +58,7 @@ public class AbstractHandlerEvent<T> implements HandlerEvent<T>
|
||||
this.oldItem = oldItem;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param obj
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
@@ -98,24 +79,14 @@ public class AbstractHandlerEvent<T> implements HandlerEvent<T>
|
||||
&& Objects.equal(oldItem, other.oldItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hashCode(eventType, item, oldItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
@@ -128,13 +99,9 @@ public class AbstractHandlerEvent<T> implements HandlerEvent<T>
|
||||
//J+
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the type of the event.
|
||||
*
|
||||
*
|
||||
* @return type of the event
|
||||
*/
|
||||
@Override
|
||||
public HandlerEventType getEventType()
|
||||
@@ -144,9 +111,6 @@ public class AbstractHandlerEvent<T> implements HandlerEvent<T>
|
||||
|
||||
/**
|
||||
* Returns changed item.
|
||||
*
|
||||
*
|
||||
* @return changed item
|
||||
*/
|
||||
@Override
|
||||
public T getItem()
|
||||
@@ -155,7 +119,7 @@ public class AbstractHandlerEvent<T> implements HandlerEvent<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns old item or null. This method will always return null expect of
|
||||
* Returns old item or null. This method will always return null expect of
|
||||
* modification events.
|
||||
*
|
||||
*
|
||||
@@ -167,14 +131,4 @@ public class AbstractHandlerEvent<T> implements HandlerEvent<T>
|
||||
return oldItem;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** event type */
|
||||
private final HandlerEventType eventType;
|
||||
|
||||
/** changed item */
|
||||
private final T item;
|
||||
|
||||
/** old item */
|
||||
private final T oldItem;
|
||||
}
|
||||
|
||||
@@ -24,14 +24,12 @@
|
||||
|
||||
package sonia.scm.event;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.HandlerEventType;
|
||||
|
||||
/**
|
||||
* Base class for handler events.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.23
|
||||
*
|
||||
* @param <T>
|
||||
@@ -39,19 +37,10 @@ import sonia.scm.HandlerEventType;
|
||||
public interface HandlerEvent<T>
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns the type of the event,
|
||||
*
|
||||
*
|
||||
* @return event type
|
||||
*/
|
||||
public HandlerEventType getEventType();
|
||||
|
||||
/**
|
||||
* Returns the item which has changed.
|
||||
*
|
||||
*
|
||||
* @return changed item
|
||||
*/
|
||||
public T getItem();
|
||||
|
||||
|
||||
@@ -24,18 +24,12 @@
|
||||
|
||||
package sonia.scm.event;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.github.legman.EventBus;
|
||||
import com.github.legman.Subscribe;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.util.ServiceUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
@@ -43,30 +37,20 @@ import java.util.ServiceLoader;
|
||||
* themselves. The ScmEventBus searches its implementation with the
|
||||
* {@link ServiceLoader}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @apiviz.landmark
|
||||
* @see EventBus
|
||||
* @since 1.23
|
||||
*/
|
||||
public abstract class ScmEventBus {
|
||||
|
||||
/**
|
||||
* Field description
|
||||
*/
|
||||
private static ScmEventBus instance;
|
||||
|
||||
/**
|
||||
* the logger for ScmEventBus
|
||||
*/
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(ScmEventBus.class);
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the singleton instance of the ScmEventBus
|
||||
*
|
||||
* @return singleton instance
|
||||
*/
|
||||
public static ScmEventBus getInstance() {
|
||||
synchronized (ScmEventBus.class) {
|
||||
@@ -86,10 +70,9 @@ public abstract class ScmEventBus {
|
||||
return instance;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Post a event through the event bus. All registered subscribers will be
|
||||
* Post an event through the event bus. All registered subscribers will be
|
||||
* notified by the event bus.
|
||||
*
|
||||
* @param event event to send through the event bus
|
||||
@@ -97,17 +80,13 @@ public abstract class ScmEventBus {
|
||||
public abstract void post(Object event);
|
||||
|
||||
/**
|
||||
* Register all handler methods with the {@link Subscribe} annotation as
|
||||
* Register all handler methods with the {@link com.github.legman.Subscribe} annotation as
|
||||
* subscriber for the event bus.
|
||||
*
|
||||
* @param subscriber subscriber object
|
||||
*/
|
||||
public abstract void register(Object subscriber);
|
||||
|
||||
/**
|
||||
* Unregister the given subscriber object from the event bus.
|
||||
*
|
||||
* @param subscriber subscriber object to unregister
|
||||
*/
|
||||
public abstract void unregister(Object subscriber);
|
||||
}
|
||||
|
||||
@@ -30,52 +30,34 @@ import static sonia.scm.api.v2.resources.ScmPathInfo.REST_API_PATH;
|
||||
* Useful constants for filter implementations.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public final class Filters
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
public static final String PATTERN_ALL = "/*";
|
||||
|
||||
/** Field description */
|
||||
public static final String PATTERN_DEBUG = "/debug.html";
|
||||
|
||||
/** Field description */
|
||||
public static final String PATTERN_RESTAPI = REST_API_PATH + "/*";
|
||||
|
||||
/** authentication priority */
|
||||
public static final int PRIORITY_AUTHENTICATION = 5000;
|
||||
|
||||
/** authorization priority */
|
||||
public static final int PRIORITY_AUTHORIZATION = 6000;
|
||||
|
||||
/** base url priority */
|
||||
public static final int PRIORITY_BASEURL = 1000;
|
||||
|
||||
/** post authentication priority */
|
||||
public static final int PRIORITY_POST_AUTHENTICATION = 5500;
|
||||
|
||||
/** pre authorization priority */
|
||||
public static final int PRIORITY_POST_AUTHORIZATION = 6500;
|
||||
|
||||
/** post base url priority */
|
||||
public static final int PRIORITY_POST_BASEURL = 1500;
|
||||
|
||||
/** pre authentication priority */
|
||||
public static final int PRIORITY_PRE_AUTHENTICATION = 4500;
|
||||
|
||||
/** pre authorization priority */
|
||||
public static final int PRIORITY_PRE_AUTHORIZATION = 5500;
|
||||
|
||||
/** pre base url priority */
|
||||
public static final int PRIORITY_PRE_BASEURL = 500;
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private Filters() {}
|
||||
}
|
||||
|
||||
@@ -27,25 +27,20 @@ package sonia.scm.filter;
|
||||
/**
|
||||
* Configuration for the {@link GZipResponseFilter}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.16
|
||||
*/
|
||||
public class GZipFilterConfig
|
||||
{
|
||||
|
||||
private boolean bufferResponse = true;
|
||||
|
||||
/**
|
||||
* Returns true if the response should be buffered.
|
||||
*
|
||||
*
|
||||
* @return true if the response should be buffered
|
||||
*/
|
||||
public boolean isBufferResponse()
|
||||
{
|
||||
return bufferResponse;
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Enables or disables response buffering. Default buffering is enabled.
|
||||
@@ -57,8 +52,4 @@ public class GZipFilterConfig
|
||||
this.bufferResponse = bufferResponse;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private boolean bufferResponse = true;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.filter;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import jakarta.servlet.ServletOutputStream;
|
||||
import jakarta.servlet.WriteListener;
|
||||
@@ -40,41 +39,31 @@ import java.util.zip.GZIPOutputStream;
|
||||
/**
|
||||
* Response stream for gzip encoding.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.15
|
||||
*/
|
||||
public class GZipResponseStream extends ServletOutputStream
|
||||
{
|
||||
|
||||
/**
|
||||
* the logger for GZipResponseStream
|
||||
*/
|
||||
protected ByteArrayOutputStream baos = null;
|
||||
|
||||
protected GZIPOutputStream gzipstream = null;
|
||||
|
||||
protected boolean closed = false;
|
||||
|
||||
protected ServletOutputStream output = null;
|
||||
|
||||
protected HttpServletResponse response = null;
|
||||
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(GZipResponseStream.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param response
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public GZipResponseStream(HttpServletResponse response) throws IOException
|
||||
{
|
||||
this(response, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param response
|
||||
* @param config
|
||||
*
|
||||
* @throws IOException
|
||||
* @since 1.16
|
||||
*/
|
||||
public GZipResponseStream(HttpServletResponse response,
|
||||
@@ -108,14 +97,7 @@ public class GZipResponseStream extends ServletOutputStream
|
||||
}
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void close() throws IOException
|
||||
{
|
||||
@@ -147,12 +129,6 @@ public class GZipResponseStream extends ServletOutputStream
|
||||
closed = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void flush() throws IOException
|
||||
{
|
||||
@@ -164,24 +140,12 @@ public class GZipResponseStream extends ServletOutputStream
|
||||
gzipstream.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
public void reset()
|
||||
public void reset()
|
||||
{
|
||||
|
||||
// noop
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param b
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void write(int b) throws IOException
|
||||
{
|
||||
@@ -193,30 +157,12 @@ public class GZipResponseStream extends ServletOutputStream
|
||||
gzipstream.write((byte) b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param b
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void write(byte b[]) throws IOException
|
||||
{
|
||||
write(b, 0, b.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param b
|
||||
* @param off
|
||||
* @param len
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void write(byte b[], int off, int len) throws IOException
|
||||
{
|
||||
@@ -228,14 +174,7 @@ public class GZipResponseStream extends ServletOutputStream
|
||||
gzipstream.write(b, off, len);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns true if the stream is closed.
|
||||
*
|
||||
*
|
||||
* @return true if the stream is closed
|
||||
*/
|
||||
public boolean isClosed()
|
||||
{
|
||||
return closed;
|
||||
@@ -255,20 +194,4 @@ public class GZipResponseStream extends ServletOutputStream
|
||||
}
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
protected ByteArrayOutputStream baos = null;
|
||||
|
||||
/** Field description */
|
||||
protected GZIPOutputStream gzipstream = null;
|
||||
|
||||
/** Field description */
|
||||
protected boolean closed = false;
|
||||
|
||||
/** Field description */
|
||||
protected ServletOutputStream output = null;
|
||||
|
||||
/** Field description */
|
||||
protected HttpServletResponse response = null;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.filter;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import jakarta.servlet.ServletOutputStream;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
@@ -38,18 +37,19 @@ import java.io.PrintWriter;
|
||||
/**
|
||||
* Response wrapper for gzip encoding.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.15
|
||||
*/
|
||||
public class GZipResponseWrapper extends HttpServletResponseWrapper
|
||||
{
|
||||
protected GZipFilterConfig config = null;
|
||||
|
||||
protected HttpServletResponse origResponse = null;
|
||||
|
||||
protected GZipResponseStream stream = null;
|
||||
|
||||
/** response writer */
|
||||
protected PrintWriter writer = null;
|
||||
|
||||
/**
|
||||
* Constructs a new GZipResponseWrapper
|
||||
*
|
||||
*
|
||||
* @param response http response to wrap
|
||||
*/
|
||||
public GZipResponseWrapper(HttpServletResponse response)
|
||||
{
|
||||
super(response);
|
||||
@@ -57,12 +57,7 @@ public class GZipResponseWrapper extends HttpServletResponseWrapper
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param response
|
||||
* @since 1.16
|
||||
* @param config
|
||||
*/
|
||||
public GZipResponseWrapper(HttpServletResponse response,
|
||||
GZipFilterConfig config)
|
||||
@@ -72,13 +67,8 @@ public class GZipResponseWrapper extends HttpServletResponseWrapper
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
public void finishResponse()
|
||||
public void finishResponse()
|
||||
{
|
||||
IOUtil.close(writer);
|
||||
|
||||
@@ -88,12 +78,6 @@ public class GZipResponseWrapper extends HttpServletResponseWrapper
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void flushBuffer() throws IOException
|
||||
{
|
||||
@@ -103,27 +87,11 @@ public class GZipResponseWrapper extends HttpServletResponseWrapper
|
||||
}
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public GZipFilterConfig getConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public ServletOutputStream getOutputStream() throws IOException
|
||||
{
|
||||
@@ -140,14 +108,6 @@ public class GZipResponseWrapper extends HttpServletResponseWrapper
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public PrintWriter getWriter() throws IOException
|
||||
{
|
||||
@@ -168,43 +128,14 @@ public class GZipResponseWrapper extends HttpServletResponseWrapper
|
||||
return writer;
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param length
|
||||
*/
|
||||
@Override
|
||||
public void setContentLength(int length) {}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private GZipResponseStream createOutputStream() throws IOException
|
||||
{
|
||||
return new GZipResponseStream(origResponse, config);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** gzip filter config */
|
||||
protected GZipFilterConfig config = null;
|
||||
|
||||
/** original http response */
|
||||
protected HttpServletResponse origResponse = null;
|
||||
|
||||
/** gzip stream */
|
||||
protected GZipResponseStream stream = null;
|
||||
|
||||
/** response writer */
|
||||
protected PrintWriter writer = null;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.group;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.HandlerEventType;
|
||||
import sonia.scm.event.ScmEventBus;
|
||||
@@ -33,7 +32,6 @@ import sonia.scm.event.ScmEventBus;
|
||||
* Abstract base class for {@link GroupManager} implementations. This class
|
||||
* implements the listener methods of the {@link GroupManager} interface.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public abstract class AbstractGroupManager implements GroupManager
|
||||
{
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.group;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.github.sdorra.ssp.PermissionObject;
|
||||
import com.github.sdorra.ssp.StaticPermissions;
|
||||
@@ -48,14 +47,11 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Organizes users into a group for easier permissions management.
|
||||
* <p>
|
||||
* TODO for 2.0: Use a set instead of a list for members
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@IndexedType(permission = "group:list")
|
||||
@StaticPermissions(
|
||||
@@ -69,51 +65,46 @@ import java.util.List;
|
||||
public class Group extends BasicPropertiesAware
|
||||
implements ModelObject, PermissionObject, ReducedModelObject, AuditLogEntity {
|
||||
|
||||
/**
|
||||
* Field description
|
||||
*/
|
||||
private static final long serialVersionUID = 1752369869345245872L;
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
private boolean external = false;
|
||||
|
||||
@Indexed
|
||||
private Long creationDate;
|
||||
|
||||
@Indexed(defaultQuery = true, highlighted = true)
|
||||
private String description;
|
||||
|
||||
@Indexed
|
||||
private Long lastModified;
|
||||
|
||||
private List<String> members;
|
||||
|
||||
@Indexed(defaultQuery = true, boost = 1.5f)
|
||||
private String name;
|
||||
|
||||
private String type;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructs {@link Group} object. This constructor is required by JAXB.
|
||||
* This constructor is required by JAXB.
|
||||
*/
|
||||
public Group() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs {@link Group} object.
|
||||
*
|
||||
* @param type of the group
|
||||
* @param name of the group
|
||||
*/
|
||||
public Group(String type, String name) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.members = Lists.newArrayList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs {@link Group} object.
|
||||
*
|
||||
* @param type of the group
|
||||
* @param name of the group
|
||||
* @param members of the groups
|
||||
*/
|
||||
public Group(String type, String name, List<String> members) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.members = members;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs {@link Group} object.
|
||||
*
|
||||
* @param type of the group
|
||||
* @param name of the group
|
||||
* @param members of the groups
|
||||
*/
|
||||
public Group(String type, String name, String... members) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
@@ -124,30 +115,14 @@ public class Group extends BasicPropertiesAware
|
||||
}
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Add a new member to the group.
|
||||
*
|
||||
* @param member - The name of new group member
|
||||
* @return true if the operation was successful
|
||||
*/
|
||||
public boolean add(String member) {
|
||||
return getMembers().add(member);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all members of the group.
|
||||
*/
|
||||
public void clear() {
|
||||
members.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of the group.
|
||||
*
|
||||
* @return a clone of the group
|
||||
*/
|
||||
@Override
|
||||
public Group clone() {
|
||||
Group group = null;
|
||||
@@ -174,12 +149,6 @@ public class Group extends BasicPropertiesAware
|
||||
group.setExternal(external);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this {@link Group} is the same as the obj argument.
|
||||
*
|
||||
* @param obj - the reference object with which to compare
|
||||
* @return true if this {@link Group} is the same as the obj argument
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
@@ -204,8 +173,6 @@ public class Group extends BasicPropertiesAware
|
||||
|
||||
/**
|
||||
* Returns a hash code value for this {@link Group}.
|
||||
*
|
||||
* @return a hash code value for this {@link Group}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
@@ -213,21 +180,10 @@ public class Group extends BasicPropertiesAware
|
||||
lastModified, properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given member from this group.
|
||||
*
|
||||
* @param member to remove from this group
|
||||
* @return true if the operation was successful
|
||||
*/
|
||||
public boolean remove(String member) {
|
||||
return members.remove(member);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link String} that represents this group.
|
||||
*
|
||||
* @return a {@link String} that represents this group
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
//J-
|
||||
@@ -244,22 +200,11 @@ public class Group extends BasicPropertiesAware
|
||||
//J+
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns a timestamp of the creation date of this group.
|
||||
*
|
||||
* @return a timestamp of the creation date of this group
|
||||
*/
|
||||
public Long getCreationDate() {
|
||||
return creationDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of this group.
|
||||
*
|
||||
* @return the description of this group
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
@@ -267,8 +212,6 @@ public class Group extends BasicPropertiesAware
|
||||
/**
|
||||
* Returns the unique name of this group. This method is an alias for the
|
||||
* {@link #getName()} method.
|
||||
*
|
||||
* @return the unique name of this group
|
||||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
@@ -280,21 +223,11 @@ public class Group extends BasicPropertiesAware
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a timestamp of the last modified date of this group.
|
||||
*
|
||||
* @return a timestamp of the last modified date of this group
|
||||
*/
|
||||
@Override
|
||||
public Long getLastModified() {
|
||||
return lastModified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link java.util.List} of all members of this group.
|
||||
*
|
||||
* @return a {@link java.util.List} of all members of this group
|
||||
*/
|
||||
public List<String> getMembers() {
|
||||
if (external) {
|
||||
return Collections.emptyList();
|
||||
@@ -307,8 +240,6 @@ public class Group extends BasicPropertiesAware
|
||||
|
||||
/**
|
||||
* Returns the unique name of this group.
|
||||
*
|
||||
* @return the unique name of this group
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
@@ -316,149 +247,54 @@ public class Group extends BasicPropertiesAware
|
||||
|
||||
/**
|
||||
* Returns the type of this group. The default type is xml.
|
||||
*
|
||||
* @return the type of this group
|
||||
*/
|
||||
@Override
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the members of the groups managed external of scm-manager.
|
||||
*
|
||||
* @return {@code true} if the group is an external group
|
||||
*/
|
||||
public boolean isExternal() {
|
||||
return external;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the member is a member of this group.
|
||||
*
|
||||
* @param member - The name of the member
|
||||
* @return true if the member is a member of this group
|
||||
*/
|
||||
public boolean isMember(String member) {
|
||||
return (members != null) && members.contains(member);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the group is valid.
|
||||
*
|
||||
* @return true if the group is valid
|
||||
*/
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return ValidationUtil.isNameValid(name) && Util.isNotEmpty(type);
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Sets the date the group was created.
|
||||
*
|
||||
* @param creationDate - date the group was last modified
|
||||
*/
|
||||
public void setCreationDate(Long creationDate) {
|
||||
this.creationDate = creationDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the description of the group.
|
||||
*
|
||||
* @param description of the group
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the date the group was last modified.
|
||||
*
|
||||
* @param lastModified - date the group was last modified
|
||||
*/
|
||||
public void setLastModified(Long lastModified) {
|
||||
this.lastModified = lastModified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the members of the group.
|
||||
*
|
||||
* @param members of the group
|
||||
*/
|
||||
public void setMembers(List<String> members) {
|
||||
this.members = members;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the group.
|
||||
*
|
||||
* @param name of the group
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of the group.
|
||||
*
|
||||
* @param type of the group
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code true} to mark the group as external.
|
||||
*
|
||||
* @param {@code true} for a external group
|
||||
*/
|
||||
public void setExternal(boolean external) {
|
||||
this.external = external;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* external group
|
||||
*/
|
||||
private boolean external = false;
|
||||
|
||||
/**
|
||||
* timestamp of the creation date of this group
|
||||
*/
|
||||
@Indexed
|
||||
private Long creationDate;
|
||||
|
||||
/**
|
||||
* description of this group
|
||||
*/
|
||||
@Indexed(defaultQuery = true, highlighted = true)
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* timestamp of the last modified date of this group
|
||||
*/
|
||||
@Indexed
|
||||
private Long lastModified;
|
||||
|
||||
/**
|
||||
* members of this group
|
||||
*/
|
||||
private List<String> members;
|
||||
|
||||
/**
|
||||
* name of this group
|
||||
*/
|
||||
@Indexed(defaultQuery = true, boost = 1.5f)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* type of this group
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* Get the entity name which is used for the audit log
|
||||
* @since 2.43.0
|
||||
|
||||
@@ -24,16 +24,14 @@
|
||||
|
||||
package sonia.scm.group;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.GenericDAO;
|
||||
|
||||
/**
|
||||
* Data access object for groups. This class should only used by the
|
||||
* Data access object for groups. This class should only be used by the
|
||||
* {@link GroupManager}. Plugins and other classes should use the
|
||||
* {@link GroupManager} instead.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.14
|
||||
*/
|
||||
public interface GroupDAO extends GenericDAO<Group> {}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.group;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
|
||||
import sonia.scm.HandlerEventType;
|
||||
@@ -34,33 +33,17 @@ import sonia.scm.event.Event;
|
||||
/**
|
||||
* The GroupEvent is fired if a group object changes.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.23
|
||||
*/
|
||||
@Event
|
||||
public class GroupEvent extends AbstractHandlerEvent<Group>
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs a new group event.
|
||||
*
|
||||
*
|
||||
* @param eventType type of the event
|
||||
* @param group changed group
|
||||
*/
|
||||
public GroupEvent(HandlerEventType eventType, Group group)
|
||||
{
|
||||
super(eventType, group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new group event.
|
||||
*
|
||||
*
|
||||
* @param eventType type of the event
|
||||
* @param group changed group
|
||||
* @param oldGroup old group
|
||||
*/
|
||||
public GroupEvent(HandlerEventType eventType, Group group, Group oldGroup)
|
||||
{
|
||||
super(eventType, group, oldGroup);
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.group;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.Manager;
|
||||
import sonia.scm.search.Searchable;
|
||||
@@ -32,13 +31,10 @@ import sonia.scm.search.Searchable;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The central class for managing {@link Group}s.
|
||||
* This class is a singleton and is available via injection.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public interface GroupManager
|
||||
extends Manager<Group>, Searchable<Group>
|
||||
@@ -46,11 +42,6 @@ public interface GroupManager
|
||||
|
||||
/**
|
||||
* Returns a {@link Collection} of all groups assigned to the given member.
|
||||
*
|
||||
*
|
||||
* @param member - The name of the member
|
||||
*
|
||||
* @return all groups assigned to the given member
|
||||
*/
|
||||
Collection<Group> getGroupsForMember(String member);
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.group;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.ManagerDecorator;
|
||||
import sonia.scm.search.SearchRequest;
|
||||
@@ -32,54 +31,31 @@ import sonia.scm.search.SearchRequest;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Decorator for {@link GroupManager}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.23
|
||||
*/
|
||||
public class GroupManagerDecorator
|
||||
extends ManagerDecorator<Group> implements GroupManager
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param decorated
|
||||
*/
|
||||
public GroupManagerDecorator(GroupManager decorated)
|
||||
{
|
||||
super(decorated);
|
||||
this.decorated = decorated;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*
|
||||
* @param searchRequest
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Collection<Group> search(SearchRequest searchRequest)
|
||||
{
|
||||
return decorated.search(searchRequest);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the decorated {@link GroupManager}.
|
||||
*
|
||||
*
|
||||
* @return decorated {@link GroupManager}
|
||||
*
|
||||
* @since 1.34
|
||||
*/
|
||||
public GroupManager getDecorated()
|
||||
@@ -87,14 +63,6 @@ public class GroupManagerDecorator
|
||||
return decorated;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*
|
||||
* @param member
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Collection<Group> getGroupsForMember(String member)
|
||||
{
|
||||
@@ -106,6 +74,5 @@ public class GroupManagerDecorator
|
||||
return decorated.getAllNames();
|
||||
}
|
||||
|
||||
/** Field description */
|
||||
private final GroupManager decorated;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.group;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.DecoratorFactory;
|
||||
import sonia.scm.plugin.ExtensionPoint;
|
||||
@@ -32,7 +31,6 @@ import sonia.scm.plugin.ExtensionPoint;
|
||||
/**
|
||||
* Factory for group manager decorators.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.23
|
||||
*/
|
||||
@ExtensionPoint
|
||||
|
||||
@@ -30,7 +30,6 @@ import sonia.scm.ModificationHandlerEvent;
|
||||
/**
|
||||
* Event which is fired whenever a group is modified.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.48
|
||||
*/
|
||||
public class GroupModificationEvent extends GroupEvent implements ModificationHandlerEvent<Group>
|
||||
|
||||
@@ -21,16 +21,13 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.i18n;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.util.ClassLoaders;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import java.util.Locale;
|
||||
@@ -41,23 +38,14 @@ import java.util.ResourceBundle;
|
||||
* This class is a wrapper for {@link ResourceBundle}, it applies some missing
|
||||
* format options missing in {@link ResourceBundle}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.15
|
||||
*/
|
||||
public class Bundle
|
||||
{
|
||||
private final ResourceBundle bundle;
|
||||
|
||||
/** Field description */
|
||||
private static final String SEPARATOR = System.getProperty("line.separator");
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param bundle
|
||||
*/
|
||||
private Bundle(ResourceBundle bundle)
|
||||
{
|
||||
this.bundle = bundle;
|
||||
@@ -68,7 +56,6 @@ public class Bundle
|
||||
/**
|
||||
* Creates a new bundle instance
|
||||
*
|
||||
*
|
||||
* @param path path to the properties file
|
||||
*
|
||||
* @return new bundle instance
|
||||
@@ -81,7 +68,6 @@ public class Bundle
|
||||
/**
|
||||
* Creates a new bundle instance
|
||||
*
|
||||
*
|
||||
* @param path path to the properties file
|
||||
* @param locale locale for the properties file
|
||||
*
|
||||
@@ -95,7 +81,6 @@ public class Bundle
|
||||
/**
|
||||
* Creates a new bundle instance
|
||||
*
|
||||
*
|
||||
* @param path path to the properties file
|
||||
* @param locale locale for the properties file
|
||||
* @param classLoader classLoader to load
|
||||
@@ -128,7 +113,7 @@ public class Bundle
|
||||
* @param key key in the properties file
|
||||
* @param args format arguments
|
||||
*
|
||||
* @return formated message
|
||||
* @return formatted message
|
||||
*/
|
||||
public String getLine(String key, Object... args)
|
||||
{
|
||||
@@ -142,7 +127,7 @@ public class Bundle
|
||||
* @param key key in the properties file
|
||||
* @param args format arguments
|
||||
*
|
||||
* @return formated message
|
||||
* @return formatted message
|
||||
*/
|
||||
public String getString(String key, Object... args)
|
||||
{
|
||||
@@ -164,7 +149,7 @@ public class Bundle
|
||||
* @param key key in the properties file
|
||||
* @param args format arguments
|
||||
*
|
||||
* @return formated message or null
|
||||
* @return formatted message or null
|
||||
*
|
||||
* @since 1.37
|
||||
*/
|
||||
@@ -180,9 +165,4 @@ public class Bundle
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** resource bundle */
|
||||
private final ResourceBundle bundle;
|
||||
}
|
||||
|
||||
@@ -24,53 +24,22 @@
|
||||
|
||||
package sonia.scm.i18n;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class I18nException extends RuntimeException
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final long serialVersionUID = 1845326427312983227L;
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
public I18nException() {}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
public I18nException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param cause
|
||||
*/
|
||||
public I18nException(Throwable cause)
|
||||
{
|
||||
super(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param message
|
||||
* @param cause
|
||||
*/
|
||||
public I18nException(String message, Throwable cause)
|
||||
{
|
||||
super(message, cause);
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.i18n;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.cache.Cache;
|
||||
@@ -35,8 +34,6 @@ import sonia.scm.util.ClassLoaders;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Locale;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The I18nMessages class instantiates a class and initializes all {@link String}
|
||||
* fields with values from a resource bundle. The resource bundle must have the
|
||||
@@ -45,25 +42,17 @@ import java.util.Locale;
|
||||
* {@link I18n} annotation which holds the key. I18nMessages injects also the
|
||||
* locale and the bundle if it founds a field with the corresponding type.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.37
|
||||
*/
|
||||
public final class I18nMessages
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final Cache<CacheKey, Object> cache =
|
||||
CacheBuilder.newBuilder().build();
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private I18nMessages() {}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Same as {@link #get(java.lang.Class, java.util.Locale)}, with locale
|
||||
@@ -87,8 +76,6 @@ public final class I18nMessages
|
||||
* @param msgClass message class
|
||||
* @param request servlet request
|
||||
* @param <T> type of message class
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static <T> T get(Class<T> msgClass, HttpServletRequest request)
|
||||
{
|
||||
@@ -96,15 +83,13 @@ public final class I18nMessages
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a instance of the given message class with all message fields
|
||||
* Returns an instance of the given message class with all message fields
|
||||
* initialized.
|
||||
*
|
||||
*
|
||||
* @param msgClass message class
|
||||
* @param locale locale
|
||||
* @param <T> type of the message class
|
||||
*
|
||||
* @return instance of message class
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public synchronized static <T> T get(Class<T> msgClass, Locale locale)
|
||||
@@ -121,18 +106,6 @@ public final class I18nMessages
|
||||
return instance;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param msgClass
|
||||
* @param locale
|
||||
* @param <T>
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private static <T> T createInstance(Class<T> msgClass, Locale locale)
|
||||
{
|
||||
Bundle bundle = Bundle.getBundle(msgClass.getName(), locale,
|
||||
@@ -152,18 +125,6 @@ public final class I18nMessages
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param bundle
|
||||
* @param locale
|
||||
* @param msgClass
|
||||
* @param instance
|
||||
*
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
private static void initializeInstance(Bundle bundle, Locale locale,
|
||||
Class msgClass, Object instance)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
@@ -202,41 +163,19 @@ public final class I18nMessages
|
||||
}
|
||||
}
|
||||
|
||||
//~--- inner classes --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class description
|
||||
*
|
||||
*
|
||||
* @version Enter version here..., 14/03/15
|
||||
* @author Enter your name here...
|
||||
*/
|
||||
private static class CacheKey
|
||||
{
|
||||
private final Locale locale;
|
||||
|
||||
private final Class msgClass;
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param locale
|
||||
* @param msgClass
|
||||
*/
|
||||
public CacheKey(Locale locale, Class msgClass)
|
||||
{
|
||||
this.locale = locale;
|
||||
this.msgClass = msgClass;
|
||||
}
|
||||
|
||||
//~--- methods ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param obj
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
@@ -256,24 +195,11 @@ public final class I18nMessages
|
||||
&& Objects.equal(msgClass, other.msgClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hashCode(locale, msgClass);
|
||||
}
|
||||
|
||||
//~--- fields -------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final Locale locale;
|
||||
|
||||
/** Field description */
|
||||
private final Class msgClass;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,79 +24,30 @@
|
||||
|
||||
package sonia.scm.io;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class AbstractReader<T>
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param input
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public abstract T read(InputStream input) throws IOException;
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param data
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public T read(byte[] data) throws IOException
|
||||
{
|
||||
return read(new ByteArrayInputStream(data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param path
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public T read(String path) throws IOException
|
||||
{
|
||||
return read(new File(path));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param file
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public T read(File file) throws IOException
|
||||
{
|
||||
T result = null;
|
||||
|
||||
@@ -24,12 +24,9 @@
|
||||
|
||||
package sonia.scm.io;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
@@ -46,64 +43,26 @@ import java.io.Writer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public abstract class AbstractResourceProcessor implements ResourceProcessor
|
||||
{
|
||||
private Map<String, String> variableMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param variableMap
|
||||
* @param reader
|
||||
* @param writer
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
protected abstract void process(Map<String, String> variableMap,
|
||||
BufferedReader reader, BufferedWriter writer)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@Override
|
||||
public void addVariable(String key, String value)
|
||||
{
|
||||
variableMap.put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param input
|
||||
* @param output
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void process(InputStream input, OutputStream output) throws IOException
|
||||
{
|
||||
process(new InputStreamReader(input), new OutputStreamWriter(output));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param input
|
||||
* @param output
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void process(File input, File output) throws IOException
|
||||
{
|
||||
@@ -123,15 +82,6 @@ public abstract class AbstractResourceProcessor implements ResourceProcessor
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param reader
|
||||
* @param writer
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void process(Reader reader, Writer writer) throws IOException
|
||||
{
|
||||
@@ -159,20 +109,10 @@ public abstract class AbstractResourceProcessor implements ResourceProcessor
|
||||
process(variableMap, bufferedReader, bufferedWriter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param key
|
||||
*/
|
||||
@Override
|
||||
public void removeVariable(String key)
|
||||
{
|
||||
variableMap.remove(key);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private Map<String, String> variableMap = new HashMap<>();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.io;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -33,8 +32,6 @@ import sonia.scm.util.ChecksumUtil;
|
||||
import sonia.scm.util.IOUtil;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -42,65 +39,28 @@ import java.io.IOException;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public abstract class AbstractUnArchiver implements UnArchiver
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
public static final String FILE_SOURCE_PROPERTIES = "scm-source.properties";
|
||||
|
||||
/** Field description */
|
||||
public static final String PROPERTY_CHECKSUM = "scm.unarchiver.checksum";
|
||||
|
||||
/** Field description */
|
||||
public static final String PROPERTY_SOURCEFILE = "scm.unarchiver.source";
|
||||
|
||||
/** the logger for AbstractUnArchiver */
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(AbstractUnArchiver.class);
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param archive
|
||||
* @param outputDirectory
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
protected abstract void extractArchive(File archive, File outputDirectory)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param archive
|
||||
* @param outputDirectory
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void extract(File archive, File outputDirectory) throws IOException
|
||||
{
|
||||
extract(archive, outputDirectory, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param archive
|
||||
* @param outputDirectory
|
||||
* @param force
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void extract(File archive, File outputDirectory, boolean force)
|
||||
throws IOException
|
||||
@@ -118,15 +78,6 @@ public abstract class AbstractUnArchiver implements UnArchiver
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param archive
|
||||
* @param outputDirectory
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private void extractAndCreateProperties(File archive, File outputDirectory)
|
||||
throws IOException
|
||||
{
|
||||
@@ -137,15 +88,6 @@ public abstract class AbstractUnArchiver implements UnArchiver
|
||||
writeProperties(outputDirectory, checksum);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param outputDirectory
|
||||
* @param checksum
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private void writeProperties(File outputDirectory, String checksum)
|
||||
throws IOException
|
||||
{
|
||||
@@ -170,16 +112,6 @@ public abstract class AbstractUnArchiver implements UnArchiver
|
||||
}
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param sourcePropsFile
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getChecksumProperty(File sourcePropsFile)
|
||||
{
|
||||
Properties properties = new Properties();
|
||||
@@ -202,15 +134,6 @@ public abstract class AbstractUnArchiver implements UnArchiver
|
||||
return properties.getProperty(PROPERTY_CHECKSUM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param archive
|
||||
* @param outputDirectory
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean isModified(File archive, File outputDirectory)
|
||||
{
|
||||
boolean modified = true;
|
||||
|
||||
@@ -24,46 +24,18 @@
|
||||
|
||||
package sonia.scm.io;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class AbstractWriter<T>
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param object
|
||||
* @param output
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public abstract void write(T object, OutputStream output) throws IOException;
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param object
|
||||
* @param file
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public void write(T object, File file) throws IOException
|
||||
{
|
||||
OutputStream output = null;
|
||||
@@ -79,15 +51,6 @@ public abstract class AbstractWriter<T>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param object
|
||||
* @param path
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public void write(T object, String path) throws IOException
|
||||
{
|
||||
write(object, new File(path));
|
||||
|
||||
@@ -24,35 +24,17 @@
|
||||
|
||||
package sonia.scm.io;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
public interface Command
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
|
||||
public CommandResult execute() throws IOException;
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param file
|
||||
*/
|
||||
|
||||
public void setWorkDirectory(File file);
|
||||
}
|
||||
|
||||
@@ -24,34 +24,16 @@
|
||||
|
||||
package sonia.scm.io;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
public interface CommandResult
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public String getOutput();
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public int getReturnCode();
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public boolean isSuccessfull();
|
||||
}
|
||||
|
||||
@@ -37,44 +37,32 @@ public interface ContentType {
|
||||
|
||||
/**
|
||||
* Returns the primary part of the content type (e.g.: text of text/plain).
|
||||
*
|
||||
* @return primary content type part
|
||||
*/
|
||||
String getPrimary();
|
||||
|
||||
/**
|
||||
* Returns the secondary part of the content type (e.g.: plain of text/plain).
|
||||
*
|
||||
* @return secondary content type part
|
||||
*/
|
||||
String getSecondary();
|
||||
|
||||
/**
|
||||
* Returns the raw presentation of the content type (e.g.: text/plain).
|
||||
*
|
||||
* @return raw presentation
|
||||
*/
|
||||
String getRaw();
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the content type is text based.
|
||||
*
|
||||
* @return {@code true} for text content
|
||||
*/
|
||||
boolean isText();
|
||||
|
||||
/**
|
||||
* Returns an optional with the programming language
|
||||
* or empty if the content is not programming language.
|
||||
*
|
||||
* @return programming language or empty
|
||||
*/
|
||||
Optional<String> getLanguage();
|
||||
|
||||
/**
|
||||
* Returns a map of syntax modes such as codemirror, ace or prism.
|
||||
*
|
||||
* @return map of syntax modes
|
||||
* @since 2.28.0
|
||||
*/
|
||||
default Map<String, String> getSyntaxModes() {
|
||||
|
||||
@@ -54,7 +54,6 @@ public interface ContentTypeResolver {
|
||||
/**
|
||||
* Returns a map of syntax highlighting modes such as ace, codemirror or prism by language.
|
||||
* @param language name of the coding language
|
||||
* @return map of syntax highlighting modes
|
||||
* @since 2.28.0
|
||||
*/
|
||||
default Map<String, String> findSyntaxModesByLanguage(String language) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user