a800fde0
jcartign
First version, in...
|
1
2
3
4
5
|
package fr.plil.sio.persistence.jdbc;
import fr.plil.sio.persistence.api.Group;
import fr.plil.sio.persistence.api.GroupService;
import fr.plil.sio.persistence.api.Right;
|
7940aa22
jcartign
Finishing API jav...
|
6
|
import org.springframework.beans.factory.annotation.Autowired;
|
a800fde0
jcartign
First version, in...
|
7
8
9
10
|
import org.springframework.stereotype.Service;
@Service
public class GroupServiceJdbc implements GroupService {
|
7940aa22
jcartign
Finishing API jav...
|
11
12
13
14
|
@Autowired
private GroupRepository groupRepository;
|
a800fde0
jcartign
First version, in...
|
15
16
|
@Override
public Group create(String name) {
|
7940aa22
jcartign
Finishing API jav...
|
17
18
19
20
21
22
23
24
25
26
27
|
if (name == null) {
throw new IllegalArgumentException("name cannot be null");
}
Group group = groupRepository.findByName(name);
if (group != null) {
throw new IllegalStateException("a group with the same name already exists");
}
group = new Group();
group.setName(name);
groupRepository.save(group);
return group;
|
a800fde0
jcartign
First version, in...
|
28
29
30
|
}
@Override
|
5418cb05
jcartign
Javadoc of API is...
|
31
|
public boolean delete(String name) {
|
292aec6f
jcartign
First version bef...
|
32
|
throw new IllegalStateException("not implemented !");
|
a800fde0
jcartign
First version, in...
|
33
34
35
36
|
}
@Override
public Group findByName(String name) {
|
7940aa22
jcartign
Finishing API jav...
|
37
38
39
40
|
if (name == null) {
throw new IllegalArgumentException("name cannot be null");
}
return groupRepository.findByName(name);
|
a800fde0
jcartign
First version, in...
|
41
42
43
|
}
@Override
|
5418cb05
jcartign
Javadoc of API is...
|
44
|
public boolean addRight(String groupName, Right right) {
|
292aec6f
jcartign
First version bef...
|
45
|
throw new IllegalStateException("not implemented !");
|
a800fde0
jcartign
First version, in...
|
46
47
48
|
}
@Override
|
5418cb05
jcartign
Javadoc of API is...
|
49
|
public boolean removeRight(String groupName, Right right) {
|
292aec6f
jcartign
First version bef...
|
50
|
throw new IllegalStateException("not implemented !");
|
a800fde0
jcartign
First version, in...
|
51
52
|
}
}
|