mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 08:25:44 +01:00
improve ChangesetViewer api
This commit is contained in:
@@ -69,6 +69,9 @@ public interface RepositoryHandler
|
|||||||
*
|
*
|
||||||
* @param repository
|
* @param repository
|
||||||
* @return null if ChangesetViewer is not supported
|
* @return null if ChangesetViewer is not supported
|
||||||
|
*
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
public ChangesetViewer getChangesetViewer(Repository repository);
|
public ChangesetViewer getChangesetViewer(Repository repository)
|
||||||
|
throws RepositoryException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,19 @@ public interface RepositoryManager
|
|||||||
*/
|
*/
|
||||||
public Repository get(String type, String name);
|
public Repository get(String type, String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param repository
|
||||||
|
* @return null if ChangesetViewer is not supported
|
||||||
|
*
|
||||||
|
* @throws RepositoryException
|
||||||
|
*/
|
||||||
|
public ChangesetViewer getChangesetViewer(Repository repository)
|
||||||
|
throws RepositoryException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -120,6 +120,8 @@ public class RepositoryResource
|
|||||||
* @param max
|
* @param max
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
*
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}/changesets")
|
@Path("{id}/changesets")
|
||||||
@@ -127,41 +129,31 @@ public class RepositoryResource
|
|||||||
public Response getChangesets(@PathParam("id") String id,
|
public Response getChangesets(@PathParam("id") String id,
|
||||||
@QueryParam("changeset") String startId,
|
@QueryParam("changeset") String startId,
|
||||||
@DefaultValue("25") @QueryParam("max") int max)
|
@DefaultValue("25") @QueryParam("max") int max)
|
||||||
|
throws RepositoryException
|
||||||
{
|
{
|
||||||
Response response = null;
|
Response response = null;
|
||||||
Repository repository = repositoryManager.get(id);
|
Repository repository = repositoryManager.get(id);
|
||||||
|
|
||||||
if (repository != null)
|
if (repository != null)
|
||||||
{
|
{
|
||||||
RepositoryHandler handler =
|
ChangesetViewer changesetViewer =
|
||||||
repositoryManager.getHandler(repository.getType());
|
repositoryManager.getChangesetViewer(repository);
|
||||||
|
|
||||||
if (handler != null)
|
if (changesetViewer != null)
|
||||||
{
|
{
|
||||||
ChangesetViewer changesetViewer =
|
List<Changeset> changesets = null;
|
||||||
handler.getChangesetViewer(repository);
|
|
||||||
|
|
||||||
if (changesetViewer != null)
|
if (Util.isNotEmpty(startId))
|
||||||
{
|
{
|
||||||
List<Changeset> changesets = null;
|
changesets = changesetViewer.getChangesets(startId, max);
|
||||||
|
|
||||||
if (Util.isNotEmpty(startId))
|
|
||||||
{
|
|
||||||
changesets = changesetViewer.getChangesets(startId, max);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
changesets = changesetViewer.getLastChangesets(max);
|
|
||||||
}
|
|
||||||
|
|
||||||
response =
|
|
||||||
Response.ok(new GenericEntity<List<Changeset>>(changesets) {}
|
|
||||||
).build();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
response = Response.status(Response.Status.NOT_FOUND).build();
|
changesets = changesetViewer.getLastChangesets(max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
response = Response.ok(new GenericEntity<List<Changeset>>(changesets) {}
|
||||||
|
).build();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import sonia.scm.HandlerEvent;
|
|||||||
import sonia.scm.SCMContextProvider;
|
import sonia.scm.SCMContextProvider;
|
||||||
import sonia.scm.Type;
|
import sonia.scm.Type;
|
||||||
import sonia.scm.repository.AbstractRepositoryManager;
|
import sonia.scm.repository.AbstractRepositoryManager;
|
||||||
|
import sonia.scm.repository.ChangesetViewer;
|
||||||
import sonia.scm.repository.PermissionType;
|
import sonia.scm.repository.PermissionType;
|
||||||
import sonia.scm.repository.PermissionUtil;
|
import sonia.scm.repository.PermissionUtil;
|
||||||
import sonia.scm.repository.Repository;
|
import sonia.scm.repository.Repository;
|
||||||
@@ -393,6 +394,26 @@ public class XmlRepositoryManager extends AbstractRepositoryManager
|
|||||||
return repositories;
|
return repositories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param repository
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*
|
||||||
|
* @throws RepositoryException
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ChangesetViewer getChangesetViewer(Repository repository)
|
||||||
|
throws RepositoryException
|
||||||
|
{
|
||||||
|
AssertUtil.assertIsNotNull(repository);
|
||||||
|
isReader(repository);
|
||||||
|
|
||||||
|
return getHandler(repository).getChangesetViewer(repository);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user