mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
added webservice method for fetch tags of a repository
This commit is contained in:
@@ -61,6 +61,7 @@ import sonia.scm.repository.RepositoryIsNotArchivedException;
|
|||||||
import sonia.scm.repository.RepositoryManager;
|
import sonia.scm.repository.RepositoryManager;
|
||||||
import sonia.scm.repository.RepositoryNotFoundException;
|
import sonia.scm.repository.RepositoryNotFoundException;
|
||||||
import sonia.scm.repository.RepositoryUtil;
|
import sonia.scm.repository.RepositoryUtil;
|
||||||
|
import sonia.scm.repository.Tags;
|
||||||
import sonia.scm.repository.api.BlameCommandBuilder;
|
import sonia.scm.repository.api.BlameCommandBuilder;
|
||||||
import sonia.scm.repository.api.BrowseCommandBuilder;
|
import sonia.scm.repository.api.BrowseCommandBuilder;
|
||||||
import sonia.scm.repository.api.CatCommandBuilder;
|
import sonia.scm.repository.api.CatCommandBuilder;
|
||||||
@@ -133,8 +134,8 @@ public class RepositoryResource
|
|||||||
* @param blameViewerUtil
|
* @param blameViewerUtil
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public RepositoryResource(
|
public RepositoryResource(ScmConfiguration configuration,
|
||||||
ScmConfiguration configuration, RepositoryManager repositoryManager,
|
RepositoryManager repositoryManager,
|
||||||
Provider<WebSecurityContext> securityContextProvider,
|
Provider<WebSecurityContext> securityContextProvider,
|
||||||
RepositoryServiceFactory servicefactory)
|
RepositoryServiceFactory servicefactory)
|
||||||
{
|
{
|
||||||
@@ -343,8 +344,7 @@ public class RepositoryResource
|
|||||||
@TypeHint(BlameResult.class)
|
@TypeHint(BlameResult.class)
|
||||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||||
public Response getBlame(@PathParam("id") String id,
|
public Response getBlame(@PathParam("id") String id,
|
||||||
@QueryParam("revision") String revision,
|
@QueryParam("revision") String revision, @QueryParam("path") String path)
|
||||||
@QueryParam("path") String path)
|
|
||||||
throws RepositoryException, IOException
|
throws RepositoryException, IOException
|
||||||
{
|
{
|
||||||
Response response = null;
|
Response response = null;
|
||||||
@@ -419,8 +419,7 @@ public class RepositoryResource
|
|||||||
@TypeHint(BrowserResult.class)
|
@TypeHint(BrowserResult.class)
|
||||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||||
public Response getBrowserResult(@PathParam("id") String id,
|
public Response getBrowserResult(@PathParam("id") String id,
|
||||||
@QueryParam("revision") String revision,
|
@QueryParam("revision") String revision, @QueryParam("path") String path)
|
||||||
@QueryParam("path") String path)
|
|
||||||
throws RepositoryException, IOException
|
throws RepositoryException, IOException
|
||||||
{
|
{
|
||||||
Response response = null;
|
Response response = null;
|
||||||
@@ -611,8 +610,7 @@ public class RepositoryResource
|
|||||||
@TypeHint(ChangesetPagingResult.class)
|
@TypeHint(ChangesetPagingResult.class)
|
||||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||||
public Response getChangesets(@PathParam("id") String id,
|
public Response getChangesets(@PathParam("id") String id,
|
||||||
@QueryParam("path") String path,
|
@QueryParam("path") String path, @QueryParam("revision") String revision,
|
||||||
@QueryParam("revision") String revision,
|
|
||||||
@DefaultValue("0")
|
@DefaultValue("0")
|
||||||
@QueryParam("start") int start, @DefaultValue("20")
|
@QueryParam("start") int start, @DefaultValue("20")
|
||||||
@QueryParam("limit") int limit) throws RepositoryException, IOException
|
@QueryParam("limit") int limit) throws RepositoryException, IOException
|
||||||
@@ -689,8 +687,7 @@ public class RepositoryResource
|
|||||||
@TypeHint(StreamingOutput.class)
|
@TypeHint(StreamingOutput.class)
|
||||||
@Produces({ MediaType.APPLICATION_OCTET_STREAM })
|
@Produces({ MediaType.APPLICATION_OCTET_STREAM })
|
||||||
public Response getContent(@PathParam("id") String id,
|
public Response getContent(@PathParam("id") String id,
|
||||||
@QueryParam("revision") String revision,
|
@QueryParam("revision") String revision, @QueryParam("path") String path)
|
||||||
@QueryParam("path") String path)
|
|
||||||
{
|
{
|
||||||
Response response = null;
|
Response response = null;
|
||||||
StreamingOutput output = null;
|
StreamingOutput output = null;
|
||||||
@@ -762,8 +759,7 @@ public class RepositoryResource
|
|||||||
@TypeHint(DiffStreamingOutput.class)
|
@TypeHint(DiffStreamingOutput.class)
|
||||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||||
public Response getDiff(@PathParam("id") String id,
|
public Response getDiff(@PathParam("id") String id,
|
||||||
@QueryParam("revision") String revision,
|
@QueryParam("revision") String revision, @QueryParam("path") String path)
|
||||||
@QueryParam("path") String path)
|
|
||||||
throws RepositoryException, IOException
|
throws RepositoryException, IOException
|
||||||
{
|
{
|
||||||
AssertUtil.assertIsNotEmpty(id);
|
AssertUtil.assertIsNotEmpty(id);
|
||||||
@@ -816,6 +812,66 @@ public class RepositoryResource
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all {@link Tags} of a repository.<br />
|
||||||
|
* <br />
|
||||||
|
* Status codes:
|
||||||
|
* <ul>
|
||||||
|
* <li>200 get successful</li>
|
||||||
|
* <li>400 bad request, the content feature is not
|
||||||
|
* supported by this type of repositories.</li>
|
||||||
|
* <li>404 not found, if the repository or the path could not be found</li>
|
||||||
|
* <li>500 internal server error</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @param id the id of the repository
|
||||||
|
*
|
||||||
|
* @return all {@link Tags} of a repository
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
|
*
|
||||||
|
* @since 1.18
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Path("{id}/tags")
|
||||||
|
public Response getTags(@PathParam("id") String id)
|
||||||
|
throws RepositoryException, IOException
|
||||||
|
{
|
||||||
|
Response response = null;
|
||||||
|
RepositoryService service = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
service = servicefactory.create(id);
|
||||||
|
|
||||||
|
Tags tags = service.getTagsCommand().getTags();
|
||||||
|
|
||||||
|
if (tags != null)
|
||||||
|
{
|
||||||
|
response = Response.ok(tags).build();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
response = Response.status(Status.NOT_FOUND).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (RepositoryNotFoundException ex)
|
||||||
|
{
|
||||||
|
response = Response.status(Response.Status.NOT_FOUND).build();
|
||||||
|
}
|
||||||
|
catch (CommandNotSupportedException ex)
|
||||||
|
{
|
||||||
|
response = Response.status(Response.Status.BAD_REQUEST).build();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Closeables.closeQuietly(service);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user