View Javadoc
1   /*******************************************************************************
2    *   Gisgraphy Project 
3    * 
4    *   This library is free software; you can redistribute it and/or
5    *   modify it under the terms of the GNU Lesser General Public
6    *   License as published by the Free Software Foundation; either
7    *   version 2.1 of the License, or (at your option) any later version.
8    * 
9    *   This library is distributed in the hope that it will be useful,
10   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   *   Lesser General Public License for more details.
13   * 
14   *   You should have received a copy of the GNU Lesser General Public
15   *   License along with this library; if not, write to the Free Software
16   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
17   * 
18   *  Copyright 2008  Gisgraphy project 
19   *  David Masclet <davidmasclet@gisgraphy.com>
20   *  
21   *  
22   *******************************************************************************/
23  package com.gisgraphy.service;
24  
25  import java.util.List;
26  
27  import org.springframework.security.userdetails.UsernameNotFoundException;
28  
29  import com.gisgraphy.dao.UserDao;
30  import com.gisgraphy.model.User;
31  
32  /**
33   * Business Service Interface to handle communication between web and
34   * persistence layer.
35   * 
36   * @author <a href="mailto:matt@raibledesigns.com">Matt Raible</a> Modified by
37   *         <a href="mailto:dan@getrolling.com">Dan Kibler </a>
38   */
39  public interface UserManager extends UniversalManager {
40  
41      /**
42       * Convenience method for testing - allows you to mock the DAO and set it on
43       * an interface.
44       * 
45       * @param userDao
46       *                the UserDao implementation to use
47       */
48      void setUserDao(UserDao userDao);
49  
50      /**
51       * Retrieves a user by userId. An exception is thrown if user not found
52       * 
53       * @param userId
54       *                the identifier for the user
55       * @return User
56       */
57      User getUser(String userId);
58  
59      /**
60       * Finds a user by their username.
61       * 
62       * @param username
63       *                the user's username used to login
64       * @return User a populated user object
65       * @throws org.acegisecurity.userdetails.UsernameNotFoundException
66       *                 exception thrown when user not found
67       */
68      User getUserByUsername(String username) throws UsernameNotFoundException;
69  
70      /**
71       * Retrieves a list of users, filtering with parameters on a user object
72       * 
73       * @param user
74       *                parameters to filter on
75       * @return List
76       */
77      List<User> getUsers(User user);
78  
79      /**
80       * Saves a user's information
81       * 
82       * @param user
83       *                the user's information
84       * @throws UserExistsException
85       *                 thrown when user already exists
86       * @return user the updated user object
87       */
88      User saveUser(User user) throws UserExistsException;
89  
90      /**
91       * Removes a user from the database by their userId
92       * 
93       * @param userId
94       *                the user's id
95       */
96      void removeUser(String userId);
97  }