mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 06:25:45 +01:00
simplify update method of AbstractResource
This commit is contained in:
@@ -29,6 +29,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.api.rest.resources;
|
package sonia.scm.api.rest.resources;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
@@ -40,6 +42,7 @@ import javax.ws.rs.POST;
|
|||||||
import javax.ws.rs.PUT;
|
import javax.ws.rs.PUT;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
import javax.ws.rs.WebApplicationException;
|
import javax.ws.rs.WebApplicationException;
|
||||||
import javax.ws.rs.core.Context;
|
import javax.ws.rs.core.Context;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
@@ -195,13 +198,12 @@ public abstract class AbstractResource<T>
|
|||||||
* @param name
|
* @param name
|
||||||
* @param item
|
* @param item
|
||||||
*
|
*
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
@PUT
|
@PUT
|
||||||
@Path("{name}")
|
@Path("{name}")
|
||||||
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||||
public Response update(@Context UriInfo uriInfo,
|
public void update(@Context UriInfo uriInfo, @PathParam("name") String name,
|
||||||
@PathParam("name") String name, T item)
|
T item)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -211,9 +213,6 @@ public abstract class AbstractResource<T>
|
|||||||
{
|
{
|
||||||
throw new WebApplicationException(ex);
|
throw new WebApplicationException(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response.created(
|
|
||||||
uriInfo.getAbsolutePath().resolve(getId(item))).build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
@@ -228,6 +227,7 @@ public abstract class AbstractResource<T>
|
|||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("{name}")
|
@Path("{name}")
|
||||||
|
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||||
public T get(@PathParam("name") String name)
|
public T get(@PathParam("name") String name)
|
||||||
{
|
{
|
||||||
T item = getItem(name);
|
T item = getItem(name);
|
||||||
@@ -247,6 +247,7 @@ public abstract class AbstractResource<T>
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
|
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||||
public T[] getAll()
|
public T[] getAll()
|
||||||
{
|
{
|
||||||
return getAllItems();
|
return getAllItems();
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ import javax.ws.rs.core.MediaType;
|
|||||||
*/
|
*/
|
||||||
@Path("repositories")
|
@Path("repositories")
|
||||||
@Singleton
|
@Singleton
|
||||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
|
||||||
public class RepositoryResource extends AbstractResource<Repository>
|
public class RepositoryResource extends AbstractResource<Repository>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ import javax.ws.rs.core.MediaType;
|
|||||||
*/
|
*/
|
||||||
@Path("users")
|
@Path("users")
|
||||||
@Singleton
|
@Singleton
|
||||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
|
||||||
public class UserResource extends AbstractResource<User>
|
public class UserResource extends AbstractResource<User>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user