added client method to fetch a single changeset

This commit is contained in:
Sebastian Sdorra
2012-01-19 16:05:57 +01:00
parent ce6558f256
commit fbd971fd9a
5 changed files with 113 additions and 0 deletions

View File

@@ -35,6 +35,7 @@ package sonia.scm.client;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.Changeset;
import sonia.scm.repository.ChangesetPagingResult;
/**
@@ -45,6 +46,18 @@ import sonia.scm.repository.ChangesetPagingResult;
public interface ClientChangesetHandler
{
/**
* Method description
*
*
* @param revision
*
* @return
*
* @since 1.12
*/
public Changeset getChangeset(String revision);
/**
* Method description
*

View File

@@ -35,6 +35,7 @@ package sonia.scm.client;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.Changeset;
import sonia.scm.repository.ChangesetPagingResult;
import sonia.scm.repository.Repository;
@@ -66,6 +67,42 @@ public class JerseyClientChangesetHandler implements ClientChangesetHandler
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param revision
*
* @return
*/
@Override
public Changeset getChangeset(String revision)
{
Changeset changeset = null;
String url =
session.getUrlProvider().getRepositoryUrlProvider().getChangesetUrl(
repository.getId(), revision);
WebResource resource = session.getClient().resource(url);
ClientResponse response = null;
try
{
response = resource.get(ClientResponse.class);
if (response.getStatus() != ScmClientException.SC_NOTFOUND)
{
ClientUtil.checkResponse(response, 200);
changeset = response.getEntity(Changeset.class);
}
}
finally
{
ClientUtil.close(response);
}
return changeset;
}
/**
* Method description
*

View File

@@ -79,6 +79,19 @@ public interface RepositoryUrlProvider extends ModelUrlProvider
public String getChangesetUrl(String repositoryId, String path,
String revision, int start, int limit);
/**
* Method description
*
*
* @param repositoryId
* @param revision
*
* @return
*
* @since 1.12
*/
public String getChangesetUrl(String repositoryId, String revision);
/**
* Method description
*

View File

@@ -63,6 +63,11 @@ public class RestRepositoryUrlProvider extends RestModelUrlProvider
/** Field description */
public static final String PART_BROWSE = "browse";
/**
* @since 1.12
*/
public static final String PART_CHANGESET = "changeset";
/** Field description */
public static final String PART_CHANGESETS = "changesets";
@@ -177,6 +182,26 @@ public class RestRepositoryUrlProvider extends RestModelUrlProvider
PARAMETER_LIMIT, limit).toString();
}
/**
* Method description
*
*
* @param repositoryId
* @param revision
*
* @return
*
* @since 1.12
*/
@Override
public String getChangesetUrl(String repositoryId, String revision)
{
revision = UrlUtil.fixRevision(revision);
return new UrlBuilder(base).appendUrlPart(repositoryId).appendUrlPart(
PART_CHANGESET).appendUrlPart(revision).append(extension).toString();
}
/**
* Method description
*

View File

@@ -64,6 +64,11 @@ public class WUIRepositoryUrlProvider extends WUIModelUrlProvider
/** Field description */
public static final String VIEW_BLAME = "blame";
/**
* @since 1.12
*/
public static final String VIEW_CHANGESET = "changeset";
/** Field description */
public static final String VIEW_CONTENT = "content";
@@ -167,6 +172,26 @@ public class WUIRepositoryUrlProvider extends WUIModelUrlProvider
repositoryId).append(start).append(limit).toString();
}
/**
* Method description
*
*
* @param repositoryId
* @param revision
*
* @return
*
* @since 1.12
*/
@Override
public String getChangesetUrl(String repositoryId, String revision)
{
revision = UrlUtil.fixRevision(revision);
return new WUIUrlBuilder(baseUrl, VIEW_CHANGESET).append(
repositoryId).append(revision).toString();
}
/**
* Method description
*