Blame view

src/main/java/fr/plil/sio/persistence/jdbc/RightServiceJdbc.java 1.76 KB
a800fde0   jcartign   First version, in...
1
2
3
4
  package fr.plil.sio.persistence.jdbc;
  
  import fr.plil.sio.persistence.api.Right;
  import fr.plil.sio.persistence.api.RightService;
a54db7eb   msahmane   Ajout des fichier...
5
  import fr.plil.sio.persistence.api.User;
a800fde0   jcartign   First version, in...
6
7
  import org.springframework.stereotype.Service;
  
5418cb05   jcartign   Javadoc of API is...
8
  import java.util.List;
a54db7eb   msahmane   Ajout des fichier...
9
  import org.springframework.beans.factory.annotation.Autowired;
5418cb05   jcartign   Javadoc of API is...
10
  
a800fde0   jcartign   First version, in...
11
  @Service
292aec6f   jcartign   First version bef...
12
  public class RightServiceJdbc implements RightService {
a54db7eb   msahmane   Ajout des fichier...
13
14
15
16
17
      
      @Autowired
      private RightRepository rightRepository;
      
      
a800fde0   jcartign   First version, in...
18
19
      @Override
      public Right create(String name) {
a54db7eb   msahmane   Ajout des fichier...
20
21
22
23
24
25
26
27
28
29
30
        if (name == null) {
              throw new IllegalArgumentException("name cannot be null");
          }
          Right right = rightRepository.findByName(name);
          if (right != null) {
              throw new IllegalStateException("a group with the same name already exists");
          }
          right = new Right();
          right.setName(name);
          rightRepository.save(right);
          return right;
a800fde0   jcartign   First version, in...
31
32
33
34
      }
  
      @Override
      public Right create(String name, Right parent) {
a54db7eb   msahmane   Ajout des fichier...
35
36
37
38
39
40
41
42
43
44
45
46
          if(name == null || parent == null)
              throw new IllegalArgumentException("Name cannot be null");
          
          Right right = rightRepository.findByName(parent.getName());
          if(right != null)
              throw new IllegalStateException("A right with the same name already exists");
          
          right = new Right();
          right.setName(name);
          rightRepository.save(right);
          
          return right;
a800fde0   jcartign   First version, in...
47
48
49
      }
  
      @Override
5418cb05   jcartign   Javadoc of API is...
50
      public boolean delete(Right right) {
292aec6f   jcartign   First version bef...
51
          throw new IllegalStateException("not implemented !");
a800fde0   jcartign   First version, in...
52
53
54
      }
  
      @Override
5418cb05   jcartign   Javadoc of API is...
55
      public List<Right> findByName(String name) {
292aec6f   jcartign   First version bef...
56
          throw new IllegalStateException("not implemented !");
5418cb05   jcartign   Javadoc of API is...
57
58
59
60
      }
  
      @Override
      public Right findOne(Long id) {
292aec6f   jcartign   First version bef...
61
          throw new IllegalStateException("not implemented !");
a800fde0   jcartign   First version, in...
62
63
      }
  }