mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
added rest webservice method to fetch a single commit
This commit is contained in:
@@ -91,6 +91,7 @@ import javax.ws.rs.core.GenericEntity;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Request;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
import javax.ws.rs.core.StreamingOutput;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
@@ -409,7 +410,6 @@ public class RepositoryResource
|
||||
* <li>500 internal server error</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param request the current request
|
||||
* @param type the type of the repository
|
||||
* @param name the name of the repository
|
||||
*
|
||||
@@ -438,6 +438,73 @@ public class RepositoryResource
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Changeset} from the given repository
|
||||
* with the specified revision.<br />
|
||||
* <br />
|
||||
* Status codes:
|
||||
* <ul>
|
||||
* <li>200 get successful</li>
|
||||
* <li>400 bad request, the changeset feature is not
|
||||
* supported by this type of repositories.</li>
|
||||
* <li>404 not found, if the repository or
|
||||
* the revision could not be found</li>
|
||||
* <li>500 internal server error</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param id the id of the repository
|
||||
* @param revision the revision of the changeset
|
||||
*
|
||||
* @return a {@link Changeset} from the given repository
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
@GET
|
||||
@Path("{id}/changeset/{revision}")
|
||||
public Response getChangeset(@PathParam("id") String id,
|
||||
@PathParam("revision") String revision)
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
Response response = null;
|
||||
|
||||
if (Util.isNotEmpty(id) && Util.isNotEmpty(revision))
|
||||
{
|
||||
try
|
||||
{
|
||||
Changeset changeset = changesetViewerUtil.getChangeset(id, revision);
|
||||
|
||||
if (changeset != null)
|
||||
{
|
||||
response = Response.ok(changeset).build();
|
||||
}
|
||||
else
|
||||
{
|
||||
response = Response.status(Status.NOT_FOUND).build();
|
||||
}
|
||||
}
|
||||
catch (RepositoryNotFoundException ex)
|
||||
{
|
||||
response = Response.status(Response.Status.NOT_FOUND).build();
|
||||
}
|
||||
catch (NotSupportedFeatuerException ex)
|
||||
{
|
||||
response = Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isWarnEnabled())
|
||||
{
|
||||
logger.warn("id or revision is empty");
|
||||
}
|
||||
|
||||
response = Response.status(Status.BAD_REQUEST).build();
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of {@link Changeset} for the given repository.<br />
|
||||
* <br />
|
||||
|
||||
Reference in New Issue
Block a user