Blame view

src/main/java/fr/plil/sio/persistence/api/UserService.java 1.84 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
      /**
       * 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.
33ac96dc   jcartign   More in-lab fixes
8
       * Only references at one level are loaded (i.e. the group where the user belong).
5418cb05   jcartign   Javadoc of API is...
9
10
       *
       * @param name the name of the user
f2ed17f6   jcartign   upgrading Javadoc
11
       * @param groupName the name of the group
5418cb05   jcartign   Javadoc of API is...
12
13
14
15
16
       * @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...
17
  
5418cb05   jcartign   Javadoc of API is...
18
19
20
21
22
23
24
25
      /**
       * 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...
26
  
5418cb05   jcartign   Javadoc of API is...
27
28
29
30
31
32
33
      /**
       * 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...
34
35
      User findByName(String name);
  
5418cb05   jcartign   Javadoc of API is...
36
37
38
39
40
41
42
43
44
45
      /**
       * 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...
46
  }