Package api

Source Code of api.AuthUserFrontend

package api;

import org.orm.PersistentException;
import org.orm.PersistentTransaction;

public class AuthUserFrontend {
  /**
   *
   * @param user
   * @param password
   * @return
   */
    public int addUser(String user, String password){
     
      int respuesta = 0;
      if(user!=null && user.replace(" ","")!="" && password!=null && password.replace(" ","")!="" ){
      PersistentTransaction t;
      try {
       
        /*
         * If exits username
         */
        orm.Tau_userfrontend lormTau_userfrontend = orm.Tau_userfrontendDAO.loadTau_userfrontendByQuery(" uf_user='"+user+"'", null);
        if(lormTau_userfrontend==null){
          /*
           * Save
           */
          t = orm.AuthPersistentManager.instance().getSession().beginTransaction();
          try {
            orm.Tau_userfrontend lormTau_userfrontendCreate = orm.Tau_userfrontendDAO.createTau_userfrontend();
            lormTau_userfrontendCreate.setUf_password(password);
            lormTau_userfrontendCreate.setUf_user(user);
            // TODO Initialize the properties of the persistent object here, the following properties must be initialized before saving : tau_sessionuserfrontend, uf_password, uf_user
            orm.Tau_userfrontendDAO.save(lormTau_userfrontendCreate);
            t.commit();
           
            lormTau_userfrontendCreate = null;
            respuesta = 1;
          }
          catch (Exception e) {
            t.rollback();
            respuesta = -1;
          }
         
        }
        else {
          /*
           * Exit object
           */
          respuesta = -2;
        }
        lormTau_userfrontend = null;
      } catch (PersistentException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
        respuesta = -3;
      }

      t = null;
      }
      else {
        respuesta = -4;
      }
     
      return respuesta;
     
    }
}
TOP

Related Classes of api.AuthUserFrontend

TOP
Copyright © 2018 www.massapi.com. 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.