Blame view

src/main/java/fr/plil/sio/persistence/api/UserService.java 1.76 KB
a800fde0   jcartign   First version, in...
1
2
3
4
  package fr.plil.sio.persistence.api;
  
  public interface UserService {
  
5418cb05   jcartign   Javadoc of API is...
5
6
7
8
9
      /**
       * Create an user with a specific name in the database and affected to an existing group.
       * There is no two users with the same name in the database.
       *
       * @param name the name of the user
f2ed17f6   jcartign   upgrading Javadoc
10
       * @param groupName the name of the group
5418cb05   jcartign   Javadoc of API is...
11
12
13
14
15
       * @return an instance of the user
       * @throws IllegalArgumentException if name or groupName is null, or if group does not exist.
       * @throws IllegalStateException    if an user with the same name is already present
       */
      User create(String name, String groupName);
a800fde0   jcartign   First version, in...
16
  
5418cb05   jcartign   Javadoc of API is...
17
18
19
20
21
22
23
24
      /**
       * Delete an user in the database.
       *
       * @param name the name of the user to remove
       * @return true if user has been deleted, false if user is not found in the database.
       * @throws IllegalArgumentException if name is null
       */
      boolean delete(String name);
a800fde0   jcartign   First version, in...
25
  
5418cb05   jcartign   Javadoc of API is...
26
27
28
29
30
31
32
      /**
       * Find an user in the database based on its name.
       *
       * @param name the name of the user to search for.
       * @return an instance of the user if found, else null.
       * @throws IllegalArgumentException if name is null
       */
a800fde0   jcartign   First version, in...
33
34
      User findByName(String name);
  
5418cb05   jcartign   Javadoc of API is...
35
36
37
38
39
40
41
42
43
44
      /**
       * Check method to control if an user has a specific right. The following rule is used: an user has a specific
       * right if the group where the user is contains the specific right or one of its parents.
       *
       * @param userName the name of the user
       * @param right    the specific right
       * @return true if the group where the user is contains the specific right or one of its parents, false else.
       * @throws IllegalArgumentException if userName or right is null, or if the user or right does not exist in the db.
       */
      boolean isUserHasRight(String userName, Right right);
a800fde0   jcartign   First version, in...
45
  }