Blame view

src/main/java/fr/plil/sio/persistence/api/GroupService.java 1.89 KB
fd5e74ca   jcartign   First student ver...
1
2
3
4
5
6
  package fr.plil.sio.persistence.api;
  
  public interface GroupService {
  
      /**
       * Create a group with a specific name in the database.
62ed607d   jcartign   Porting update fr...
7
       * There is no two groups with the same name or the same ID in the database.
fd5e74ca   jcartign   First student ver...
8
9
10
11
       *
       * @param name the name of the group
       * @return an instance of the group
       * @throws IllegalArgumentException if name is null
62ed607d   jcartign   Porting update fr...
12
       * @throws IllegalStateException if a group with the same name is already present
fd5e74ca   jcartign   First student ver...
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
       */
      Group create(String name);
  
      /**
       * Delete a group in the database. Remove all users in the group.
       *
       * @param name the name of the group to remove
       * @return true if group has been deleted, false if group is not found in the database.
       * @throws IllegalArgumentException if name is null
       */
      boolean delete(String name);
  
      /**
       * Find a group in the database based on its name.
       *
       * @param name the name of the group to search for.
       * @return an instance of the group if found, else null.
       * @throws IllegalArgumentException if name is null
       */
      Group findByName(String name);
  
      /**
62ed607d   jcartign   Porting update fr...
35
       * Add a right in the group.
fd5e74ca   jcartign   First student ver...
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
       *
       * @param groupName the name of the group.
       * @param right     the right to add
       * @return true if right is added in the group, false if right was already present.
       * @throws IllegalArgumentException if groupName or right is null, or if group or right cannot be found.
       */
      boolean addRight(String groupName, Right right);
  
      /**
       * Remove a right associated with a group.
       *
       * @param groupName the name of the group.
       * @param right     the right to remove
       * @return true if right is removed from the group, false if teh right was not present in the group.
       * @throws IllegalArgumentException if groupName or right is null, or if group or right cannot be found.
       */
      boolean removeRight(String groupName, Right right);
  }