()
- {
- @Override
- public void modify(User item)
- {
- item.setDisplayName("Modified DisplayName");
- }
- @Override
- public boolean isCorrectModified(User item)
- {
- return "Modified DisplayName".equals(item.getDisplayName());
- }
- };
- }
-
- /**
- * Method description
- *
- *
- * @param number
- *
- * @return
- */
- @Override
- protected User createTestData(int number)
- {
- User user = null;
-
- switch (number)
- {
- case 1 :
- user = UserTestData.createAdams();
-
- break;
-
- case 2 :
- user = UserTestData.createDent();
-
- break;
-
- case 3 :
- user = UserTestData.createMarvin();
-
- break;
-
- case 4 :
- user = UserTestData.createPerfect();
-
- break;
- }
-
- return user;
- }
-}
diff --git a/scm-clients/scm-client-impl/src/test/resources/logback.xml b/scm-clients/scm-client-impl/src/test/resources/logback.xml
deleted file mode 100644
index 26effea73e..0000000000
--- a/scm-clients/scm-client-impl/src/test/resources/logback.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/scm-core/pom.xml b/scm-core/pom.xml
index a06eb544dc..f19ad7453e 100644
--- a/scm-core/pom.xml
+++ b/scm-core/pom.xml
@@ -128,26 +128,24 @@
2.0.0-SNAPSHOT
provided
-
+
+
- com.github.sdorra
+ com.github.sdorra.shiro-static-permissions
ssp-lib
- ${ssp.version}
- com.github.sdorra
+ com.github.sdorra.shiro-static-permissions
ssp-processor
- ${ssp.version}
true
-
+
com.github.sdorra
shiro-unit
- 1.0.0
test
diff --git a/scm-core/src/main/java/sonia/scm/config/Configuration.java b/scm-core/src/main/java/sonia/scm/config/Configuration.java
new file mode 100644
index 0000000000..e9bf3528d5
--- /dev/null
+++ b/scm-core/src/main/java/sonia/scm/config/Configuration.java
@@ -0,0 +1,28 @@
+package sonia.scm.config;
+
+import com.github.sdorra.ssp.PermissionObject;
+import com.github.sdorra.ssp.StaticPermissions;
+
+/**
+ * Base for all kinds of configurations.
+ *
+ * Allows for permission like
+ *
+ *
+ * - "configuration:read:global",
+ * - "configuration:write:svn",
+ * - "configuration:*:git",
+ * - "configuration:*"
+ *
+ *
+ *
+ *
+ * And for permission checks like {@code ConfigurationPermissions.read(configurationObject).check();}
+ */
+@StaticPermissions(
+ value = "configuration",
+ permissions = {"read", "write"},
+ globalPermissions = {}
+)
+public interface Configuration extends PermissionObject {
+}
diff --git a/scm-core/src/main/java/sonia/scm/config/ScmConfiguration.java b/scm-core/src/main/java/sonia/scm/config/ScmConfiguration.java
index ac22c1403e..6e1db68f91 100644
--- a/scm-core/src/main/java/sonia/scm/config/ScmConfiguration.java
+++ b/scm-core/src/main/java/sonia/scm/config/ScmConfiguration.java
@@ -1,19 +1,19 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -24,39 +24,33 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* http://bitbucket.org/sdorra/scm-manager
- *
*/
-
package sonia.scm.config;
-//~--- non-JDK imports --------------------------------------------------------
import com.google.common.collect.Sets;
import com.google.inject.Singleton;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import sonia.scm.event.ScmEventBus;
import sonia.scm.util.HttpUtil;
import sonia.scm.xml.XmlSetStringAdapter;
-//~--- JDK imports ------------------------------------------------------------
-
-import java.io.File;
-
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import java.io.File;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+//~--- JDK imports ------------------------------------------------------------
/**
* The main configuration object for SCM-Manager.
@@ -64,41 +58,141 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
*
* @author Sebastian Sdorra
*/
+
@Singleton
@XmlRootElement(name = "scm-config")
@XmlAccessorType(XmlAccessType.FIELD)
-public class ScmConfiguration
-{
+public class ScmConfiguration implements Configuration {
- /** Default JavaScript date format */
+ /**
+ * Default JavaScript date format
+ */
public static final String DEFAULT_DATEFORMAT = "YYYY-MM-DD HH:mm:ss";
- /** Default plugin url */
+ /**
+ * Default plugin url
+ */
public static final String DEFAULT_PLUGINURL =
"http://plugins.scm-manager.org/scm-plugin-backend/api/{version}/plugins?os={os}&arch={arch}&snapshot=false";
- /** Default plugin url from version 1.0 */
+ /**
+ * Default plugin url from version 1.0
+ */
public static final String OLD_PLUGINURL =
"http://plugins.scm-manager.org/plugins.xml.gz";
- /** Path to the configuration file */
+ /**
+ * Path to the configuration file
+ */
public static final String PATH =
"config".concat(File.separator).concat("config.xml");
- /** the logger for ScmConfiguration */
+ /**
+ * the logger for ScmConfiguration
+ */
private static final Logger logger =
LoggerFactory.getLogger(ScmConfiguration.class);
- //~--- methods --------------------------------------------------------------
+
+ @XmlElement(name = "admin-groups")
+ @XmlJavaTypeAdapter(XmlSetStringAdapter.class)
+ private Set adminGroups;
+
+
+ @XmlElement(name = "admin-users")
+ @XmlJavaTypeAdapter(XmlSetStringAdapter.class)
+ private Set adminUsers;
+
+
+ @XmlElement(name = "base-url")
+ private String baseUrl;
+
+
+ @XmlElement(name = "force-base-url")
+ private boolean forceBaseUrl;
+
+ /**
+ * Maximum allowed login attempts.
+ *
+ * @since 1.34
+ */
+ @XmlElement(name = "login-attempt-limit")
+ private int loginAttemptLimit = -1;
+
+ /**
+ * glob patterns for urls which are excluded from proxy
+ */
+ @XmlElement(name = "proxy-excludes")
+ @XmlJavaTypeAdapter(XmlSetStringAdapter.class)
+ private Set proxyExcludes;
+
+
+ private String proxyPassword;
+
+
+ private int proxyPort = 8080;
+
+
+ private String proxyServer = "proxy.mydomain.com";
+
+
+ private String proxyUser;
+
+ /**
+ * Skip failed authenticators.
+ *
+ * @since 1.36
+ */
+ @XmlElement(name = "skip-failed-authenticators")
+ private boolean skipFailedAuthenticators = false;
+
+
+ @XmlElement(name = "plugin-url")
+ private String pluginUrl = DEFAULT_PLUGINURL;
+
+ /**
+ * Login attempt timeout.
+ *
+ * @since 1.34
+ */
+ @XmlElement(name = "login-attempt-limit-timeout")
+ private long loginAttemptLimitTimeout = TimeUnit.MINUTES.toSeconds(5l);
+
+
+ private boolean enableProxy = false;
+
+ /**
+ * Authentication realm for basic authentication.
+ */
+ private String realmDescription = HttpUtil.AUTHENTICATION_REALM;
+ private boolean enableRepositoryArchive = false;
+ private boolean disableGroupingGrid = false;
+ /**
+ * JavaScript date format from moment.js
+ *
+ * @see http://momentjs.com/docs/#/parsing/
+ */
+ private String dateFormat = DEFAULT_DATEFORMAT;
+ private boolean anonymousAccessEnabled = false;
+
+ /**
+ * Enables xsrf cookie protection.
+ *
+ * @since 1.47
+ */
+ @XmlElement(name = "xsrf-protection")
+ private boolean enabledXsrfProtection = true;
+
+ @XmlElement(name = "default-namespace-strategy")
+ private String defaultNamespaceStrategy = "sonia.scm.repository.DefaultNamespaceStrategy";
+
/**
* Calls the {@link sonia.scm.ConfigChangedListener#configChanged(Object)}
* method of all registered listeners.
*/
- public void fireChangeEvent()
- {
- if (logger.isDebugEnabled())
- {
+ public void fireChangeEvent() {
+ if (logger.isDebugEnabled()) {
logger.debug("fire config changed event");
}
@@ -109,12 +203,9 @@ public class ScmConfiguration
/**
* Load all properties from another {@link ScmConfiguration} object.
*
- *
- *
* @param other
*/
- public void load(ScmConfiguration other)
- {
+ public void load(ScmConfiguration other) {
this.realmDescription = other.realmDescription;
this.dateFormat = other.dateFormat;
this.pluginUrl = other.pluginUrl;
@@ -135,29 +226,14 @@ public class ScmConfiguration
this.loginAttemptLimit = other.loginAttemptLimit;
this.loginAttemptLimitTimeout = other.loginAttemptLimitTimeout;
this.enabledXsrfProtection = other.enabledXsrfProtection;
+ this.defaultNamespaceStrategy = other.defaultNamespaceStrategy;
}
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Returns a set of admin group names.
- *
- *
- * @return set of admin group names
- */
- public Set getAdminGroups()
- {
+ public Set getAdminGroups() {
return adminGroups;
}
- /**
- * Returns a set of admin user names.
- *
- *
- * @return set of admin user names
- */
- public Set getAdminUsers()
- {
+ public Set getAdminUsers() {
return adminUsers;
}
@@ -165,11 +241,10 @@ public class ScmConfiguration
* Returns the complete base url of the scm-manager including the context path.
* For example http://localhost:8080/scm
*
- * @since 1.5
* @return complete base url of the scm-manager
+ * @since 1.5
*/
- public String getBaseUrl()
- {
+ public String getBaseUrl() {
return baseUrl;
}
@@ -177,23 +252,14 @@ public class ScmConfiguration
* Returns the date format for the user interface. This format is a
* JavaScript date format, from the library moment.js.
*
- * @see http://momentjs.com/docs/#/parsing/
* @return moment.js date format
+ * @see http://momentjs.com/docs/#/parsing/
*/
- public String getDateFormat()
- {
+ public String getDateFormat() {
return dateFormat;
}
- /**
- * Returns maximum allowed login attempts.
- *
- * @return maximum allowed login attempts
- *
- * @since 1.34
- */
- public int getLoginAttemptLimit()
- {
+ public int getLoginAttemptLimit() {
return loginAttemptLimit;
}
@@ -202,11 +268,9 @@ public class ScmConfiguration
* because of too many failed login attempts.
*
* @return login attempt timeout in seconds
- *
* @since 1.34
*/
- public long getLoginAttemptLimitTimeout()
- {
+ public long getLoginAttemptLimitTimeout() {
return loginAttemptLimitTimeout;
}
@@ -222,8 +286,7 @@ public class ScmConfiguration
*
* @return the complete plugin url.
*/
- public String getPluginUrl()
- {
+ public String getPluginUrl() {
return pluginUrl;
}
@@ -231,289 +294,141 @@ public class ScmConfiguration
* Returns a set of glob patterns for urls which should excluded from
* proxy settings.
*
- *
* @return set of glob patterns
* @since 1.23
*/
- public Set getProxyExcludes()
- {
- if (proxyExcludes == null)
- {
+ public Set getProxyExcludes() {
+ if (proxyExcludes == null) {
proxyExcludes = Sets.newHashSet();
}
return proxyExcludes;
}
- /**
- * Method description
- *
- *
- * @return
- * @since 1.7
- */
- public String getProxyPassword()
- {
+ public String getProxyPassword() {
return proxyPassword;
}
- /**
- * Returns the proxy port.
- *
- *
- * @return proxy port
- */
- public int getProxyPort()
- {
+ public int getProxyPort() {
return proxyPort;
}
/**
* Returns the servername or ip of the proxyserver.
*
- *
* @return servername or ip of the proxyserver
*/
- public String getProxyServer()
- {
+ public String getProxyServer() {
return proxyServer;
}
- /**
- * Method description
- *
- *
- * @return
- * @since 1.7
- */
- public String getProxyUser()
- {
+ public String getProxyUser() {
return proxyUser;
}
- /**
- * Returns the realm description.
- *
- *
- * @return realm description
- * @since 1.36
- */
- public String getRealmDescription()
- {
+ public String getRealmDescription() {
return realmDescription;
}
-
- /**
- * Returns true if the anonymous access to the SCM-Manager is enabled.
- *
- *
- * @return true if the anonymous access to the SCM-Manager is enabled
- */
- public boolean isAnonymousAccessEnabled()
- {
+ public boolean isAnonymousAccessEnabled() {
return anonymousAccessEnabled;
}
- /**
- * Method description
- *
- * @since 1.9
- * @return
- */
- public boolean isDisableGroupingGrid()
- {
+ public boolean isDisableGroupingGrid() {
return disableGroupingGrid;
}
/**
* Returns {@code true} if the cookie xsrf protection is enabled.
- *
- * @see Issue 793
+ *
* @return {@code true} if the cookie xsrf protection is enabled
- *
+ * @see Issue 793
* @since 1.47
*/
- public boolean isEnabledXsrfProtection()
- {
+ public boolean isEnabledXsrfProtection() {
return enabledXsrfProtection;
}
- /**
- * Returns true if proxy is enabled.
- *
- *
- * @return true if proxy is enabled
- */
- public boolean isEnableProxy()
- {
+ public boolean isEnableProxy() {
return enableProxy;
}
- /**
- * Returns true if the repository archive is enabled.
- *
- *
- * @return true if the repository archive is enabled
- * @since 1.14
- */
- public boolean isEnableRepositoryArchive()
- {
+ public boolean isEnableRepositoryArchive() {
return enableRepositoryArchive;
}
- /**
- * Returns true if force base url is enabled.
- *
- * @since 1.5
- * @return true if force base url is enabled
- */
- public boolean isForceBaseUrl()
- {
+ public boolean isForceBaseUrl() {
return forceBaseUrl;
}
- /**
- * Returns true if the login attempt limit is enabled.
- *
- *
- * @return true if login attempt limit is enabled
- *
- * @since 1.37
- */
- public boolean isLoginAttemptLimitEnabled()
- {
+ public boolean isLoginAttemptLimitEnabled() {
return loginAttemptLimit > 0;
}
+ public String getDefaultNamespaceStrategy() {
+ return defaultNamespaceStrategy;
+ }
+
+
/**
* Returns true if failed authenticators are skipped.
*
- *
* @return true if failed authenticators are skipped
- *
* @since 1.36
*/
- public boolean isSkipFailedAuthenticators()
- {
+ public boolean isSkipFailedAuthenticators() {
return skipFailedAuthenticators;
}
- //~--- set methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param adminGroups
- */
- public void setAdminGroups(Set adminGroups)
- {
+ public void setAdminGroups(Set adminGroups) {
this.adminGroups = adminGroups;
}
- /**
- * Method description
- *
- *
- * @param adminUsers
- */
- public void setAdminUsers(Set adminUsers)
- {
+ public void setAdminUsers(Set adminUsers) {
this.adminUsers = adminUsers;
}
- /**
- * Method description
- *
- *
- * @param anonymousAccessEnabled
- */
- public void setAnonymousAccessEnabled(boolean anonymousAccessEnabled)
- {
+ public void setAnonymousAccessEnabled(boolean anonymousAccessEnabled) {
this.anonymousAccessEnabled = anonymousAccessEnabled;
}
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @since 1.5
- */
- public void setBaseUrl(String baseUrl)
- {
+ public void setBaseUrl(String baseUrl) {
this.baseUrl = baseUrl;
}
- /**
- * Sets the date format for the ui.
- *
- *
- * @param dateFormat date format for ui
- */
- public void setDateFormat(String dateFormat)
- {
+ public void setDateFormat(String dateFormat) {
this.dateFormat = dateFormat;
}
- /**
- * Method description
- *
- * @since 1.9
- *
- * @param disableGroupingGrid
- */
- public void setDisableGroupingGrid(boolean disableGroupingGrid)
- {
+ public void setDisableGroupingGrid(boolean disableGroupingGrid) {
this.disableGroupingGrid = disableGroupingGrid;
}
- /**
- * Method description
- *
- *
- * @param enableProxy
- */
- public void setEnableProxy(boolean enableProxy)
- {
+ public void setEnableProxy(boolean enableProxy) {
this.enableProxy = enableProxy;
}
/**
* Enable or disable the repository archive. Default is disabled.
*
- *
* @param enableRepositoryArchive true to disable the repository archive
* @since 1.14
*/
- public void setEnableRepositoryArchive(boolean enableRepositoryArchive)
- {
+ public void setEnableRepositoryArchive(boolean enableRepositoryArchive) {
this.enableRepositoryArchive = enableRepositoryArchive;
}
- /**
- * Method description
- *
- *
- * @param forceBaseUrl
- * @since 1.5
- */
- public void setForceBaseUrl(boolean forceBaseUrl)
- {
+ public void setForceBaseUrl(boolean forceBaseUrl) {
this.forceBaseUrl = forceBaseUrl;
}
/**
* Set maximum allowed login attempts.
*
- *
* @param loginAttemptLimit login attempt limit
- *
* @since 1.34
*/
- public void setLoginAttemptLimit(int loginAttemptLimit)
- {
+ public void setLoginAttemptLimit(int loginAttemptLimit) {
this.loginAttemptLimit = loginAttemptLimit;
}
@@ -522,22 +437,13 @@ public class ScmConfiguration
* because of too many failed login attempts.
*
* @param loginAttemptLimitTimeout login attempt timeout in seconds
- *
* @since 1.34
*/
- public void setLoginAttemptLimitTimeout(long loginAttemptLimitTimeout)
- {
+ public void setLoginAttemptLimitTimeout(long loginAttemptLimitTimeout) {
this.loginAttemptLimitTimeout = loginAttemptLimitTimeout;
}
- /**
- * Method description
- *
- *
- * @param pluginUrl
- */
- public void setPluginUrl(String pluginUrl)
- {
+ public void setPluginUrl(String pluginUrl) {
this.pluginUrl = pluginUrl;
}
@@ -545,194 +451,64 @@ public class ScmConfiguration
* Set glob patterns for urls which are should be excluded from proxy
* settings.
*
- *
* @param proxyExcludes glob patterns
* @since 1.23
*/
- public void setProxyExcludes(Set proxyExcludes)
- {
+ public void setProxyExcludes(Set proxyExcludes) {
this.proxyExcludes = proxyExcludes;
}
- /**
- * Method description
- *
- *
- * @param proxyPassword
- * @since 1.7
- */
- public void setProxyPassword(String proxyPassword)
- {
+ public void setProxyPassword(String proxyPassword) {
this.proxyPassword = proxyPassword;
}
- /**
- * Method description
- *
- *
- * @param proxyPort
- */
- public void setProxyPort(int proxyPort)
- {
+ public void setProxyPort(int proxyPort) {
this.proxyPort = proxyPort;
}
- /**
- * Method description
- *
- *
- * @param proxyServer
- */
- public void setProxyServer(String proxyServer)
- {
+ public void setProxyServer(String proxyServer) {
this.proxyServer = proxyServer;
}
- /**
- * Method description
- *
- *
- * @param proxyUser
- * @since 1.7
- */
- public void setProxyUser(String proxyUser)
- {
+ public void setProxyUser(String proxyUser) {
this.proxyUser = proxyUser;
}
- /**
- * Sets the realm description.
- *
- *
- * @param realmDescription
- * @since 1.36
- */
- public void setRealmDescription(String realmDescription)
- {
+ public void setRealmDescription(String realmDescription) {
this.realmDescription = realmDescription;
}
/**
- * If set to true the authentication chain is not stopped, if an
+ * If set to true the authentication chain is not stopped, if an
* authenticator finds the user but fails to authenticate the user.
*
* @param skipFailedAuthenticators true to skip failed authenticators
- *
* @since 1.36
*/
- public void setSkipFailedAuthenticators(boolean skipFailedAuthenticators)
- {
+ public void setSkipFailedAuthenticators(boolean skipFailedAuthenticators) {
this.skipFailedAuthenticators = skipFailedAuthenticators;
}
/**
* Set {@code true} to enable xsrf cookie protection.
- *
+ *
* @param enabledXsrfProtection {@code true} to enable xsrf protection
* @see Issue 793
- *
* @since 1.47
*/
- public void setEnabledXsrfProtection(boolean enabledXsrfProtection)
- {
+ public void setEnabledXsrfProtection(boolean enabledXsrfProtection) {
this.enabledXsrfProtection = enabledXsrfProtection;
}
- //~--- fields ---------------------------------------------------------------
+ public void setDefaultNamespaceStrategy(String defaultNamespaceStrategy) {
+ this.defaultNamespaceStrategy = defaultNamespaceStrategy;
+ }
- /** Field description */
- @XmlElement(name = "admin-groups")
- @XmlJavaTypeAdapter(XmlSetStringAdapter.class)
- private Set adminGroups;
-
- /** Field description */
- @XmlElement(name = "admin-users")
- @XmlJavaTypeAdapter(XmlSetStringAdapter.class)
- private Set adminUsers;
-
- /** Field description */
- @XmlElement(name = "base-url")
- private String baseUrl;
-
- /** Field description */
- @XmlElement(name = "force-base-url")
- private boolean forceBaseUrl;
-
- /**
- * Maximum allowed login attempts.
- *
- * @since 1.34
- */
- @XmlElement(name = "login-attempt-limit")
- private int loginAttemptLimit = -1;
-
- /** glob patterns for urls which are excluded from proxy */
- @XmlElement(name = "proxy-excludes")
- @XmlJavaTypeAdapter(XmlSetStringAdapter.class)
- private Set proxyExcludes;
-
- /** Field description */
- private String proxyPassword;
-
- /** Field description */
- private int proxyPort = 8080;
-
- /** Field description */
- private String proxyServer = "proxy.mydomain.com";
-
- /** Field description */
- private String proxyUser;
-
- /**
- * Skip failed authenticators.
- *
- * @since 1.36
- */
- @XmlElement(name = "skip-failed-authenticators")
- private boolean skipFailedAuthenticators = false;
-
- /** Field description */
- @XmlElement(name = "plugin-url")
- private String pluginUrl = DEFAULT_PLUGINURL;
-
- /**
- * Login attempt timeout.
- *
- * @since 1.34
- */
- @XmlElement(name = "login-attempt-limit-timeout")
- private long loginAttemptLimitTimeout = TimeUnit.MINUTES.toSeconds(5l);
-
- /** Field description */
- private boolean enableProxy = false;
-
- /**
- *
- * Authentication realm for basic authentication.
- *
- */
- private String realmDescription = HttpUtil.AUTHENTICATION_REALM;
-
- /** Field description */
- private boolean enableRepositoryArchive = false;
-
- /** Field description */
- private boolean disableGroupingGrid = false;
-
- /**
- * JavaScript date format from moment.js
- * @see http://momentjs.com/docs/#/parsing/
- */
- private String dateFormat = DEFAULT_DATEFORMAT;
-
- /** Field description */
- private boolean anonymousAccessEnabled = false;
-
- /**
- * Enables xsrf cookie protection.
- *
- * @since 1.47
- */
- @XmlElement(name = "xsrf-protection")
- private boolean enabledXsrfProtection = true;
+ @Override
+ // Only for permission checks, don't serialize to XML
+ @XmlTransient
+ public String getId() {
+ // Don't change this without migrating SCM permission configuration!
+ return "global";
+ }
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/AbstactImportHandler.java b/scm-core/src/main/java/sonia/scm/repository/AbstactImportHandler.java
index 2da506674d..6e0827af4a 100644
--- a/scm-core/src/main/java/sonia/scm/repository/AbstactImportHandler.java
+++ b/scm-core/src/main/java/sonia/scm/repository/AbstactImportHandler.java
@@ -36,19 +36,16 @@ package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Throwables;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import sonia.scm.repository.ImportResult.Builder;
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.File;
import java.io.IOException;
-
import java.util.List;
+//~--- JDK imports ------------------------------------------------------------
+
/**
* Abstract base class for directory based {@link ImportHandler} and
* {@link AdvancedImportHandler}.
@@ -164,23 +161,24 @@ public abstract class AbstactImportHandler implements AdvancedImportHandler
logger.trace("search for repositories to import");
- try
- {
-
- List repositoryNames =
- RepositoryUtil.getRepositoryNames(getRepositoryHandler(),
- getDirectoryNames());
-
- for (String repositoryName : repositoryNames)
- {
- importRepository(manager, builder, throwExceptions, repositoryName);
- }
-
- }
- catch (IOException ex)
- {
- handleException(ex, throwExceptions);
- }
+ // TODO #8783
+// try
+// {
+//
+// List repositoryNames =
+// RepositoryUtil.getRepositoryNames(getRepositoryHandler(),
+// getDirectoryNames());
+//
+// for (String repositoryName : repositoryNames)
+// {
+// importRepository(manager, builder, throwExceptions, repositoryName);
+// }
+//
+// }
+// catch (IOException ex)
+// {
+// handleException(ex, throwExceptions);
+// }
return builder.build();
}
@@ -214,46 +212,48 @@ public abstract class AbstactImportHandler implements AdvancedImportHandler
* @param manager
* @param builder
* @param throwExceptions
- * @param repositoryName
+ * @param directoryName
*
* @throws IOException
* @throws RepositoryException
*/
private void importRepository(RepositoryManager manager, Builder builder,
- boolean throwExceptions, String repositoryName)
+ boolean throwExceptions, String directoryName)
throws IOException, RepositoryException
{
- logger.trace("check repository {} for import", repositoryName);
+ logger.trace("check repository {} for import", directoryName);
- Repository repository = manager.get(getTypeName(), repositoryName);
-
- if (repository == null)
- {
- try
- {
- importRepository(manager, repositoryName);
- builder.addImportedDirectory(repositoryName);
- }
- catch (IOException ex)
- {
- builder.addFailedDirectory(repositoryName);
- handleException(ex, throwExceptions);
- }
- catch (IllegalStateException ex)
- {
- builder.addFailedDirectory(repositoryName);
- handleException(ex, throwExceptions);
- }
- catch (RepositoryException ex)
- {
- builder.addFailedDirectory(repositoryName);
- handleException(ex, throwExceptions);
- }
- }
- else if (logger.isDebugEnabled())
- {
- logger.debug("repository {} is allready managed", repositoryName);
- }
+ // TODO #8783
+//
+// Repository repository = manager.get(namespaceAndName);
+//
+// if (repository == null)
+// {
+// try
+// {
+// importRepository(manager, repositoryName);
+// builder.addImportedDirectory(repositoryName);
+// }
+// catch (IOException ex)
+// {
+// builder.addFailedDirectory(repositoryName);
+// handleException(ex, throwExceptions);
+// }
+// catch (IllegalStateException ex)
+// {
+// builder.addFailedDirectory(repositoryName);
+// handleException(ex, throwExceptions);
+// }
+// catch (RepositoryException ex)
+// {
+// builder.addFailedDirectory(repositoryName);
+// handleException(ex, throwExceptions);
+// }
+// }
+// else if (logger.isDebugEnabled())
+// {
+// logger.debug("repository {} is already managed", repositoryName);
+// }
}
/**
diff --git a/scm-core/src/main/java/sonia/scm/repository/AbstractRepositoryHandler.java b/scm-core/src/main/java/sonia/scm/repository/AbstractRepositoryHandler.java
index a327b50dae..33b6cb8030 100644
--- a/scm-core/src/main/java/sonia/scm/repository/AbstractRepositoryHandler.java
+++ b/scm-core/src/main/java/sonia/scm/repository/AbstractRepositoryHandler.java
@@ -56,7 +56,7 @@ import sonia.scm.store.ConfigurationStoreFactory;
*
* @param
*/
-public abstract class AbstractRepositoryHandler
+public abstract class AbstractRepositoryHandler
implements RepositoryHandler
{
diff --git a/scm-core/src/main/java/sonia/scm/repository/AbstractSimpleRepositoryHandler.java b/scm-core/src/main/java/sonia/scm/repository/AbstractSimpleRepositoryHandler.java
index b49d4355b9..536b7bd9e9 100644
--- a/scm-core/src/main/java/sonia/scm/repository/AbstractSimpleRepositoryHandler.java
+++ b/scm-core/src/main/java/sonia/scm/repository/AbstractSimpleRepositoryHandler.java
@@ -1,19 +1,19 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -24,13 +24,11 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* http://bitbucket.org/sdorra/scm-manager
- *
*/
-
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
@@ -54,91 +52,56 @@ import java.net.URL;
//~--- JDK imports ------------------------------------------------------------
/**
- *
- * @author Sebastian Sdorra
- *
- *
* @param
+ * @author Sebastian Sdorra
*/
-public abstract class AbstractSimpleRepositoryHandler
- extends AbstractRepositoryHandler implements RepositoryDirectoryHandler
-{
+public abstract class AbstractSimpleRepositoryHandler
+ extends AbstractRepositoryHandler implements RepositoryDirectoryHandler {
- /** Field description */
public static final String DEFAULT_VERSION_INFORMATION = "unknown";
- /** Field description */
public static final String DIRECTORY_REPOSITORY = "repositories";
- /** Field description */
public static final String DOT = ".";
- /** the logger for AbstractSimpleRepositoryHandler */
+ /**
+ * the logger for AbstractSimpleRepositoryHandler
+ */
private static final Logger logger =
LoggerFactory.getLogger(AbstractSimpleRepositoryHandler.class);
- //~--- constructors ---------------------------------------------------------
+ private FileSystem fileSystem;
+
- /**
- * Constructs ...
- *
- *
- * @param storeFactory
- * @param fileSystem
- */
public AbstractSimpleRepositoryHandler(ConfigurationStoreFactory storeFactory,
- FileSystem fileSystem)
- {
+ FileSystem fileSystem) {
super(storeFactory);
this.fileSystem = fileSystem;
}
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param repository
- *
- * @throws IOException
- * @throws RepositoryException
- */
@Override
public Repository create(Repository repository)
- throws RepositoryException
- {
+ throws RepositoryException {
File directory = getDirectory(repository);
- if (directory.exists())
- {
+ if (directory.exists()) {
throw RepositoryAlreadyExistsException.create(repository);
}
checkPath(directory);
- try
- {
+ try {
fileSystem.create(directory);
create(repository, directory);
postCreate(repository, directory);
return repository;
- }
- catch (Exception ex)
- {
- if (directory.exists())
- {
- if (logger.isDebugEnabled())
- {
- logger.debug(
- "delete repository directory {}, because of failed repository creation",
- directory);
- }
-
+ } catch (Exception ex) {
+ if (directory.exists()) {
+ logger.warn("delete repository directory {}, because of failed repository creation", directory);
try {
fileSystem.destroy(directory);
} catch (IOException e) {
- logger.error("could not delete directory after failed repository creation: {}", directory, e);
+ logger.error("Could not destroy directory", e);
}
}
@@ -148,77 +111,48 @@ public abstract class AbstractSimpleRepositoryHandler {
+
+ private final Set strategies;
+ private final ScmConfiguration scmConfiguration;
+
+ @Inject
+ public NamespaceStrategyProvider(Set strategies, ScmConfiguration scmConfiguration) {
+ this.strategies = strategies;
+ this.scmConfiguration = scmConfiguration;
+ }
+
+ @Override
+ public NamespaceStrategy get() {
+ String namespaceStrategy = scmConfiguration.getDefaultNamespaceStrategy();
+
+ for (NamespaceStrategy s : this.strategies) {
+ if (s.getClass().getCanonicalName().equals(namespaceStrategy)) {
+ return s;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/scm-core/src/main/java/sonia/scm/repository/Repository.java b/scm-core/src/main/java/sonia/scm/repository/Repository.java
index 0b4d1c4dcd..44841893e7 100644
--- a/scm-core/src/main/java/sonia/scm/repository/Repository.java
+++ b/scm-core/src/main/java/sonia/scm/repository/Repository.java
@@ -48,6 +48,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -58,7 +59,7 @@ import java.util.List;
* @author Sebastian Sdorra
*/
@StaticPermissions(
- value = "repository",
+ value = "repository",
permissions = {"read", "write", "modify", "delete", "healthCheck"}
)
@XmlAccessorType(XmlAccessType.FIELD)
@@ -99,9 +100,10 @@ public class Repository extends BasicPropertiesAware implements ModelObject, Per
* @param type type of the {@link Repository}
* @param name name of the {@link Repository}
*/
- public Repository(String id, String type, String name) {
+ public Repository(String id, String type, String namespace, String name) {
this.id = id;
this.type = type;
+ this.namespace = namespace;
this.name = name;
}
@@ -176,44 +178,28 @@ public class Repository extends BasicPropertiesAware implements ModelObject, Per
return healthCheckFailures;
}
- /**
- * Returns the unique id of the {@link Repository}.
- *
- * @return unique id
- */
@Override
public String getId() {
return id;
}
- /**
- * Returns the timestamp of the last modified date of the {@link Repository}.
- *
- * @return timestamp of the last modified date
- */
@Override
public Long getLastModified() {
return lastModified;
}
- /**
- * Returns the name of the {@link Repository}.
- *
- * @return name of the {@link Repository}
- */
+
public String getName() {
return name;
}
- public String getNamespace() {
- return namespace;
+ public String getNamespace() { return namespace; }
+
+ @XmlTransient
+ public NamespaceAndName getNamespaceAndName() {
+ return new NamespaceAndName(getNamespace(), getName());
}
- /**
- * Returns the access permissions of the {@link Repository}.
- *
- * @return access permissions
- */
public List getPermissions() {
if (permissions == null) {
permissions = Lists.newArrayList();
@@ -370,9 +356,7 @@ public class Repository extends BasicPropertiesAware implements ModelObject, Per
* @since 1.17
*/
public String createUrl(String baseUrl) {
- String url = HttpUtil.append(baseUrl, type);
-
- return HttpUtil.append(url, name);
+ return HttpUtil.concatenate(baseUrl, type, namespace, name);
}
/**
diff --git a/scm-core/src/main/java/sonia/scm/repository/SimpleRepositoryConfig.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryConfig.java
similarity index 82%
rename from scm-core/src/main/java/sonia/scm/repository/SimpleRepositoryConfig.java
rename to scm-core/src/main/java/sonia/scm/repository/RepositoryConfig.java
index 3654b9c8b4..3db13e5618 100644
--- a/scm-core/src/main/java/sonia/scm/repository/SimpleRepositoryConfig.java
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryConfig.java
@@ -33,15 +33,12 @@
package sonia.scm.repository;
-//~--- non-JDK imports --------------------------------------------------------
-
import sonia.scm.Validateable;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import java.io.File;
+import sonia.scm.config.Configuration;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import java.io.File;
/**
* Basic {@link Repository} configuration class.
@@ -49,7 +46,7 @@ import javax.xml.bind.annotation.XmlRootElement;
* @author Sebastian Sdorra
*/
@XmlRootElement
-public class SimpleRepositoryConfig implements Validateable
+public abstract class RepositoryConfig implements Validateable, Configuration
{
/**
@@ -119,4 +116,19 @@ public class SimpleRepositoryConfig implements Validateable
/** directory for repositories */
private File repositoryDirectory;
+
+ /**
+ * Specifies the identifier of the concrete {@link RepositoryConfig} when checking permissions of an object.
+ * The permission Strings will have the following format: "configuration:*:ID", where the ID part is defined by this
+ * method.
+ *
+ * For example: "configuration:read:git".
+ *
+ * No need to serialize this.
+ *
+ * @return identifier of this RepositoryConfig in permission strings
+ */
+ @Override
+ @XmlTransient // Only for permission checks, don't serialize to XML
+ public abstract String getId();
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryDAO.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryDAO.java
index 9a2d4b5662..ce309ecee6 100644
--- a/scm-core/src/main/java/sonia/scm/repository/RepositoryDAO.java
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryDAO.java
@@ -49,27 +49,22 @@ public interface RepositoryDAO extends GenericDAO
/**
* Returns true if a repository with specified
- * type and name exists in the backend.
+ * namespace and name exists in the backend.
*
*
- * @param type type of the repository
- * @param name name of the repository
+ * @param namespaceAndName namespace and name of the repository
*
* @return true if the repository exists
*/
- public boolean contains(String type, String name);
+ boolean contains(NamespaceAndName namespaceAndName);
//~--- get methods ----------------------------------------------------------
/**
- * Returns the repository with the specified type and name or null
+ * Returns the repository with the specified namespace and name or null
* if no such repository exists in the backend.
*
- *
- * @param type
- * @param name
- *
- * @return repository with the specified type and name or null
+ * @return repository with the specified namespace and name or null
*/
- public Repository get(String type, String name);
+ Repository get(NamespaceAndName namespaceAndName);
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryDirectoryHandler.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryDirectoryHandler.java
index 3fda4a76be..2f766fb1f6 100644
--- a/scm-core/src/main/java/sonia/scm/repository/RepositoryDirectoryHandler.java
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryDirectoryHandler.java
@@ -43,13 +43,5 @@ import java.io.File;
public interface RepositoryDirectoryHandler extends RepositoryHandler
{
- /**
- * Method description
- *
- *
- * @param repository
- *
- * @return
- */
public File getDirectory(Repository repository);
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryHandlerConfigChangedEvent.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryHandlerConfigChangedEvent.java
index 844c4a78d6..645274e494 100644
--- a/scm-core/src/main/java/sonia/scm/repository/RepositoryHandlerConfigChangedEvent.java
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryHandlerConfigChangedEvent.java
@@ -37,7 +37,7 @@ import sonia.scm.event.Event;
* @since 2.0.0
*/
@Event
-public class RepositoryHandlerConfigChangedEvent
+public class RepositoryHandlerConfigChangedEvent
{
private final C configuration;
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryManager.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryManager.java
index 0edd21f4c2..493d8f6dbb 100644
--- a/scm-core/src/main/java/sonia/scm/repository/RepositoryManager.java
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryManager.java
@@ -82,18 +82,17 @@ public interface RepositoryManager
//~--- get methods ----------------------------------------------------------
/**
- * Returns a {@link Repository} by its type and name or
+ * Returns a {@link Repository} by its namespace and name or
* null if the {@link Repository} could not be found.
*
*
- * @param type type of the {@link Repository}
- * @param name name of the {@link Repository}
+ * @param namespaceAndName namespace and name of the {@link Repository}
*
*
- * @return {@link Repository} by its type and name or null
+ * @return {@link Repository} by its namespace and name or null
* if the {@link Repository} could not be found
*/
- public Repository get(String type, String name);
+ public Repository get(NamespaceAndName namespaceAndName);
/**
* Returns all configured repository types.
@@ -114,18 +113,6 @@ public interface RepositoryManager
*/
public Repository getFromRequest(HttpServletRequest request);
- /**
- * Returns the {@link Repository} associated to the given type and path.
- *
- *
- * @param type type of the repository (hg, git ...)
- * @param uri
- *
- * @return the {@link Repository} associated to the given type and path
- * @since 1.9
- */
- public Repository getFromTypeAndUri(String type, String uri);
-
/**
* Returns the {@link Repository} associated to the request uri.
*
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryManagerDecorator.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryManagerDecorator.java
index d99a6483ab..6990baf7c5 100644
--- a/scm-core/src/main/java/sonia/scm/repository/RepositoryManagerDecorator.java
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryManagerDecorator.java
@@ -91,9 +91,9 @@ public class RepositoryManagerDecorator
//~--- get methods ----------------------------------------------------------
@Override
- public Repository get(String namespace, String name)
+ public Repository get(NamespaceAndName namespaceAndName)
{
- return decorated.get(namespace, name);
+ return decorated.get(namespaceAndName);
}
/**
@@ -135,21 +135,6 @@ public class RepositoryManagerDecorator
return decorated.getFromRequest(request);
}
- /**
- * {@inheritDoc}
- *
- *
- * @param type
- * @param uri
- *
- * @return
- */
- @Override
- public Repository getFromTypeAndUri(String type, String uri)
- {
- return decorated.getFromTypeAndUri(type, uri);
- }
-
/**
* {@inheritDoc}
*
diff --git a/scm-core/src/main/java/sonia/scm/repository/RepositoryUtil.java b/scm-core/src/main/java/sonia/scm/repository/RepositoryUtil.java
index e271992248..a90eb4cc34 100644
--- a/scm-core/src/main/java/sonia/scm/repository/RepositoryUtil.java
+++ b/scm-core/src/main/java/sonia/scm/repository/RepositoryUtil.java
@@ -35,278 +35,86 @@ package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
+import com.google.common.base.Preconditions;
import sonia.scm.io.DirectoryFileFilter;
import sonia.scm.util.IOUtil;
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.File;
import java.io.IOException;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+//~--- JDK imports ------------------------------------------------------------
+
/**
*
* @author Sebastian Sdorra
* @since 1.11
*/
-public final class RepositoryUtil
-{
+public final class RepositoryUtil {
- /** the logger for RepositoryUtil */
- private static final Logger logger =
- LoggerFactory.getLogger(RepositoryUtil.class);
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs ...
- *
- */
private RepositoryUtil() {}
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param directory
- * @param names
- *
- * @return
- */
- public static List searchRepositoryDirectories(File directory,
- String... names)
- {
- List repositories = new ArrayList();
+ public static List searchRepositoryDirectories(File directory, String... names) {
+ List repositories = new ArrayList<>();
searchRepositoryDirectories(repositories, directory, Arrays.asList(names));
return repositories;
}
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- *
- * @param handler
- * @param directoryPath
- * @return
- *
- * @throws IOException
- */
- public static String getRepositoryName(AbstractRepositoryHandler handler,
- String directoryPath)
- throws IOException
- {
- return getRepositoryName(handler.getConfig().getRepositoryDirectory(),
- new File(directoryPath));
+ @SuppressWarnings("squid:S2083") // ignore, because the path is validated at {@link #getRepositoryId(File, File)}
+ public static String getRepositoryId(AbstractRepositoryHandler handler, String directoryPath) throws IOException {
+ return getRepositoryId(handler.getConfig().getRepositoryDirectory(), new File(directoryPath));
}
- /**
- * Method description
- *
- *
- *
- * @param config
- * @param directoryPath
- * @return
- *
- * @throws IOException
- */
- public static String getRepositoryName(SimpleRepositoryConfig config,
- String directoryPath)
- throws IOException
- {
- return getRepositoryName(config.getRepositoryDirectory(),
- new File(directoryPath));
+ public static String getRepositoryId(AbstractRepositoryHandler handler, File directory) throws IOException {
+ return getRepositoryId(handler.getConfig(), directory);
}
- /**
- * Method description
- *
- *
- *
- * @param handler
- * @param directory
- * @return
- *
- * @throws IOException
- */
- public static String getRepositoryName(AbstractRepositoryHandler handler,
- File directory)
- throws IOException
- {
- return getRepositoryName(handler.getConfig().getRepositoryDirectory(),
- directory);
+ public static String getRepositoryId(RepositoryConfig config, File directory) throws IOException {
+ return getRepositoryId(config.getRepositoryDirectory(), directory);
}
- /**
- * Method description
- *
- *
- *
- * @param config
- * @param directory
- * @return
- *
- * @throws IOException
- */
- public static String getRepositoryName(SimpleRepositoryConfig config,
- File directory)
- throws IOException
- {
- return getRepositoryName(config.getRepositoryDirectory(), directory);
- }
-
- /**
- * Method description
- *
- *
- *
- * @param baseDirectory
- * @param directory
- * @return
- *
- * @throws IOException
- */
- public static String getRepositoryName(File baseDirectory, File directory)
- throws IOException
- {
- String name = null;
+ public static String getRepositoryId(File baseDirectory, File directory) throws IOException {
String path = directory.getCanonicalPath();
- int directoryLength = baseDirectory.getCanonicalPath().length();
+ String basePath = baseDirectory.getCanonicalPath();
- if (directoryLength < path.length())
- {
- name = IOUtil.trimSeperatorChars(path.substring(directoryLength));
+ Preconditions.checkArgument(
+ path.startsWith(basePath),
+ "repository path %s is not in the main repository path %s", path, basePath
+ );
- // replace windows path seperator
- name = name.replaceAll("\\\\", "/");
- }
- else if (logger.isWarnEnabled())
- {
- logger.warn("path is shorter as the main repository path");
- }
+ String id = IOUtil.trimSeperatorChars(path.substring(basePath.length()));
- return name;
+ Preconditions.checkArgument(
+ !id.contains("\\") && !id.contains("/"),
+ "got illegal repository directory with separators in id: %s", path
+ );
+
+ return id;
}
- /**
- * Method description
- *
- *
- * @param handler
- * @param directoryNames
- *
- * @return
- *
- * @throws IOException
- */
- public static List getRepositoryNames(
- AbstractRepositoryHandler handler, String... directoryNames)
- throws IOException
- {
- return getRepositoryNames(handler.getConfig(), directoryNames);
- }
-
- /**
- * Method description
- *
- *
- * @param config
- * @param directoryNames
- *
- * @return
- *
- * @throws IOException
- */
- public static List getRepositoryNames(SimpleRepositoryConfig config,
- String... directoryNames)
- throws IOException
- {
- return getRepositoryNames(config.getRepositoryDirectory(), directoryNames);
- }
-
- /**
- * Method description
- *
- *
- * @param baseDirectory
- * @param directoryNames
- *
- * @return
- *
- * @throws IOException
- */
- public static List getRepositoryNames(File baseDirectory,
- String... directoryNames)
- throws IOException
- {
- List repositories = new ArrayList();
- List repositoryFiles = searchRepositoryDirectories(baseDirectory,
- directoryNames);
-
- for (File file : repositoryFiles)
- {
- String name = getRepositoryName(baseDirectory, file);
-
- if (name != null)
- {
- repositories.add(name);
- }
- }
-
- return repositories;
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param repositories
- * @param directory
- * @param names
- */
- private static void searchRepositoryDirectories(List repositories,
- File directory, List names)
- {
+ private static void searchRepositoryDirectories(List repositories, File directory, List names) {
boolean found = false;
- for (String name : names)
- {
- if (new File(directory, name).exists())
- {
+ for (String name : names) {
+ if (new File(directory, name).exists()) {
found = true;
break;
}
}
- if (found)
- {
+ if (found) {
repositories.add(directory);
- }
- else
- {
+ } else {
File[] directories = directory.listFiles(DirectoryFileFilter.instance);
- if (directories != null)
- {
- for (File d : directories)
- {
+ if (directories != null) {
+ for (File d : directories) {
searchRepositoryDirectories(repositories, d, names);
}
}
diff --git a/scm-core/src/main/java/sonia/scm/repository/api/RepositoryServiceFactory.java b/scm-core/src/main/java/sonia/scm/repository/api/RepositoryServiceFactory.java
index 315156db0d..2e4ff644f4 100644
--- a/scm-core/src/main/java/sonia/scm/repository/api/RepositoryServiceFactory.java
+++ b/scm-core/src/main/java/sonia/scm/repository/api/RepositoryServiceFactory.java
@@ -50,6 +50,7 @@ import sonia.scm.cache.CacheManager;
import sonia.scm.config.ScmConfiguration;
import sonia.scm.event.ScmEventBus;
import sonia.scm.repository.ClearRepositoryCacheEvent;
+import sonia.scm.repository.NamespaceAndName;
import sonia.scm.repository.PostReceiveRepositoryHookEvent;
import sonia.scm.repository.PreProcessorUtil;
import sonia.scm.repository.Repository;
@@ -186,8 +187,7 @@ public final class RepositoryServiceFactory
* Creates a new RepositoryService for the given repository.
*
*
- * @param type type of the repository
- * @param name name of the repository
+ * @param namespaceAndName namespace and name of the repository
*
* @return a implementation of RepositoryService
* for the given type of repository
@@ -200,24 +200,19 @@ public final class RepositoryServiceFactory
* @throws ScmSecurityException if current user has not read permissions
* for that repository
*/
- public RepositoryService create(String type, String name)
+ public RepositoryService create(NamespaceAndName namespaceAndName)
throws RepositoryNotFoundException
{
- Preconditions.checkArgument(!Strings.isNullOrEmpty(type),
- "a non empty type is required");
- Preconditions.checkArgument(!Strings.isNullOrEmpty(name),
- "a non empty name is required");
+ Preconditions.checkArgument(namespaceAndName != null,
+ "a non empty namespace and name is required");
- Repository repository = repositoryManager.get(type, name);
+ Repository repository = repositoryManager.get(namespaceAndName);
if (repository == null)
{
- StringBuilder msg =
- new StringBuilder("could not find a repository with type ");
+ String msg = "could not find a repository with namespace/name " + namespaceAndName;
- msg.append(type).append(" and name ").append(name);
-
- throw new RepositoryNotFoundException(msg.toString());
+ throw new RepositoryNotFoundException(msg);
}
return create(repository);
diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/HookEventFacade.java b/scm-core/src/main/java/sonia/scm/repository/spi/HookEventFacade.java
index 899892a5b7..93ed5f1111 100644
--- a/scm-core/src/main/java/sonia/scm/repository/spi/HookEventFacade.java
+++ b/scm-core/src/main/java/sonia/scm/repository/spi/HookEventFacade.java
@@ -35,7 +35,7 @@ package sonia.scm.repository.spi;
import com.google.inject.Inject;
import com.google.inject.Provider;
-
+import sonia.scm.repository.NamespaceAndName;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.RepositoryHookEvent;
@@ -72,50 +72,15 @@ public final class HookEventFacade
//~--- methods --------------------------------------------------------------
- /**
- * Method description
- *
- *
- * @param id
- *
- * @return
- *
- * @throws RepositoryException
- */
- public HookEventHandler handle(String id) throws RepositoryException
- {
+ public HookEventHandler handle(String id) throws RepositoryException {
return handle(repositoryManagerProvider.get().get(id));
}
- /**
- * Method description
- *
- *
- * @param type
- * @param repositoryName
- *
- * @return
- *
- * @throws RepositoryException
- */
- public HookEventHandler handle(String type, String repositoryName)
- throws RepositoryException
- {
- return handle(repositoryManagerProvider.get().get(type, repositoryName));
+ public HookEventHandler handle(NamespaceAndName namespaceAndName) throws RepositoryException {
+ return handle(repositoryManagerProvider.get().get(namespaceAndName));
}
- /**
- * Method description
- *
- *
- * @param repository
- *
- * @return
- *
- * @throws RepositoryException
- */
- public HookEventHandler handle(Repository repository)
- throws RepositoryException
+ public HookEventHandler handle(Repository repository) throws RepositoryException
{
if (repository == null)
{
diff --git a/scm-core/src/main/java/sonia/scm/url/ModelUrlProvider.java b/scm-core/src/main/java/sonia/scm/url/ModelUrlProvider.java
deleted file mode 100644
index ea60645d00..0000000000
--- a/scm-core/src/main/java/sonia/scm/url/ModelUrlProvider.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-package sonia.scm.url;
-
-/**
- * @since 1.9
- * @author Sebastian Sdorra
- */
-public interface ModelUrlProvider
-{
-
- /**
- * Method description
- *
- *
- * @param name
- *
- * @return
- */
- public String getDetailUrl(String name);
-
- /**
- * Method description
- *
- *
- * @return
- */
- public String getAllUrl();
-
-}
diff --git a/scm-core/src/main/java/sonia/scm/url/RepositoryUrlProvider.java b/scm-core/src/main/java/sonia/scm/url/RepositoryUrlProvider.java
deleted file mode 100644
index ebc3f5b907..0000000000
--- a/scm-core/src/main/java/sonia/scm/url/RepositoryUrlProvider.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-
-package sonia.scm.url;
-
-/**
- * @since 1.9
- * @author Sebastian Sdorra
- */
-public interface RepositoryUrlProvider extends ModelUrlProvider
-{
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- * @param path
- * @param revision
- *
- * @return
- */
- public String getBlameUrl(String repositoryId, String path, String revision);
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- * @param path
- * @param revision
- *
- * @return
- */
- public String getBrowseUrl(String repositoryId, String path, String revision);
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- * @param path
- * @param revision
- * @param start
- * @param limit
- *
- * @return
- */
- public String getChangesetUrl(String repositoryId, String path,
- String revision, int start, int limit);
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- * @param revision
- *
- * @return
- *
- * @since 1.12
- */
- public String getChangesetUrl(String repositoryId, String revision);
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- * @param start
- * @param limit
- *
- * @return
- */
- public String getChangesetUrl(String repositoryId, int start, int limit);
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- * @param path
- * @param revision
- *
- * @return
- */
- public String getContentUrl(String repositoryId, String path,
- String revision);
-
- /**
- * Method description
- *
- *
- * @param type
- * @param name
- *
- * @return
- * @since 1.11
- */
- public String getDetailUrl(String type, String name);
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- * @param revision
- *
- * @return
- */
- public String getDiffUrl(String repositoryId, String revision);
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- *
- * @return
- * @since 1.18
- */
- public String getTagsUrl(String repositoryId);
-}
diff --git a/scm-core/src/main/java/sonia/scm/url/RestModelUrlProvider.java b/scm-core/src/main/java/sonia/scm/url/RestModelUrlProvider.java
deleted file mode 100644
index 3974135a53..0000000000
--- a/scm-core/src/main/java/sonia/scm/url/RestModelUrlProvider.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-
-package sonia.scm.url;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.util.HttpUtil;
-
-/**
- * @since 1.9
- * @author Sebastian Sdorra
- */
-public class RestModelUrlProvider implements ModelUrlProvider
-{
-
- /**
- * Constructs ...
- *
- *
- * @param baseUrl
- * @param modelSuffix
- * @param extension
- */
- public RestModelUrlProvider(String baseUrl, String modelSuffix,
- String extension)
- {
- this.base = HttpUtil.append(baseUrl, modelSuffix);
- this.extension = extension;
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public String getAllUrl()
- {
- return base.concat(extension);
- }
-
- /**
- * Method description
- *
- *
- * @param name
- *
- * @return
- */
- @Override
- public String getDetailUrl(String name)
- {
- return HttpUtil.append(base, name).concat(extension);
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- protected String base;
-
- /** Field description */
- protected String extension;
-}
diff --git a/scm-core/src/main/java/sonia/scm/url/RestRepositoryUrlProvider.java b/scm-core/src/main/java/sonia/scm/url/RestRepositoryUrlProvider.java
deleted file mode 100644
index 6c4f0f3235..0000000000
--- a/scm-core/src/main/java/sonia/scm/url/RestRepositoryUrlProvider.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-
-package sonia.scm.url;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.util.UrlBuilder;
-
-/**
- * @since 1.9
- * @author Sebastian Sdorra
- */
-public class RestRepositoryUrlProvider extends RestModelUrlProvider
- implements RepositoryUrlProvider
-{
-
- /** Field description */
- public static final String PARAMETER_LIMIT = "limit";
-
- /** Field description */
- public static final String PARAMETER_PATH = "path";
-
- /** Field description */
- public static final String PARAMETER_REVISION = "revision";
-
- /** Field description */
- public static final String PARAMETER_START = "start";
-
- /** Field description */
- public static final String PART_BLAME = "blame";
-
- /** Field description */
- public static final String PART_BROWSE = "browse";
-
- /**
- * @since 1.12
- */
- public static final String PART_CHANGESET = "changeset";
-
- /** Field description */
- public static final String PART_CHANGESETS = "changesets";
-
- /** Field description */
- public static final String PART_CONTENT = "content";
-
- /** Field description */
- public static final String PART_DIFF = "diff";
-
- /** Field description */
- public static final String PART_TAGS = "tags";
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs ...
- *
- *
- * @param baseUrl
- * @param modelSuffix
- * @param extension
- */
- public RestRepositoryUrlProvider(String baseUrl, String modelSuffix,
- String extension)
- {
- super(baseUrl, modelSuffix, extension);
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- * @param path
- * @param revision
- *
- * @return
- */
- @Override
- public String getBlameUrl(String repositoryId, String path, String revision)
- {
- revision = UrlUtil.fixRevision(revision);
-
- return new UrlBuilder(base).appendUrlPart(repositoryId).appendUrlPart(
- PART_BLAME).append(extension).appendParameter(
- PARAMETER_PATH, path).appendParameter(
- PARAMETER_REVISION, revision).toString();
- }
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- * @param path
- * @param revision
- *
- * @return
- */
- @Override
- public String getBrowseUrl(String repositoryId, String path, String revision)
- {
- revision = UrlUtil.fixRevision(revision);
-
- return new UrlBuilder(base).appendUrlPart(repositoryId).appendUrlPart(
- PART_BROWSE).append(extension).appendParameter(
- PARAMETER_PATH, path).appendParameter(
- PARAMETER_REVISION, revision).toString();
- }
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- * @param path
- * @param revision
- * @param start
- * @param limit
- *
- * @return
- */
- @Override
- public String getChangesetUrl(String repositoryId, String path,
- String revision, int start, int limit)
- {
- revision = UrlUtil.fixRevision(revision);
-
- return new UrlBuilder(base).appendUrlPart(repositoryId).appendUrlPart(
- PART_CHANGESETS).append(extension).appendParameter(
- PARAMETER_PATH, path).appendParameter(
- PARAMETER_REVISION, revision).appendParameter(
- PARAMETER_START, start).appendParameter(
- PARAMETER_LIMIT, limit).toString();
- }
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- * @param start
- * @param limit
- *
- * @return
- */
- @Override
- public String getChangesetUrl(String repositoryId, int start, int limit)
- {
- return new UrlBuilder(base).appendUrlPart(repositoryId).appendUrlPart(
- PART_CHANGESETS).append(extension).appendParameter(
- PARAMETER_START, start).appendParameter(
- PARAMETER_LIMIT, limit).toString();
- }
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- * @param revision
- *
- * @return
- *
- * @since 1.12
- */
- @Override
- public String getChangesetUrl(String repositoryId, String revision)
- {
- revision = UrlUtil.fixRevision(revision);
-
- return new UrlBuilder(base).appendUrlPart(repositoryId).appendUrlPart(
- PART_CHANGESET).appendUrlPart(revision).append(extension).toString();
- }
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- * @param path
- * @param revision
- *
- * @return
- */
- @Override
- public String getContentUrl(String repositoryId, String path, String revision)
- {
- revision = UrlUtil.fixRevision(revision);
-
- return new UrlBuilder(base).appendUrlPart(repositoryId).appendUrlPart(
- PART_CONTENT).appendParameter(PARAMETER_PATH, path).appendParameter(
- PARAMETER_REVISION, revision).toString();
- }
-
- /**
- * Method description
- *
- *
- * @param type
- * @param name
- *
- * @return
- * @since 1.11
- */
- @Override
- public String getDetailUrl(String type, String name)
- {
- return new UrlBuilder(base).appendUrlPart(type).appendUrlPart(name).append(
- extension).toString();
- }
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- * @param revision
- *
- * @return
- */
- @Override
- public String getDiffUrl(String repositoryId, String revision)
- {
- revision = UrlUtil.fixRevision(revision);
-
- return new UrlBuilder(base).appendUrlPart(repositoryId).appendUrlPart(
- PART_DIFF).appendParameter(PARAMETER_REVISION, revision).toString();
- }
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- *
- * @return
- * @since 1.18
- */
- @Override
- public String getTagsUrl(String repositoryId)
- {
- return new UrlBuilder(base).appendUrlPart(repositoryId).appendUrlPart(
- PART_TAGS).append(extension).toString();
- }
-}
diff --git a/scm-core/src/main/java/sonia/scm/url/RestSecurityUrlProvider.java b/scm-core/src/main/java/sonia/scm/url/RestSecurityUrlProvider.java
deleted file mode 100644
index 513f728708..0000000000
--- a/scm-core/src/main/java/sonia/scm/url/RestSecurityUrlProvider.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer. 2. Redistributions in
- * binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other
- * materials provided with the distribution. 3. Neither the name of SCM-Manager;
- * nor the names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-
-package sonia.scm.url;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.util.HttpUtil;
-
-/**
- *
- * @author Sebastian Sdorra
- * @since 1.41
- */
-public class RestSecurityUrlProvider implements SecurityUrlProvider
-{
-
- /** Field description */
- private static final String PATH_ENCRYPT = "security/cipher/encrypt";
-
- /** Field description */
- private static final String PATH_KEY = "security/key";
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs ...
- *
- *
- * @param baseUrl
- */
- public RestSecurityUrlProvider(String baseUrl)
- {
- this.baseUrl = baseUrl;
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public String getEncryptUrl()
- {
- return HttpUtil.append(baseUrl, PATH_ENCRYPT);
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public String getGenerateKeyUrl()
- {
- return HttpUtil.append(baseUrl, PATH_KEY);
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private final String baseUrl;
-}
diff --git a/scm-core/src/main/java/sonia/scm/url/RestUrlProvider.java b/scm-core/src/main/java/sonia/scm/url/RestUrlProvider.java
deleted file mode 100644
index 4abba6db0b..0000000000
--- a/scm-core/src/main/java/sonia/scm/url/RestUrlProvider.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-
-package sonia.scm.url;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.util.HttpUtil;
-
-/**
- * @since 1.9
- * @author Sebastian Sdorra
- */
-public class RestUrlProvider implements UrlProvider
-{
-
- /** Field description */
- public static final String PART_API = "api/rest/";
-
- /** Field description */
- public static final String PART_AUTHENTICATION = "auth/access_token";
-
- /** Field description */
- public static final String PART_CONFIG = "config";
-
- /** Field description */
- public static final String PART_GROUP = "groups";
-
- /** Field description */
- public static final String PART_REPOSITORIES = "repositories";
-
- /** Field description */
- public static final String PART_STATE = "auth";
-
- /** Field description */
- public static final String PART_USER = "users";
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs ...
- *
- *
- * @param baseUrl
- * @param extension
- */
- public RestUrlProvider(String baseUrl, String extension)
- {
- this.baseUrl = HttpUtil.append(baseUrl, PART_API);
- this.extension = extension;
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public String getAuthenticationUrl()
- {
- return HttpUtil.append(baseUrl, PART_AUTHENTICATION).concat(extension);
- }
-
- /**
- * Method description
- *
- *
- * @return
- *
- * @since 1.43
- */
- @Override
- public String getBaseUrl()
- {
- return baseUrl;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public String getConfigUrl()
- {
- return HttpUtil.append(baseUrl, PART_CONFIG).concat(extension);
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public ModelUrlProvider getGroupUrlProvider()
- {
- return new RestModelUrlProvider(baseUrl, PART_GROUP, extension);
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public RepositoryUrlProvider getRepositoryUrlProvider()
- {
- return new RestRepositoryUrlProvider(baseUrl, PART_REPOSITORIES, extension);
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public SecurityUrlProvider getSecurityUrlProvider()
- {
- return new RestSecurityUrlProvider(baseUrl);
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public String getStateUrl()
- {
- return HttpUtil.append(baseUrl, PART_STATE).concat(extension);
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public ModelUrlProvider getUserUrlProvider()
- {
- return new RestModelUrlProvider(baseUrl, PART_USER, extension);
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- protected String baseUrl;
-
- /** Field description */
- protected String extension;
-}
diff --git a/scm-core/src/main/java/sonia/scm/url/SecurityUrlProvider.java b/scm-core/src/main/java/sonia/scm/url/SecurityUrlProvider.java
deleted file mode 100644
index e000c9b754..0000000000
--- a/scm-core/src/main/java/sonia/scm/url/SecurityUrlProvider.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer. 2. Redistributions in
- * binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other
- * materials provided with the distribution. 3. Neither the name of SCM-Manager;
- * nor the names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-
-package sonia.scm.url;
-
-/**
- *
- * @author Sebastian Sdorra
- * @since 1.41
- */
-public interface SecurityUrlProvider
-{
-
- /**
- * Method description
- *
- *
- * @return
- */
- public String getGenerateKeyUrl();
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- public String getEncryptUrl();
-}
diff --git a/scm-core/src/main/java/sonia/scm/url/UrlProvider.java b/scm-core/src/main/java/sonia/scm/url/UrlProvider.java
deleted file mode 100644
index 1ab798d60b..0000000000
--- a/scm-core/src/main/java/sonia/scm/url/UrlProvider.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-
-package sonia.scm.url;
-
-/**
- * @since 1.9
- * @author Sebastian Sdorra
- */
-public interface UrlProvider
-{
-
- /**
- * Method description
- *
- *
- * @return
- */
- public String getAuthenticationUrl();
-
- /**
- * Method description
- *
- *
- * @return
- *
- * @since 1.43
- */
- public String getBaseUrl();
-
- /**
- * Method description
- *
- *
- * @return
- */
- public String getConfigUrl();
-
- /**
- * Method description
- *
- *
- * @return
- */
- public ModelUrlProvider getGroupUrlProvider();
-
- /**
- * Method description
- *
- *
- * @return
- */
- public RepositoryUrlProvider getRepositoryUrlProvider();
-
- /**
- * Method description
- *
- *
- * @return
- *
- * @since 1.41
- */
- public SecurityUrlProvider getSecurityUrlProvider();
-
- /**
- * Method description
- *
- *
- * @return
- */
- public String getStateUrl();
-
- /**
- * Method description
- *
- *
- * @return
- */
- public ModelUrlProvider getUserUrlProvider();
-}
diff --git a/scm-core/src/main/java/sonia/scm/url/UrlProviderFactory.java b/scm-core/src/main/java/sonia/scm/url/UrlProviderFactory.java
deleted file mode 100644
index bb4b998817..0000000000
--- a/scm-core/src/main/java/sonia/scm/url/UrlProviderFactory.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-
-package sonia.scm.url;
-
-/**
- * @since 1.9
- * @author Sebastian Sdorra
- */
-public final class UrlProviderFactory
-{
-
- /** Field description */
- public static final String TYPE_RESTAPI_JSON = "json-rest-api";
-
- /** Field description */
- public static final String TYPE_RESTAPI_XML = "xml-rest-api";
-
- /** Field description */
- public static final String TYPE_WUI = "wui";
-
- /** Field description */
- private static final String EXTENSION_JSON = ".json";
-
- /** Field description */
- private static final String EXTENSION_XML = ".xml";
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs ...
- *
- */
- private UrlProviderFactory() {}
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- *
- * @param baseUrl
- * @param type
- *
- * @return
- */
- public static UrlProvider createUrlProvider(String baseUrl, String type)
- {
- UrlProvider provider = null;
-
- if (TYPE_RESTAPI_JSON.equals(type))
- {
- provider = new RestUrlProvider(baseUrl, EXTENSION_JSON);
- }
- else if (TYPE_RESTAPI_XML.equals(type))
- {
- provider = new RestUrlProvider(baseUrl, EXTENSION_XML);
- }
- else if (TYPE_WUI.equals(type))
- {
- provider = new WUIUrlProvider(baseUrl);
- }
-
- return provider;
- }
-}
diff --git a/scm-core/src/main/java/sonia/scm/url/UrlUtil.java b/scm-core/src/main/java/sonia/scm/url/UrlUtil.java
deleted file mode 100644
index 0d90da10b6..0000000000
--- a/scm-core/src/main/java/sonia/scm/url/UrlUtil.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-
-package sonia.scm.url;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.util.Util;
-
-/**
- *
- * @author Sebastian Sdorra
- * @since 1.11
- */
-public final class UrlUtil
-{
-
- /**
- * Constructs ...
- *
- */
- private UrlUtil() {}
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param revision
- *
- * @return
- */
- public static String fixRevision(String revision)
- {
- String fixedRevision = revision;
-
- if (Util.isNotEmpty(revision))
- {
- int index = revision.indexOf(':');
-
- if (index > 0)
- {
- fixedRevision = revision.substring(index + 1);
- }
- }
-
- return fixedRevision;
- }
-}
diff --git a/scm-core/src/main/java/sonia/scm/url/WUIModelUrlProvider.java b/scm-core/src/main/java/sonia/scm/url/WUIModelUrlProvider.java
deleted file mode 100644
index bef0ef3b68..0000000000
--- a/scm-core/src/main/java/sonia/scm/url/WUIModelUrlProvider.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-
-package sonia.scm.url;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.util.HttpUtil;
-
-/**
- * @since 1.9
- * @author Sebastian Sdorra
- */
-public class WUIModelUrlProvider implements ModelUrlProvider
-{
-
- /**
- * Constructs ...
- *
- *
- * @param baseUrl
- * @param component
- */
- public WUIModelUrlProvider(String baseUrl, String component)
- {
- this.url = HttpUtil.appendHash(baseUrl, component);
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public String getAllUrl()
- {
- return url;
- }
-
- /**
- * Method description
- *
- *
- * @param name
- *
- * @return
- */
- @Override
- public String getDetailUrl(String name)
- {
- return url.concat(WUIUrlBuilder.SEPARATOR).concat(name);
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private String url;
-}
diff --git a/scm-core/src/main/java/sonia/scm/url/WUIRepositoryUrlProvider.java b/scm-core/src/main/java/sonia/scm/url/WUIRepositoryUrlProvider.java
deleted file mode 100644
index 7809adbcc3..0000000000
--- a/scm-core/src/main/java/sonia/scm/url/WUIRepositoryUrlProvider.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-
-package sonia.scm.url;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.util.HttpUtil;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class WUIRepositoryUrlProvider extends WUIModelUrlProvider
- implements RepositoryUrlProvider
-{
-
- /** Field description */
- public static final String COMPONENT_BROWSER = "repositoryBrowser";
-
- /**
- * @since 1.15
- */
- public static final String COMPONENT_CHANGESET = "changesetPanel";
-
- /** Field description */
- public static final String COMPONENT_CHANGESETS =
- "repositoryChangesetViewerPanel";
-
- /** Field description */
- public static final String COMPONENT_CONTENT = "contentPanel";
-
- /** Field description */
- public static final String COMPONENT_DETAIL = "repositoryPanel";
-
- /** Field description */
- public static final String COMPONENT_DIFF = "diffPanel";
-
- /** Field description */
- public static final String VIEW_BLAME = "blame";
-
- /**
- * @since 1.12
- */
- public static final String VIEW_CHANGESET = "changeset";
-
- /** Field description */
- public static final String VIEW_CONTENT = "content";
-
- /** Field description */
- public static final String VIEW_HISTORY = "history";
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs ...
- *
- *
- * @param baseUrl
- * @param component
- */
- public WUIRepositoryUrlProvider(String baseUrl, String component)
- {
- super(baseUrl, component);
- this.baseUrl = baseUrl;
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- * @param path
- * @param revision
- *
- * @return
- */
- @Override
- public String getBlameUrl(String repositoryId, String path, String revision)
- {
- revision = UrlUtil.fixRevision(revision);
-
- return new WUIUrlBuilder(baseUrl, COMPONENT_CONTENT).append(
- repositoryId).append(revision).append(path).append(VIEW_BLAME).toString();
- }
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- * @param path
- * @param revision
- *
- * @return
- */
- @Override
- public String getBrowseUrl(String repositoryId, String path, String revision)
- {
- revision = UrlUtil.fixRevision(revision);
-
- return new WUIUrlBuilder(baseUrl, COMPONENT_BROWSER).append(
- repositoryId).append(revision).append(path).toString();
- }
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- * @param path
- * @param revision
- * @param start
- * @param limit
- *
- * @return
- */
- @Override
- public String getChangesetUrl(String repositoryId, String path,
- String revision, int start, int limit)
- {
- revision = UrlUtil.fixRevision(revision);
-
- // TODO handle start and limit
- return new WUIUrlBuilder(baseUrl, COMPONENT_CONTENT).append(
- repositoryId).append(revision).append(path).append(
- VIEW_HISTORY).toString();
- }
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- * @param start
- * @param limit
- *
- * @return
- */
- @Override
- public String getChangesetUrl(String repositoryId, int start, int limit)
- {
- return new WUIUrlBuilder(baseUrl, COMPONENT_CHANGESETS).append(
- repositoryId).append(start).append(limit).toString();
- }
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- * @param revision
- *
- * @return
- *
- * @since 1.12
- */
- @Override
- public String getChangesetUrl(String repositoryId, String revision)
- {
- revision = UrlUtil.fixRevision(revision);
-
- return new WUIUrlBuilder(baseUrl,
- COMPONENT_CHANGESET).append(repositoryId).append(revision).toString();
- }
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- * @param path
- * @param revision
- *
- * @return
- */
- @Override
- public String getContentUrl(String repositoryId, String path, String revision)
- {
- revision = UrlUtil.fixRevision(revision);
-
- return new WUIUrlBuilder(baseUrl, COMPONENT_CONTENT).append(
- repositoryId).append(revision).append(path).append(
- VIEW_HISTORY).toString();
- }
-
- /**
- * Method description
- *
- *
- * @param type
- * @param name
- *
- * @return
- * @since 1.11
- */
- @Override
- public String getDetailUrl(String type, String name)
- {
- name = type.concat(HttpUtil.SEPARATOR_PATH).concat(name);
-
- return new WUIUrlBuilder(baseUrl, COMPONENT_DETAIL).append(name).toString();
- }
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- * @param revision
- *
- * @return
- */
- @Override
- public String getDiffUrl(String repositoryId, String revision)
- {
- revision = UrlUtil.fixRevision(revision);
-
- return new WUIUrlBuilder(baseUrl,
- COMPONENT_DIFF).append(repositoryId).append(revision).toString();
- }
-
- /**
- * Method description
- *
- *
- * @param repositoryId
- *
- * @return
- * @since 1.18
- */
- @Override
- public String getTagsUrl(String repositoryId)
- {
- return getBrowseUrl(repositoryId, null, null);
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private String baseUrl;
-}
diff --git a/scm-core/src/main/java/sonia/scm/url/WUIUrlBuilder.java b/scm-core/src/main/java/sonia/scm/url/WUIUrlBuilder.java
deleted file mode 100644
index c9744effe3..0000000000
--- a/scm-core/src/main/java/sonia/scm/url/WUIUrlBuilder.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-
-package sonia.scm.url;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.util.HttpUtil;
-
-/**
- * @since 1.9
- * @author Sebastian Sdorra
- */
-public class WUIUrlBuilder
-{
-
- /** Field description */
- public static final String NULL = "null";
-
- /** Field description */
- public static final String SEPARATOR = ";";
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs ...
- *
- *
- * @param baseUrl
- * @param component
- */
- public WUIUrlBuilder(String baseUrl, String component)
- {
- this.url = HttpUtil.appendHash(baseUrl, component);
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param value
- *
- * @return
- */
- public WUIUrlBuilder append(String value)
- {
- if (value == null)
- {
- value = NULL;
- }
-
- if (!this.url.endsWith(SEPARATOR))
- {
- this.url = this.url.concat(SEPARATOR);
- }
-
- this.url = this.url.concat(value);
-
- return this;
- }
-
- /**
- * Method description
- *
- *
- * @param value
- *
- * @return
- */
- public WUIUrlBuilder append(int value)
- {
- return append(String.valueOf(value));
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public String toString()
- {
- return url;
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private String url;
-}
diff --git a/scm-core/src/main/java/sonia/scm/url/WUIUrlProvider.java b/scm-core/src/main/java/sonia/scm/url/WUIUrlProvider.java
deleted file mode 100644
index bd94bf562e..0000000000
--- a/scm-core/src/main/java/sonia/scm/url/WUIUrlProvider.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-
-package sonia.scm.url;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.util.HttpUtil;
-
-/**
- * @since 1.9
- * @author Sebastian Sdorra
- */
-public class WUIUrlProvider implements UrlProvider
-{
-
- /** Field description */
- public static final String COMPONENT_CONFIG = "scmConfig";
-
- /** Field description */
- public static final String COMPONENT_GROUP = "groupPanel";
-
- /** Field description */
- public static final String COMPONENT_REPOSITORY = "repositoryPanel";
-
- /** Field description */
- public static final String COMPONENT_USER = "userPanel";
-
- /** Field description */
- public static final String PART_INDEX = "index.html";
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs ...
- *
- *
- * @param baseUrl
- */
- public WUIUrlProvider(String baseUrl)
- {
- this.baseUrl = HttpUtil.append(baseUrl, PART_INDEX);
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Returns the baseUrl, because there is no authentication url.
- *
- *
- * @returns the baseUrl, because there is no authentication url
- *
- * @return
- */
- @Override
- public String getAuthenticationUrl()
- {
- return baseUrl;
- }
-
- /**
- * Method description
- *
- *
- * @return
- *
- * @since 1.43
- */
- @Override
- public String getBaseUrl()
- {
- return baseUrl;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public String getConfigUrl()
- {
- return HttpUtil.appendHash(baseUrl, COMPONENT_CONFIG);
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public ModelUrlProvider getGroupUrlProvider()
- {
- return new WUIModelUrlProvider(baseUrl, COMPONENT_GROUP);
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public RepositoryUrlProvider getRepositoryUrlProvider()
- {
- return new WUIRepositoryUrlProvider(baseUrl, COMPONENT_REPOSITORY);
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public SecurityUrlProvider getSecurityUrlProvider()
- {
- throw new UnsupportedOperationException(
- "this provider does not support security url provider.");
- }
-
- /**
- * Returns the baseUrl, because there is no state url.
- *
- *
- * @return the baseUrl, because there is no state url
- */
- @Override
- public String getStateUrl()
- {
- return baseUrl;
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- public ModelUrlProvider getUserUrlProvider()
- {
- return new WUIModelUrlProvider(baseUrl, COMPONENT_USER);
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private String baseUrl;
-}
diff --git a/scm-core/src/main/java/sonia/scm/util/HttpUtil.java b/scm-core/src/main/java/sonia/scm/util/HttpUtil.java
index 27abcaffbe..30995a0b3c 100644
--- a/scm-core/src/main/java/sonia/scm/util/HttpUtil.java
+++ b/scm-core/src/main/java/sonia/scm/util/HttpUtil.java
@@ -39,27 +39,23 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.CharMatcher;
import com.google.common.base.Objects;
import com.google.common.base.Strings;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import sonia.scm.config.ScmConfiguration;
-//~--- JDK imports ------------------------------------------------------------
-
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
-
import java.net.URLDecoder;
import java.net.URLEncoder;
-
+import java.util.Arrays;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+//~--- JDK imports ------------------------------------------------------------
/**
* Util method for the http protocol.
@@ -86,9 +82,9 @@ public final class HttpUtil
/**
* Name of bearer authentication cookie.
- *
+ *
* TODO find a better place
- *
+ *
* @since 2.0.0
*/
public static final String COOKIE_BEARER_AUTHENTICATION = "X-Bearer-Token";
@@ -101,7 +97,7 @@ public final class HttpUtil
* @since 2.0.0
*/
public static final String HEADER_AUTHORIZATION = "Authorization";
-
+
/**
* content-length header
* @since 1.46
@@ -252,13 +248,23 @@ public final class HttpUtil
//~--- methods --------------------------------------------------------------
+ /**
+ * Joins all path elements together separated by {@code {@link #SEPARATOR_PATH}}.
+ *
+ * @param pathElements path elements
+ *
+ * @return concatenated path
+ * @since 2.0.0
+ */
+ public static String concatenate(String... pathElements) {
+ return Arrays.stream(pathElements).reduce(HttpUtil::append).orElse("");
+ }
+
/**
* Appends the suffix to given uri.
*
- *
- * @param uri uri
+ * @param uri uri
* @param suffix suffix
- *
* @return
* @since 1.9
*/
diff --git a/scm-core/src/main/java/sonia/scm/web/VndMediaType.java b/scm-core/src/main/java/sonia/scm/web/VndMediaType.java
index c7b8d369bd..792e8e8f57 100644
--- a/scm-core/src/main/java/sonia/scm/web/VndMediaType.java
+++ b/scm-core/src/main/java/sonia/scm/web/VndMediaType.java
@@ -18,6 +18,9 @@ public class VndMediaType {
public static final String USER_COLLECTION = PREFIX + "userCollection" + SUFFIX;
public static final String GROUP_COLLECTION = PREFIX + "groupCollection" + SUFFIX;
public static final String REPOSITORY_COLLECTION = PREFIX + "repositoryCollection" + SUFFIX;
+ public static final String ME = PREFIX + "me" + SUFFIX;
+
+ public static final String CONFIG = PREFIX + "config" + SUFFIX;
private VndMediaType() {
}
diff --git a/scm-core/src/main/java/sonia/scm/web/filter/RegexPermissionFilter.java b/scm-core/src/main/java/sonia/scm/web/filter/RegexPermissionFilter.java
deleted file mode 100644
index 40c41a5954..0000000000
--- a/scm-core/src/main/java/sonia/scm/web/filter/RegexPermissionFilter.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-
-package sonia.scm.web.filter;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-
-import sonia.scm.config.ScmConfiguration;
-import sonia.scm.repository.Repository;
-import sonia.scm.repository.RepositoryManager;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public abstract class RegexPermissionFilter extends PermissionFilter
-{
-
- /** Field description */
- public static final Pattern PATTERN_REPOSITORYNAME =
- Pattern.compile("/[^/]+/([^/]+)(?:/.*)?");
-
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs ...
- *
- *
- *
- * @param configuration
- * @param repositoryManager
- */
- public RegexPermissionFilter(ScmConfiguration configuration,
- RepositoryManager repositoryManager)
- {
- super(configuration);
- this.repositoryManager = repositoryManager;
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- protected abstract String getType();
-
- /**
- * Method description
- *
- *
- * @param request
- *
- * @return
- */
- @Override
- protected Repository getRepository(HttpServletRequest request)
- {
- Repository repository = null;
- String uri = request.getRequestURI();
-
- uri = uri.substring(request.getContextPath().length());
-
- Matcher m = PATTERN_REPOSITORYNAME.matcher(uri);
-
- if (m.matches())
- {
- String repositoryname = m.group(1);
-
- repository = getRepository(repositoryname);
- }
-
- return repository;
- }
-
- /**
- * Method description
- *
- *
- * @param name
- *
- * @return
- */
- protected Repository getRepository(String name)
- {
- return repositoryManager.get(getType(), name);
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private RepositoryManager repositoryManager;
-}
diff --git a/scm-core/src/test/java/sonia/scm/repository/RepositoryTest.java b/scm-core/src/test/java/sonia/scm/repository/RepositoryTest.java
index 11bb602611..f13f4cbc67 100644
--- a/scm-core/src/test/java/sonia/scm/repository/RepositoryTest.java
+++ b/scm-core/src/test/java/sonia/scm/repository/RepositoryTest.java
@@ -34,7 +34,7 @@ package sonia.scm.repository;
import org.junit.Test;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
/**
*
@@ -50,7 +50,7 @@ public class RepositoryTest
@Test
public void testCreateUrl()
{
- Repository repository = new Repository("123", "hg", "test/repo");
+ Repository repository = new Repository("123", "hg", "test", "repo");
assertEquals("http://localhost:8080/scm/hg/test/repo",
repository.createUrl("http://localhost:8080/scm"));
diff --git a/scm-core/src/test/java/sonia/scm/repository/RepositoryUtilTest.java b/scm-core/src/test/java/sonia/scm/repository/RepositoryUtilTest.java
new file mode 100644
index 0000000000..82e85568d0
--- /dev/null
+++ b/scm-core/src/test/java/sonia/scm/repository/RepositoryUtilTest.java
@@ -0,0 +1,78 @@
+package sonia.scm.repository;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import java.io.File;
+import java.io.IOException;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+@RunWith(MockitoJUnitRunner.class)
+public class RepositoryUtilTest {
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ @Mock
+ private AbstractRepositoryHandler repositoryHandler;
+
+ private RepositoryConfig repositoryConfig = new RepositoryConfig() {
+ @Override
+ public String getId() {
+ return "repository";
+ }
+ };
+
+ @Before
+ public void setUpMocks() {
+ when(repositoryHandler.getConfig()).thenReturn(repositoryConfig);
+ }
+
+ @Test
+ public void testGetRepositoryId() throws IOException {
+ File repositoryTypeRoot = temporaryFolder.newFolder();
+ repositoryConfig.setRepositoryDirectory(repositoryTypeRoot);
+
+ File repository = new File(repositoryTypeRoot, "abc");
+ String id = RepositoryUtil.getRepositoryId(repositoryHandler, repository.getPath());
+ assertEquals("abc", id);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testGetRepositoryIdWithInvalidPath() throws IOException {
+ File repositoryTypeRoot = temporaryFolder.newFolder();
+ repositoryConfig.setRepositoryDirectory(repositoryTypeRoot);
+
+ File repository = new File("/etc/abc");
+ String id = RepositoryUtil.getRepositoryId(repositoryHandler, repository.getPath());
+ assertEquals("abc", id);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testGetRepositoryIdWithInvalidPathButSameLength() throws IOException {
+ File repositoryTypeRoot = temporaryFolder.newFolder();
+ repositoryConfig.setRepositoryDirectory(repositoryTypeRoot);
+
+ File repository = new File(temporaryFolder.newFolder(), "abc");
+
+ String id = RepositoryUtil.getRepositoryId(repositoryHandler, repository.getPath());
+ assertEquals("abc", id);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testGetRepositoryIdWithInvalidId() throws IOException {
+ File repositoryTypeRoot = temporaryFolder.newFolder();
+ repositoryConfig.setRepositoryDirectory(repositoryTypeRoot);
+
+ File repository = new File(repositoryTypeRoot, "abc/123");
+ RepositoryUtil.getRepositoryId(repositoryHandler, repository.getPath());
+ }
+
+}
diff --git a/scm-core/src/test/java/sonia/scm/url/JSONRestModelUrlProviderTest.java b/scm-core/src/test/java/sonia/scm/url/JSONRestModelUrlProviderTest.java
deleted file mode 100644
index 778ca9883b..0000000000
--- a/scm-core/src/test/java/sonia/scm/url/JSONRestModelUrlProviderTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-package sonia.scm.url;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class JSONRestModelUrlProviderTest extends RestModelUrlProviderTestBase
-{
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- @Override
- protected UrlProvider createUrlProvider(String baseUrl)
- {
- return UrlProviderFactory.createUrlProvider(baseUrl,
- UrlProviderFactory.TYPE_RESTAPI_JSON);
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- protected String getExtension()
- {
- return EXTENSION_JSON;
- }
-}
diff --git a/scm-core/src/test/java/sonia/scm/url/JSONRestRepositoryUrlProviderTest.java b/scm-core/src/test/java/sonia/scm/url/JSONRestRepositoryUrlProviderTest.java
deleted file mode 100644
index 68c38d0446..0000000000
--- a/scm-core/src/test/java/sonia/scm/url/JSONRestRepositoryUrlProviderTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-package sonia.scm.url;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class JSONRestRepositoryUrlProviderTest
- extends RestRepositoryUrlProviderTestBase
-{
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- @Override
- protected RepositoryUrlProvider createRepositoryUrlProvider(String baseUrl)
- {
- return UrlProviderFactory.createUrlProvider(baseUrl,
- UrlProviderFactory.TYPE_RESTAPI_JSON).getRepositoryUrlProvider();
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- protected String getExtension()
- {
- return EXTENSION_JSON;
- }
-}
diff --git a/scm-core/src/test/java/sonia/scm/url/JSONRestUrlProviderTest.java b/scm-core/src/test/java/sonia/scm/url/JSONRestUrlProviderTest.java
deleted file mode 100644
index a887efa96c..0000000000
--- a/scm-core/src/test/java/sonia/scm/url/JSONRestUrlProviderTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-package sonia.scm.url;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class JSONRestUrlProviderTest extends RestUrlProviderTestBase
-{
-
- /**
- * Method description
- *
- *
- *
- * @param baseUrl
- * @return
- */
- @Override
- protected UrlProvider createUrlProvider(String baseUrl)
- {
- return UrlProviderFactory.createUrlProvider(baseUrl,
- UrlProviderFactory.TYPE_RESTAPI_JSON);
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- protected String getExtension()
- {
- return EXTENSION_JSON;
- }
-}
diff --git a/scm-core/src/test/java/sonia/scm/url/ModelUrlProviderTestBase.java b/scm-core/src/test/java/sonia/scm/url/ModelUrlProviderTestBase.java
deleted file mode 100644
index 14d38c1928..0000000000
--- a/scm-core/src/test/java/sonia/scm/url/ModelUrlProviderTestBase.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-package sonia.scm.url;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public abstract class ModelUrlProviderTestBase extends UrlTestBase
-{
-
- /** Field description */
- public static final String ITEM = "hitchhiker";
-
- /** Field description */
- public static final String MODEL_GROUPS = "groups";
-
- /** Field description */
- public static final String MODEL_REPOSITORY = "repositories";
-
- /** Field description */
- public static final String MODEL_USERS = "users";
-
- /** Field description */
- private static final String[] MODELS = new String[] { MODEL_REPOSITORY,
- MODEL_USERS, MODEL_GROUPS };
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- *
- * @param baseUrl
- * @return
- */
- protected abstract ModelUrlProvider createGroupModelUrlProvider(
- String baseUrl);
-
- /**
- * Method description
- *
- *
- *
- * @param baseUrl
- * @return
- */
- protected abstract ModelUrlProvider createRepositoryModelUrlProvider(
- String baseUrl);
-
- /**
- * Method description
- *
- *
- *
- * @param baseUrl
- * @return
- */
- protected abstract ModelUrlProvider createUserModelUrlProvider(
- String baseUrl);
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param model
- *
- * @return
- */
- protected abstract String getExpectedAllUrl(String baseUrl, String model);
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param model
- * @param item
- *
- * @return
- */
- protected abstract String getExpectedDetailUrl(String baseUrl, String model,
- String item);
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- */
- @Test
- public void testGetAllUrl()
- {
- for (String model : MODELS)
- {
- assertEquals(getExpectedAllUrl(BASEURL, model),
- createModelUrlProvider(BASEURL, model).getAllUrl());
- }
- }
-
- /**
- * Method description
- *
- */
- @Test
- public void testGetDetailUrl()
- {
- for (String model : MODELS)
- {
- assertEquals(getExpectedDetailUrl(BASEURL, model, ITEM),
- createModelUrlProvider(BASEURL, model).getDetailUrl(ITEM));
- }
- }
-
- /**
- * Method description
- *
- *
- *
- * @param baseUrl
- * @param model
- *
- * @return
- */
- private ModelUrlProvider createModelUrlProvider(String baseUrl, String model)
- {
- ModelUrlProvider urlProvider = null;
-
- if (MODEL_REPOSITORY.equals(model))
- {
- urlProvider = createRepositoryModelUrlProvider(baseUrl);
- }
- else if (MODEL_USERS.equals(model))
- {
- urlProvider = createUserModelUrlProvider(baseUrl);
- }
- else if (MODEL_GROUPS.equals(model))
- {
- urlProvider = createGroupModelUrlProvider(baseUrl);
- }
-
- return urlProvider;
- }
-}
diff --git a/scm-core/src/test/java/sonia/scm/url/RepositoryUrlProviderTestBase.java b/scm-core/src/test/java/sonia/scm/url/RepositoryUrlProviderTestBase.java
deleted file mode 100644
index 0c2e36dfd3..0000000000
--- a/scm-core/src/test/java/sonia/scm/url/RepositoryUrlProviderTestBase.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-package sonia.scm.url;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public abstract class RepositoryUrlProviderTestBase extends UrlTestBase
-{
-
- /** Field description */
- private static final String NAME = "scm/main";
-
- /** Field description */
- private static final String PATH = "scm-webapp/pom.xml";
-
- /** Field description */
- private static final String REPOSITORY_ID =
- "E3882BE7-7D0D-421B-B178-B2AA9E897135";
-
- /** Field description */
- private static final String REVISION = "b282fb2dd12a";
-
- /** Field description */
- private static final String TYPE = "hg";
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- protected abstract RepositoryUrlProvider createRepositoryUrlProvider(
- String baseUrl);
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param repositoryId
- * @param path
- * @param revision
- *
- * @return
- */
- protected abstract String getExpectedBlameUrl(String baseUrl,
- String repositoryId, String path, String revision);
-
- /**
- * Method description
- *
- *
- *
- * @param baseUrl
- * @param repositoryId
- * @param path
- * @param revision
- *
- * @return
- */
- protected abstract String getExpectedBrowseUrl(String baseUrl,
- String repositoryId, String path, String revision);
-
- /**
- * Method description
- *
- *
- *
- * @param baseUrl
- * @param repositoryId
- * @param path
- * @param revision
- * @param start
- * @param limit
- *
- * @return
- */
- protected abstract String getExpectedChangesetUrl(String baseUrl,
- String repositoryId, String path, String revision, int start,
- int limit);
-
- /**
- * Method description
- *
- *
- *
- * @param baseUrl
- * @param repositoryId
- * @param start
- * @param limit
- *
- * @return
- */
- protected abstract String getExpectedChangesetUrl(String baseUrl,
- String repositoryId, int start, int limit);
-
- /**
- * Method description
- *
- *
- *
- * @param baseUrl
- * @param repositoryId
- * @param path
- * @param revision
- *
- * @return
- */
- protected abstract String getExpectedContentUrl(String baseUrl,
- String repositoryId, String path, String revision);
-
- /**
- * Method description
- *
- *
- *
- * @param baseUrl
- * @param type
- * @param name
- *
- * @return
- * @since 1.11
- */
- protected abstract String getExpectedDetailUrl(String baseUrl, String type,
- String name);
-
- /**
- * Method description
- *
- *
- *
- * @param baseUrl
- * @param repositoryId
- * @param revision
- *
- * @return
- */
- protected abstract String getExpectedDiffUrl(String baseUrl,
- String repositoryId, String revision);
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- */
- @Test
- public void testGetBlameUrl()
- {
- assertEquals(
- getExpectedBlameUrl(BASEURL, REPOSITORY_ID, PATH, REVISION),
- createRepositoryUrlProvider(BASEURL).getBlameUrl(
- REPOSITORY_ID, PATH, REVISION));
- }
-
- /**
- * Method description
- *
- */
- @Test
- public void testGetBrowserUrl()
- {
- assertEquals(
- getExpectedBrowseUrl(BASEURL, REPOSITORY_ID, PATH, REVISION),
- createRepositoryUrlProvider(BASEURL).getBrowseUrl(
- REPOSITORY_ID, PATH, REVISION));
- }
-
- /**
- * Method description
- *
- */
- @Test
- public void testGetChangesetUrl()
- {
- assertEquals(
- getExpectedChangesetUrl(BASEURL, REPOSITORY_ID, PATH, REVISION, 0, 20),
- createRepositoryUrlProvider(BASEURL).getChangesetUrl(
- REPOSITORY_ID, PATH, REVISION, 0, 20));
- assertEquals(
- getExpectedChangesetUrl(BASEURL, REPOSITORY_ID, 0, 20),
- createRepositoryUrlProvider(BASEURL).getChangesetUrl(
- REPOSITORY_ID, 0, 20));
- }
-
- /**
- * Method description
- *
- */
- @Test
- public void testGetContentUrl()
- {
- assertEquals(
- getExpectedContentUrl(BASEURL, REPOSITORY_ID, PATH, REVISION),
- createRepositoryUrlProvider(BASEURL).getContentUrl(
- REPOSITORY_ID, PATH, REVISION));
- }
-
- /**
- * Method description
- *
- */
- @Test
- public void testGetDetailUrl()
- {
- assertEquals(getExpectedDetailUrl(BASEURL, TYPE, NAME),
- createRepositoryUrlProvider(BASEURL).getDetailUrl(TYPE, NAME));
- }
-
- /**
- * Method description
- *
- */
- @Test
- public void testGetDiffUrl()
- {
- assertEquals(getExpectedDiffUrl(BASEURL, REPOSITORY_ID, REVISION),
- createRepositoryUrlProvider(BASEURL).getDiffUrl(REPOSITORY_ID,
- REVISION));
- }
-}
diff --git a/scm-core/src/test/java/sonia/scm/url/RestModelUrlProviderTestBase.java b/scm-core/src/test/java/sonia/scm/url/RestModelUrlProviderTestBase.java
deleted file mode 100644
index 2e7f25818f..0000000000
--- a/scm-core/src/test/java/sonia/scm/url/RestModelUrlProviderTestBase.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-package sonia.scm.url;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.util.HttpUtil;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public abstract class RestModelUrlProviderTestBase
- extends ModelUrlProviderTestBase
-{
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- protected abstract UrlProvider createUrlProvider(String baseUrl);
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- protected abstract String getExtension();
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- @Override
- protected ModelUrlProvider createGroupModelUrlProvider(String baseUrl)
- {
- return createUrlProvider(baseUrl).getGroupUrlProvider();
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- @Override
- protected ModelUrlProvider createRepositoryModelUrlProvider(String baseUrl)
- {
- return createUrlProvider(baseUrl).getRepositoryUrlProvider();
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param urlPart
- *
- * @return
- */
- protected String createRestUrl(String baseUrl, String urlPart)
- {
- return createRestUrl(baseUrl, urlPart, getExtension());
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- @Override
- protected ModelUrlProvider createUserModelUrlProvider(String baseUrl)
- {
- return createUrlProvider(baseUrl).getUserUrlProvider();
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param model
- *
- * @return
- */
- @Override
- protected String getExpectedAllUrl(String baseUrl, String model)
- {
- return createRestUrl(baseUrl, model);
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param model
- * @param item
- *
- * @return
- */
- @Override
- protected String getExpectedDetailUrl(String baseUrl, String model,
- String item)
- {
- return createRestUrl(baseUrl,
- model.concat(HttpUtil.SEPARATOR_PATH).concat(item));
- }
-}
diff --git a/scm-core/src/test/java/sonia/scm/url/RestRepositoryUrlProviderTestBase.java b/scm-core/src/test/java/sonia/scm/url/RestRepositoryUrlProviderTestBase.java
deleted file mode 100644
index 31783f7eea..0000000000
--- a/scm-core/src/test/java/sonia/scm/url/RestRepositoryUrlProviderTestBase.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-package sonia.scm.url;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.util.HttpUtil;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public abstract class RestRepositoryUrlProviderTestBase
- extends RepositoryUrlProviderTestBase
-{
-
- /** Field description */
- public static final String URLPART_PREFIX = "repositories";
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- protected abstract String getExtension();
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param repositoryId
- * @param path
- * @param revision
- *
- * @return
- */
- @Override
- protected String getExpectedBlameUrl(String baseUrl, String repositoryId,
- String path, String revision)
- {
- return createRestUrl(
- baseUrl,
- repositoryId.concat(HttpUtil.SEPARATOR_PATH).concat("blame")).concat(
- "?path=").concat(path).concat("&revision=").concat(revision);
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param repositoryId
- * @param path
- * @param revision
- *
- * @return
- */
- @Override
- protected String getExpectedBrowseUrl(String baseUrl, String repositoryId,
- String path, String revision)
- {
- return createRestUrl(
- baseUrl,
- repositoryId.concat(HttpUtil.SEPARATOR_PATH).concat("browse")).concat(
- "?path=").concat(path).concat("&revision=").concat(revision);
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param repositoryId
- * @param path
- * @param revision
- * @param start
- * @param limit
- *
- * @return
- */
- @Override
- protected String getExpectedChangesetUrl(String baseUrl, String repositoryId,
- String path, String revision, int start, int limit)
- {
- return createRestUrl(
- baseUrl,
- repositoryId.concat(HttpUtil.SEPARATOR_PATH).concat(
- "changesets")).concat("?path=").concat(path).concat(
- "&revision=").concat(revision).concat("&start=").concat(
- String.valueOf(start)).concat("&limit=").concat(
- String.valueOf(limit));
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param repositoryId
- * @param start
- * @param limit
- *
- * @return
- */
- @Override
- protected String getExpectedChangesetUrl(String baseUrl, String repositoryId,
- int start, int limit)
- {
- return createRestUrl(
- baseUrl,
- repositoryId.concat(HttpUtil.SEPARATOR_PATH).concat(
- "changesets")).concat("?start=").concat(String.valueOf(start)).concat(
- "&limit=").concat(String.valueOf(limit));
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param repositoryId
- * @param path
- * @param revision
- *
- * @return
- */
- @Override
- protected String getExpectedContentUrl(String baseUrl, String repositoryId,
- String path, String revision)
- {
- return createRestUrl(
- baseUrl,
- "repositories".concat(HttpUtil.SEPARATOR_PATH).concat(
- repositoryId).concat(HttpUtil.SEPARATOR_PATH).concat(
- "content"), "").concat("?path=").concat(path).concat(
- "&revision=").concat(revision);
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param type
- * @param name
- *
- * @return
- */
- @Override
- protected String getExpectedDetailUrl(String baseUrl, String type,
- String name)
- {
- return createRestUrl(baseUrl,
- type.concat(HttpUtil.SEPARATOR_PATH).concat(name));
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param repositoryId
- * @param revision
- *
- * @return
- */
- @Override
- protected String getExpectedDiffUrl(String baseUrl, String repositoryId,
- String revision)
- {
- return createRestUrl(
- baseUrl,
- "repositories".concat(HttpUtil.SEPARATOR_PATH).concat(
- repositoryId).concat(HttpUtil.SEPARATOR_PATH).concat(
- "diff"), "").concat("?revision=").concat(revision);
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param urlPart
- *
- * @return
- */
- private String createRestUrl(String baseUrl, String urlPart)
- {
- return createRestUrl(
- baseUrl,
- URLPART_PREFIX.concat(HttpUtil.SEPARATOR_PATH).concat(urlPart),
- getExtension());
- }
-}
diff --git a/scm-core/src/test/java/sonia/scm/url/RestUrlProviderTestBase.java b/scm-core/src/test/java/sonia/scm/url/RestUrlProviderTestBase.java
deleted file mode 100644
index 3b39e22816..0000000000
--- a/scm-core/src/test/java/sonia/scm/url/RestUrlProviderTestBase.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-package sonia.scm.url;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public abstract class RestUrlProviderTestBase extends UrlProviderTestBase
-{
-
- /**
- * Method description
- *
- *
- * @return
- */
- protected abstract String getExtension();
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param urlPart
- *
- * @return
- */
- protected String createRestUrl(String baseUrl, String urlPart)
- {
- return createRestUrl(baseUrl, urlPart, getExtension());
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- @Override
- protected String getExpectedAuthenticationUrl(String baseUrl)
- {
- return createRestUrl(baseUrl, "auth/access_token");
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- @Override
- protected String getExpectedConfigUrl(String baseUrl)
- {
- return createRestUrl(baseUrl, "config");
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- @Override
- protected String getExpectedStateUrl(String baseUrl)
- {
- return createRestUrl(baseUrl, "auth");
- }
-}
diff --git a/scm-core/src/test/java/sonia/scm/url/UrlProviderTestBase.java b/scm-core/src/test/java/sonia/scm/url/UrlProviderTestBase.java
deleted file mode 100644
index 61c35b7b64..0000000000
--- a/scm-core/src/test/java/sonia/scm/url/UrlProviderTestBase.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-package sonia.scm.url;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public abstract class UrlProviderTestBase extends UrlTestBase
-{
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- *
- * @param baseUrl
- * @return
- */
- protected abstract UrlProvider createUrlProvider(String baseUrl);
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- protected abstract String getExpectedAuthenticationUrl(String baseUrl);
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- protected abstract String getExpectedConfigUrl(String baseUrl);
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- protected abstract String getExpectedStateUrl(String baseUrl);
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- */
- @Test
- public void testGetAuthenticationUrl()
- {
- assertEquals(getExpectedAuthenticationUrl(BASEURL),
- createUrlProvider(BASEURL).getAuthenticationUrl());
- }
-
- /**
- * Method description
- *
- */
- @Test
- public void testGetConfigUrl()
- {
- assertEquals(getExpectedConfigUrl(BASEURL),
- createUrlProvider(BASEURL).getConfigUrl());
- }
-
- /**
- * Method description
- *
- */
- @Test
- public void testGetGroupUrlProvider()
- {
- assertNotNull(createUrlProvider(BASEURL).getGroupUrlProvider());
- }
-
- /**
- * Method description
- *
- */
- @Test
- public void testGetStateUrl()
- {
- assertEquals(getExpectedStateUrl(BASEURL),
- createUrlProvider(BASEURL).getStateUrl());
- }
-
- /**
- * Method description
- *
- */
- @Test
- public void testGetUserRepositoryUrlProvider()
- {
- assertNotNull(createUrlProvider(BASEURL).getRepositoryUrlProvider());
- }
-
- /**
- * Method description
- *
- */
- @Test
- public void testGetUserUrlProvider()
- {
- assertNotNull(createUrlProvider(BASEURL).getUserUrlProvider());
- }
-}
diff --git a/scm-core/src/test/java/sonia/scm/url/UrlTestBase.java b/scm-core/src/test/java/sonia/scm/url/UrlTestBase.java
deleted file mode 100644
index 28202cb420..0000000000
--- a/scm-core/src/test/java/sonia/scm/url/UrlTestBase.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-package sonia.scm.url;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.util.HttpUtil;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public abstract class UrlTestBase
-{
-
- /** Field description */
- public static final String EXTENSION_JSON = ".json";
-
- /** Field description */
- public static final String EXTENSION_XML = ".xml";
-
- /** Field description */
- public static final String URLSUFFIX_INDEX = "/index.html";
-
- /** Field description */
- public static final String URLSUFFIX_RESTAPI = "/api/rest/";
-
- /** Field description */
- protected static final String BASEURL = "http://scm.scm-manager.org/scm";
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- protected String createBaseRestUrl(String baseUrl)
- {
- return baseUrl.concat(URLSUFFIX_RESTAPI);
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param urlPart
- * @param extension
- *
- * @return
- */
- protected String createRestUrl(String baseUrl, String urlPart,
- String extension)
- {
- return createBaseRestUrl(baseUrl).concat(urlPart).concat(extension);
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- protected String createWuiUrl(String baseUrl)
- {
- return baseUrl.concat(URLSUFFIX_INDEX);
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param param
- *
- * @return
- */
- protected String createWuiUrl(String baseUrl, String param)
- {
- return baseUrl.concat(URLSUFFIX_INDEX).concat(
- HttpUtil.SEPARATOR_HASH).concat(param);
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- protected UrlProvider createWuiUrlProvider(String baseUrl)
- {
- return UrlProviderFactory.createUrlProvider(baseUrl,
- UrlProviderFactory.TYPE_WUI);
- }
-}
diff --git a/scm-core/src/test/java/sonia/scm/url/UrlUtilTest.java b/scm-core/src/test/java/sonia/scm/url/UrlUtilTest.java
deleted file mode 100644
index 255d7912df..0000000000
--- a/scm-core/src/test/java/sonia/scm/url/UrlUtilTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-
-package sonia.scm.url;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class UrlUtilTest
-{
-
- /**
- * Method description
- *
- */
- @Test
- public void testFixRevision()
- {
- assertEquals("42694c4a4a7a", UrlUtil.fixRevision("42694c4a4a7a"));
- assertEquals("42694c4a4a7a", UrlUtil.fixRevision("298:42694c4a4a7a"));
- assertNull(UrlUtil.fixRevision(null));
- }
-}
diff --git a/scm-core/src/test/java/sonia/scm/url/WUIModelUrlProviderTest.java b/scm-core/src/test/java/sonia/scm/url/WUIModelUrlProviderTest.java
deleted file mode 100644
index b6073a841a..0000000000
--- a/scm-core/src/test/java/sonia/scm/url/WUIModelUrlProviderTest.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-package sonia.scm.url;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class WUIModelUrlProviderTest extends ModelUrlProviderTestBase
-{
-
- /**
- * Constructs ...
- *
- */
- public WUIModelUrlProviderTest()
- {
- modelMap = new HashMap();
- modelMap.put(MODEL_REPOSITORY, "repositoryPanel");
- modelMap.put(MODEL_USERS, "userPanel");
- modelMap.put(MODEL_GROUPS, "groupPanel");
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- @Override
- protected ModelUrlProvider createGroupModelUrlProvider(String baseUrl)
- {
- return createWuiUrlProvider(baseUrl).getGroupUrlProvider();
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- @Override
- protected ModelUrlProvider createRepositoryModelUrlProvider(String baseUrl)
- {
- return createWuiUrlProvider(baseUrl).getRepositoryUrlProvider();
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- @Override
- protected ModelUrlProvider createUserModelUrlProvider(String baseUrl)
- {
- return createWuiUrlProvider(baseUrl).getUserUrlProvider();
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param model
- *
- * @return
- */
- @Override
- protected String getExpectedAllUrl(String baseUrl, String model)
- {
- return createModelBaseUrl(baseUrl, model);
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param model
- * @param item
- *
- * @return
- */
- @Override
- protected String getExpectedDetailUrl(String baseUrl, String model,
- String item)
- {
- return createModelBaseUrl(baseUrl, model).concat(
- WUIUrlBuilder.SEPARATOR).concat(item);
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param model
- *
- * @return
- */
- private String createModelBaseUrl(String baseUrl, String model)
- {
- return createWuiUrl(baseUrl, modelMap.get(model));
- }
-
- //~--- fields ---------------------------------------------------------------
-
- /** Field description */
- private Map modelMap;
-}
diff --git a/scm-core/src/test/java/sonia/scm/url/WUIRepositoryUrlProviderTest.java b/scm-core/src/test/java/sonia/scm/url/WUIRepositoryUrlProviderTest.java
deleted file mode 100644
index 91a1a8fb8a..0000000000
--- a/scm-core/src/test/java/sonia/scm/url/WUIRepositoryUrlProviderTest.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-package sonia.scm.url;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import sonia.scm.util.HttpUtil;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class WUIRepositoryUrlProviderTest extends RepositoryUrlProviderTestBase
-{
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- @Override
- protected RepositoryUrlProvider createRepositoryUrlProvider(String baseUrl)
- {
- return UrlProviderFactory.createUrlProvider(baseUrl,
- UrlProviderFactory.TYPE_WUI).getRepositoryUrlProvider();
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param repositoryId
- * @param path
- * @param revision
- *
- * @return
- */
- @Override
- protected String getExpectedBlameUrl(String baseUrl, String repositoryId,
- String path, String revision)
- {
- return createRepositoryWuiUrl(baseUrl, "contentPanel", repositoryId).concat(
- ";").concat(revision).concat(";").concat(path).concat(";blame");
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param repositoryId
- * @param path
- * @param revision
- *
- * @return
- */
- @Override
- protected String getExpectedBrowseUrl(String baseUrl, String repositoryId,
- String path, String revision)
- {
- return createRepositoryWuiUrl(
- baseUrl, "repositoryBrowser", repositoryId).concat(";").concat(
- revision).concat(";").concat(path);
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param repositoryId
- * @param path
- * @param revision
- * @param start
- * @param limit
- *
- * @return
- */
- @Override
- protected String getExpectedChangesetUrl(String baseUrl, String repositoryId,
- String path, String revision, int start, int limit)
- {
- return createRepositoryWuiUrl(baseUrl, "contentPanel", repositoryId).concat(
- ";").concat(revision).concat(";").concat(path).concat(";history");
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param repositoryId
- * @param start
- * @param limit
- *
- * @return
- */
- @Override
- protected String getExpectedChangesetUrl(String baseUrl, String repositoryId,
- int start, int limit)
- {
- return createRepositoryWuiUrl(
- baseUrl, "repositoryChangesetViewerPanel", repositoryId).concat(
- ";").concat(String.valueOf(start)).concat(";").concat(
- String.valueOf(limit));
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param repositoryId
- * @param path
- * @param revision
- *
- * @return
- */
- @Override
- protected String getExpectedContentUrl(String baseUrl, String repositoryId,
- String path, String revision)
- {
- return createRepositoryWuiUrl(baseUrl, "contentPanel", repositoryId).concat(
- ";").concat(revision).concat(";").concat(path).concat(";history");
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param type
- * @param name
- *
- * @return
- */
- @Override
- protected String getExpectedDetailUrl(String baseUrl, String type,
- String name)
- {
- return createRepositoryWuiUrl(
- baseUrl, "repositoryPanel",
- type.concat(HttpUtil.SEPARATOR_PATH).concat(name));
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param repositoryId
- * @param revision
- *
- * @return
- */
- @Override
- protected String getExpectedDiffUrl(String baseUrl, String repositoryId,
- String revision)
- {
- return createRepositoryWuiUrl(baseUrl, "diffPanel",
- repositoryId).concat(";").concat(revision);
- }
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- * @param component
- * @param repository
- *
- * @return
- */
- private String createRepositoryWuiUrl(String baseUrl, String component,
- String repository)
- {
- return createWuiUrl(baseUrl, component).concat(
- WUIUrlBuilder.SEPARATOR).concat(repository);
- }
-}
diff --git a/scm-core/src/test/java/sonia/scm/url/WUIUrlBuilderTest.java b/scm-core/src/test/java/sonia/scm/url/WUIUrlBuilderTest.java
deleted file mode 100644
index 4fdefc5fb1..0000000000
--- a/scm-core/src/test/java/sonia/scm/url/WUIUrlBuilderTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-package sonia.scm.url;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import org.junit.Test;
-
-import sonia.scm.util.HttpUtil;
-
-import static org.junit.Assert.*;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class WUIUrlBuilderTest
-{
-
- /** Field description */
- private static final String BASEURL =
- "http://scm.scm-manager.org/scm/index.html";
-
- /** Field description */
- private static final String COMPONENT = "testCmp";
-
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- */
- @Test
- public void testStringAppend()
- {
- WUIUrlBuilder builder = createBuilder();
-
- builder.append("testParam");
- assertEquals(createBaseWuiUrl().concat(";testParam"), builder.toString());
- builder = createBuilder();
- builder.append("param1").append("param2").append("param3");
- assertEquals(createBaseWuiUrl().concat(";param1;param2;param3"),
- builder.toString());
- }
-
- /**
- * Method description
- *
- */
- @Test
- public void testIntAppend()
- {
- WUIUrlBuilder builder = createBuilder();
-
- builder.append(3);
- assertEquals(createBaseWuiUrl().concat(";3"), builder.toString());
- builder = createBuilder();
- builder.append(1).append(2).append(3);
- assertEquals(createBaseWuiUrl().concat(";1;2;3"),
- builder.toString());
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- private String createBaseWuiUrl()
- {
- return BASEURL.concat(HttpUtil.SEPARATOR_HASH).concat(COMPONENT);
- }
-
- /**
- * Method description
- *
- *
- * @return
- */
- private WUIUrlBuilder createBuilder()
- {
- return new WUIUrlBuilder(BASEURL, COMPONENT);
- }
-}
diff --git a/scm-core/src/test/java/sonia/scm/url/WUIUrlProviderTest.java b/scm-core/src/test/java/sonia/scm/url/WUIUrlProviderTest.java
deleted file mode 100644
index 19ec89835a..0000000000
--- a/scm-core/src/test/java/sonia/scm/url/WUIUrlProviderTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-package sonia.scm.url;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class WUIUrlProviderTest extends UrlProviderTestBase
-{
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- @Override
- protected UrlProvider createUrlProvider(String baseUrl)
- {
- return UrlProviderFactory.createUrlProvider(baseUrl,
- UrlProviderFactory.TYPE_WUI);
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- @Override
- protected String getExpectedAuthenticationUrl(String baseUrl)
- {
- return createWuiUrl(baseUrl);
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- @Override
- protected String getExpectedConfigUrl(String baseUrl)
- {
- return createWuiUrl(baseUrl, "scmConfig");
- }
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- @Override
- protected String getExpectedStateUrl(String baseUrl)
- {
- return createWuiUrl(baseUrl);
- }
-}
diff --git a/scm-core/src/test/java/sonia/scm/url/XMLRestModelUrlProviderTest.java b/scm-core/src/test/java/sonia/scm/url/XMLRestModelUrlProviderTest.java
deleted file mode 100644
index 7017e0551a..0000000000
--- a/scm-core/src/test/java/sonia/scm/url/XMLRestModelUrlProviderTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-package sonia.scm.url;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class XMLRestModelUrlProviderTest extends RestModelUrlProviderTestBase
-{
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- @Override
- protected UrlProvider createUrlProvider(String baseUrl)
- {
- return UrlProviderFactory.createUrlProvider(baseUrl,
- UrlProviderFactory.TYPE_RESTAPI_XML);
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- protected String getExtension()
- {
- return EXTENSION_XML;
- }
-}
diff --git a/scm-core/src/test/java/sonia/scm/url/XMLRestUrlProviderTest.java b/scm-core/src/test/java/sonia/scm/url/XMLRestUrlProviderTest.java
deleted file mode 100644
index 33e19aa258..0000000000
--- a/scm-core/src/test/java/sonia/scm/url/XMLRestUrlProviderTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * Copyright (c) 2010, Sebastian Sdorra
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of SCM-Manager; nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * http://bitbucket.org/sdorra/scm-manager
- *
- */
-
-
-package sonia.scm.url;
-
-/**
- *
- * @author Sebastian Sdorra
- */
-public class XMLRestUrlProviderTest extends RestUrlProviderTestBase
-{
-
- /**
- * Method description
- *
- *
- * @param baseUrl
- *
- * @return
- */
- @Override
- protected UrlProvider createUrlProvider(String baseUrl)
- {
- return UrlProviderFactory.createUrlProvider(baseUrl,
- UrlProviderFactory.TYPE_RESTAPI_XML);
- }
-
- //~--- get methods ----------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @return
- */
- @Override
- protected String getExtension()
- {
- return EXTENSION_XML;
- }
-}
diff --git a/scm-core/src/test/java/sonia/scm/util/HttpUtilTest.java b/scm-core/src/test/java/sonia/scm/util/HttpUtilTest.java
index b85221f8c8..5e6fa3e10e 100644
--- a/scm-core/src/test/java/sonia/scm/util/HttpUtilTest.java
+++ b/scm-core/src/test/java/sonia/scm/util/HttpUtilTest.java
@@ -54,6 +54,18 @@ import javax.servlet.http.HttpServletRequest;
public class HttpUtilTest
{
+ @Test
+ public void concatenateTest() {
+ assertEquals(
+ "/scm/git/hitchhiker/tricia",
+ HttpUtil.concatenate("/scm", "git", "hitchhiker", "tricia")
+ );
+ assertEquals(
+ "scm/git/hitchhiker/tricia",
+ HttpUtil.concatenate("scm", "git", "hitchhiker", "tricia")
+ );
+ }
+
/**
* Method description
*
@@ -63,19 +75,19 @@ public class HttpUtilTest
{
//J-
assertEquals(
- "http://www.scm-manager/scm/test",
+ "http://www.scm-manager/scm/test",
HttpUtil.append("http://www.scm-manager/scm/", "test")
);
assertEquals(
- "http://www.scm-manager/scm/test",
+ "http://www.scm-manager/scm/test",
HttpUtil.append("http://www.scm-manager/scm", "test")
);
assertEquals(
- "http://www.scm-manager/scm/test",
+ "http://www.scm-manager/scm/test",
HttpUtil.append("http://www.scm-manager/scm", "/test")
);
assertEquals(
- "http://www.scm-manager/scm/test",
+ "http://www.scm-manager/scm/test",
HttpUtil.append("http://www.scm-manager/scm/", "/test")
);
//J+
diff --git a/scm-dao-xml/src/main/java/sonia/scm/repository/xml/XmlRepositoryDAO.java b/scm-dao-xml/src/main/java/sonia/scm/repository/xml/XmlRepositoryDAO.java
index 7c17c365aa..4510706721 100644
--- a/scm-dao-xml/src/main/java/sonia/scm/repository/xml/XmlRepositoryDAO.java
+++ b/scm-dao-xml/src/main/java/sonia/scm/repository/xml/XmlRepositoryDAO.java
@@ -36,11 +36,11 @@ package sonia.scm.repository.xml;
import com.google.inject.Inject;
import com.google.inject.Singleton;
-
+import sonia.scm.repository.NamespaceAndName;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryDAO;
-import sonia.scm.xml.AbstractXmlDAO;
import sonia.scm.store.ConfigurationStoreFactory;
+import sonia.scm.xml.AbstractXmlDAO;
/**
*
@@ -71,36 +71,18 @@ public class XmlRepositoryDAO
//~--- methods --------------------------------------------------------------
- /**
- * Method description
- *
- *
- * @param type
- * @param name
- *
- * @return
- */
@Override
- public boolean contains(String type, String name)
+ public boolean contains(NamespaceAndName namespaceAndName)
{
- return db.contains(type, name);
+ return db.contains(namespaceAndName);
}
//~--- get methods ----------------------------------------------------------
- /**
- * Method description
- *
- *
- * @param type
- * @param name
- *
- * @return
- */
@Override
- public Repository get(String type, String name)
+ public Repository get(NamespaceAndName namespaceAndName)
{
- return db.get(type, name);
+ return db.get(namespaceAndName);
}
//~--- methods --------------------------------------------------------------
diff --git a/scm-dao-xml/src/main/java/sonia/scm/repository/xml/XmlRepositoryDatabase.java b/scm-dao-xml/src/main/java/sonia/scm/repository/xml/XmlRepositoryDatabase.java
index a5c599c291..93be611213 100644
--- a/scm-dao-xml/src/main/java/sonia/scm/repository/xml/XmlRepositoryDatabase.java
+++ b/scm-dao-xml/src/main/java/sonia/scm/repository/xml/XmlRepositoryDatabase.java
@@ -35,34 +35,26 @@ package sonia.scm.repository.xml;
//~--- non-JDK imports --------------------------------------------------------
+import sonia.scm.repository.NamespaceAndName;
import sonia.scm.repository.Repository;
import sonia.scm.xml.XmlDatabase;
-//~--- JDK imports ------------------------------------------------------------
-
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+//~--- JDK imports ------------------------------------------------------------
-/**
- *
- * @author Sebastian Sdorra
- */
@XmlRootElement(name = "repository-db")
@XmlAccessorType(XmlAccessType.FIELD)
public class XmlRepositoryDatabase implements XmlDatabase
{
- /**
- * Constructs ...
- *
- */
public XmlRepositoryDatabase()
{
long c = System.currentTimeMillis();
@@ -71,108 +63,43 @@ public class XmlRepositoryDatabase implements XmlDatabase
lastModified = c;
}
- //~--- methods --------------------------------------------------------------
-
- /**
- * Method description
- *
- *
- * @param type
- * @param name
- *
- * @return
- */
- static String createKey(String type, String name)
+ static String createKey(NamespaceAndName namespaceAndName)
{
- return type.concat(":").concat(name);
+ return namespaceAndName.getNamespace() + ":" + namespaceAndName.getName();
}
- /**
- * Method description
- *
- *
- * @param repository
- *
- * @return
- */
static String createKey(Repository repository)
{
- return createKey(repository.getType(), repository.getName());
+ return createKey(repository.getNamespaceAndName());
}
- /**
- * Method description
- *
- *
- * @param repository
- */
@Override
public void add(Repository repository)
{
repositoryMap.put(createKey(repository), repository);
}
- /**
- * Method description
- *
- *
- *
- * @param type
- * @param name
- *
- * @return
- */
- public boolean contains(String type, String name)
+ public boolean contains(NamespaceAndName namespaceAndName)
{
- return repositoryMap.containsKey(createKey(type, name));
+ return repositoryMap.containsKey(createKey(namespaceAndName));
}
- /**
- * Method description
- *
- *
- * @param id
- *
- * @return
- */
@Override
public boolean contains(String id)
{
return get(id) != null;
}
- /**
- * Method description
- *
- *
- * @param repository
- *
- * @return
- */
public boolean contains(Repository repository)
{
return repositoryMap.containsKey(createKey(repository));
}
- /**
- * Method description
- *
- *
- * @param repository
- */
public void remove(Repository repository)
{
repositoryMap.remove(createKey(repository));
}
- /**
- * Method description
- *
- *
- * @param id
- *
- * @return
- */
@Override
public Repository remove(String id)
{
@@ -183,12 +110,6 @@ public class XmlRepositoryDatabase implements XmlDatabase
return r;
}
- /**
- * Method description
- *
- *
- * @return
- */
@Override
public Collection values()
{
@@ -197,18 +118,9 @@ public class XmlRepositoryDatabase implements XmlDatabase
//~--- get methods ----------------------------------------------------------
- /**
- * Method description
- *
- *
- * @param type
- * @param name
- *
- * @return
- */
- public Repository get(String type, String name)
+ public Repository get(NamespaceAndName namespaceAndName)
{
- return repositoryMap.get(createKey(type, name));
+ return repositoryMap.get(createKey(namespaceAndName));
}
/**
@@ -298,6 +210,5 @@ public class XmlRepositoryDatabase implements XmlDatabase
/** Field description */
@XmlJavaTypeAdapter(XmlRepositoryMapAdapter.class)
@XmlElement(name = "repositories")
- private Map repositoryMap = new LinkedHashMap();
+ private Map repositoryMap = new LinkedHashMap<>();
}
diff --git a/scm-dao-xml/src/main/java/sonia/scm/repository/xml/XmlRepositoryMapAdapter.java b/scm-dao-xml/src/main/java/sonia/scm/repository/xml/XmlRepositoryMapAdapter.java
index a90a2d4fa9..4d6686dfb2 100644
--- a/scm-dao-xml/src/main/java/sonia/scm/repository/xml/XmlRepositoryMapAdapter.java
+++ b/scm-dao-xml/src/main/java/sonia/scm/repository/xml/XmlRepositoryMapAdapter.java
@@ -37,57 +37,28 @@ package sonia.scm.repository.xml;
import sonia.scm.repository.Repository;
-//~--- JDK imports ------------------------------------------------------------
-
+import javax.xml.bind.annotation.adapters.XmlAdapter;
import java.util.LinkedHashMap;
import java.util.Map;
-import javax.xml.bind.annotation.adapters.XmlAdapter;
+//~--- JDK imports ------------------------------------------------------------
/**
*
* @author Sebastian Sdorra
*/
-public class XmlRepositoryMapAdapter
- extends XmlAdapter>
-{
+public class XmlRepositoryMapAdapter extends XmlAdapter> {
- /**
- * Method description
- *
- *
- * @param repositoryMap
- *
- * @return
- *
- * @throws Exception
- */
@Override
- public XmlRepositoryList marshal(Map repositoryMap)
- throws Exception
- {
+ public XmlRepositoryList marshal(Map repositoryMap) {
return new XmlRepositoryList(repositoryMap);
}
- /**
- * Method description
- *
- *
- * @param repositories
- *
- * @return
- *
- * @throws Exception
- */
@Override
- public Map unmarshal(XmlRepositoryList repositories)
- throws Exception
- {
- Map repositoryMap = new LinkedHashMap();
+ public Map unmarshal(XmlRepositoryList repositories) {
+ Map repositoryMap = new LinkedHashMap<>();
- for (Repository repository : repositories)
- {
+ for (Repository repository : repositories) {
repositoryMap.put(XmlRepositoryDatabase.createKey(repository),
repository);
}
diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitConfig.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitConfig.java
index 77352c6ca0..3569fee179 100644
--- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitConfig.java
+++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitConfig.java
@@ -39,6 +39,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
/**
*
@@ -46,7 +47,7 @@ import javax.xml.bind.annotation.XmlRootElement;
*/
@XmlRootElement(name = "config")
@XmlAccessorType(XmlAccessType.FIELD)
-public class GitConfig extends SimpleRepositoryConfig {
+public class GitConfig extends RepositoryConfig {
@XmlElement(name = "gc-expression")
private String gcExpression;
@@ -59,4 +60,11 @@ public class GitConfig extends SimpleRepositoryConfig {
public void setGcExpression(String gcExpression) {
this.gcExpression = gcExpression;
}
+
+ @Override
+ @XmlTransient // Only for permission checks, don't serialize to XML
+ public String getId() {
+ // Don't change this without migrating SCM permission configuration!
+ return "git";
+ }
}
diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitRepositoryModifyListener.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitRepositoryModifyListener.java
index db2b7b09ec..1cbcdc35bf 100644
--- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitRepositoryModifyListener.java
+++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitRepositoryModifyListener.java
@@ -30,9 +30,9 @@
*/
package sonia.scm.repository;
+import com.github.legman.Subscribe;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Objects;
-import com.google.common.eventbus.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.EagerSingleton;
diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitReceiveHook.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitReceiveHook.java
index 3ecd6047e9..eeda60ed02 100644
--- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitReceiveHook.java
+++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitReceiveHook.java
@@ -40,24 +40,21 @@ import org.eclipse.jgit.transport.PostReceiveHook;
import org.eclipse.jgit.transport.PreReceiveHook;
import org.eclipse.jgit.transport.ReceiveCommand;
import org.eclipse.jgit.transport.ReceivePack;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import sonia.scm.repository.GitRepositoryHandler;
import sonia.scm.repository.RepositoryHookType;
import sonia.scm.repository.RepositoryUtil;
import sonia.scm.repository.spi.GitHookContextProvider;
import sonia.scm.repository.spi.HookEventFacade;
-//~--- JDK imports ------------------------------------------------------------
-
import java.io.File;
import java.io.IOException;
-
import java.util.Collection;
import java.util.List;
+//~--- JDK imports ------------------------------------------------------------
+
/**
*
* @author Sebastian Sdorra
@@ -131,15 +128,14 @@ public class GitReceiveHook implements PreReceiveHook, PostReceiveHook
try
{
Repository repository = rpack.getRepository();
- String repositoryName = resolveRepositoryName(repository);
+ String id = resolveRepositoryId(repository);
- logger.trace("resolved repository name to {}", repositoryName);
+ logger.trace("resolved repository to id {}", id);
GitHookContextProvider context = new GitHookContextProvider(rpack,
receiveCommands);
- hookEventFacade.handle(GitRepositoryHandler.TYPE_NAME,
- repositoryName).fireHookEvent(type, context);
+ hookEventFacade.handle(id).fireHookEvent(type, context);
}
catch (Exception ex)
@@ -191,7 +187,7 @@ public class GitReceiveHook implements PreReceiveHook, PostReceiveHook
*
* @throws IOException
*/
- private String resolveRepositoryName(Repository repository) throws IOException
+ private String resolveRepositoryId(Repository repository) throws IOException
{
File directory;
@@ -204,7 +200,7 @@ public class GitReceiveHook implements PreReceiveHook, PostReceiveHook
directory = repository.getWorkTree();
}
- return RepositoryUtil.getRepositoryName(handler, directory);
+ return RepositoryUtil.getRepositoryId(handler, directory);
}
//~--- fields ---------------------------------------------------------------
diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitRepositoryResolver.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitRepositoryResolver.java
index 2ddf4b3de9..76e742a71a 100644
--- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitRepositoryResolver.java
+++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitRepositoryResolver.java
@@ -36,8 +36,8 @@ package sonia.scm.web;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
import com.google.inject.Inject;
-
import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryCache;
@@ -46,19 +46,17 @@ import org.eclipse.jgit.transport.resolver.RepositoryResolver;
import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import org.eclipse.jgit.util.FS;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import sonia.scm.repository.GitConfig;
import sonia.scm.repository.GitRepositoryHandler;
+import sonia.scm.repository.RepositoryProvider;
-//~--- JDK imports ------------------------------------------------------------
-
+import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
-import javax.servlet.http.HttpServletRequest;
+//~--- JDK imports ------------------------------------------------------------
/**
*
@@ -72,17 +70,11 @@ public class GitRepositoryResolver implements RepositoryResolver env = ImmutableMap.of(
"repository", repository,
- "branches", createBranchesModel(repository),
- "commitViewLink", rup.getChangesetUrl(repository.getId(), 0, 20),
- "sourceViewLink", rup.getBrowseUrl(repository.getId(), null, null)
+ "branches", createBranchesModel(repository)
);
//J+
diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/lfs/LfsStoreRemoveListener.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/lfs/LfsStoreRemoveListener.java
index 3d69dcabe6..18fb333c74 100644
--- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/lfs/LfsStoreRemoveListener.java
+++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/lfs/LfsStoreRemoveListener.java
@@ -32,7 +32,7 @@
package sonia.scm.web.lfs;
-import com.google.common.eventbus.Subscribe;
+import com.github.legman.Subscribe;
import com.google.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/scm-plugins/scm-git-plugin/src/main/resources/sonia/scm/git.index.mustache b/scm-plugins/scm-git-plugin/src/main/resources/sonia/scm/git.index.mustache
index 81d7a5bfa3..4571e327e3 100644
--- a/scm-plugins/scm-git-plugin/src/main/resources/sonia/scm/git.index.mustache
+++ b/scm-plugins/scm-git-plugin/src/main/resources/sonia/scm/git.index.mustache
@@ -118,23 +118,6 @@
{{/branches}}
-
- Notes
-
-
-
- This page is only a quick view for git commits.
- The full commit view is here.
-
-
-
Git Informations