improve AbstractRepositoryHandler

This commit is contained in:
Sebastian Sdorra
2010-09-20 09:51:27 +02:00
parent c24d099273
commit 1581e31398
4 changed files with 74 additions and 62 deletions

View File

@@ -18,7 +18,7 @@ import javax.xml.bind.annotation.XmlRootElement;
* @author Sebastian Sdorra
*/
@XmlRootElement(name = "config")
public class HgConfig
public class HgConfig extends BasicRepositoryConfig
{
/**
@@ -29,16 +29,6 @@ public class HgConfig
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public String getBaseUrl()
{
return baseUrl;
}
/**
* Method description
@@ -64,17 +54,6 @@ public class HgConfig
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param baseUrl
*/
public void setBaseUrl(String baseUrl)
{
this.baseUrl = baseUrl;
}
/**
* Method description
*
@@ -99,8 +78,6 @@ public class HgConfig
//~--- fields ---------------------------------------------------------------
/** Field description */
private String baseUrl;
/** Field description */
private String hgBinary = "hg";

View File

@@ -261,31 +261,6 @@ public class HgRepositoryHandler extends AbstractRepositoryHandler<HgConfig>
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param repository
*
* @return
*/
@Override
protected String buildUrl(Repository repository)
{
String url = config.getBaseUrl();
if (Util.isNotEmpty(url))
{
if (!url.endsWith("/"))
{
url = url.concat("/");
}
url = url.concat(repository.getName());
}
return url;
}
//~--- get methods ----------------------------------------------------------

View File

@@ -10,6 +10,7 @@ package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.SCMContextProvider;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
@@ -27,21 +28,10 @@ import javax.xml.bind.JAXB;
*
* @param <C>
*/
public abstract class AbstractRepositoryHandler<C> implements RepositoryHandler
public abstract class AbstractRepositoryHandler<C extends BasicRepositoryConfig>
implements RepositoryHandler
{
/**
* Method description
*
*
* @param repository
*
* @return
*/
protected abstract String buildUrl(Repository repository);
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
@@ -146,6 +136,31 @@ public abstract class AbstractRepositoryHandler<C> implements RepositoryHandler
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param repository
*
* @return
*/
protected String buildUrl(Repository repository)
{
String url = config.getBaseUrl();
if (Util.isNotEmpty(url))
{
if (!url.endsWith("/"))
{
url = url.concat("/");
}
url = url.concat(repository.getName());
}
return url;
}
/**
* Method description
*

View File

@@ -0,0 +1,45 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sonia.scm.repository;
/**
*
* @author Sebastian Sdorra
*/
public class BasicRepositoryConfig
{
/**
* Method description
*
*
* @return
*/
public String getBaseUrl()
{
return baseUrl;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param baseUrl
*/
public void setBaseUrl(String baseUrl)
{
this.baseUrl = baseUrl;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private String baseUrl;
}