private File createTemp(MultipartFile multipartFile, User posteur) {
    String[] s = multipartFile.getOriginalFilename().split("\\.");
    String extention = "";
    if (s.length > 1) {
      extention = s[s.length - 1];
    }

    String chemin = "tmp";
    chemin += posteur.getLogin();
    chemin += "_" + new Date().getTime();
    chemin += new Random().nextInt(10000);
    chemin += "." + extention;

    File temporaire = new File(chemin);
    try {
      multipartFile.transferTo(temporaire);
    } catch (IllegalStateException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return temporaire;
  }
Esempio n. 2
0
  public static User getUtilisateurToutDroit() {
    User user = new User();
    user.setLogin("krack");

    Set<Role> roles = new HashSet<Role>();

    Role roleAuth = new Role();
    roleAuth.setRole(RoleEnum.ROLE_AUTHENTIFIER.toString());
    roles.add(roleAuth);

    Role roleForum = new Role();
    roleForum.setRole(RoleEnum.ROLE_ADMINISTRATEUR_FORUM.toString());
    roles.add(roleForum);

    user.setRoles(roles);
    return user;
  }
Esempio n. 3
0
  public boolean equals(User user) {
    if (user == null) {
      return false;
    }
    boolean egal = true;
    egal = egal && this.getLogin().toLowerCase().equals(user.getLogin().toLowerCase());

    return egal;
  }
Esempio n. 4
0
  @Override
  public List<Media> getMediaReadForAlbum(Album album, User utilisateurCourant) {
    String request =
        "SELECT m "
            + " FROM Media as m"
            + " WHERE m.album.id=? "
            + " and exists ("
            + "	from LectureAlbum as l where l.utilisateur.login=? and l.mediaVu = m"
            + " )";
    List<Media> medias =
        this.getHibernateTemplate().find(request, album.getId(), utilisateurCourant.getLogin());

    return medias;
  }
Esempio n. 5
0
  @Override
  public boolean isAlbumHasNotSeeMedia(Album album, User utilisateurCourant) {
    String request =
        "SELECT m "
            + " FROM Media as m"
            + " WHERE m.album.id=? "
            + " and not exists ("
            + "	from LectureAlbum as l where l.utilisateur.login=? and l.mediaVu = m"
            + " )";
    List<Media> medias =
        this.getHibernateTemplate().find(request, album.getId(), utilisateurCourant.getLogin());

    return !medias.isEmpty();
  }
Esempio n. 6
0
  public static User getUtilisateurSansDroit() {
    User user = new User();
    user.setLogin("loulou");

    return user;
  }