예제 #1
0
 @PreAuthorize("hasRole('ROLE_USER')")
 @Transactional(readOnly = false)
 public ResultClass<Integer> numberOfPages() {
   ResultClass<Integer> result = new ResultClass<>();
   result.setSingleElement(repositoryUser.numberOfPages());
   return result;
 }
예제 #2
0
 @PreAuthorize("hasRole('ROLE_USER')")
 @Transactional(readOnly = true)
 public ResultClass<User> getUser(Long id_user) {
   ResultClass<User> result = new ResultClass<>();
   result.setSingleElement(repositoryUser.getUser(id_user));
   return result;
 }
예제 #3
0
 @PreAuthorize("hasRole('ROLE_ADMIN')")
 @Transactional(propagation = Propagation.REQUIRED)
 public ResultClass<Boolean> deleteUser(Long id) {
   ResultClass<Boolean> result = new ResultClass<>();
   result.setSingleElement(repositoryUser.deleteUser(id));
   return result;
 }
예제 #4
0
 @PreAuthorize("#user.username == principal.username or hasRole('ROLE_ADMIN')")
 @Transactional(readOnly = false)
 public ResultClass<Boolean> saveUser(User user) {
   ResultClass<Boolean> result = new ResultClass<>();
   result.setSingleElement(repositoryUser.saveUser(user));
   return result;
 }
예제 #5
0
 @PreAuthorize("permitAll")
 @Transactional(readOnly = true)
 public ResultClass<User> findByUsername(String username) {
   ResultClass<User> result = new ResultClass<>();
   result.setSingleElement(repositoryUser.findByUsername(username));
   return result;
 }
예제 #6
0
 @PreAuthorize("hasRole('ROLE_USER')")
 @Transactional(readOnly = true)
 public ResultClass<User> getAll(Integer pageIndex, Boolean showAll, String typeOfUser) {
   ResultClass<User> result = new ResultClass<>();
   result.addAll(repositoryUser.getAll(pageIndex, showAll, typeOfUser));
   return result;
 }
예제 #7
0
 @PreAuthorize("hasRole('ROLE_ADMIN')")
 @Transactional(readOnly = true)
 public ResultClass<User> getAll() {
   ResultClass<User> result = new ResultClass<>();
   result.addAll(repositoryUser.getAllUsers());
   return result;
 }
예제 #8
0
 @PreAuthorize("hasPermission(#group, 'WRITE') or hasPermission(#group, 'ADMINISTRATION')")
 public Collection<User> getListUsersWithId(Group group, List<User> list) {
   // TODO Auto-generated method stub
   Collection<User> usersId = new ArrayList<User>();
   for (User u : list) {
     usersId.add(repositoryUser.findByUsername(u.getUsername()));
   }
   return usersId;
 }
예제 #9
0
  @PreAuthorize("hasRole('ROLE_ADMIN')")
  @Transactional(readOnly = true)
  public void downloadCSV(HttpServletResponse response) throws IOException {

    Collection<User> users = new ArrayList<User>();
    users = repositoryUser.getAllUsers();

    if (!users.isEmpty()) {
      UserCSV userCSV = new UserCSV();
      userCSV.downloadCSV(response, users);
    }
  }
예제 #10
0
  @PreAuthorize("hasRole('ROLE_ADMIN')")
  @Transactional(readOnly = false)
  public ResultClass<Boolean> addUser(User user) {
    ResultClass<Boolean> result = new ResultClass<>();
    StringSHA sha = new StringSHA();
    String pass = sha.getStringMessageDigest(user.getPassword());
    user.setPassword(pass);
    if (repositoryUser.addUser(user)) {
      User u = findByUsername(user.getUsername()).getSingleElement();
      manageAclService.addACLToObject(u.getId(), u.getClass().getName());

      manageAclService.addPermissionToAnObject_WRITE(u, u.getId(), u.getClass().getName());
      result.setSingleElement(true);
    } else result.setSingleElement(false);

    return result;
  }
예제 #11
0
  @PreAuthorize("hasRole('ROLE_ADMIN')")
  @Transactional(readOnly = false)
  public ResultClass<Boolean> uploadCVS(UploadForm upload, String typeOfUser, Locale locale) {
    ResultClass<Boolean> result = new ResultClass<>();
    if (!upload.getFileData().isEmpty()) {
      CsvPreference prefers =
          new CsvPreference.Builder(
                  upload.getQuoteChar().charAt(0),
                  upload.getDelimiterChar().charAt(0),
                  upload.getEndOfLineSymbols())
              .build();

      List<User> list = null;
      try {
        FileItem fileItem = upload.getFileData().getFileItem();
        UserCSV userUpload = new UserCSV();
        list =
            userUpload.readCSVUserToBean(
                fileItem.getInputStream(), upload.getCharset(), prefers, typeOfUser);
        if (list == null) {
          result.setHasErrors(true);
          result.getErrorsList().add(messageSource.getMessage("error.params", null, locale));
        } else {
          if (repositoryUser.persistListUsers(list)) {
            for (User u : list) {
              User aux = findByUsername(u.getUsername()).getSingleElement();
              manageAclService.addACLToObject(u.getId(), u.getClass().getName());
              manageAclService.addPermissionToAnObject_WRITE(
                  aux, aux.getId(), aux.getClass().getName());
            }
            result.setSingleElement(true);
          }
        }
      } catch (IOException e) {
        e.printStackTrace();
        result.setSingleElement(false);
      }
    } else {
      result.setHasErrors(true);
      result.getErrorsList().add(messageSource.getMessage("error.fileEmpty", null, locale));
    }
    return result;
  }
예제 #12
0
 @PreAuthorize("hasPermission(#group, 'WRITE') or hasPermission(#group, 'ADMINISTRATION')")
 public ResultClass<Boolean> persistListUsers(Group group, List<User> list) {
   ResultClass<Boolean> result = new ResultClass<>();
   result.setSingleElement(repositoryUser.persistListUsers(list));
   return result;
 }
예제 #13
0
 @PreAuthorize("hasRole('ROLE_USER')")
 public ResultClass<String> getAllByRole(String user_role) {
   ResultClass<String> result = new ResultClass<>();
   result.addAll(repositoryUser.getAllByRole(user_role));
   return result;
 }