View Javadoc

1   package net.ramapuram.thomas.service;
2   
3   import net.ramapuram.thomas.dao.UserDao;
4   import net.ramapuram.thomas.model.User;
5   import org.springframework.security.core.userdetails.UsernameNotFoundException;
6   
7   import java.util.List;
8   
9   
10  /**
11   * Business Service Interface to handle communication between web and
12   * persistence layer.
13   *
14   * @author <a href="mailto:matt@raibledesigns.com">Matt Raible</a>
15   *  Modified by <a href="mailto:dan@getrolling.com">Dan Kibler </a> 
16   */
17  public interface UserManager extends GenericManager<User, Long> {
18      /**
19       * Convenience method for testing - allows you to mock the DAO and set it on an interface.
20       * @param userDao the UserDao implementation to use
21       */
22      void setUserDao(UserDao userDao);
23  
24      /**
25       * Retrieves a user by userId.  An exception is thrown if user not found
26       *
27       * @param userId the identifier for the user
28       * @return User
29       */
30      User getUser(String userId);
31  
32      /**
33       * Finds a user by their username.
34       * @param username the user's username used to login
35       * @return User a populated user object
36       * @throws org.springframework.security.core.userdetails.UsernameNotFoundException
37       *         exception thrown when user not found
38       */
39      User getUserByUsername(String username) throws UsernameNotFoundException;
40  
41      /**
42       * Retrieves a list of all users.
43       * @return List
44       */
45      List<User> getUsers();
46  
47      /**
48       * Saves a user's information.
49       *
50       * @param user the user's information
51       * @throws UserExistsException thrown when user already exists
52       * @return user the updated user object
53       */
54      User saveUser(User user) throws UserExistsException;
55  
56      /**
57       * Removes a user from the database by their userId
58       *
59       * @param userId the user's id
60       */
61      void removeUser(String userId);
62  
63      /**
64       * Search a user for search terms.
65       * @param searchTerm the search terms.
66       * @return a list of matches, or all if no searchTerm.
67       */
68      List<User> search(String searchTerm);
69  }