Class ProductsResource


  • @Path("/products")
    public class ProductsResource
    extends Object
    This class implements the JAX-RS interface for the injected inventory management EJB logic.
    • Field Detail

      • logger

        private static final org.slf4j.Logger logger
      • request

        @Context
        private javax.ws.rs.core.Request request
      • uriInfo

        @Context
        private javax.ws.rs.core.UriInfo uriInfo
    • Constructor Detail

      • ProductsResource

        public ProductsResource()
    • Method Detail

      • createProduct

        @POST
        @Path("")
        @Consumes("application/x-www-form-urlencoded")
        @Produces({"application/xml","application/json"})
        @JsonbAnnotation
        public javax.ws.rs.core.Response createProduct​(@FormParam("name")
                                                       String name,
                                                       @FormParam("quantity")
                                                       Integer quantity,
                                                       @FormParam("price")
                                                       Double price,
                                                       @FormParam("category")
                                                       String category)
        Creates a product
        Parameters:
        product -
        category -
        Returns:
      • getProduct

        @GET
        @Path("{id}")
        @Produces({"application/xml","application/json"})
        @JsonbAnnotation
        public javax.ws.rs.core.Response getProduct​(@PathParam("id")
                                                    int id)
        Returns a specific product
        Parameters:
        id -
        Returns:
      • updateProduct

        @PUT
        @Path("{id}")
        @Consumes({"application/xml","application/json"})
        @Produces({"application/xml","application/json"})
        @JsonbAnnotation
        public javax.ws.rs.core.Response updateProduct​(@PathParam("id")
                                                       int id,
                                                       Product product)
        Updates a product with the values of the object passed in
        Parameters:
        id -
        product -
        Returns:
        updated product if successful
      • deleteProduct

        @DELETE
        @Path("{id}")
        public javax.ws.rs.core.Response deleteProduct​(@PathParam("id")
                                                       int id)
        Deletes the product identified.
        Parameters:
        id -
        Returns:
      • findProductsByName

        @GET
        @Path("")
        @Produces({"application/xml","application/json"})
        @JsonbAnnotation
        public javax.ws.rs.core.Response findProductsByName​(@QueryParam("name")
                                                            String name,
                                                            @QueryParam("offset") @DefaultValue("0")
                                                            int offset,
                                                            @QueryParam("limit") @DefaultValue("0")
                                                            int limit)
        Returns a simple list of products that match provided name
        Parameters:
        name -
        Returns: