merge changes from version 1.17

This commit is contained in:
Sebastian Sdorra
2012-07-23 09:11:41 +02:00
218 changed files with 14848 additions and 821 deletions

View File

@@ -6,13 +6,13 @@
<parent> <parent>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<artifactId>scm</artifactId> <artifactId>scm</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
</parent> </parent>
<groupId>sonia.scm.maven</groupId> <groupId>sonia.scm.maven</groupId>
<artifactId>scm-maven-plugins</artifactId> <artifactId>scm-maven-plugins</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
<name>scm-maven-plugins</name> <name>scm-maven-plugins</name>
<modules> <modules>

View File

@@ -6,12 +6,12 @@
<parent> <parent>
<artifactId>scm-maven-plugins</artifactId> <artifactId>scm-maven-plugins</artifactId>
<groupId>sonia.scm.maven</groupId> <groupId>sonia.scm.maven</groupId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
</parent> </parent>
<groupId>sonia.scm.maven</groupId> <groupId>sonia.scm.maven</groupId>
<artifactId>scm-maven-plugin</artifactId> <artifactId>scm-maven-plugin</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
<packaging>maven-plugin</packaging> <packaging>maven-plugin</packaging>
<name>scm-maven-plugin</name> <name>scm-maven-plugin</name>

View File

@@ -6,12 +6,12 @@
<parent> <parent>
<artifactId>scm-maven-plugins</artifactId> <artifactId>scm-maven-plugins</artifactId>
<groupId>sonia.scm.maven</groupId> <groupId>sonia.scm.maven</groupId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
</parent> </parent>
<groupId>sonia.scm.maven</groupId> <groupId>sonia.scm.maven</groupId>
<artifactId>scm-plugin-archetype</artifactId> <artifactId>scm-plugin-archetype</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
<name>scm-plugin-archetype</name> <name>scm-plugin-archetype</name>
</project> </project>

10
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<artifactId>scm</artifactId> <artifactId>scm</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
<description> <description>
The easiest way to share your Git, Mercurial The easiest way to share your Git, Mercurial
and Subversion repositories over http. and Subversion repositories over http.
@@ -390,8 +390,8 @@
<junit.version>4.10</junit.version> <junit.version>4.10</junit.version>
<!-- logging libraries --> <!-- logging libraries -->
<slf4j.version>1.6.4</slf4j.version> <slf4j.version>1.6.6</slf4j.version>
<logback.version>1.0.4</logback.version> <logback.version>1.0.6</logback.version>
<servlet.version>2.5</servlet.version> <servlet.version>2.5</servlet.version>
<guice.version>3.0</guice.version> <guice.version>3.0</guice.version>
@@ -401,8 +401,8 @@
<jetty.version>7.6.4.v20120524</jetty.version> <jetty.version>7.6.4.v20120524</jetty.version>
<!-- repostitory libraries --> <!-- repostitory libraries -->
<jgit.version>1.3.0.201202151440-r</jgit.version> <jgit.version>2.0.0.201206130900-r</jgit.version>
<svnkit.version>1.7.4-1.v1</svnkit.version> <svnkit.version>1.7.5-1</svnkit.version>
<!-- build properties --> <!-- build properties -->
<project.build.javaLevel>1.6</project.build.javaLevel> <project.build.javaLevel>1.6</project.build.javaLevel>

View File

@@ -6,13 +6,13 @@
<parent> <parent>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<artifactId>scm</artifactId> <artifactId>scm</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
</parent> </parent>
<groupId>sonia.scm.clients</groupId> <groupId>sonia.scm.clients</groupId>
<artifactId>scm-clients</artifactId> <artifactId>scm-clients</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
<name>scm-clients</name> <name>scm-clients</name>
<modules> <modules>
@@ -26,7 +26,7 @@
<dependency> <dependency>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<artifactId>scm-core</artifactId> <artifactId>scm-core</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -6,12 +6,12 @@
<parent> <parent>
<artifactId>scm-clients</artifactId> <artifactId>scm-clients</artifactId>
<groupId>sonia.scm.clients</groupId> <groupId>sonia.scm.clients</groupId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
</parent> </parent>
<groupId>sonia.scm.clients</groupId> <groupId>sonia.scm.clients</groupId>
<artifactId>scm-cli-client</artifactId> <artifactId>scm-cli-client</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
<name>scm-cli-client</name> <name>scm-cli-client</name>
<dependencies> <dependencies>
@@ -35,7 +35,7 @@
<dependency> <dependency>
<artifactId>scm-core</artifactId> <artifactId>scm-core</artifactId>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<artifactId>guice</artifactId> <artifactId>guice</artifactId>
@@ -55,7 +55,7 @@
<dependency> <dependency>
<groupId>sonia.scm.clients</groupId> <groupId>sonia.scm.clients</groupId>
<artifactId>scm-client-impl</artifactId> <artifactId>scm-client-impl</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -1,34 +1,35 @@
/** /**
* Copyright (c) 2010, Sebastian Sdorra All rights reserved. * Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. 2. Redistributions in * this list of conditions and the following disclaimer.
* binary form must reproduce the above copyright notice, this list of * 2. Redistributions in binary form must reproduce the above copyright notice,
* conditions and the following disclaimer in the documentation and/or other * this list of conditions and the following disclaimer in the documentation
* materials provided with the distribution. 3. Neither the name of SCM-Manager; * and/or other materials provided with the distribution.
* nor the names of its contributors may be used to endorse or promote products * 3. Neither the name of SCM-Manager; nor the names of its
* 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" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* http://bitbucket.org/sdorra/scm-manager * http://bitbucket.org/sdorra/scm-manager
* *
*/ */
package sonia.scm.cli; package sonia.scm.cli;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------

View File

@@ -170,7 +170,7 @@ public class CreateRepositorySubCommand extends TemplateSubCommand
Map<String, Object> env = new HashMap<String, Object>(); Map<String, Object> env = new HashMap<String, Object>();
env.put("repository", new RepositoryWrapper(repository)); env.put("repository", new RepositoryWrapper(config, repository));
renderTemplate(env, GetRepositorySubCommand.TEMPLATE); renderTemplate(env, GetRepositorySubCommand.TEMPLATE);
} }

View File

@@ -104,7 +104,7 @@ public class GetRepositorySubCommand extends TemplateSubCommand
{ {
Map<String, Object> env = new HashMap<String, Object>(); Map<String, Object> env = new HashMap<String, Object>();
env.put("repository", new RepositoryWrapper(repository)); env.put("repository", new RepositoryWrapper(config, repository));
renderTemplate(env, TEMPLATE); renderTemplate(env, TEMPLATE);
} }
else else

View File

@@ -74,7 +74,7 @@ public class ListRepositoriesSubCommand extends TemplateSubCommand
List<Repository> repositories = session.getRepositoryHandler().getAll(); List<Repository> repositories = session.getRepositoryHandler().getAll();
Map<String, Object> env = new HashMap<String, Object>(); Map<String, Object> env = new HashMap<String, Object>();
env.put("repositories", WrapperUtil.wrapRepositories(repositories)); env.put("repositories", WrapperUtil.wrapRepositories(config, repositories));
renderTemplate(env, TEMPLATE); renderTemplate(env, TEMPLATE);
} }
} }

View File

@@ -214,7 +214,7 @@ public class ModifyRepositorySubCommand extends TemplateSubCommand
Map<String, Object> env = new HashMap<String, Object>(); Map<String, Object> env = new HashMap<String, Object>();
env.put("repository", new RepositoryWrapper(repository)); env.put("repository", new RepositoryWrapper(config, repository));
renderTemplate(env, GetRepositorySubCommand.TEMPLATE); renderTemplate(env, GetRepositorySubCommand.TEMPLATE);
} }
else else

View File

@@ -120,7 +120,7 @@ public abstract class PermissionSubCommand extends TemplateSubCommand
Map<String, Object> env = new HashMap<String, Object>(); Map<String, Object> env = new HashMap<String, Object>();
env.put("repository", new RepositoryWrapper(repository)); env.put("repository", new RepositoryWrapper(config, repository));
renderTemplate(env, GetRepositorySubCommand.TEMPLATE); renderTemplate(env, GetRepositorySubCommand.TEMPLATE);
} }
else else

View File

@@ -35,6 +35,7 @@ package sonia.scm.cli.wrapper;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
import sonia.scm.cli.config.ServerConfig;
import sonia.scm.repository.Permission; import sonia.scm.repository.Permission;
import sonia.scm.repository.Repository; import sonia.scm.repository.Repository;
@@ -54,10 +55,25 @@ public class RepositoryWrapper extends AbstractWrapper
* Constructs ... * Constructs ...
* *
* *
* @param config
* @param repository * @param repository
*/ */
public RepositoryWrapper(Repository repository) public RepositoryWrapper(ServerConfig config, Repository repository)
{ {
this(config.getServerUrl(), repository);
}
/**
* Constructs ...
*
*
*
* @param baseUrl
* @param repository
*/
public RepositoryWrapper(String baseUrl, Repository repository)
{
this.baseUrl = baseUrl;
this.repository = repository; this.repository = repository;
} }
@@ -159,7 +175,7 @@ public class RepositoryWrapper extends AbstractWrapper
*/ */
public String getUrl() public String getUrl()
{ {
return repository.getUrl(); return repository.createUrl(baseUrl);
} }
/** /**
@@ -186,6 +202,9 @@ public class RepositoryWrapper extends AbstractWrapper
//~--- fields --------------------------------------------------------------- //~--- fields ---------------------------------------------------------------
/** Field description */
private String baseUrl;
/** Field description */ /** Field description */
private Repository repository; private Repository repository;
} }

View File

@@ -35,6 +35,7 @@ package sonia.scm.cli.wrapper;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
import sonia.scm.cli.config.ServerConfig;
import sonia.scm.group.Group; import sonia.scm.group.Group;
import sonia.scm.repository.Repository; import sonia.scm.repository.Repository;
import sonia.scm.user.User; import sonia.scm.user.User;
@@ -76,18 +77,22 @@ public class WrapperUtil
* Method description * Method description
* *
* *
*
* @param baseUrl
*
* @param config
* @param repositories * @param repositories
* *
* @return * @return
*/ */
public static List<RepositoryWrapper> wrapRepositories( public static List<RepositoryWrapper> wrapRepositories(ServerConfig config,
Collection<Repository> repositories) Collection<Repository> repositories)
{ {
List<RepositoryWrapper> wrappers = new ArrayList<RepositoryWrapper>(); List<RepositoryWrapper> wrappers = new ArrayList<RepositoryWrapper>();
for (Repository r : repositories) for (Repository r : repositories)
{ {
wrappers.add(new RepositoryWrapper(r)); wrappers.add(new RepositoryWrapper(config.getServerUrl(), r));
} }
return wrappers; return wrappers;

View File

@@ -6,13 +6,13 @@
<parent> <parent>
<groupId>sonia.scm.clients</groupId> <groupId>sonia.scm.clients</groupId>
<artifactId>scm-clients</artifactId> <artifactId>scm-clients</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
</parent> </parent>
<groupId>sonia.scm.clients</groupId> <groupId>sonia.scm.clients</groupId>
<artifactId>scm-client-api</artifactId> <artifactId>scm-client-api</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
<name>scm-client-api</name> <name>scm-client-api</name>
<dependencies> <dependencies>

View File

@@ -6,13 +6,13 @@
<parent> <parent>
<groupId>sonia.scm.clients</groupId> <groupId>sonia.scm.clients</groupId>
<artifactId>scm-clients</artifactId> <artifactId>scm-clients</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
</parent> </parent>
<groupId>sonia.scm.clients</groupId> <groupId>sonia.scm.clients</groupId>
<artifactId>scm-client-impl</artifactId> <artifactId>scm-client-impl</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
<name>scm-client-impl</name> <name>scm-client-impl</name>
<dependencies> <dependencies>
@@ -36,7 +36,7 @@
<dependency> <dependency>
<artifactId>scm-core</artifactId> <artifactId>scm-core</artifactId>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<artifactId>aopalliance</artifactId> <artifactId>aopalliance</artifactId>
@@ -60,7 +60,7 @@
<dependency> <dependency>
<groupId>sonia.scm.clients</groupId> <groupId>sonia.scm.clients</groupId>
<artifactId>scm-client-api</artifactId> <artifactId>scm-client-api</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
@@ -112,7 +112,7 @@
<dependency> <dependency>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<artifactId>scm-test</artifactId> <artifactId>scm-test</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>

View File

@@ -6,12 +6,12 @@
<parent> <parent>
<artifactId>scm</artifactId> <artifactId>scm</artifactId>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
</parent> </parent>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<artifactId>scm-core</artifactId> <artifactId>scm-core</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
<name>scm-core</name> <name>scm-core</name>
<dependencies> <dependencies>

View File

@@ -215,7 +215,7 @@ public class ServletContainerDetector
*/ */
public boolean isScmServer() public boolean isScmServer()
{ {
return "scm-server".equals(System.getProperty("app-name")); return "scm-server".equals(System.getProperty("app.name"));
} }
/** /**

View File

@@ -1,34 +1,35 @@
/** /**
* Copyright (c) 2010, Sebastian Sdorra All rights reserved. * Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. 2. Redistributions in * this list of conditions and the following disclaimer.
* binary form must reproduce the above copyright notice, this list of * 2. Redistributions in binary form must reproduce the above copyright notice,
* conditions and the following disclaimer in the documentation and/or other * this list of conditions and the following disclaimer in the documentation
* materials provided with the distribution. 3. Neither the name of SCM-Manager; * and/or other materials provided with the distribution.
* nor the names of its contributors may be used to endorse or promote products * 3. Neither the name of SCM-Manager; nor the names of its
* 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" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* http://bitbucket.org/sdorra/scm-manager * http://bitbucket.org/sdorra/scm-manager
* *
*/ */
package sonia.scm.filter; package sonia.scm.filter;
/** /**

View File

@@ -1,34 +1,35 @@
/** /**
* Copyright (c) 2010, Sebastian Sdorra All rights reserved. * Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. 2. Redistributions in * this list of conditions and the following disclaimer.
* binary form must reproduce the above copyright notice, this list of * 2. Redistributions in binary form must reproduce the above copyright notice,
* conditions and the following disclaimer in the documentation and/or other * this list of conditions and the following disclaimer in the documentation
* materials provided with the distribution. 3. Neither the name of SCM-Manager; * and/or other materials provided with the distribution.
* nor the names of its contributors may be used to endorse or promote products * 3. Neither the name of SCM-Manager; nor the names of its
* 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" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* http://bitbucket.org/sdorra/scm-manager * http://bitbucket.org/sdorra/scm-manager
* *
*/ */
package sonia.scm.i18n; package sonia.scm.i18n;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------

View File

@@ -182,6 +182,42 @@ public class HttpRequest
return decodeGZip; return decodeGZip;
} }
/**
* Method description
*
*
* @return
* @since 1.17
*/
public boolean isDisableCertificateValidation()
{
return disableCertificateValidation;
}
/**
* Method description
*
*
* @return
* @since 1.17
*/
public boolean isDisableHostnameValidation()
{
return disableHostnameValidation;
}
/**
* Method description
*
*
* @return
* @since 1.17
*/
public boolean isIgnoreProxySettings()
{
return ignoreProxySettings;
}
//~--- set methods ---------------------------------------------------------- //~--- set methods ----------------------------------------------------------
/** /**
@@ -214,9 +250,35 @@ public class HttpRequest
public HttpRequest setDecodeGZip(boolean decodeGZip) public HttpRequest setDecodeGZip(boolean decodeGZip)
{ {
this.decodeGZip = decodeGZip; this.decodeGZip = decodeGZip;
return this; return this;
} }
/**
* Method description
*
*
* @param disableCertificateValidation
* @since 1.17
*/
public void setDisableCertificateValidation(
boolean disableCertificateValidation)
{
this.disableCertificateValidation = disableCertificateValidation;
}
/**
* Method description
*
*
* @param disableHostnameValidation
* @since 1.17
*/
public void setDisableHostnameValidation(boolean disableHostnameValidation)
{
this.disableHostnameValidation = disableHostnameValidation;
}
/** /**
* Method description * Method description
* *
@@ -232,6 +294,18 @@ public class HttpRequest
return this; return this;
} }
/**
* Method description
*
*
* @param ignoreProxySettings
* @since 1.17
*/
public void setIgnoreProxySettings(boolean ignoreProxySettings)
{
this.ignoreProxySettings = ignoreProxySettings;
}
/** /**
* Method description * Method description
* *
@@ -277,10 +351,19 @@ public class HttpRequest
//~--- fields --------------------------------------------------------------- //~--- fields ---------------------------------------------------------------
/** Field description */ /** Field description */
private boolean decodeGZip = false; private Map<String, List<String>> headers;
/** Field description */ /** Field description */
private Map<String, List<String>> headers; private boolean ignoreProxySettings = false;
/** Field description */
private boolean disableHostnameValidation = false;
/** Field description */
private boolean disableCertificateValidation = false;
/** Field description */
private boolean decodeGZip = false;
/** Field description */ /** Field description */
private Map<String, List<String>> parameters; private Map<String, List<String>> parameters;

View File

@@ -42,6 +42,8 @@ import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -57,9 +59,14 @@ import javax.xml.bind.annotation.XmlRootElement;
*/ */
@XmlRootElement(name = "conditions") @XmlRootElement(name = "conditions")
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class PluginCondition implements Cloneable public class PluginCondition implements Cloneable, Serializable
{ {
/** Field description */
private static final long serialVersionUID = 2406156062634968672L;
//~--- constructors ---------------------------------------------------------
/** /**
* Constructs ... * Constructs ...
* *

View File

@@ -40,6 +40,8 @@ import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -55,9 +57,14 @@ import javax.xml.bind.annotation.XmlRootElement;
*/ */
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "plugin-information") @XmlRootElement(name = "plugin-information")
public class PluginInformation implements Validateable, Cloneable public class PluginInformation implements Validateable, Cloneable, Serializable
{ {
/** Field description */
private static final long serialVersionUID = 461382048865977206L;
//~--- methods --------------------------------------------------------------
/** /**
* Method description * Method description
* *

View File

@@ -33,13 +33,22 @@
package sonia.scm.plugin; package sonia.scm.plugin;
//~--- JDK imports ------------------------------------------------------------
import java.io.Serializable;
/** /**
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
*/ */
public class PluginRepository public class PluginRepository implements Serializable
{ {
/** Field description */
private static final long serialVersionUID = -9504354306304731L;
//~--- constructors ---------------------------------------------------------
/** /**
* Constructs ... * Constructs ...
* *

View File

@@ -37,15 +37,24 @@ package sonia.scm.repository;
import com.google.common.base.Objects; import com.google.common.base.Objects;
//~--- JDK imports ------------------------------------------------------------
import java.io.Serializable;
/** /**
* Single line of a file, in a {@link BlameResult}. * Single line of a file, in a {@link BlameResult}.
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
* @since 1.8 * @since 1.8
*/ */
public class BlameLine public class BlameLine implements Serializable
{ {
/** Field description */
private static final long serialVersionUID = 2816601606921153670L;
//~--- constructors ---------------------------------------------------------
/** /**
* Constructs ... * Constructs ...
* *

View File

@@ -0,0 +1,58 @@
/**
* 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.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.plugin.ExtensionPoint;
/**
* A pre processor for {@link BlameLine} objects. A pre processor is able to
* modify the object before it is delivered to the user interface.
*
* @author Sebastian Sdorra
* @since 1.17
*/
@ExtensionPoint
public interface BlameLinePreProcessor extends PreProcessor<BlameLine>
{
/**
* Process the given blame line.
*
*
* @param blameLine blame line to process.
*/
@Override
public void process(BlameLine blameLine);
}

View File

@@ -0,0 +1,62 @@
/**
* 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.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.plugin.ExtensionPoint;
/**
* The BlameLinePreProcessorFactory create {@link BlameLinePreProcessor}
* objects for a specific repository.
*
* @author Sebastian Sdorra
* @since 1.17
*/
@ExtensionPoint
public interface BlameLinePreProcessorFactory
extends PreProcessorFactory<BlameLine>
{
/**
* Create a new {@link BlameLinePreProcessor} for the given repository.
*
*
* @param repository repository
*
* @return {@link BlameLinePreProcessor} for the given repository
*/
@Override
public BlameLinePreProcessor createPreProcessor(Repository repository);
}

View File

@@ -36,9 +36,13 @@ package sonia.scm.repository;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.collect.Lists;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
import java.io.Serializable;
import java.util.Iterator;
import java.util.List; import java.util.List;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
@@ -48,17 +52,23 @@ import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
/** /**
* Class description * Changeset information by line for a given file.
* *
* TODO for 2.0 implement {@link Iterable}
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
* @since 1.8 * @since 1.8
*/ */
@XmlRootElement(name = "blame-result") @XmlRootElement(name = "blame-result")
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class BlameResult public class BlameResult implements Serializable, Iterable<BlameLine>
{ {
/** Field description */
private static final long serialVersionUID = -8606237881465520606L;
//~--- constructors ---------------------------------------------------------
/** /**
* Constructs ... * Constructs ...
* *
@@ -131,6 +141,20 @@ public class BlameResult
return Objects.hashCode(total, blameLines); return Objects.hashCode(total, blameLines);
} }
/**
* Method description
*
*
* @return
*
* @since 1.17
*/
@Override
public Iterator<BlameLine> iterator()
{
return getBlameLines().iterator();
}
/** /**
* {@inheritDoc} * {@inheritDoc}
* *
@@ -158,6 +182,9 @@ public class BlameResult
*/ */
public List<BlameLine> getBlameLines() public List<BlameLine> getBlameLines()
{ {
if ( blameLines == null ){
blameLines = Lists.newArrayList();
}
return blameLines; return blameLines;
} }

View File

@@ -33,6 +33,10 @@
package sonia.scm.repository; package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.api.RepositoryService;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
import java.io.IOException; import java.io.IOException;
@@ -43,7 +47,10 @@ import java.io.IOException;
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
* @since 1.8 * @since 1.8
*
* @deprecated use {@link RepositoryService#getBlameCommand()} instead.
*/ */
@Deprecated
public interface BlameViewer public interface BlameViewer
{ {

View File

@@ -33,11 +33,18 @@
package sonia.scm.repository; package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.api.RepositoryService;
/** /**
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
* @since 1.8 * @since 1.8
*
* @deprecated use {@link RepositoryService#getBlameCommand()} instead.
*/ */
@Deprecated
public interface BlameViewerProvider public interface BlameViewerProvider
{ {

View File

@@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
import sonia.scm.NotSupportedFeatuerException; import sonia.scm.NotSupportedFeatuerException;
import sonia.scm.cache.Cache; import sonia.scm.cache.Cache;
import sonia.scm.cache.CacheManager; import sonia.scm.cache.CacheManager;
import sonia.scm.repository.api.RepositoryService;
import sonia.scm.util.AssertUtil; import sonia.scm.util.AssertUtil;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
@@ -55,8 +56,11 @@ import java.io.IOException;
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
* @since 1.8 * @since 1.8
*
* @deprecated use {@link RepositoryService#getBlameCommand()} instead.
*/ */
@Singleton @Singleton
@Deprecated
public class BlameViewerUtil extends PartCacheClearHook public class BlameViewerUtil extends PartCacheClearHook
{ {
@@ -75,7 +79,6 @@ public class BlameViewerUtil extends PartCacheClearHook
* *
* @param repositoryManager * @param repositoryManager
* @param cacheManager * @param cacheManager
* @return
*/ */
@Inject @Inject
public BlameViewerUtil(RepositoryManager repositoryManager, public BlameViewerUtil(RepositoryManager repositoryManager,

View File

@@ -39,6 +39,8 @@ import com.google.common.base.Objects;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
import java.io.Serializable;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@@ -55,9 +57,14 @@ import javax.xml.bind.annotation.XmlRootElement;
*/ */
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "browser-result") @XmlRootElement(name = "browser-result")
public class BrowserResult implements Iterable<FileObject> public class BrowserResult implements Iterable<FileObject>, Serializable
{ {
/** Field description */
private static final long serialVersionUID = 2818662048045182761L;
//~--- constructors ---------------------------------------------------------
/** /**
* Constructs ... * Constructs ...
* *

View File

@@ -62,7 +62,7 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "changeset") @XmlRootElement(name = "changeset")
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class Changeset extends BasicPropertiesAware public class Changeset extends BasicPropertiesAware
implements Validateable, Cloneable, Serializable implements Validateable, Serializable
{ {
/** Field description */ /** Field description */
@@ -108,26 +108,6 @@ public class Changeset extends BasicPropertiesAware
//~--- methods -------------------------------------------------------------- //~--- methods --------------------------------------------------------------
/**
* {@inheritDoc}
*
*
* @return
*/
@Override
public Changeset clone()
{
Changeset changeset = new Changeset(id, date, author, description);
changeset.setBranches(branches);
changeset.setTags(tags);
changeset.setModifications(modifications);
changeset.setProperties(properties);
changeset.setParents(parents);
return changeset;
}
/** /**
* {@inheritDoc} * {@inheritDoc}
* *

View File

@@ -35,6 +35,8 @@ package sonia.scm.repository;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
import java.io.Serializable;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@@ -50,9 +52,14 @@ import javax.xml.bind.annotation.XmlRootElement;
*/ */
@XmlRootElement(name = "changeset-paging") @XmlRootElement(name = "changeset-paging")
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class ChangesetPagingResult implements Iterable<Changeset> public class ChangesetPagingResult implements Iterable<Changeset>, Serializable
{ {
/** Field description */
private static final long serialVersionUID = -8678755403658841733L;
//~--- constructors ---------------------------------------------------------
/** /**
* Constructs ... * Constructs ...
* *

View File

@@ -38,6 +38,10 @@ package sonia.scm.repository;
import sonia.scm.plugin.ExtensionPoint; import sonia.scm.plugin.ExtensionPoint;
/** /**
* A pre processor for {@link Changeset} objects. A pre processor is able to
* modify the object before it is delivered to the user interface.
*
* TODO for 2.0 extends {@link PreProcessor} interface.
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
*/ */
@@ -46,10 +50,10 @@ public interface ChangesetPreProcessor
{ {
/** /**
* Method description * Process the given changeset.
* *
* *
* @param changeset * @param changeset changeset to process
*/ */
public void process(Changeset changeset); public void process(Changeset changeset);
} }

View File

@@ -38,6 +38,10 @@ package sonia.scm.repository;
import sonia.scm.plugin.ExtensionPoint; import sonia.scm.plugin.ExtensionPoint;
/** /**
* The ChangesetPreProcessorFactory create {@link ChangesetPreProcessor}
* objects for a specific repository.
*
* TODO for 2.0 extends {@link PreProcessorFactory} interface.
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
* @since 1.7 * @since 1.7
@@ -47,12 +51,12 @@ public interface ChangesetPreProcessorFactory
{ {
/** /**
* Method description * Create a new {@link ChangesetPreProcessor} for the given repository.
* *
* *
* @param repository * @param repository repository
* *
* @return * @return {@link ChangesetPreProcessor} for the given repository
*/ */
public ChangesetPreProcessor createPreProcessor(Repository repository); public ChangesetPreProcessor createPreProcessor(Repository repository);
} }

View File

@@ -33,6 +33,10 @@
package sonia.scm.repository; package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.api.RepositoryService;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
import java.io.IOException; import java.io.IOException;
@@ -40,7 +44,10 @@ import java.io.IOException;
/** /**
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
*
* @deprecated use {@link RepositoryService#getLogCommand()} instead.
*/ */
@Deprecated
public interface ChangesetViewer public interface ChangesetViewer
{ {

View File

@@ -33,11 +33,18 @@
package sonia.scm.repository; package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.api.RepositoryService;
/** /**
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
* @since 1.8 * @since 1.8
*
* @deprecated use {@link RepositoryService#getLogCommand()} instead.
*/ */
@Deprecated
public interface ChangesetViewerProvider public interface ChangesetViewerProvider
{ {

View File

@@ -37,13 +37,13 @@ package sonia.scm.repository;
import com.google.inject.Inject; import com.google.inject.Inject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import sonia.scm.NotSupportedFeatuerException; import sonia.scm.NotSupportedFeatuerException;
import sonia.scm.cache.Cache; import sonia.scm.cache.Cache;
import sonia.scm.cache.CacheManager; import sonia.scm.cache.CacheManager;
import sonia.scm.repository.api.RepositoryService;
import sonia.scm.util.AssertUtil; import sonia.scm.util.AssertUtil;
import sonia.scm.util.Util; import sonia.scm.util.Util;
@@ -58,7 +58,10 @@ import java.util.Set;
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
* @since 1.6 * @since 1.6
*
* @deprecated use {@link RepositoryService#getLogCommand()} instead.
*/ */
@Deprecated
public class ChangesetViewerUtil extends PartCacheClearHook public class ChangesetViewerUtil extends PartCacheClearHook
{ {
@@ -468,8 +471,6 @@ public class ChangesetViewerUtil extends PartCacheClearHook
} }
} }
/** /**
* Method description * Method description
* *

View File

@@ -37,12 +37,16 @@ package sonia.scm.repository;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import sonia.scm.repository.api.RepositoryService;
/** /**
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
* @since 1.8 * @since 1.8
*
* @deprecated use {@link RepositoryService#getDiffCommand()} instead.
*/ */
@Deprecated
public interface DiffViewer public interface DiffViewer
{ {

View File

@@ -33,11 +33,18 @@
package sonia.scm.repository; package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.api.RepositoryService;
/** /**
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
* @since 1.8 * @since 1.8
*
* @deprecated use {@link RepositoryService#getDiffCommand()} instead.
*/ */
@Deprecated
public interface DiffViewerProvider public interface DiffViewerProvider
{ {

View File

@@ -1,27 +1,29 @@
/** /**
* Copyright (c) 2010, Sebastian Sdorra All rights reserved. * Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. 2. Redistributions in * this list of conditions and the following disclaimer.
* binary form must reproduce the above copyright notice, this list of * 2. Redistributions in binary form must reproduce the above copyright notice,
* conditions and the following disclaimer in the documentation and/or other * this list of conditions and the following disclaimer in the documentation
* materials provided with the distribution. 3. Neither the name of SCM-Manager; * and/or other materials provided with the distribution.
* nor the names of its contributors may be used to endorse or promote products * 3. Neither the name of SCM-Manager; nor the names of its
* 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" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* http://bitbucket.org/sdorra/scm-manager * http://bitbucket.org/sdorra/scm-manager
* *
@@ -68,6 +70,34 @@ public class EscapeUtil
} }
} }
/**
* Method description
*
*
* @param result
* @since 1.17
*/
public static void escape(BlameResult result)
{
for (BlameLine line : result.getBlameLines())
{
escape(line);
}
}
/**
* Method description
*
*
* @param line
* @since 1.17
*/
public static void escape(BlameLine line)
{
line.setDescription(escape(line.getDescription()));
escape(line.getAuthor());
}
/** /**
* Method description * Method description
* *
@@ -90,17 +120,25 @@ public class EscapeUtil
public static void escape(Changeset changeset) public static void escape(Changeset changeset)
{ {
changeset.setDescription(escape(changeset.getDescription())); changeset.setDescription(escape(changeset.getDescription()));
escape(changeset.getAuthor());
changeset.setBranches(escapeList(changeset.getBranches()));
changeset.setTags(escapeList(changeset.getTags()));
}
Person person = changeset.getAuthor(); /**
* Method description
*
*
* @param person
* @since 1.17
*/
public static void escape(Person person)
{
if (person != null) if (person != null)
{ {
person.setName(escape(person.getName())); person.setName(escape(person.getName()));
person.setMail(escape(person.getMail())); person.setMail(escape(person.getMail()));
} }
changeset.setBranches(escapeList(changeset.getBranches()));
changeset.setTags(escapeList(changeset.getTags()));
} }
/** /**

View File

@@ -41,6 +41,8 @@ import sonia.scm.LastModifiedAware;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
@@ -53,9 +55,14 @@ import javax.xml.bind.annotation.XmlRootElement;
*/ */
@XmlRootElement(name = "file") @XmlRootElement(name = "file")
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class FileObject implements LastModifiedAware public class FileObject implements LastModifiedAware, Serializable
{ {
/** Field description */
private static final long serialVersionUID = -5562537629609891499L;
//~--- methods --------------------------------------------------------------
/** /**
* {@inheritDoc} * {@inheritDoc}
* *

View File

@@ -33,9 +33,15 @@
package sonia.scm.repository; package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.plugin.ExtensionPoint; import sonia.scm.plugin.ExtensionPoint;
/** /**
* A pre processor for {@link FileObject} objects. A pre processor is able to
* modify the object before it is delivered to the user interface.
*
* TODO for 2.0 extends {@link PreProcessor} interface.
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
* @since 1.10 * @since 1.10
@@ -45,10 +51,10 @@ public interface FileObjectPreProcessor
{ {
/** /**
* Method description * Process the given file object.
* *
* *
* @param fileObject * @param fileObject file object to process
*/ */
public void process(FileObject fileObject); public void process(FileObject fileObject);
} }

View File

@@ -38,6 +38,10 @@ package sonia.scm.repository;
import sonia.scm.plugin.ExtensionPoint; import sonia.scm.plugin.ExtensionPoint;
/** /**
* The FileObjectPreProcessorFactory create {@link FileObjectPreProcessor}
* objects for a specific repository.
*
* TODO for 2.0 extends {@link PreProcessorFactory} interface.
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
* @since 1.10 * @since 1.10
@@ -47,12 +51,12 @@ public interface FileObjectPreProcessorFactory
{ {
/** /**
* Method description * Create a new {@link FileObjectPreProcessor} for the given repository.
* *
* *
* @param repository * @param repository repository
* *
* @return * @return {@link FileObjectPreProcessor} for the given repository
*/ */
public FileObjectPreProcessor createPreProcessor(Repository repository); public FileObjectPreProcessor createPreProcessor(Repository repository);
} }

View File

@@ -0,0 +1,54 @@
/**
* 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.repository;
/**
* A pre processor is able to modify a object before it is delivered
* to the user interface.
*
* @author Sebastian Sdorra
* @since 1.17
*
* @param <T> object type
*/
public interface PreProcessor<T>
{
/**
* Process the given object.
*
*
* @param item object to process
*/
public void process(T item);
}

View File

@@ -0,0 +1,57 @@
/**
* 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.repository;
/**
* A pre processor factory creates a specific {@link PreProcessor} for
* the given repository.
*
* @author Sebastian Sdorra
*
* @param <T> object type for the {@link PreProcessor}
* @since 1.17
*/
public interface PreProcessorFactory<T>
{
/**
* Create a new {@link PreProcessor} for the given repository.
*
*
* @param repository repository
*
* @return {@link PreProcessor} for the given repository
*/
public PreProcessor<T> createPreProcessor(Repository repository);
}

View File

@@ -0,0 +1,628 @@
/**
* 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.repository;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Function;
import com.google.common.collect.Collections2;
import com.google.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import java.util.Collection;
import java.util.Set;
/**
*
* @author Sebastian Sdorra
* @since 1.17
*/
public class PreProcessorUtil
{
/**
* the logger for PreProcessorUtil
*/
private static final Logger logger =
LoggerFactory.getLogger(PreProcessorUtil.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*
* @param changesetPreProcessorSet
* @param changesetPreProcessorFactorySet
* @param fileObjectPreProcessorSet
* @param fileObjectPreProcessorFactorySet
* @param blameLinePreProcessorSet
* @param blameLinePreProcessorFactorySet
*/
@Inject
public PreProcessorUtil(
Set<ChangesetPreProcessor> changesetPreProcessorSet,
Set<ChangesetPreProcessorFactory> changesetPreProcessorFactorySet,
Set<FileObjectPreProcessor> fileObjectPreProcessorSet,
Set<FileObjectPreProcessorFactory> fileObjectPreProcessorFactorySet,
Set<BlameLinePreProcessor> blameLinePreProcessorSet,
Set<BlameLinePreProcessorFactory> blameLinePreProcessorFactorySet)
{
this.changesetPreProcessorSet =
Collections2.transform(changesetPreProcessorSet,
new Function<ChangesetPreProcessor,
ChangesetPreProcessorWrapper>()
{
@Override
public ChangesetPreProcessorWrapper apply(ChangesetPreProcessor input)
{
return new ChangesetPreProcessorWrapper(input);
}
});
this.changesetPreProcessorFactorySet =
Collections2.transform(changesetPreProcessorFactorySet,
new Function<ChangesetPreProcessorFactory,
ChangesetPreProcessorFactoryWrapper>()
{
@Override
public ChangesetPreProcessorFactoryWrapper apply(
ChangesetPreProcessorFactory input)
{
return new ChangesetPreProcessorFactoryWrapper(input);
}
});
this.fileObjectPreProcessorSet =
Collections2.transform(fileObjectPreProcessorSet,
new Function<FileObjectPreProcessor,
FileObjectPreProcessorWrapper>()
{
@Override
public FileObjectPreProcessorWrapper apply(FileObjectPreProcessor input)
{
return new FileObjectPreProcessorWrapper(input);
}
});
this.fileObjectPreProcessorFactorySet =
Collections2.transform(fileObjectPreProcessorFactorySet,
new Function<FileObjectPreProcessorFactory,
FileObjectPreProcessorFactoryWrapper>()
{
@Override
public FileObjectPreProcessorFactoryWrapper apply(
FileObjectPreProcessorFactory input)
{
return new FileObjectPreProcessorFactoryWrapper(input);
}
});
this.blameLinePreProcessorSet = blameLinePreProcessorSet;
this.blameLinePreProcessorFactorySet = blameLinePreProcessorFactorySet;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param repository
* @param blameLine
*/
public void prepareForReturn(Repository repository, BlameLine blameLine)
{
if (logger.isTraceEnabled())
{
logger.trace("prepare blame line {} of repository {} for return",
blameLine.getLineNumber(), repository.getName());
}
EscapeUtil.escape(blameLine);
PreProcessorHandler<BlameLine> handler =
new PreProcessorHandler<BlameLine>(blameLinePreProcessorFactorySet,
blameLinePreProcessorSet, repository);
handler.callPreProcessors(blameLine);
handler.callPreProcessorFactories(blameLine);
}
/**
* Method description
*
*
* @param repository
* @param blameResult
*/
public void prepareForReturn(Repository repository, BlameResult blameResult)
{
if (logger.isTraceEnabled())
{
logger.trace("prepare blame result of repository {} for return",
repository.getName());
}
EscapeUtil.escape(blameResult);
PreProcessorHandler<BlameLine> handler =
new PreProcessorHandler<BlameLine>(blameLinePreProcessorFactorySet,
blameLinePreProcessorSet, repository);
handler.callPreProcessors(blameResult.getBlameLines());
handler.callPreProcessorFactories(blameResult.getBlameLines());
}
/**
* Method description
*
*
* @param repository
* @param changeset
*/
public void prepareForReturn(Repository repository, Changeset changeset)
{
if (logger.isTraceEnabled())
{
logger.trace("prepare changeset {} of repository {} for return",
changeset.getId(), repository.getName());
}
EscapeUtil.escape(changeset);
PreProcessorHandler<Changeset> handler =
new PreProcessorHandler<Changeset>(changesetPreProcessorFactorySet,
changesetPreProcessorSet, repository);
handler.callPreProcessors(changeset);
handler.callPreProcessorFactories(changeset);
}
/**
* Method description
*
*
* @param repository
* @param changeset
* @param result
*/
public void prepareForReturn(Repository repository, BrowserResult result)
{
if (logger.isTraceEnabled())
{
logger.trace("prepare browser result of repository {} for return",
repository.getName());
}
EscapeUtil.escape(result);
PreProcessorHandler<FileObject> handler =
new PreProcessorHandler<FileObject>(fileObjectPreProcessorFactorySet,
fileObjectPreProcessorSet, repository);
handler.callPreProcessors(result);
handler.callPreProcessorFactories(result);
}
/**
* Method description
*
*
* @param repository
* @param result
*/
public void prepareForReturn(Repository repository,
ChangesetPagingResult result)
{
if (logger.isTraceEnabled())
{
logger.trace("prepare changesets of repository {} for return",
repository.getName());
}
EscapeUtil.escape(result);
PreProcessorHandler<Changeset> handler =
new PreProcessorHandler<Changeset>(changesetPreProcessorFactorySet,
changesetPreProcessorSet, repository);
handler.callPreProcessors(result);
handler.callPreProcessorFactories(result);
}
//~--- inner classes --------------------------------------------------------
/**
* Class description
*
*
* @version Enter version here..., 12/06/16
* @author Enter your name here...
*/
private static class ChangesetPreProcessorFactoryWrapper
implements PreProcessorFactory<Changeset>
{
/**
* Constructs ...
*
*
* @param preProcessorFactory
*/
public ChangesetPreProcessorFactoryWrapper(
ChangesetPreProcessorFactory preProcessorFactory)
{
this.preProcessorFactory = preProcessorFactory;
}
//~--- methods ------------------------------------------------------------
/**
* Method description
*
*
* @param repository
*
* @return
*/
@Override
public PreProcessor<Changeset> createPreProcessor(Repository repository)
{
PreProcessor<Changeset> preProcessor = null;
ChangesetPreProcessor changesetPreProcessor =
preProcessorFactory.createPreProcessor(repository);
if (changesetPreProcessor != null)
{
preProcessor = new ChangesetPreProcessorWrapper(changesetPreProcessor);
}
return preProcessor;
}
//~--- fields -------------------------------------------------------------
/** Field description */
private ChangesetPreProcessorFactory preProcessorFactory;
}
/**
* Class description
*
*
* @version Enter version here..., 12/06/16
* @author Enter your name here...
*/
private static class ChangesetPreProcessorWrapper
implements PreProcessor<Changeset>
{
/**
* Constructs ...
*
*
* @param preProcessor
*/
public ChangesetPreProcessorWrapper(ChangesetPreProcessor preProcessor)
{
this.preProcessor = preProcessor;
}
//~--- methods ------------------------------------------------------------
/**
* Method description
*
*
* @param item
*/
@Override
public void process(Changeset item)
{
preProcessor.process(item);
}
//~--- fields -------------------------------------------------------------
/** Field description */
private ChangesetPreProcessor preProcessor;
}
/**
* Class description
*
*
* @version Enter version here..., 12/06/16
* @author Enter your name here...
*/
private static class FileObjectPreProcessorFactoryWrapper
implements PreProcessorFactory<FileObject>
{
/**
* Constructs ...
*
*
* @param preProcessorFactory
*/
public FileObjectPreProcessorFactoryWrapper(
FileObjectPreProcessorFactory preProcessorFactory)
{
this.preProcessorFactory = preProcessorFactory;
}
//~--- methods ------------------------------------------------------------
/**
* Method description
*
*
* @param repository
*
* @return
*/
@Override
public PreProcessor<FileObject> createPreProcessor(Repository repository)
{
PreProcessor<FileObject> preProcessor = null;
FileObjectPreProcessor fileObjectPreProcessor =
preProcessorFactory.createPreProcessor(repository);
if (fileObjectPreProcessor != null)
{
preProcessor =
new FileObjectPreProcessorWrapper(fileObjectPreProcessor);
}
return preProcessor;
}
//~--- fields -------------------------------------------------------------
/** Field description */
private FileObjectPreProcessorFactory preProcessorFactory;
}
/**
* Class description
*
*
* @version Enter version here..., 12/06/16
* @author Enter your name here...
*/
private static class FileObjectPreProcessorWrapper
implements PreProcessor<FileObject>
{
/**
* Constructs ...
*
*
* @param preProcessor
*/
public FileObjectPreProcessorWrapper(FileObjectPreProcessor preProcessor)
{
this.preProcessor = preProcessor;
}
//~--- methods ------------------------------------------------------------
/**
* Method description
*
*
* @param item
*/
@Override
public void process(FileObject item)
{
preProcessor.process(item);
}
//~--- fields -------------------------------------------------------------
/** Field description */
private FileObjectPreProcessor preProcessor;
}
/**
* Class description
*
*
* @param <T>
*
* @version Enter version here..., 12/06/16
* @author Enter your name here...
*/
private static class PreProcessorHandler<T>
{
/**
* Constructs ...
*
*
* @param preProcessorFactorySet
* @param preProcessorSet
* @param repository
*/
public PreProcessorHandler(
Collection<? extends PreProcessorFactory<T>> preProcessorFactorySet,
Collection<? extends PreProcessor<T>> preProcessorSet,
Repository repository)
{
this.preProcessorFactorySet = preProcessorFactorySet;
this.preProcessorSet = preProcessorSet;
this.repository = repository;
}
//~--- methods ------------------------------------------------------------
/**
* Method description
*
*
*
*
* @param preProcessorFactorySet
* @param repository
* @param changesets
* @param items
* @param <T>
*/
public void callPreProcessorFactories(Iterable<T> items)
{
if (Util.isNotEmpty(preProcessorFactorySet))
{
for (PreProcessorFactory<T> factory : preProcessorFactorySet)
{
PreProcessor<T> preProcessor = factory.createPreProcessor(repository);
if (preProcessor != null)
{
for (T item : items)
{
preProcessor.process(item);
}
}
}
}
}
/**
* Method description
*
*
*
* @param preProcessorFactorySet
* @param repository
* @param item
* @param <T>
*/
public void callPreProcessorFactories(T item)
{
if (Util.isNotEmpty(preProcessorFactorySet))
{
for (PreProcessorFactory<T> factory : preProcessorFactorySet)
{
PreProcessor<T> cpp = factory.createPreProcessor(repository);
if (cpp != null)
{
cpp.process(item);
}
}
}
}
/**
* Method description
*
*
* @param changesets
*
* @param preProcessorSet
* @param items
* @param <T>
*/
public void callPreProcessors(Iterable<T> items)
{
if (Util.isNotEmpty(preProcessorSet))
{
for (T item : items)
{
callPreProcessors(item);
}
}
}
/**
* Method description
*
*
* @param c
*
* @param preProcessorSet
* @param item
* @param <T>
*/
public void callPreProcessors(T item)
{
if (Util.isNotEmpty(preProcessorSet))
{
for (PreProcessor<T> preProcessor : preProcessorSet)
{
preProcessor.process(item);
}
}
}
//~--- fields -------------------------------------------------------------
/** Field description */
private Collection<? extends PreProcessorFactory<T>> preProcessorFactorySet;
/** Field description */
private Collection<? extends PreProcessor<T>> preProcessorSet;
/** Field description */
private Repository repository;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private Collection<BlameLinePreProcessorFactory> blameLinePreProcessorFactorySet;
/** Field description */
private Collection<BlameLinePreProcessor> blameLinePreProcessorSet;
/** Field description */
private Collection<ChangesetPreProcessorFactoryWrapper> changesetPreProcessorFactorySet;
/** Field description */
private Collection<ChangesetPreProcessorWrapper> changesetPreProcessorSet;
/** Field description */
private Collection<FileObjectPreProcessorFactoryWrapper> fileObjectPreProcessorFactorySet;
/** Field description */
private Collection<FileObjectPreProcessorWrapper> fileObjectPreProcessorSet;
}

View File

@@ -39,6 +39,7 @@ import com.google.common.base.Objects;
import sonia.scm.BasicPropertiesAware; import sonia.scm.BasicPropertiesAware;
import sonia.scm.ModelObject; import sonia.scm.ModelObject;
import sonia.scm.util.HttpUtil;
import sonia.scm.util.Util; import sonia.scm.util.Util;
import sonia.scm.util.ValidationUtil; import sonia.scm.util.ValidationUtil;
@@ -164,6 +165,22 @@ public class Repository extends BasicPropertiesAware implements ModelObject
repository.setArchived(archived); repository.setArchived(archived);
} }
/**
* Creates the url of the repository.
*
*
* @param baseUrl base url of the server including the context path
*
* @return url of the repository
* @since 1.17
*/
public String createUrl(String baseUrl)
{
String url = HttpUtil.append(baseUrl, type);
return HttpUtil.append(url, name);
}
/** /**
* Returns true if the {@link Repository} is the same as the obj argument. * Returns true if the {@link Repository} is the same as the obj argument.
* *
@@ -343,7 +360,9 @@ public class Repository extends BasicPropertiesAware implements ModelObject
* *
* *
* @return base url * @return base url
* @deprecated use {@link #createUrl(String)}
*/ */
@Deprecated
public String getUrl() public String getUrl()
{ {
return url; return url;
@@ -511,7 +530,9 @@ public class Repository extends BasicPropertiesAware implements ModelObject
* *
* *
* @param url base url * @param url base url
* @deprecated
*/ */
@Deprecated
public void setUrl(String url) public void setUrl(String url)
{ {
this.url = url; this.url = url;
@@ -550,6 +571,8 @@ public class Repository extends BasicPropertiesAware implements ModelObject
/** Field description */ /** Field description */
private String type; private String type;
/** Field description */ /**
* @deprecated use {@link #createUrl(java.lang.String)} instead
*/
private String url; private String url;
} }

View File

@@ -33,6 +33,10 @@
package sonia.scm.repository; package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.api.RepositoryService;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
import java.io.IOException; import java.io.IOException;
@@ -42,7 +46,10 @@ import java.io.OutputStream;
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
* @since 1.5 * @since 1.5
*
* @deprecated use {@link RepositoryService#getBrowseCommand()} instead.
*/ */
@Deprecated
public interface RepositoryBrowser public interface RepositoryBrowser
{ {

View File

@@ -33,11 +33,18 @@
package sonia.scm.repository; package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.api.RepositoryService;
/** /**
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
* @since 1.5 * @since 1.5
*
* @deprecated use {@link RepositoryService#getBrowseCommand()} instead.
*/ */
@Deprecated
public interface RepositoryBrowserProvider public interface RepositoryBrowserProvider
{ {

View File

@@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
import sonia.scm.NotSupportedFeatuerException; import sonia.scm.NotSupportedFeatuerException;
import sonia.scm.cache.Cache; import sonia.scm.cache.Cache;
import sonia.scm.cache.CacheManager; import sonia.scm.cache.CacheManager;
import sonia.scm.repository.api.RepositoryService;
import sonia.scm.util.AssertUtil; import sonia.scm.util.AssertUtil;
import sonia.scm.util.Util; import sonia.scm.util.Util;
@@ -59,8 +60,11 @@ import java.util.Set;
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
* @since 1.6 * @since 1.6
*
* @deprecated use {@link RepositoryService#getBrowseCommand()} instead.
*/ */
@Singleton @Singleton
@Deprecated
public class RepositoryBrowserUtil extends PartCacheClearHook public class RepositoryBrowserUtil extends PartCacheClearHook
{ {

View File

@@ -0,0 +1,81 @@
/**
* 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.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.Filter;
/**
*
* @author Sebastian Sdorra
* @since 1.17
*
* @param <T>
*/
public class RepositoryCacheKeyFilter<T extends RepositoryCacheKey>
implements Filter<T>
{
/**
* Constructs ...
*
*
* @param repositoryId
*/
public RepositoryCacheKeyFilter(String repositoryId)
{
this.repositoryId = repositoryId;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param item
*
* @return
*/
@Override
public boolean accept(T item)
{
return repositoryId.equals(item.getRepositoryId());
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private String repositoryId;
}

View File

@@ -62,9 +62,8 @@ public interface RepositoryHookSupport
/** /**
* Fires a post receive hook event. This methods calls the * Fires a post receive hook event. This methods calls the
* {@link PostReceiveHook#onPostReceive(Repository, List)} of each registered * {@link PostReceiveRepositoryHook#onPostReceive(Repository, List)}
* {@link PostReceiveHook}. * of each registered {@link PostReceiveRepositoryHook}.
*
* *
* @param repository that has changed * @param repository that has changed
* @param event * @param event
@@ -73,8 +72,8 @@ public interface RepositoryHookSupport
/** /**
* Fires a post receive hook event. This methods calls the * Fires a post receive hook event. This methods calls the
* {@link PostReceiveHook#onPostReceive(Repository, List)} of each registered * {@link PostReceiveRepositoryHook#onPostReceive(Repository, List)}
* {@link PostReceiveHook}. * of each registered {@link PostReceiveRepositoryHook}.
* *
* *
* @param type of the repository * @param type of the repository

View File

@@ -1,34 +1,35 @@
/** /**
* Copyright (c) 2010, Sebastian Sdorra All rights reserved. * Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. 2. Redistributions in * this list of conditions and the following disclaimer.
* binary form must reproduce the above copyright notice, this list of * 2. Redistributions in binary form must reproduce the above copyright notice,
* conditions and the following disclaimer in the documentation and/or other * this list of conditions and the following disclaimer in the documentation
* materials provided with the distribution. 3. Neither the name of SCM-Manager; * and/or other materials provided with the distribution.
* nor the names of its contributors may be used to endorse or promote products * 3. Neither the name of SCM-Manager; nor the names of its
* 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" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* http://bitbucket.org/sdorra/scm-manager * http://bitbucket.org/sdorra/scm-manager
* *
*/ */
package sonia.scm.repository; package sonia.scm.repository;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------

View File

@@ -39,6 +39,8 @@ import com.google.common.base.Objects;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
@@ -50,9 +52,14 @@ import javax.xml.bind.annotation.XmlRootElement;
*/ */
@XmlRootElement(name = "subrepository") @XmlRootElement(name = "subrepository")
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class SubRepository public class SubRepository implements Serializable
{ {
/** Field description */
private static final long serialVersionUID = 6960065820378492531L;
//~--- constructors ---------------------------------------------------------
/** /**
* Constructs ... * Constructs ...
* *

View File

@@ -0,0 +1,366 @@
/**
* 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.repository.api;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.cache.Cache;
import sonia.scm.cache.CacheManager;
import sonia.scm.repository.BlameResult;
import sonia.scm.repository.PreProcessorUtil;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryCacheKey;
import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.BlameCommand;
import sonia.scm.repository.spi.BlameCommandRequest;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.io.Serializable;
/**
* Shows changeset information by line for a given file.
* Blame is also known as annotate in some SCM systems.<br />
* <br />
* <b>Sample:</b>
* <br />
* <br />
* Print each line number and code of the file scm-core/pom.xml at
* revision 60c2f2783368:<br />
* <pre><code>
* BlameCommandBuilder blame = repositoryService.getBlameCommand();
* BlameResult result = blame.setRevision("60c2f2783368")
* .getBlameResult("scm-core/pom.xml");
*
* for ( BlameLine line : result ){
* System.out.println(line.getLineNumber() + ": " + line.getCode());
* }
* </code></pre>
*
* @author Sebastian Sdorra
* @since 1.17
*/
public final class BlameCommandBuilder
{
/** name of the cache */
static final String CACHE_NAME = "sonia.cache.cmd.blame";
/**
* the logger for BlameCommandBuilder
*/
private static final Logger logger =
LoggerFactory.getLogger(BlameCommandBuilder.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs a new {@link BlameCommandBuilder}, this constructor should
* only be called from the {@link RepositoryService}.
*
* @param cacheManager cache manager
* @param blameCommand implementation of the {@link BlameCommand}
* @param repository repository to query
* @param preProcessorUtil
*/
BlameCommandBuilder(CacheManager cacheManager, BlameCommand blameCommand,
Repository repository, PreProcessorUtil preProcessorUtil)
{
this.cache = cacheManager.getCache(CacheKey.class, BlameResult.class,
CACHE_NAME);
this.blameCommand = blameCommand;
this.repository = repository;
this.preProcessorUtil = preProcessorUtil;
}
//~--- methods --------------------------------------------------------------
/**
* Reset each parameter to its default value.
*
* @return {@code this}
*/
public BlameCommandBuilder reset()
{
request.reset();
this.disableCache = false;
this.disablePreProcessors = false;
return this;
}
//~--- get methods ----------------------------------------------------------
/**
* Returns changeset informations by line for the given file.
*
* @param path path of the file
* @return changeset informations by line for the given file
*
* @throws IllegalArgumentException if the path is null or empty
*
* @throws IOException
* @throws RepositoryException
*/
public BlameResult getBlameResult(String path)
throws IOException, RepositoryException
{
Preconditions.checkArgument(!Strings.isNullOrEmpty(path),
"path is required");
BlameCommandRequest requestClone = request.clone();
requestClone.setPath(path);
BlameResult result = null;
if (disableCache)
{
if (logger.isDebugEnabled())
{
logger.debug("create blame for {} with disabled cache", requestClone);
}
result = blameCommand.getBlameResult(requestClone);
}
else
{
CacheKey key = new CacheKey(repository, request);
result = cache.get(key);
if (result == null)
{
if (logger.isDebugEnabled())
{
logger.debug("create blame for {}", requestClone);
}
result = blameCommand.getBlameResult(requestClone);
if (result != null)
{
cache.put(key, result);
}
}
else if (logger.isDebugEnabled())
{
logger.debug("retrive blame from cache for {}", requestClone);
}
}
if (!disablePreProcessors && (result != null))
{
preProcessorUtil.prepareForReturn(repository, result);
}
return result;
}
//~--- set methods ----------------------------------------------------------
/**
* Disables the cache. This means that every {@link BlameResult}
* is directly retrieved from the {@link Repository}. <b>Note: </b> Disabling
* the cache cost a lot of performance and could be much more slower.
*
*
* @param disableCache true to disable the cache
*
* @return {@code this}
*/
public BlameCommandBuilder setDisableCache(boolean disableCache)
{
this.disableCache = disableCache;
return this;
}
/**
* Disable the execution of pre processors.
*
*
* @param disablePreProcessors true to disable the pre processors execution
*
* @return {@code this}
*/
public BlameCommandBuilder setDisablePreProcessors(
boolean disablePreProcessors)
{
this.disablePreProcessors = disablePreProcessors;
return this;
}
/**
* Sets the start revision for the blame.
*
*
* @param revision revision to start from
*
* @return {@code this}
*/
public BlameCommandBuilder setRevision(String revision)
{
request.setRevision(revision);
return this;
}
//~--- inner classes --------------------------------------------------------
/**
* Key for cache.
*
*
* @version Enter version here..., 12/06/05
* @author Enter your name here...
*/
static class CacheKey implements RepositoryCacheKey, Serializable
{
/** Field description */
private static final long serialVersionUID = 8373766042131887789L;
//~--- constructors -------------------------------------------------------
/**
* Constructs ...
*
*
* @param repository
* @param request
*/
public CacheKey(Repository repository, BlameCommandRequest request)
{
this.repositoryId = repository.getId();
this.request = request;
}
//~--- methods ------------------------------------------------------------
/**
* Method description
*
*
* @param obj
*
* @return
*/
@Override
public boolean equals(Object obj)
{
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final CacheKey other = (CacheKey) obj;
return Objects.equal(repositoryId, other.repositoryId)
&& Objects.equal(request, other.request);
}
/**
* Method description
*
*
* @return
*/
@Override
public int hashCode()
{
return Objects.hashCode(repositoryId, request);
}
//~--- get methods --------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
public String getRepositoryId()
{
return repositoryId;
}
//~--- fields -------------------------------------------------------------
/** Field description */
private String repositoryId;
/** Field description */
private BlameCommandRequest request;
}
//~--- fields ---------------------------------------------------------------
/** implementation of the blame command */
private BlameCommand blameCommand;
/** the cache */
private Cache<CacheKey, BlameResult> cache;
/** disable change */
private boolean disableCache = false;
/** disable the execution of pre processors */
private boolean disablePreProcessors = false;
/** Field description */
private PreProcessorUtil preProcessorUtil;
/** the repository */
private Repository repository;
/** request for the blame command implementation */
private BlameCommandRequest request = new BlameCommandRequest();
}

View File

@@ -0,0 +1,384 @@
/**
* 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.repository.api;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Objects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.cache.Cache;
import sonia.scm.cache.CacheManager;
import sonia.scm.repository.BrowserResult;
import sonia.scm.repository.FileObject;
import sonia.scm.repository.FileObjectNameComparator;
import sonia.scm.repository.PreProcessorUtil;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryCacheKey;
import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.BrowseCommand;
import sonia.scm.repository.spi.BrowseCommandRequest;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
/**
* BrowseCommandBuilder is able to browse the files of a {@link Repository}.
* <br /><br />
* <b>Sample:</b>
* <br />
* <br />
* Print all paths from folder scm-core at revision 11aeec7db845:<br />
* <pre><code>
* BrowseCommandBuilder browse = repositoryService.getBrowseCommand();
* BrowserResult result = browse.setPath("scm-core")
* .setRevision("11aeec7db845")
* .getBrowserResult();
*
* for ( FileObject fo : result ){
* System.out.println( fo.getPath() );
* }
* </pre></code>
*
* @author Sebastian Sdorra
* @since 1.17
*/
public final class BrowseCommandBuilder
{
/** Name of the cache */
static final String CACHE_NAME = "sonia.cache.cmd.browse";
/**
* the logger for BrowseCommandBuilder
*/
private static final Logger logger =
LoggerFactory.getLogger(BrowseCommandBuilder.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs a new {@link LogCommandBuilder}, this constructor should
* only be called from the {@link RepositoryService}.
*
* @param cacheManager cache manager
* @param logCommand implementation of the {@link LogCommand}
* @param browseCommand
* @param repository repository to query
* @param preProcessorUtil
*/
BrowseCommandBuilder(CacheManager cacheManager, BrowseCommand browseCommand,
Repository repository, PreProcessorUtil preProcessorUtil)
{
this.cache = cacheManager.getCache(CacheKey.class, BrowserResult.class,
CACHE_NAME);
this.browseCommand = browseCommand;
this.repository = repository;
this.preProcessorUtil = preProcessorUtil;
}
//~--- methods --------------------------------------------------------------
/**
* Reset each parameter to its default value.
*
*
* @return {@code this}
*/
public BrowseCommandBuilder reset()
{
request.reset();
this.disableCache = false;
this.disablePreProcessors = false;
return this;
}
//~--- get methods ----------------------------------------------------------
/**
* Return the files for the given parameters.
*
*
* @return files for the given parameters
*
* @throws IOException
* @throws RepositoryException
*/
public BrowserResult getBrowserResult()
throws IOException, RepositoryException
{
BrowserResult result = null;
if (disableCache)
{
if (logger.isDebugEnabled())
{
logger.debug("create browser result for {} with disabled cache",
request);
}
result = browseCommand.getBrowserResult(request);
}
else
{
CacheKey key = new CacheKey(repository, request);
result = cache.get(key);
if (result == null)
{
if (logger.isDebugEnabled())
{
logger.debug("create browser result for {}", request);
}
result = browseCommand.getBrowserResult(request);
if (result != null)
{
cache.put(key, result);
}
}
else if (logger.isDebugEnabled())
{
logger.debug("retrive browser result from cache for {}", request);
}
}
if (!disablePreProcessors && (result != null))
{
preProcessorUtil.prepareForReturn(repository, result);
List<FileObject> fileObjects = result.getFiles();
if (fileObjects != null)
{
Collections.sort(fileObjects, FileObjectNameComparator.instance);
result.setFiles(fileObjects);
}
}
return result;
}
//~--- set methods ----------------------------------------------------------
/**
* Disables the cache. This means that every {@link BrowserResult}
* is directly retrieved from the {@link Repository}. <b>Note: </b> Disabling
* the cache cost a lot of performance and could be much more slower.
*
*
* @param disableCache true to disable the cache
*
* @return {@code this}
*/
public BrowseCommandBuilder setDisableCache(boolean disableCache)
{
this.disableCache = disableCache;
return this;
}
/**
* Disable the execution of pre processors.
*
*
* @param disablePreProcessors true to disable the pre processors execution
*
* @return {@code this}
*/
public BrowseCommandBuilder setDisablePreProcessors(
boolean disablePreProcessors)
{
this.disablePreProcessors = disablePreProcessors;
return this;
}
/**
* Retrieve only files which are children of the given path.
* This path have to be a directory.
*
* @param path path of the folder
*
* @return {@code this}
*/
public BrowseCommandBuilder setPath(String path)
{
request.setPath(path);
return this;
}
/**
* Retrieve only files of the given revision.
*
* @param revision revision for the files
*
* @return {@code this}
*/
public BrowseCommandBuilder setRevision(String revision)
{
request.setRevision(revision);
return this;
}
//~--- inner classes --------------------------------------------------------
/**
* Key for cache.
*
*
* @version Enter version here..., 12/06/05
* @author Enter your name here...
*/
static class CacheKey implements RepositoryCacheKey, Serializable
{
/** Field description */
private static final long serialVersionUID = 8078650026812373524L;
//~--- constructors -------------------------------------------------------
/**
* Constructs ...
*
*
* @param repository
* @param request
*/
public CacheKey(Repository repository, BrowseCommandRequest request)
{
this.repositoryId = repository.getId();
this.request = request;
}
//~--- methods ------------------------------------------------------------
/**
* Method description
*
*
* @param obj
*
* @return
*/
@Override
public boolean equals(Object obj)
{
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final CacheKey other = (CacheKey) obj;
return Objects.equal(repositoryId, other.repositoryId)
&& Objects.equal(request, other.request);
}
/**
* Method description
*
*
* @return
*/
@Override
public int hashCode()
{
return Objects.hashCode(repositoryId, request);
}
//~--- get methods --------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
public String getRepositoryId()
{
return repositoryId;
}
//~--- fields -------------------------------------------------------------
/** Field description */
private String repositoryId;
/** Field description */
private BrowseCommandRequest request;
}
//~--- fields ---------------------------------------------------------------
/** implementation of the browse command */
private BrowseCommand browseCommand;
/** cache */
private Cache<CacheKey, BrowserResult> cache;
/** disables the cache */
private boolean disableCache = false;
/** disables the execution of pre processors */
private boolean disablePreProcessors = false;
/** Field description */
private PreProcessorUtil preProcessorUtil;
/** the repsitory */
private Repository repository;
/** request for the command */
private BrowseCommandRequest request = new BrowseCommandRequest();
}

View File

@@ -0,0 +1,213 @@
/**
* 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.repository.api;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.io.Closeables;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.CatCommand;
import sonia.scm.repository.spi.CatCommandRequest;
//~--- JDK imports ------------------------------------------------------------
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* Shows the content of a file in the {@link Repository}.<br />
* <br />
* <b>Sample:</b>
* <br />
* <br />
* Print the content of the file core/pom.xml from revision 46a23689ac91:<br />
* <pre><code>
* CatCommandBuilder cat = repositoryService.getCatCommand();
* String content = cat.setRevision("46a23689ac91").getContent("core/pom.xml");
* System.out.println(content);
* </code></pre>
*
* @author Sebastian Sdorra
* @since 1.17
*/
public final class CatCommandBuilder
{
/**
* the logger for CatCommandBuilder
*/
private static final Logger logger =
LoggerFactory.getLogger(CatCommandBuilder.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs a new {@link CatCommandBuilder}, this constructor should
* only be called from the {@link RepositoryService}.
*
* @param catCommand implementation of the {@link CatCommand}
*/
CatCommandBuilder(CatCommand catCommand)
{
this.catCommand = catCommand;
}
//~--- methods --------------------------------------------------------------
/**
* Reset each parameter to its default value.
*
* @return {@code this}
*/
public CatCommandBuilder reset()
{
request.reset();
return this;
}
/**
* Passes the content of the given file to the outputstream.
*
* @param outputStream outputstream for the content
* @param path file path
*
* @return {@code this}
*
* @throws IOException
* @throws RepositoryException
*/
public CatCommandBuilder retriveContent(OutputStream outputStream,
String path)
throws IOException, RepositoryException
{
getCatResult(outputStream, path);
return this;
}
//~--- get methods ----------------------------------------------------------
/**
* Returns the content of the given file.
*
* @param path file path
* @return content of the file
*
* @throws IOException
* @throws RepositoryException
*/
public String getContent(String path) throws IOException, RepositoryException
{
String content = null;
ByteArrayOutputStream baos = null;
try
{
baos = new ByteArrayOutputStream();
getCatResult(baos, path);
content = baos.toString();
}
finally
{
Closeables.closeQuietly(baos);
}
return content;
}
//~--- set methods ----------------------------------------------------------
/**
* Sets the revision of the file.
*
*
* @param revision revision of the file
*
* @return {@code this}
*/
public CatCommandBuilder setRevision(String revision)
{
request.setRevision(revision);
return this;
}
//~--- get methods ----------------------------------------------------------
/**
* Executes the cat command.
*
*
* @param outputStream the outputstream for the content
* @param path path of the file
*
* @throws IOException
* @throws RepositoryException
*/
private void getCatResult(OutputStream outputStream, String path)
throws IOException, RepositoryException
{
Preconditions.checkNotNull(outputStream, "OutputStream is required");
Preconditions.checkArgument(!Strings.isNullOrEmpty(path),
"path is required");
CatCommandRequest requestClone = request.clone();
requestClone.setPath(path);
if (logger.isDebugEnabled())
{
logger.debug("create cat for {}", requestClone);
}
catCommand.getCatResult(requestClone, outputStream);
}
//~--- fields ---------------------------------------------------------------
/** implementation of the cat command */
private CatCommand catCommand;
/** request for the cat command */
private CatCommandRequest request = new CatCommandRequest();
}

View File

@@ -0,0 +1,45 @@
/**
* 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.repository.api;
/**
* Enumeration of available commands.
*
* @author Sebastian Sdorra
* @since 1.17
*/
public enum Command
{
LOG, BROWSE, CAT, DIFF, BLAME
}

View File

@@ -0,0 +1,94 @@
/**
* 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.repository.api;
/**
* This exception is thrown if the {@link RepositoryService} does not support
* the requested command.
*
* @author Sebastian Sdorra
* @since 1.17
*/
public final class CommandNotSupportedException extends RuntimeException
{
/**
* Constructs a new {@link CommandNotSupportedException}.
*
*
* @param command not supported command
*/
public CommandNotSupportedException(Command command)
{
//J-
this(
command,
"The requested feature "
.concat(command.toString())
.concat(" is not supported")
);
//J+
}
/**
* Constructs a new {@link CommandNotSupportedException}.
*
*
* @param command not supported command
* @param message message to be shown
*/
public CommandNotSupportedException(Command command, String message)
{
super(message);
this.command = command;
}
//~--- get methods ----------------------------------------------------------
/**
* Returns the command which is not supported.
*
*
* @return not supported command
*/
public Command getCommand()
{
return command;
}
//~--- fields ---------------------------------------------------------------
/** not supported command */
private Command command;
}

View File

@@ -0,0 +1,215 @@
/**
* 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.repository.api;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Preconditions;
import com.google.common.io.Closeables;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.DiffCommand;
import sonia.scm.repository.spi.DiffCommandRequest;
//~--- JDK imports ------------------------------------------------------------
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* Shows differences between revisions for a specified file or
* the entire revision.<br />
* <b>Note:</b> One of the parameter path or revision have to be set.<br />
* <br />
* <b>Sample:</b>
* <br />
* <br />
* Print the differences from revision 33b93c443867:<br />
* <pre><code>
* DiffCommandBuilder diff = repositoryService.getDiffCommand();
* String content = diff.setRevision("33b93c443867").getContent();
* System.out.println(content);
* </code></pre>
*
*
* TODO check current behavior.
*
* @author Sebastian Sdorra
* @since 1.17
*/
public final class DiffCommandBuilder
{
/**
* the logger for DiffCommandBuilder
*/
private static final Logger logger =
LoggerFactory.getLogger(DiffCommandBuilder.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs a new {@link DiffCommandBuilder}, this constructor should
* only be called from the {@link RepositoryService}.
*
* @param implementation of {@link DiffCommand}
*
* @param diffCommand
*/
DiffCommandBuilder(DiffCommand diffCommand)
{
this.diffCommand = diffCommand;
}
//~--- methods --------------------------------------------------------------
/**
* Passes the difference of the given parameter to the outputstream.
*
*
* @param outputStream outputstream for the difference
*
* @return {@code this}
*
* @throws IOException
* @throws RepositoryException
*/
public DiffCommandBuilder retriveContent(OutputStream outputStream)
throws IOException, RepositoryException
{
getDiffResult(outputStream);
return this;
}
//~--- get methods ----------------------------------------------------------
/**
* Returns the content of the difference as string.
*
* @return content of the difference
*
* @throws IOException
* @throws RepositoryException
*/
public String getContent() throws IOException, RepositoryException
{
String content = null;
ByteArrayOutputStream baos = null;
try
{
baos = new ByteArrayOutputStream();
getDiffResult(baos);
content = baos.toString();
}
finally
{
Closeables.closeQuietly(baos);
}
return content;
}
//~--- set methods ----------------------------------------------------------
/**
* Show the difference only for the given path.
*
*
* @param path path for difference
*
* @return {@code this}
*/
public DiffCommandBuilder setPath(String path)
{
request.setPath(path);
return this;
}
/**
* Show the difference only for the given revision.
*
*
* @param revision revision for difference
*
* @return {@code this}
*/
public DiffCommandBuilder setRevision(String revision)
{
request.setRevision(revision);
return this;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param outputStream
* @param path
*
* @throws IOException
* @throws RepositoryException
*/
private void getDiffResult(OutputStream outputStream)
throws IOException, RepositoryException
{
Preconditions.checkNotNull(outputStream, "OutputStream is required");
Preconditions.checkArgument(request.isValid(),
"path and/or revision is required");
if (logger.isDebugEnabled())
{
logger.debug("create diff for {}", request);
}
diffCommand.getDiffResult(request, outputStream);
}
//~--- fields ---------------------------------------------------------------
/** implementation of the diff command */
private DiffCommand diffCommand;
/** request for the diff command implementation */
private DiffCommandRequest request = new DiffCommandRequest();
}

View File

@@ -0,0 +1,528 @@
/**
* 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.repository.api;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.cache.Cache;
import sonia.scm.cache.CacheManager;
import sonia.scm.repository.Changeset;
import sonia.scm.repository.ChangesetPagingResult;
import sonia.scm.repository.PreProcessorUtil;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryCacheKey;
import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.LogCommand;
import sonia.scm.repository.spi.LogCommandRequest;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.io.Serializable;
/**
* LogCommandBuilder is able to show the history of a file in a
* {@link Repository} or the entire history of a {@link Repository}.
* This class could be used to retrieve a single {@link Changeset} by its id
* or to get a list of changesets in a {@link ChangesetPagingResult}
* which can be used for paging.<br />
* <br />
* <b>Samples:</b>
* <br />
* <br />
* Retrieve a single {@link Changeset}:<br />
* <pre><code>
* LogCommand log = repositoryService.getLogCommand();
* Changeset changeset = log.getChangeset("id-of-the-commit");
* </code></pre>
*
* Retrieve changesets of a {@link Repository} with paging:<br />
* <pre><code>
* LogCommand log = repositoryService.getLogCommand();
* ChangesetPagingResult changesetPagingResult =
* log.setPagingStart(25).setPagingLimit(25).getChangesets();
* </code></pre>
*
* Retrieve all changesets of a file in a {@link Repository}:<br />
* <pre><code>
* LogCommand log = repositoryService.getLogCommand();
* ChangesetPagingResult changesetPagingResult =
* log.setPath("pom.xml").disablePagingLimit().getChangesets();
* </code></pre>
*
* @author Sebastian Sdorra
* @since 1.17
*/
public final class LogCommandBuilder
{
/** name of the cache */
static final String CACHE_NAME = "sonia.cache.cmd.log";
/**
* the logger for LogCommandBuilder
*/
private static final Logger logger =
LoggerFactory.getLogger(LogCommandBuilder.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs a new {@link LogCommandBuilder}, this constructor should
* only be called from the {@link RepositoryService}.
*
* @param cacheManager cache manager
* @param logCommand implementation of the {@link LogCommand}
* @param repository repository to query
* @param preProcessorUtil
*/
LogCommandBuilder(CacheManager cacheManager, LogCommand logCommand,
Repository repository, PreProcessorUtil preProcessorUtil)
{
this.cache = cacheManager.getCache(CacheKey.class,
ChangesetPagingResult.class, CACHE_NAME);
this.logCommand = logCommand;
this.repository = repository;
this.preProcessorUtil = preProcessorUtil;
}
//~--- methods --------------------------------------------------------------
/**
* Disable paging limit all available changesets will be retrieved.
* This method does the same as {@link #setPagingLimit(int)}
* with a value of -1.
*
*
* @return {@code this}
*/
public LogCommandBuilder disablePagingLimit()
{
request.setPagingLimit(-1);
return this;
}
/**
* Reset each parameter to its default value.
*
*
* @return {@code this}
*/
public LogCommandBuilder reset()
{
request.reset();
this.disableCache = false;
this.disablePreProcessors = false;
return this;
}
//~--- get methods ----------------------------------------------------------
/**
* Returns the {@link Changeset} with the given id or null if the
* {@link Changeset} could not be found in the {@link Repository}.
*
*
* @param id id of the {@link Changeset}
*
* @return the {@link Changeset} with the given id or null
*
* @throws IOException
* @throws RepositoryException
*/
public Changeset getChangeset(String id)
throws IOException, RepositoryException
{
Changeset changeset = null;
if (disableCache)
{
if (logger.isDebugEnabled())
{
logger.debug("get changeset for {} with disabled cache", id);
}
changeset = logCommand.getChangeset(id);
}
else
{
CacheKey key = new CacheKey(repository, id);
ChangesetPagingResult cpr = cache.get(key);
if (cpr == null)
{
if (logger.isDebugEnabled())
{
logger.debug("get changeset for {}", id);
}
changeset = logCommand.getChangeset(id);
if (changeset != null)
{
cpr = new ChangesetPagingResult(1, ImmutableList.of(changeset));
cache.put(key, cpr);
}
}
else
{
if (logger.isDebugEnabled())
{
logger.debug("get changeset {} from cache", id);
}
changeset = cpr.iterator().next();
}
}
if (!disablePreProcessors && (changeset != null))
{
preProcessorUtil.prepareForReturn(repository, changeset);
}
return changeset;
}
/**
* Return all changesets with the given parameters.
*
*
* @return all changesets with the given parameters
*
* @throws IOException
* @throws RepositoryException
*/
public ChangesetPagingResult getChangesets()
throws IOException, RepositoryException
{
ChangesetPagingResult cpr = null;
if (disableCache)
{
if (logger.isDebugEnabled())
{
logger.debug("get changesets for {} with disabled cache", request);
}
cpr = logCommand.getChangesets(request);
}
else
{
CacheKey key = new CacheKey(repository, request);
cpr = cache.get(key);
if (cpr == null)
{
if (logger.isDebugEnabled())
{
logger.debug("get changesets for {}", request);
}
cpr = logCommand.getChangesets(request);
if (cpr != null)
{
cache.put(key, cpr);
}
}
else if (logger.isDebugEnabled())
{
logger.debug("get changesets from cache for {}", request);
}
}
if (!disablePreProcessors && (cpr != null))
{
preProcessorUtil.prepareForReturn(repository, cpr);
}
return cpr;
}
//~--- set methods ----------------------------------------------------------
/**
* Disables the cache for changesets. This means that every {@link Changeset}
* is directly retrieved from the {@link Repository}. <b>Note: </b> Disabling
* the cache cost a lot of performance and could be much more slower.
*
*
* @param disableCache true to disable the cache
*
* @return {@code this}
*/
public LogCommandBuilder setDisableCache(boolean disableCache)
{
this.disableCache = disableCache;
return this;
}
/**
* Disable the execution of pre processors.
*
*
* @param disablePreProcessors true to disable the pre processors execution
*
* @return {@code this}
*/
public LogCommandBuilder setDisablePreProcessors(boolean disablePreProcessors)
{
this.disablePreProcessors = disablePreProcessors;
return this;
}
/**
* Retrieve changesets until the given the {@link Changeset}
* with the given id.
*
*
* @param endChangeset id of the end {@link Changeset}
*
* @return {@code this}
*/
public LogCommandBuilder setEndChangeset(String endChangeset)
{
request.setEndChangeset(endChangeset);
return this;
}
/**
* Set the limit for the returned changesets. The default value is 20.
* Setting the value to -1 means to disable the limit.
*
*
* @param pagingLimit limit for returned changesets
*
* @return {@code this}
*/
public LogCommandBuilder setPagingLimit(int pagingLimit)
{
request.setPagingLimit(pagingLimit);
return this;
}
/**
* Sets the start value for paging. The value is 0.
*
*
* @param pagingStart start value for paging
*
* @return {@code this}
*/
public LogCommandBuilder setPagingStart(int pagingStart)
{
request.setPagingStart(pagingStart);
return this;
}
/**
* Retrieve only changesets which are affect the given path.
*
*
* @param path file path in the {@link Repository}.
*
* @return {@code this}
*/
public LogCommandBuilder setPath(String path)
{
request.setPath(path);
return this;
}
/**
* Start at the given {@link Changeset}.
*
*
* @param startChangeset changeset id to start with
*
* @return {@code this}
*/
public LogCommandBuilder setStartChangeset(String startChangeset)
{
request.setStartChangeset(startChangeset);
return this;
}
//~--- inner classes --------------------------------------------------------
/**
* Class description
*
*
* @version Enter version here..., 12/06/05
* @author Enter your name here...
*/
static class CacheKey implements RepositoryCacheKey, Serializable
{
/** Field description */
private static final long serialVersionUID = 5701675009949268863L;
//~--- constructors -------------------------------------------------------
/**
* Constructs ...
*
*
* @param repository
* @param request
*/
public CacheKey(Repository repository, LogCommandRequest request)
{
this.repositoryId = repository.getId();
this.request = request;
}
/**
* Constructs ...
*
*
*
* @param repository
* @param changesetId
*/
public CacheKey(Repository repository, String changesetId)
{
this.repositoryId = repository.getId();
this.changesetId = changesetId;
}
//~--- methods ------------------------------------------------------------
/**
* Method description
*
*
* @param obj
*
* @return
*/
@Override
public boolean equals(Object obj)
{
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final CacheKey other = (CacheKey) obj;
return Objects.equal(repositoryId, other.repositoryId)
&& Objects.equal(changesetId, other.changesetId)
&& Objects.equal(request, other.request);
}
/**
* Method description
*
*
* @return
*/
@Override
public int hashCode()
{
return Objects.hashCode(repositoryId, changesetId, request);
}
//~--- get methods --------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
public String getRepositoryId()
{
return repositoryId;
}
//~--- fields -------------------------------------------------------------
/** Field description */
private String changesetId;
/** Field description */
private String repositoryId;
/** Field description */
private LogCommandRequest request;
}
//~--- fields ---------------------------------------------------------------
/** cache for changesets */
private Cache<CacheKey, ChangesetPagingResult> cache;
/** disable cache */
private boolean disableCache = false;
/** disable the execution of pre processors */
private boolean disablePreProcessors = false;
/** Implementation of the log command */
private LogCommand logCommand;
/** Field description */
private PreProcessorUtil preProcessorUtil;
/** repository to query */
private Repository repository;
/** request for the log command */
private LogCommandRequest request = new LogCommandRequest();
}

View File

@@ -0,0 +1,271 @@
/**
* 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.repository.api;
//~--- non-JDK imports --------------------------------------------------------
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.cache.CacheManager;
import sonia.scm.repository.PreProcessorUtil;
import sonia.scm.repository.Repository;
import sonia.scm.repository.spi.RepositoryServiceProvider;
//~--- JDK imports ------------------------------------------------------------
import java.io.Closeable;
import java.io.IOException;
/**
* From the {@link RepositoryService} it is possible to access all commands for
* a single {@link Repository}. The {@link RepositoryService} is only access
* able from the {@link RepositoryServiceFactory}.<br />
* <br />
*
* <b>Note:</b> Not every {@link RepositoryService} supports every command. If
* the command is not supported the method will trow a
* {@link CommandNotSupportedException}. It is possible to check if the command
* is supported by the {@link RepositoryService} with the
* {@link RepositoryService#isSupported(Command)} method.<br />
* <br />
*
* <b>Warning:</b> You should always close the connection to the repository
* after work is finished. For closing the connection to the repository use the
* {@link #close()} method.
*
* @author Sebastian Sdorra
* @since 1.17
*
* @apiviz.uses sonia.scm.repository.api.Command
* @apiviz.uses sonia.scm.repository.api.BlameCommandBuilder
* @apiviz.uses sonia.scm.repository.api.BrowseCommandBuilder
* @apiviz.uses sonia.scm.repository.api.CatCommandBuilder
* @apiviz.uses sonia.scm.repository.api.DiffCommandBuilder
* @apiviz.uses sonia.scm.repository.api.LogCommandBuilder
*/
public final class RepositoryService implements Closeable
{
/**
* the logger for RepositoryService
*/
private static final Logger logger =
LoggerFactory.getLogger(RepositoryService.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs a new {@link RepositoryService}. This constructor should only
* be called from the {@link RepositoryServiceFactory}.
*
* @param cacheManager cache manager
* @param provider implementation for {@link RepositoryServiceProvider}
* @param repository the repository
* @param preProcessorUtil
*/
RepositoryService(CacheManager cacheManager,
RepositoryServiceProvider provider, Repository repository,
PreProcessorUtil preProcessorUtil)
{
this.cacheManager = cacheManager;
this.provider = provider;
this.repository = repository;
this.preProcessorUtil = preProcessorUtil;
}
//~--- methods --------------------------------------------------------------
/**
* Closes the connection to the repository and releases all locks
* and resources. This method should be called in a finally block e.g.:
*
* <pre><code>
* RepositoryService service = null;
* try {
* service = factory.create("repositoryId");
* // do something with the service
* } finally {
* if ( service != null ){
* service.close();
* }
* }
* </code></pre>
*/
@Override
public void close()
{
try
{
provider.close();
}
catch (IOException ex)
{
logger.error("cound not close repository service provider", ex);
}
}
//~--- get methods ----------------------------------------------------------
/**
* The blame command shows changeset information by line for a given file.
*
* @return instance of {@link BlameCommandBuilder}
* @throws CommandNotSupportedException if the command is not supported
* by the implementation of the repository service provider.
*/
public BlameCommandBuilder getBlameCommand()
{
if (logger.isDebugEnabled())
{
logger.debug("create blame command for repository {}",
repository.getName());
}
return new BlameCommandBuilder(cacheManager, provider.getBlameCommand(),
repository, preProcessorUtil);
}
/**
* The browse command allows browsing of a repository.
*
* @return instance of {@link BrowseCommandBuilder}
* @throws CommandNotSupportedException if the command is not supported
* by the implementation of the repository service provider.
*/
public BrowseCommandBuilder getBrowseCommand()
{
if (logger.isDebugEnabled())
{
logger.debug("create browse command for repository {}",
repository.getName());
}
return new BrowseCommandBuilder(cacheManager, provider.getBrowseCommand(),
repository, preProcessorUtil);
}
/**
* The cat command show the content of a given file.
*
* @return instance of {@link CatCommandBuilder}
* @throws CommandNotSupportedException if the command is not supported
* by the implementation of the repository service provider.
*/
public CatCommandBuilder getCatCommand()
{
if (logger.isDebugEnabled())
{
logger.debug("create cat command for repository {}",
repository.getName());
}
return new CatCommandBuilder(provider.getCatCommand());
}
/**
* The diff command shows differences between revisions for a specified file
* or the entire revision.
*
* @return instance of {@link DiffCommandBuilder}
* @throws CommandNotSupportedException if the command is not supported
* by the implementation of the repository service provider.
*/
public DiffCommandBuilder getDiffCommand()
{
if (logger.isDebugEnabled())
{
logger.debug("create diff command for repository {}",
repository.getName());
}
return new DiffCommandBuilder(provider.getDiffCommand());
}
/**
* The log command shows revision history of entire repository or files.
*
* @return instance of {@link LogCommandBuilder}
* @throws CommandNotSupportedException if the command is not supported
* by the implementation of the repository service provider.
*/
public LogCommandBuilder getLogCommand()
{
if (logger.isDebugEnabled())
{
logger.debug("create log command for repository {}",
repository.getName());
}
return new LogCommandBuilder(cacheManager, provider.getLogCommand(),
repository, preProcessorUtil);
}
/**
* Returns the repository of this service.
*
* @return repository of this service
*/
public Repository getRepository()
{
return repository;
}
/**
* Returns true if the command is supported by the repository service.
*
*
* @param command command
*
* @return true if the command is supported
*/
public boolean isSupported(Command command)
{
return provider.getSupportedCommands().contains(command);
}
//~--- fields ---------------------------------------------------------------
/** cache manager */
private CacheManager cacheManager;
/** Field description */
private PreProcessorUtil preProcessorUtil;
/** implementation of the repository service provider */
private RepositoryServiceProvider provider;
/** the repository */
private Repository repository;
}

View File

@@ -0,0 +1,406 @@
/**
* 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.repository.api;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.HandlerEvent;
import sonia.scm.cache.Cache;
import sonia.scm.cache.CacheManager;
import sonia.scm.repository.BlameResult;
import sonia.scm.repository.BrowserResult;
import sonia.scm.repository.ChangesetPagingResult;
import sonia.scm.repository.PermissionType;
import sonia.scm.repository.PermissionUtil;
import sonia.scm.repository.PostReceiveRepositoryHook;
import sonia.scm.repository.PreProcessorUtil;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryCacheKeyFilter;
import sonia.scm.repository.RepositoryHookEvent;
import sonia.scm.repository.RepositoryListener;
import sonia.scm.repository.RepositoryManager;
import sonia.scm.repository.RepositoryNotFoundException;
import sonia.scm.repository.spi.RepositoryServiceProvider;
import sonia.scm.repository.spi.RepositoryServiceResolver;
import sonia.scm.security.ScmSecurityException;
import sonia.scm.web.security.WebSecurityContext;
//~--- JDK imports ------------------------------------------------------------
import java.util.Set;
/**
* The {@link RepositoryServiceFactory} is the entrypoint of the repository api.
* You could create {@link RepositoryService} from a {@link Repository} and
* with the {@link RepositoryService} you could browse and control the entire
* {@link Repository}.
* <p>&nbsp;</p>
* <b>Simple usage example:</b>
*
* <pre><code>
* public class Sample {
*
* private final RepositoryServiceFactory factory;
*
* {@literal @}Inject
* public Sample(RepositoryServiceFactory factory){
* this.factory = factory;
* }
*
* public Changeset getChangeset(String repositoryId, String commitId){
* Changeset changeset = null;
* RepositoryService service = null;
* try {
* service = factory.create(repositoryId);
* changeset = service.getLogCommand().getChangeset(commitId);
* } finally {
* if ( service != null ){
* service.close();
* }
* }
* return changeset;
* }
*
* }
* </code></pre>
*
* @author Sebastian Sdorra
* @since 1.17
*
* @apiviz.landmark
* @apiviz.uses sonia.scm.repository.api.RepositoryService
*/
@Singleton
public final class RepositoryServiceFactory
{
/**
* the logger for RepositoryServiceFactory
*/
private static final Logger logger =
LoggerFactory.getLogger(RepositoryServiceFactory.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs a new {@link RepositoryServiceFactory}. This constructor
* should not be called manually, it should only be used by the injection
* container.
*
* @param cacheManager cache manager
* @param repositoryManager manager for repositories
* @param securityContextProvider provider for the current security context
* @param resolvers a set of {@link RepositoryServiceResolver}
* @param preProcessorUtil helper object for pre processor handling
*/
@Inject
public RepositoryServiceFactory(
CacheManager cacheManager, RepositoryManager repositoryManager,
Provider<WebSecurityContext> securityContextProvider,
Set<RepositoryServiceResolver> resolvers,
PreProcessorUtil preProcessorUtil)
{
this.cacheManager = cacheManager;
this.repositoryManager = repositoryManager;
this.securityContextProvider = securityContextProvider;
this.resolvers = resolvers;
this.preProcessorUtil = preProcessorUtil;
CacheClearHook cch = new CacheClearHook(cacheManager);
repositoryManager.addHook(cch);
repositoryManager.addListener(cch);
}
//~--- methods --------------------------------------------------------------
/**
* Creates a new RepositoryService for the given repository.
*
*
* @param repositoryId id of the repository
*
* @return a implementation of RepositoryService
* for the given type of repository
*
* @throws RepositoryNotFoundException if no repository
* with the given id is available
* @throws RepositoryServiceNotFoundException if no repository service
* implementation for this kind of repository is available
* @throws IllegalArgumentException if the repository id is null or empty
* @throws ScmSecurityException if current user has not read permissions
* for that repository
*/
public RepositoryService create(String repositoryId)
throws RepositoryNotFoundException
{
Preconditions.checkArgument(!Strings.isNullOrEmpty(repositoryId),
"a non empty repositoryId is required");
Repository repository = repositoryManager.get(repositoryId);
if (repository == null)
{
throw new RepositoryNotFoundException(
"could not find a repository with id ".concat(repositoryId));
}
return create(repository);
}
/**
* Creates a new RepositoryService for the given repository.
*
*
* @param type type of the repository
* @param name name of the repository
*
* @return a implementation of RepositoryService
* for the given type of repository
*
* @throws RepositoryNotFoundException if no repository
* with the given id is available
* @throws RepositoryServiceNotFoundException if no repository service
* implementation for this kind of repository is available
* @throws IllegalArgumentException if one of the parameters is null or empty
* @throws ScmSecurityException if current user has not read permissions
* for that repository
*/
public RepositoryService create(String type, String name)
throws RepositoryNotFoundException
{
Preconditions.checkArgument(!Strings.isNullOrEmpty(type),
"a non empty type is required");
Preconditions.checkArgument(!Strings.isNullOrEmpty(name),
"a non empty name is required");
Repository repository = repositoryManager.get(type, name);
if (repository == null)
{
StringBuilder msg =
new StringBuilder("could not find a repository with type ");
msg.append(type).append(" and name ").append(name);
throw new RepositoryNotFoundException(msg.toString());
}
return create(repository);
}
/**
* Creates a new RepositoryService for the given repository.
*
*
* @param repository the repository
*
* @return a implementation of RepositoryService
* for the given type of repository
*
* @throws RepositoryServiceNotFoundException if no repository service
* implementation for this kind of repository is available
* @throws NullPointerException if the repository is null
* @throws ScmSecurityException if current user has not read permissions
* for that repository
*/
public RepositoryService create(Repository repository)
{
Preconditions.checkNotNull(repository, "repository is required");
// check for read permissions of current user
PermissionUtil.assertPermission(repository, securityContextProvider,
PermissionType.READ);
RepositoryService service = null;
for (RepositoryServiceResolver resolver : resolvers)
{
RepositoryServiceProvider provider = resolver.reslove(repository);
if (provider != null)
{
if (logger.isDebugEnabled())
{
logger.debug(
"create new repository service for repository {} of type {}",
repository.getName(), repository.getType());
}
service = new RepositoryService(cacheManager, provider, repository,
preProcessorUtil);
break;
}
}
if (service == null)
{
throw new RepositoryServiceNotFoundException(repository);
}
return service;
}
//~--- inner classes --------------------------------------------------------
/**
* TODO find a more elegant way
*
*
* @version Enter version here..., 12/06/16
* @author Enter your name here...
*/
private static class CacheClearHook extends PostReceiveRepositoryHook
implements RepositoryListener
{
/**
* Constructs ...
*
*
* @param cacheManager
*/
public CacheClearHook(CacheManager cacheManager)
{
this.blameCache =
cacheManager.getCache(BlameCommandBuilder.CacheKey.class,
BlameResult.class,
BlameCommandBuilder.CACHE_NAME);
this.browseCache =
cacheManager.getCache(BrowseCommandBuilder.CacheKey.class,
BrowserResult.class,
BrowseCommandBuilder.CACHE_NAME);
this.logCache = cacheManager.getCache(LogCommandBuilder.CacheKey.class,
ChangesetPagingResult.class, LogCommandBuilder.CACHE_NAME);
}
//~--- methods ------------------------------------------------------------
/**
* Method description
*
*
* @param event
*/
@Override
public void onEvent(RepositoryHookEvent event)
{
Repository repository = event.getRepository();
if (repository != null)
{
String id = repository.getId();
clearCaches(id);
}
}
/**
* Method description
*
*
* @param repository
* @param event
*/
@Override
public void onEvent(Repository repository, HandlerEvent event)
{
if (event == HandlerEvent.DELETE)
{
clearCaches(repository.getId());
}
}
/**
* Method description
*
*
* @param repositoryId
*/
@SuppressWarnings("unchecked")
private void clearCaches(final String repositoryId)
{
if (logger.isDebugEnabled())
{
logger.debug("clear caches for repository id {}", repositoryId);
}
RepositoryCacheKeyFilter filter =
new RepositoryCacheKeyFilter(repositoryId);
blameCache.removeAll(filter);
browseCache.removeAll(filter);
logCache.removeAll(filter);
}
//~--- fields -------------------------------------------------------------
/** Field description */
private Cache<BlameCommandBuilder.CacheKey, BlameResult> blameCache;
/** Field description */
private Cache<BrowseCommandBuilder.CacheKey, BrowserResult> browseCache;
/** Field description */
private Cache<LogCommandBuilder.CacheKey, ChangesetPagingResult> logCache;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private CacheManager cacheManager;
/** Field description */
private PreProcessorUtil preProcessorUtil;
/** Field description */
private RepositoryManager repositoryManager;
/** Field description */
private Set<RepositoryServiceResolver> resolvers;
/** Field description */
private Provider<WebSecurityContext> securityContextProvider;
}

View File

@@ -0,0 +1,80 @@
/**
* 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.repository.api;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.Repository;
/**
* This exception is throw if no {@link RepositoryService}
* is available for the given {@link Repository}.
*
* @author Sebastian Sdorra
* @since 1.17
*/
public final class RepositoryServiceNotFoundException extends RuntimeException
{
/**
* Constructs a new {@link RepositoryServiceNotFoundException}.
*
*
* @param repository unsupported repository
*/
public RepositoryServiceNotFoundException(Repository repository)
{
super("could not find a repository service provider implementation for repository "
.concat(repository.getName()));
this.repository = repository;
}
//~--- get methods ----------------------------------------------------------
/**
* Returns the unsupported repository.
*
*
* @return unsupported repository
*/
public Repository getRepository()
{
return repository;
}
//~--- fields ---------------------------------------------------------------
/** unsupported repository */
private Repository repository;
}

View File

@@ -0,0 +1,37 @@
/**
* 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
*
*/
/**
* API for repository access.
*/
package sonia.scm.repository.api;

View File

@@ -0,0 +1,66 @@
/**
* 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.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.BlameResult;
import sonia.scm.repository.RepositoryException;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
/**
*
* @author Sebastian Sdorra
* @since 1.17
*/
public interface BlameCommand
{
/**
* Method description
*
*
* @param request
*
* @return
*
* @throws IOException
* @throws RepositoryException
*/
public BlameResult getBlameResult(BlameCommandRequest request)
throws IOException, RepositoryException;
}

View File

@@ -0,0 +1,68 @@
/**
* 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.repository.spi;
/**
*
* @author Sebastian Sdorra
* @since 1.17
*/
public final class BlameCommandRequest extends FileBaseCommandRequest
{
/**
* Method description
*
*
* @return
*/
@Override
public BlameCommandRequest clone()
{
BlameCommandRequest clone = null;
try
{
clone = (BlameCommandRequest) super.clone();
}
catch (CloneNotSupportedException e)
{
// this shouldn't happen, since we are Cloneable
throw new InternalError("BlameCommandRequest seems not to be cloneable");
}
return clone;
}
}

View File

@@ -0,0 +1,66 @@
/**
* 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.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.BrowserResult;
import sonia.scm.repository.RepositoryException;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
/**
*
* @author Sebastian Sdorra
* @since 1.17
*/
public interface BrowseCommand
{
/**
* Method description
*
*
* @param request
*
* @return
*
* @throws IOException
* @throws RepositoryException
*/
public BrowserResult getBrowserResult(BrowseCommandRequest request)
throws IOException, RepositoryException;
}

View File

@@ -0,0 +1,46 @@
/**
* 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.repository.spi;
//~--- JDK imports ------------------------------------------------------------
import java.io.Serializable;
/**
*
* @author Sebastian Sdorra
* @since 1.17
*/
public final class BrowseCommandRequest extends FileBaseCommandRequest
implements Resetable, Serializable {}

View File

@@ -0,0 +1,65 @@
/**
* 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.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.RepositoryException;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.io.OutputStream;
/**
*
* @author Sebastian Sdorra
* @since 1.17
*/
public interface CatCommand
{
/**
* Method description
*
*
* @param request
* @param output
*
* @throws IOException
* @throws RepositoryException
*/
public void getCatResult(CatCommandRequest request, OutputStream output)
throws IOException, RepositoryException;
}

View File

@@ -0,0 +1,69 @@
/**
* 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.repository.spi;
/**
*
* @author Sebastian Sdorra
* @since 1.17
*/
public final class CatCommandRequest extends FileBaseCommandRequest
implements Cloneable
{
/**
* Method description
*
*
* @return
*/
@Override
public CatCommandRequest clone()
{
CatCommandRequest clone = null;
try
{
clone = (CatCommandRequest) super.clone();
}
catch (CloneNotSupportedException e)
{
// this shouldn't happen, since we are Cloneable
throw new InternalError("CatCommandRequest seems not to be cloneable");
}
return clone;
}
}

View File

@@ -0,0 +1,66 @@
/**
* 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.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.RepositoryException;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.io.OutputStream;
/**
*
* @author Sebastian Sdorra
* @since 1.17
*/
public interface DiffCommand
{
/**
* Method description
*
*
* @param request
* @param output
*
* @throws IOException
* @throws RuntimeException
* @throws RepositoryException
*/
public void getDiffResult(DiffCommandRequest request, OutputStream output)
throws IOException, RepositoryException;
}

View File

@@ -0,0 +1,90 @@
/**
* 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.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Strings;
import sonia.scm.Validateable;
/**
*
* @author Sebastian Sdorra
* @since 1.17
*/
public final class DiffCommandRequest extends FileBaseCommandRequest
implements Cloneable, Validateable
{
/**
* Method description
*
*
* @return
*/
@Override
public DiffCommandRequest clone()
{
DiffCommandRequest clone = null;
try
{
clone = (DiffCommandRequest) super.clone();
}
catch (CloneNotSupportedException e)
{
// this shouldn't happen, since we are Cloneable
throw new InternalError("DiffCommandRequest seems not to be cloneable");
}
return clone;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
public boolean isValid()
{
return !Strings.isNullOrEmpty(getPath())
||!Strings.isNullOrEmpty(getRevision());
}
}

View File

@@ -0,0 +1,205 @@
/**
* 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.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Objects;
//~--- JDK imports ------------------------------------------------------------
import java.io.Serializable;
/**
*
* @author Sebastian Sdorra
* @since 1.17
*/
public abstract class FileBaseCommandRequest
implements Resetable, Serializable, Cloneable
{
/**
* Method description
*
*
* @param obj
*
* @return
*/
@Override
public boolean equals(Object obj)
{
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final FileBaseCommandRequest other = (FileBaseCommandRequest) obj;
return Objects.equal(path, other.path)
&& Objects.equal(revision, other.revision);
}
/**
* Method description
*
*
* @return
*/
@Override
public int hashCode()
{
return Objects.hashCode(path, revision);
}
/**
* Method description
*
*/
@Override
public void reset()
{
path = null;
revision = null;
}
/**
* Method description
*
*
* @return
*/
@Override
public String toString()
{
//J-
return Objects.toStringHelper(this)
.add("path", path)
.add("revision", revision)
.toString();
//J+
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param path
*/
public void setPath(String path)
{
this.path = path;
}
/**
* Method description
*
*
* @param revision
*/
public void setRevision(String revision)
{
this.revision = revision;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
String getPath()
{
return path;
}
/**
* Method description
*
*
* @return
*/
String getRevision()
{
return revision;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @return
*
* @throws CloneNotSupportedException
*/
@Override
protected FileBaseCommandRequest clone() throws CloneNotSupportedException
{
FileBaseCommandRequest clone = null;
try
{
clone = (FileBaseCommandRequest) super.clone();
}
catch (CloneNotSupportedException e)
{
// this shouldn't happen, since we are Cloneable
throw new InternalError(
"FileBaseCommandRequest seems not to be cloneable");
}
return clone;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private String path;
/** Field description */
private String revision;
}

View File

@@ -0,0 +1,81 @@
/**
* 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.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.Changeset;
import sonia.scm.repository.ChangesetPagingResult;
import sonia.scm.repository.RepositoryException;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
/**
*
* @author Sebastian Sdorra
* @since 1.17
*/
public interface LogCommand
{
/**
* Method description
*
*
* @param id
*
* @return
*
* @throws IOException
* @throws RepositoryException
*/
public Changeset getChangeset(String id)
throws IOException, RepositoryException;
/**
* Method description
*
*
* @param request
*
* @return
*
* @throws IOException
* @throws RepositoryException
*/
public ChangesetPagingResult getChangesets(LogCommandRequest request)
throws IOException, RepositoryException;
}

View File

@@ -0,0 +1,270 @@
/**
* 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.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Objects;
//~--- JDK imports ------------------------------------------------------------
import java.io.Serializable;
/**
*
* @author Sebastian Sdorra
* @since 1.17
*/
public final class LogCommandRequest implements Serializable, Resetable
{
/**
* Method description
*
*
* @param obj
*
* @return
*/
@Override
public boolean equals(Object obj)
{
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final LogCommandRequest other = (LogCommandRequest) obj;
return Objects.equal(startChangeset, other.startChangeset)
&& Objects.equal(endChangeset, other.endChangeset)
&& Objects.equal(pagingStart, other.pagingStart)
&& Objects.equal(pagingLimit, other.pagingLimit)
&& Objects.equal(path, other.path);
}
/**
* Method description
*
*
* @return
*/
@Override
public int hashCode()
{
return Objects.hashCode(startChangeset, endChangeset, pagingStart,
pagingLimit, path);
}
/**
* Method description
*
*/
@Override
public void reset()
{
startChangeset = null;
endChangeset = null;
pagingStart = 0;
pagingLimit = 20;
path = null;
}
/**
* Method description
*
*
* @return
*/
@Override
public String toString()
{
//J-
return Objects.toStringHelper(this)
.add("startChangeset", startChangeset)
.add("endChangeset", endChangeset)
.add("pagingStart", pagingStart)
.add("pagingLimit", pagingLimit)
.add("path", path)
.toString();
//J+
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param endChangeset
*/
public void setEndChangeset(String endChangeset)
{
this.endChangeset = endChangeset;
}
/**
* Method description
*
*
* @param pagingLimit
*/
public void setPagingLimit(int pagingLimit)
{
this.pagingLimit = pagingLimit;
}
/**
* Method description
*
*
* @param pagingStart
*/
public void setPagingStart(int pagingStart)
{
this.pagingStart = pagingStart;
}
/**
* Method description
*
*
* @param path
*/
public void setPath(String path)
{
this.path = path;
}
/**
* Method description
*
*
* @param startChangeset
*/
public void setStartChangeset(String startChangeset)
{
this.startChangeset = startChangeset;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
String getEndChangeset()
{
return endChangeset;
}
/**
* Method description
*
*
* @return
*/
int getPagingLimit()
{
return pagingLimit;
}
/**
* Method description
*
*
* @return
*/
int getPagingStart()
{
return pagingStart;
}
/**
* Method description
*
*
* @return
*/
String getPath()
{
return path;
}
/**
* Method description
*
*
* @return
*/
String getStartChangeset()
{
return startChangeset;
}
/**
* Method description
*
*
* @return
*/
boolean isPagingUnlimited()
{
return pagingLimit < 0;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private String endChangeset;
/** Field description */
private int pagingLimit = 20;
/** Field description */
private int pagingStart = 0;
/** Field description */
private String path;
/** Field description */
private String startChangeset;
}

View File

@@ -0,0 +1,137 @@
/**
* 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.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.api.Command;
import sonia.scm.repository.api.CommandNotSupportedException;
//~--- JDK imports ------------------------------------------------------------
import java.io.Closeable;
import java.io.IOException;
import java.util.Set;
/**
*
* @author Sebastian Sdorra
* @since 1.17
*/
public abstract class RepositoryServiceProvider implements Closeable
{
/**
* Method description
*
*
* @return
*/
public abstract Set<Command> getSupportedCommands();
//~--- methods --------------------------------------------------------------
/**
* The default implementation of this method does nothing. If you need to
* free resources, close connections or release locks than you have to
* override this method.
*
*
* @throws IOException
*/
@Override
public void close() throws IOException
{
// should be implmentented from a service provider
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public BlameCommand getBlameCommand()
{
throw new CommandNotSupportedException(Command.BLAME);
}
/**
* Method description
*
*
* @return
*/
public BrowseCommand getBrowseCommand()
{
throw new CommandNotSupportedException(Command.BROWSE);
}
/**
* Method description
*
*
* @return
*/
public CatCommand getCatCommand()
{
throw new CommandNotSupportedException(Command.CAT);
}
/**
* Method description
*
*
* @return
*/
public DiffCommand getDiffCommand()
{
throw new CommandNotSupportedException(Command.DIFF);
}
/**
* Method description
*
*
* @return
*/
public LogCommand getLogCommand()
{
throw new CommandNotSupportedException(Command.LOG);
}
}

View File

@@ -0,0 +1,59 @@
/**
* 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.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.plugin.ExtensionPoint;
import sonia.scm.repository.Repository;
/**
*
* @author Sebastian Sdorra
* @since 1.17
*/
@ExtensionPoint
public interface RepositoryServiceResolver
{
/**
* Method description
*
*
* @param repository
*
* @return
*/
public RepositoryServiceProvider reslove(Repository repository);
}

View File

@@ -0,0 +1,49 @@
/**
* 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.repository.spi;
/**
*
* @author Sebastian Sdorra
* @since 1.17
*/
public interface Resetable
{
/**
* Method description
*
*/
public void reset();
}

View File

@@ -0,0 +1,37 @@
/**
* 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
*
*/
/**
* SPI for repository access. This package is only for service provider.
*/
package sonia.scm.repository.spi;

View File

@@ -1,34 +1,35 @@
/** /**
* Copyright (c) 2010, Sebastian Sdorra All rights reserved. * Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. 2. Redistributions in * this list of conditions and the following disclaimer.
* binary form must reproduce the above copyright notice, this list of * 2. Redistributions in binary form must reproduce the above copyright notice,
* conditions and the following disclaimer in the documentation and/or other * this list of conditions and the following disclaimer in the documentation
* materials provided with the distribution. 3. Neither the name of SCM-Manager; * and/or other materials provided with the distribution.
* nor the names of its contributors may be used to endorse or promote products * 3. Neither the name of SCM-Manager; nor the names of its
* 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" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* http://bitbucket.org/sdorra/scm-manager * http://bitbucket.org/sdorra/scm-manager
* *
*/ */
package sonia.scm.resources; package sonia.scm.resources;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------

View File

@@ -1,34 +1,35 @@
/** /**
* Copyright (c) 2010, Sebastian Sdorra All rights reserved. * Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. 2. Redistributions in * this list of conditions and the following disclaimer.
* binary form must reproduce the above copyright notice, this list of * 2. Redistributions in binary form must reproduce the above copyright notice,
* conditions and the following disclaimer in the documentation and/or other * this list of conditions and the following disclaimer in the documentation
* materials provided with the distribution. 3. Neither the name of SCM-Manager; * and/or other materials provided with the distribution.
* nor the names of its contributors may be used to endorse or promote products * 3. Neither the name of SCM-Manager; nor the names of its
* 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" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* http://bitbucket.org/sdorra/scm-manager * http://bitbucket.org/sdorra/scm-manager
* *
*/ */
package sonia.scm.store; package sonia.scm.store;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------

View File

@@ -1,34 +1,35 @@
/** /**
* Copyright (c) 2010, Sebastian Sdorra All rights reserved. * Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. 2. Redistributions in * this list of conditions and the following disclaimer.
* binary form must reproduce the above copyright notice, this list of * 2. Redistributions in binary form must reproduce the above copyright notice,
* conditions and the following disclaimer in the documentation and/or other * this list of conditions and the following disclaimer in the documentation
* materials provided with the distribution. 3. Neither the name of SCM-Manager; * and/or other materials provided with the distribution.
* nor the names of its contributors may be used to endorse or promote products * 3. Neither the name of SCM-Manager; nor the names of its
* 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" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* http://bitbucket.org/sdorra/scm-manager * http://bitbucket.org/sdorra/scm-manager
* *
*/ */
package sonia.scm.store; package sonia.scm.store;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------

View File

@@ -1,34 +1,35 @@
/** /**
* Copyright (c) 2010, Sebastian Sdorra All rights reserved. * Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. 2. Redistributions in * this list of conditions and the following disclaimer.
* binary form must reproduce the above copyright notice, this list of * 2. Redistributions in binary form must reproduce the above copyright notice,
* conditions and the following disclaimer in the documentation and/or other * this list of conditions and the following disclaimer in the documentation
* materials provided with the distribution. 3. Neither the name of SCM-Manager; * and/or other materials provided with the distribution.
* nor the names of its contributors may be used to endorse or promote products * 3. Neither the name of SCM-Manager; nor the names of its
* 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" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* http://bitbucket.org/sdorra/scm-manager * http://bitbucket.org/sdorra/scm-manager
* *
*/ */
package sonia.scm.store; package sonia.scm.store;
/** /**

View File

@@ -47,6 +47,7 @@ import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
@@ -398,6 +399,23 @@ public class Util
return parseDate(dateString, null); return parseDate(dateString, null);
} }
/**
* Method description
*
*
* @param value
* @param start
*
* @return
*
* @since 1.17
*/
public static boolean startWithIgnoreCase(String value, String start)
{
return (value != null) && (start != null)
&& value.toUpperCase(Locale.ENGLISH).startsWith(start);
}
/** /**
* Method description * Method description
* *

View File

@@ -1,34 +1,35 @@
/** /**
* Copyright (c) 2010, Sebastian Sdorra All rights reserved. * Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. 2. Redistributions in * this list of conditions and the following disclaimer.
* binary form must reproduce the above copyright notice, this list of * 2. Redistributions in binary form must reproduce the above copyright notice,
* conditions and the following disclaimer in the documentation and/or other * this list of conditions and the following disclaimer in the documentation
* materials provided with the distribution. 3. Neither the name of SCM-Manager; * and/or other materials provided with the distribution.
* nor the names of its contributors may be used to endorse or promote products * 3. Neither the name of SCM-Manager; nor the names of its
* 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" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* http://bitbucket.org/sdorra/scm-manager * http://bitbucket.org/sdorra/scm-manager
* *
*/ */
package sonia.scm.web.cgi; package sonia.scm.web.cgi;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------

View File

@@ -120,18 +120,44 @@ public class BasicAuthenticationFilter extends HttpFilter
User user = null; User user = null;
String authentication = request.getHeader(HEADER_AUTHORIZATION); String authentication = request.getHeader(HEADER_AUTHORIZATION);
if (Util.isNotEmpty(authentication) if (Util.startWithIgnoreCase(authentication, AUTHORIZATION_BASIC_PREFIX))
&& authentication.toUpperCase().startsWith(AUTHORIZATION_BASIC_PREFIX))
{ {
if (logger.isTraceEnabled())
{
logger.trace("found basic authorization header, start authentication");
}
user = authenticate(request, response, securityContext, authentication); user = authenticate(request, response, securityContext, authentication);
if (logger.isTraceEnabled())
{
if (user != null)
{
logger.trace("user {} successfully authenticated", user.getName());
}
else
{
logger.trace("authentcation failed, user object is null");
}
}
} }
else if (securityContext.isAuthenticated()) else if (securityContext.isAuthenticated())
{ {
if (logger.isTraceEnabled())
{
logger.trace("user is allready authenticated");
}
user = securityContext.getUser(); user = securityContext.getUser();
} }
if (user == null) if (user == null)
{ {
if (logger.isTraceEnabled())
{
logger.trace("could not find user send unauthorized");
}
HttpUtil.sendUnauthorized(response); HttpUtil.sendUnauthorized(response);
} }
else else
@@ -192,6 +218,11 @@ public class BasicAuthenticationFilter extends HttpFilter
if (Util.isNotEmpty(username) && Util.isNotEmpty(password)) if (Util.isNotEmpty(username) && Util.isNotEmpty(password))
{ {
if (logger.isTraceEnabled())
{
logger.trace("try to authenticate user {}", username);
}
user = securityContext.authenticate(request, response, username, user = securityContext.authenticate(request, response, username,
password); password);
} }

View File

@@ -35,6 +35,8 @@ package sonia.scm.web.filter;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Strings;
import com.google.common.io.Closeables;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -89,7 +91,7 @@ public class LoggingFilter extends HttpFilter
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
boolean logBody = logger.isTraceEnabled(); boolean logBody = logger.isTraceEnabled() && isTextRequest(request);
BufferedHttpServletRequest bufferedRequest = BufferedHttpServletRequest bufferedRequest =
new BufferedHttpServletRequest(request, logBody); new BufferedHttpServletRequest(request, logBody);
BufferedHttpServletResponse bufferedResponse = BufferedHttpServletResponse bufferedResponse =
@@ -189,7 +191,12 @@ public class LoggingFilter extends HttpFilter
if (logger.isTraceEnabled()) if (logger.isTraceEnabled())
{ {
logger.trace("Content: ".concat(new String(request.getContentBuffer()))); byte[] contentBuffer = request.getContentBuffer();
if ((contentBuffer != null) && (contentBuffer.length > 0))
{
logger.trace("Content: ".concat(new String(contentBuffer)));
}
} }
} }
@@ -227,9 +234,12 @@ public class LoggingFilter extends HttpFilter
logger.debug("Header: {} = {}", header.getKey(), header.getValue()); logger.debug("Header: {} = {}", header.getKey(), header.getValue());
} }
if (logger.isTraceEnabled()) if (logger.isTraceEnabled() && isTextRequest(orgResponse))
{ {
byte[] content = response.getContentBuffer(); byte[] content = response.getContentBuffer();
if ((content != null) && (content.length > 0))
{
ServletOutputStream out = null; ServletOutputStream out = null;
try try
@@ -239,10 +249,53 @@ public class LoggingFilter extends HttpFilter
} }
finally finally
{ {
out.close(); Closeables.closeQuietly(out);
} }
logger.trace("Content: ".concat(new String(content))); logger.trace("Content: ".concat(new String(content)));
} }
} }
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param request
*
* @return
*/
private boolean isTextRequest(HttpServletRequest request)
{
return isTextRequest(request.getContentType());
}
/**
* Method description
*
*
* @param response
*
* @return
*/
private boolean isTextRequest(HttpServletResponse response)
{
return isTextRequest(response.getContentType());
}
/**
* Method description
*
*
* @param contentType
*
* @return
*/
private boolean isTextRequest(String contentType)
{
return !Strings.isNullOrEmpty(contentType)
&& contentType.toLowerCase().startsWith("text");
}
} }

View File

@@ -151,6 +151,15 @@ public abstract class PermissionFilter extends HttpFilter
if (hasPermission(repository, securityContext, writeRequest)) if (hasPermission(repository, securityContext, writeRequest))
{ {
if (logger.isTraceEnabled())
{
logger.trace("{} access to repository {} for user {} granted",
new Object[] { writeRequest
? "write"
: "read", repository.getName(),
user.getName() });
}
chain.doFilter(request, response); chain.doFilter(request, response);
} }
else else

View File

@@ -0,0 +1,62 @@
/**
* 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.repository;
//~--- non-JDK imports --------------------------------------------------------
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author Sebastian Sdorra
*/
public class RepositoryTest
{
/**
* Method description
*
*/
@Test
public void testCreateUrl()
{
Repository repository = new Repository("123", "hg", "test/repo");
assertEquals("http://localhost:8080/scm/hg/test/repo",
repository.createUrl("http://localhost:8080/scm"));
assertEquals("http://localhost:8080/scm/hg/test/repo",
repository.createUrl("http://localhost:8080/scm/"));
}
}

View File

@@ -1,34 +1,35 @@
/** /**
* Copyright (c) 2010, Sebastian Sdorra All rights reserved. * Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. 2. Redistributions in * this list of conditions and the following disclaimer.
* binary form must reproduce the above copyright notice, this list of * 2. Redistributions in binary form must reproduce the above copyright notice,
* conditions and the following disclaimer in the documentation and/or other * this list of conditions and the following disclaimer in the documentation
* materials provided with the distribution. 3. Neither the name of SCM-Manager; * and/or other materials provided with the distribution.
* nor the names of its contributors may be used to endorse or promote products * 3. Neither the name of SCM-Manager; nor the names of its
* 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" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* http://bitbucket.org/sdorra/scm-manager * http://bitbucket.org/sdorra/scm-manager
* *
*/ */
package sonia.scm.util; package sonia.scm.util;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------

View File

@@ -6,12 +6,12 @@
<parent> <parent>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<artifactId>scm</artifactId> <artifactId>scm</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
</parent> </parent>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<artifactId>scm-dao-orientdb</artifactId> <artifactId>scm-dao-orientdb</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
<name>scm-dao-orientdb</name> <name>scm-dao-orientdb</name>
<dependencies> <dependencies>
@@ -26,7 +26,7 @@
<dependency> <dependency>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<artifactId>scm-core</artifactId> <artifactId>scm-core</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
@@ -52,7 +52,7 @@
<dependency> <dependency>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<artifactId>scm-test</artifactId> <artifactId>scm-test</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>

View File

@@ -6,12 +6,12 @@
<parent> <parent>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<artifactId>scm</artifactId> <artifactId>scm</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
</parent> </parent>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<artifactId>scm-dao-xml</artifactId> <artifactId>scm-dao-xml</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
<name>scm-dao-xml</name> <name>scm-dao-xml</name>
<dependencies> <dependencies>
@@ -26,7 +26,7 @@
<dependency> <dependency>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<artifactId>scm-core</artifactId> <artifactId>scm-core</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
</dependency> </dependency>
<!-- test --> <!-- test -->
@@ -34,7 +34,7 @@
<dependency> <dependency>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<artifactId>scm-test</artifactId> <artifactId>scm-test</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>

View File

@@ -6,13 +6,13 @@
<parent> <parent>
<artifactId>scm</artifactId> <artifactId>scm</artifactId>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
</parent> </parent>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<artifactId>scm-plugin-backend</artifactId> <artifactId>scm-plugin-backend</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
<name>${project.artifactId}</name> <name>${project.artifactId}</name>
<dependencies> <dependencies>
@@ -42,7 +42,7 @@
<dependency> <dependency>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<artifactId>scm-core</artifactId> <artifactId>scm-core</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -6,13 +6,13 @@
<parent> <parent>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<artifactId>scm</artifactId> <artifactId>scm</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
</parent> </parent>
<groupId>sonia.scm.plugins</groupId> <groupId>sonia.scm.plugins</groupId>
<artifactId>scm-plugins</artifactId> <artifactId>scm-plugins</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
<name>scm-plugins</name> <name>scm-plugins</name>
<modules> <modules>
@@ -26,7 +26,7 @@
<dependency> <dependency>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<artifactId>scm-core</artifactId> <artifactId>scm-core</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>
@@ -59,7 +59,7 @@
<plugin> <plugin>
<groupId>sonia.scm.maven</groupId> <groupId>sonia.scm.maven</groupId>
<artifactId>scm-maven-plugin</artifactId> <artifactId>scm-maven-plugin</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
<executions> <executions>
<execution> <execution>
<phase>process-resources</phase> <phase>process-resources</phase>

View File

@@ -6,12 +6,12 @@
<parent> <parent>
<artifactId>scm-plugins</artifactId> <artifactId>scm-plugins</artifactId>
<groupId>sonia.scm.plugins</groupId> <groupId>sonia.scm.plugins</groupId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
</parent> </parent>
<groupId>sonia.scm.plugins</groupId> <groupId>sonia.scm.plugins</groupId>
<artifactId>scm-git-plugin</artifactId> <artifactId>scm-git-plugin</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
<name>scm-git-plugin</name> <name>scm-git-plugin</name>
<url>https://bitbucket.org/sdorra/scm-manager</url> <url>https://bitbucket.org/sdorra/scm-manager</url>
<description>Plugin for the version control system Git</description> <description>Plugin for the version control system Git</description>
@@ -55,7 +55,7 @@
<dependency> <dependency>
<groupId>sonia.scm</groupId> <groupId>sonia.scm</groupId>
<artifactId>scm-test</artifactId> <artifactId>scm-test</artifactId>
<version>1.17-SNAPSHOT</version> <version>1.18-SNAPSHOT</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>

View File

@@ -37,6 +37,7 @@ package sonia.scm.repository;
import org.eclipse.jgit.api.BlameCommand; import org.eclipse.jgit.api.BlameCommand;
import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.blame.BlameResult; import org.eclipse.jgit.blame.BlameResult;
import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.PersonIdent; import org.eclipse.jgit.lib.PersonIdent;
@@ -128,7 +129,7 @@ public class GitBlameViewer implements BlameViewer
{ {
RevCommit commit = gitBlameResult.getSourceCommit(i); RevCommit commit = gitBlameResult.getSourceCommit(i);
if ( commit != null ) if (commit != null)
{ {
PersonIdent author = gitBlameResult.getSourceAuthor(i); PersonIdent author = gitBlameResult.getSourceAuthor(i);
BlameLine blameLine = new BlameLine(); BlameLine blameLine = new BlameLine();
@@ -136,7 +137,6 @@ public class GitBlameViewer implements BlameViewer
blameLine.setLineNumber(i + 1); blameLine.setLineNumber(i + 1);
blameLine.setAuthor(new Person(author.getName(), blameLine.setAuthor(new Person(author.getName(),
author.getEmailAddress())); author.getEmailAddress()));
blameLine.setDescription(commit.getShortMessage()); blameLine.setDescription(commit.getShortMessage());
long when = GitUtil.getCommitTime(commit); long when = GitUtil.getCommitTime(commit);
@@ -160,6 +160,10 @@ public class GitBlameViewer implements BlameViewer
{ {
logger.error("could not open repository", ex); logger.error("could not open repository", ex);
} }
catch (GitAPIException ex)
{
logger.error("could not create blame view", ex);
}
return blameResult; return blameResult;
} }

View File

@@ -237,9 +237,9 @@ public class GitChangesetConverter implements Closeable
} }
else else
{ {
if (logger.isWarnEnabled()) if (logger.isTraceEnabled())
{ {
logger.warn("no parent at position 0 for commit {}", commit); logger.trace("no parent at position 0 for commit {}", commit);
} }
treeWalk.addTree(new EmptyTreeIterator()); treeWalk.addTree(new EmptyTreeIterator());
@@ -247,9 +247,9 @@ public class GitChangesetConverter implements Closeable
} }
else else
{ {
if (logger.isWarnEnabled()) if (logger.isTraceEnabled())
{ {
logger.warn("no parent available for commit {}", commit); logger.trace("no parent available for commit {}", commit);
} }
treeWalk.addTree(new EmptyTreeIterator()); treeWalk.addTree(new EmptyTreeIterator());

Some files were not shown because too many files have changed in this diff Show More