Package org.nextime.ion.framework.business

Examples of org.nextime.ion.framework.business.User


    String password = lform.getPassword();

    // v�rifier l'utilisateur sur le framework
    try {
      Mapping.begin();
      User user = User.getInstance(login);
      Mapping.rollback();
      if (!lform.getPassword().equals(user.getPassword())) {
        ActionError error = new ActionError("error.login.badPassword");
        ActionErrors errors = new ActionErrors();
        errors.add("password", error);
        request.setAttribute(ERROR_KEY, errors);
        return (new ActionForward(mapping.getInput()));
      }
      Mapping.begin();
      boolean result = new SecurityManagerImpl().canLogIntoBackoffice(user);
      Mapping.rollback();
      if ( !result ) {
        ActionError error = new ActionError("error.login.notAuthorized");
        ActionErrors errors = new ActionErrors();
        errors.add("login", error);
        request.setAttribute(ERROR_KEY, errors);
        return (new ActionForward(mapping.getInput()));
      }
      request.getSession().setAttribute("userLogin",user.getLogin());
    } catch (Exception e) {
      Mapping.rollback();
      ActionError error = new ActionError("error.login.badLogin");
      ActionErrors errors = new ActionErrors();
      errors.add("login", error);
View Full Code Here


    }

    // all it's ok : update user
    try {
      Mapping.begin();
      User user = User.create(sform.getLogin());
      user.setMetaData("name", sform.getName());
      user.setMetaData("email", sform.getEmail());
      user.setPassword(sform.getPassword());
      user.resetGroups();
      if (sform.getGroups() != null) {
        for (int i = 0; i < sform.getGroups().length; i++) {
          Group group = Group.getInstance(sform.getGroups()[i]);
          user.addGroup(group);
        }
      }
      Mapping.commit();

    } catch (Exception e) {
View Full Code Here

        : request.getParameter("id").toString();
   
    // all it's ok : delete user
    try {
      Mapping.begin();
      User user = User.getInstance(id);
      user.remove();
      Mapping.commit();
     
    } catch (Exception e) {
      Mapping.rollback();
      throw new ServletException(e);
View Full Code Here

    // fill data | first time
    if (sform.getName() == null) {
      try {   
        Mapping.begin();
        User user = User.getInstance(id);       
        Mapping.rollback();
       
        sform.setEmail((String)user.getMetaData("email"));
        sform.setName((String)user.getMetaData("name"));
        sform.setGroups(user.getGroupsIds());
        sform.setPassword(user.getPassword());       
       
      } catch (Exception e) {
        Mapping.rollback();
        throw new ServletException(e);
      }

      // Forward to the view page
      return (mapping.findForward("view"));
    }   

    // fill data | errors
    if (errors.size() > 0) {
      try {
        request.setAttribute(ERROR_KEY, errors);
               
      } catch (Exception e) {
        Mapping.rollback();
        throw new ServletException(e);
      }

      // Forward to the view page
      return (mapping.findForward("view"));
    }

    // all it's ok : update user
    try {
      Mapping.begin();
      User user = User.getInstance(id);
      user.setMetaData("name", sform.getName());
      user.setMetaData("email", sform.getEmail());
      user.setPassword(sform.getPassword());     
      Mapping.commit();
     
    } catch (Exception e) {
      Mapping.rollback();
      throw new ServletException(e);
View Full Code Here

      if (request.getParameter("editSubmit") == null) {
        Mapping.begin();

        // initialisation du formulaire       
        User u = User.getInstance(id);
        UserForm f = (UserForm) form;
        f.setLogin(u.getLogin());
        f.setPassword(u.getPassword());
        f.setGroups(u.getGroupsIds());
        request.setAttribute("metaData", ((UserImpl) u).getMetaData());

        Mapping.commit();
        return new ActionForward( mapping.getInput() );
      }

      // effectu les modifications
      Mapping.begin();
      UserForm f = (UserForm) form;
      User u = User.getInstance(id);
      u.setPassword(f.getPassword());
      String[] g = f.getGroups();
      u.resetGroups();
      if (g != null) {
        for (int i = 0; i < g.length; i++) {
          u.addGroup(Group.getInstance(g[i]));
        }
      }

      // *********************************************************
      // les metaData sont g�r�es separement car je n'ai
      // aucune id�e du nombre et du nom des champs qu'il va
      // y avoir.
      // cette partie est un peu bancale mais en g�n�ral dans un
      // veritable backoffice le nombre de champs composant le
      // formulaire est connu et on peut les g�rer comme ce que j'ai
      // fait plus haut ( login, password ... )
      // CETTE PARTIE N'EST DONC PAS A REPRENDRE.

      // sauve les metaData
      Enumeration ps = request.getParameterNames();
      while (ps.hasMoreElements()) {
        String name = ps.nextElement() + "";
        if (name.startsWith("META_")) {
          name = name.substring(5);
          u.setMetaData(name, request.getParameter("META_" + name));
        }
      }
      // efface la metaData si il y a besoin
      String mtd = request.getParameter("metaToDelete");
      if ((mtd + "").trim().equals(""))
        mtd = null;
      if (mtd != null) {
        u.removeMetaData(mtd);
        request.setAttribute("metaData", ((UserImpl) u).getMetaData());
      }
      // ajoute la metaData si il y a besoin
      String mtd2 = request.getParameter("newMETA");
      if ((mtd2 + "").trim().equals(""))
        mtd2 = null;
      if (mtd2 != null) {
        u.setMetaData(mtd2, "");
        request.setAttribute("metaData", ((UserImpl) u).getMetaData());
      }
      Mapping.commit();

      // si on a simplement effac� ou ajout� une metadonn�e, on retourne au fromulaire
View Full Code Here

    // fill data | first time
    if (sform.getName() == null) {
      try {   
        Mapping.begin();
        User user = User.getInstance(id);
        Vector groups = Group.listAll();
        Mapping.rollback();
       
        sform.setEmail((String)user.getMetaData("email"));
        sform.setName((String)user.getMetaData("name"));
        sform.setGroups(user.getGroupsIds());
        sform.setPassword(user.getPassword());
        request.setAttribute("groups", groups);
       
      } catch (Exception e) {
        Mapping.rollback();
        throw new ServletException(e);
      }

      // Forward to the view page
      return (mapping.findForward("view"));
    }   

    // fill data | errors
    if (errors.size() > 0) {
      try {
        Mapping.begin();       
        Vector groups = Group.listAll();
        Mapping.rollback();
       
        request.setAttribute("groups", groups);
        request.setAttribute(ERROR_KEY, errors);
               
      } catch (Exception e) {
        Mapping.rollback();
        throw new ServletException(e);
      }

      // Forward to the view page
      return (mapping.findForward("view"));
    }

    // all it's ok : update user
    try {
      Mapping.begin();
      User user = User.getInstance(id);
      user.setMetaData("name", sform.getName());
      user.setMetaData("email", sform.getEmail());
      user.setPassword(sform.getPassword());
      user.resetGroups();
      for( int i=0; i<sform.getGroups().length; i++ ) {
        Group group = Group.getInstance(sform.getGroups()[i]);
        user.addGroup(group);
      }
      Mapping.commit();
     
    } catch (Exception e) {
      Mapping.rollback();
View Full Code Here

  }

  protected boolean check() {
    try {
      Mapping.begin();
      User user = null;
      try {
        if (getUser() != null) {
          user = User.getInstance(getUser());
        }
      } catch (Exception e) {
View Full Code Here

      // creation de l'objet
      UserForm f = (UserForm) form;
      Mapping.begin();
      id = f.getLogin();
      User u = User.create(f.getLogin());
      u.setPassword(f.getPassword());
      String[] g = f.getGroups();
      if (g != null) {
        for (int i = 0; i < g.length; i++) {
          u.addGroup(Group.getInstance(g[i]));
        }
      }
      Mapping.commit();     

    } catch (Exception e) {     
View Full Code Here

TOP

Related Classes of org.nextime.ion.framework.business.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.