Пример #1
0
  public static Momin findOrCreateUser(Momin user) throws TaskException {

    TaskDao dao = new TaskDao();

    Momin m = dao.getMomin(user.getId());

    // utilisateur n'existe pas dans la base
    if (m == null) {
      if (user.getId().charAt(0) != 'f') {
        UserService usrSrvc = UserServiceFactory.getUserService();
        User u = usrSrvc.getCurrentUser();
        user.setEmail(u.getEmail());
        //				user.setId(u.getUserId());
        user.setName(u.getNickname());
      }
      dao.save(user);
      m = user;
      MailService mailService = MailServiceFactory.getMailService();
      Message message =
          new Message(
              "*****@*****.**",
              "*****@*****.**",
              "Un nouveau utilisateur ",
              user.getEmail()
                  + " "
                  + user.getName()
                  + " a accéder à l'application pour la première fois");
      try {
        mailService.send(message);
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    m = m.clon();
    //
    //	m.setFriendsCalendar(Arrays.asList("105208827974973865566&#0&#naitsoft","110949677754069966012&#0&#sharpensoul","18580476422013912411&#0&#test","11701531798136846518&#0&#test1"));
    return m;
  }
Пример #2
0
 public void save(Momin m) {
   em.getTransaction().begin();
   if (m.getId() == null) em.persist(m);
   else em.merge(m);
   em.getTransaction().commit();
 }