mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 00:45:44 +01:00
improve AbstractRepositoryHandler
This commit is contained in:
@@ -18,7 +18,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(name = "config")
|
@XmlRootElement(name = "config")
|
||||||
public class HgConfig
|
public class HgConfig extends BasicRepositoryConfig
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,16 +29,6 @@ public class HgConfig
|
|||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String getBaseUrl()
|
|
||||||
{
|
|
||||||
return baseUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
@@ -64,17 +54,6 @@ public class HgConfig
|
|||||||
|
|
||||||
//~--- set methods ----------------------------------------------------------
|
//~--- set methods ----------------------------------------------------------
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param baseUrl
|
|
||||||
*/
|
|
||||||
public void setBaseUrl(String baseUrl)
|
|
||||||
{
|
|
||||||
this.baseUrl = baseUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -99,8 +78,6 @@ public class HgConfig
|
|||||||
|
|
||||||
//~--- fields ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
/** Field description */
|
|
||||||
private String baseUrl;
|
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private String hgBinary = "hg";
|
private String hgBinary = "hg";
|
||||||
|
|||||||
@@ -261,31 +261,6 @@ public class HgRepositoryHandler extends AbstractRepositoryHandler<HgConfig>
|
|||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
//~--- 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 ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ package sonia.scm.repository;
|
|||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
import sonia.scm.SCMContextProvider;
|
import sonia.scm.SCMContextProvider;
|
||||||
|
import sonia.scm.util.Util;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
@@ -27,21 +28,10 @@ import javax.xml.bind.JAXB;
|
|||||||
*
|
*
|
||||||
* @param <C>
|
* @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
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -146,6 +136,31 @@ public abstract class AbstractRepositoryHandler<C> implements RepositoryHandler
|
|||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
//~--- 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
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user