mark url of repository as deprecated

This commit is contained in:
Sebastian Sdorra
2012-06-15 18:30:34 +02:00
parent d9cedfd8b1
commit 2e8481e63f
2 changed files with 85 additions and 1 deletions

View File

@@ -39,6 +39,7 @@ import com.google.common.base.Objects;
import sonia.scm.BasicPropertiesAware;
import sonia.scm.ModelObject;
import sonia.scm.util.HttpUtil;
import sonia.scm.util.Util;
import sonia.scm.util.ValidationUtil;
@@ -164,6 +165,22 @@ public class Repository extends BasicPropertiesAware implements ModelObject
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.
*
@@ -343,7 +360,9 @@ public class Repository extends BasicPropertiesAware implements ModelObject
*
*
* @return base url
* @deprecated use {@link #createUrl(String)}
*/
@Deprecated
public String getUrl()
{
return url;
@@ -511,7 +530,9 @@ public class Repository extends BasicPropertiesAware implements ModelObject
*
*
* @param url base url
* @deprecated
*/
@Deprecated
public void setUrl(String url)
{
this.url = url;
@@ -550,6 +571,8 @@ public class Repository extends BasicPropertiesAware implements ModelObject
/** Field description */
private String type;
/** Field description */
/**
* @deprecated use {@link #createUrl(java.lang.String)} instead
*/
private String url;
}

View File

@@ -0,0 +1,61 @@
/**
* 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/"));
}
}