generate repository urls

This commit is contained in:
Sebastian Sdorra
2010-11-19 19:17:54 +01:00
parent f8699c3318
commit 7bbcacf2b0
11 changed files with 121 additions and 136 deletions

View File

@@ -41,7 +41,6 @@ import org.slf4j.LoggerFactory;
import sonia.scm.ConfigChangedListener;
import sonia.scm.SCMContextProvider;
import sonia.scm.util.IOUtil;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
@@ -60,7 +59,7 @@ import javax.xml.bind.JAXB;
*
* @param <C>
*/
public abstract class AbstractRepositoryHandler<C extends BasicRepositoryConfig>
public abstract class AbstractRepositoryHandler<C extends SimpleRepositoryConfig>
implements RepositoryHandler
{
@@ -213,31 +212,6 @@ public abstract class AbstractRepositoryHandler<C extends BasicRepositoryConfig>
//~--- 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
*
@@ -247,7 +221,6 @@ public abstract class AbstractRepositoryHandler<C extends BasicRepositoryConfig>
protected void initNewRepository(Repository repository)
{
repository.setId(UUID.randomUUID().toString());
repository.setUrl(buildUrl(repository));
repository.setCreationDate(System.currentTimeMillis());
}

View File

@@ -43,7 +43,6 @@ import sonia.scm.SCMContextProvider;
import sonia.scm.io.CommandResult;
import sonia.scm.io.ExtendedCommand;
import sonia.scm.util.IOUtil;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
@@ -105,6 +104,24 @@ public abstract class AbstractSimpleRepositoryHandler<C extends SimpleRepository
storeRepositoryConfig(repository);
}
/**
* Method description
*
*
*
* @param repository
* @return
*/
@Override
public String createResourcePath(Repository repository)
{
StringBuilder path = new StringBuilder("/");
path.append(getType().getName()).append("/").append(repository.getName());
return path.toString();
}
/**
* Method description
*
@@ -430,15 +447,6 @@ public abstract class AbstractSimpleRepositoryHandler<C extends SimpleRepository
repository = null;
}
else
{
String url = buildUrl(repository);
if (Util.isNotEmpty(url))
{
repository.setUrl(url);
}
}
return repository;
}

View File

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

View File

@@ -46,4 +46,14 @@ import sonia.scm.ListenerSupport;
*/
public interface RepositoryHandler
extends Handler<Repository, RepositoryException>,
ListenerSupport<ConfigChangedListener> {}
ListenerSupport<ConfigChangedListener>
{
/**
* Method description
*
*
* @return
*/
public String createResourcePath( Repository repository );
}

View File

@@ -39,7 +39,7 @@ import java.io.File;
*
* @author Sebastian Sdorra
*/
public class SimpleRepositoryConfig extends BasicRepositoryConfig
public class SimpleRepositoryConfig
{
/**