public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    ActionErrors errors = new ActionErrors();
    ActionForward forward = new ActionForward();
    // return value
    FormAgregarRolSistema formAgregarRolSistema = (FormAgregarRolSistema) form;

    try {
      SessionManager.beginTransaction();

      String nombre = formAgregarRolSistema.getNombre();

      PersistentArrayList acciones = formAgregarRolSistema.getAccionesPersistentesSeleccionadas();

      // Agrega el usuario
      Cysdreq cysdreq = Cysdreq.getPersistentInstance();
      HashMap params = new HashMap(2);
      params.put("nombreRol", nombre);
      params.put("tiposDeAcciones", acciones);
      cysdreq.ejecutarAccion(new AgregarRolSistema(), cysdreq, params);

      SessionManager.commit();

    } catch (Throwable e) {
      e.printStackTrace();
      SessionManager.rollback();
      errors.add("rolSistema", new ActionError("errors.registrarRolSistema"));
    }

    if (!errors.isEmpty()) {
      saveErrors(request, errors);
      forward = mapping.findForward("error");
    } else forward = mapping.findForward("globalSuccess");

    return (forward);
  }
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    ActionErrors errors = new ActionErrors();
    ActionForward forward = new ActionForward();
    // return value
    String username = (String) PropertyUtils.getSimpleProperty(form, "usuario");
    String password = (String) PropertyUtils.getSimpleProperty(form, "password");

    try {
      // obtiene la transacción asociada al administrador de persistencia.
      SessionManager.beginTransaction();

      Cysdreq cysdreq;
      try {
        cysdreq =
            (Cysdreq)
                PersistenceManagers.findObject(
                    SessionManager.getSession(), SessionManager.ROOT_OBJECT_ID);
        System.out.println("Cysdreq obtenido");
      } catch (Throwable t) {
        // Report the error using the appropriate name and ID.
        errors.add("login", new ActionError("errors.obtenerSistema"));
        throw t;
      }

      Usuario usuario = cysdreq.getUsuario(username, password);
      if (usuario == null) {
        errors.add("login", new ActionError("errors.login.inexistente"));
      } else {
        UserBean userBean = new UserBean();
        userBean.setLongUsername(usuario.getNombre());
        userBean.setUsername(usuario.getUsuario());
        userBean.setPassword(usuario.getPassword());

        // Save our logged-in user in the session
        HttpSession session = request.getSession();
        session.setAttribute(USER_KEY, userBean);
      }

      SessionManager.commit();
    } catch (Throwable t) {
      SessionManager.rollback();
      t.printStackTrace();
      // Report the error using the appropriate name and ID.
      errors.add("sistema", new ActionError("errors.errorDesconocido"));
    }

    // If a message is required, save the specified key(s)
    // into the request for use by the <struts:errors> tag.

    if (!errors.isEmpty()) {
      saveErrors(request, errors);

      // Forward control to the appropriate 'failure' URI (change name as desired)
      forward = mapping.findForward("error");

    } else {

      // Forward control to the appropriate 'success' URI (change name as desired)
      forward = mapping.findForward("success");
    }

    // Finish with
    return (forward);
  }