
com.github.panchitoboy.common.ecb.boundary.RestBoundary Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common-ecb Show documentation
Show all versions of common-ecb Show documentation
Libreria de ayuda la generacion de servicios REST
The newest version!
package com.github.panchitoboy.common.ecb.boundary;
import java.io.IOException;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
public abstract class RestBoundary extends Boundary {
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response list() throws IOException {
return Response.status(200).entity(findAll()).build();
}
@GET
@Path("{id}")
@Produces(MediaType.APPLICATION_JSON)
public Response element(@PathParam("id") long id) {
return Response.status(200).entity(find(id)).build();
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response insert(T instance) {
return Response.status(200).entity(create(instance)).build();
}
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response renovate(T instance) {
return Response.status(200).entity(update(instance)).build();
}
@DELETE
@Path("{id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response delete(@PathParam("id") long id) {
return Response.status(200).entity(remove(id)).build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy