Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
titleSample Code
@Path("/user")
public class UserRestServices
{
    private String genPassword()

    @GET
    @Path("/sayhello")
    @Produces(MediaType.TEXT_HTML)
    public String sayHtmlHelloTest() 
    // Test entry point, call this from url in browser to make sure service up and running

    @POST@GET
    @Path("/cu/{user}")
    @Produces(MediaType.APPLICATION_JSON)
    public Response createUser(@PathParam("user") String userId) 
    // create a user from url in browser, calls __createUser

    @POST
    @Path("/cu")
    @Consumes(MediaType.APPLICATION_JSON)
    public Response createUserFromObject(User usr) 
    // create a user from java marshalled object, calls __createUser
    
    private Response    __createUser( User usr )
    // actually makes call to DB

    @DELETE
    @Path("/du")
    @Consumes(MediaType.APPLICATION_JSON)
    public Response deleteUser(User us)
    // deletes a user if they exist in DB

    @PUT
    @Path("/uu/{user}")
    @Consumes(MediaType.APPLICATION_JSON)
    public Response updateUser(User us)
    // updates a user if they exist in DB

    @GET
    @Path("/fu/{user}/{pwd}")
    @Produces(MediaType.APPLICATION_JSON)
    public Response findUser(@PathParam("user") String userId, @PathParam("pwd") String pwd)
    // finds a user if they exist in the DB
}

...