View Javadoc

1   package net.ramapuram.thomas.service;
2   
3   import net.ramapuram.thomas.model.User;
4   
5   import javax.jws.WebService;
6   import javax.ws.rs.DELETE;
7   import javax.ws.rs.GET;
8   import javax.ws.rs.POST;
9   import javax.ws.rs.Path;
10  import javax.ws.rs.PathParam;
11  import javax.ws.rs.Produces;
12  import java.util.List;
13  
14  /**
15   * Web Service interface so hierarchy of Generic Manager isn't carried through.
16   */
17  @WebService
18  @Path("/")
19  @Produces({"application/json", "application/xml"})
20  public interface UserService {
21      /**
22       * Retrieves a user by userId.  An exception is thrown if user not found
23       *
24       * @param userId the identifier for the user
25       * @return User
26       */
27      @GET
28      @Path("/user/{id}")
29      User getUser(@PathParam("id") String userId);
30  
31      /**
32       * Finds a user by their username.
33       *
34       * @param username the user's username used to login
35       * @return User a populated user object
36       */
37      @GET
38      @Path("/{username}")
39      User getUserByUsername(@PathParam("username") String username);
40  
41      /**
42       * Retrieves a list of all users.
43       *
44       * @return List
45       */
46      @GET
47      @Path("/users")
48      List<User> getUsers();
49  
50      /**
51       * Saves a user's information
52       *
53       * @param user the user's information
54       * @return updated user
55       * @throws UserExistsException thrown when user already exists
56       */
57      @POST
58      @Path("/user")
59      User saveUser(User user) throws UserExistsException;
60  
61      /**
62       * Removes a user from the database by their userId
63       *
64       * @param userId the user's id
65       */
66      @DELETE
67      @Path("/user")
68      void removeUser(String userId);
69  }