public ActionForward executeAction( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ISicresServicioRPAdmin oServicio = new ISicresServicioRPAdminAdapter(); // Se obtiene la entidad Entidad entidad = new Entidad(); entidad.setIdentificador(MultiEntityContextHolder.getEntity()); String id = (String) request.getParameter("idUsuario"); if (id == null || id.equals("")) { id = (String) request.getSession(false).getAttribute("idUsuario"); } if (id != null && !id.equals("")) { // Mostramos la página de editarUsuario.jsp OptionsBean perfiles = oServicio.obtenerPerfilesCombo(entidad); Utils.traducePerfiles(perfiles, LocaleFilterHelper.getCurrentLocale(request)); request.setAttribute("perfil", perfiles); request.setAttribute("oficina", oServicio.obtenerOficinasCombo(entidad)); // request.setAttribute("id", id); request.getSession(false).setAttribute("idUsuario", id); UsuarioForm usuarioForm = (UsuarioForm) form; UsuarioRegistradorBean usuario = null; if (isLdapMethod(entidad.getIdentificador())) usuario = oServicio.obtenerUsuarioLdap(Integer.parseInt(id), entidad); else usuario = oServicio.obtenerUsuario(Integer.parseInt(id), entidad); // request.setAttribute("nombreUsuario", usuario.getNombre()); // Si no tenemos usuario en el formulario es la primera vez que se carga, rellenar con datos // de negocio if (usuarioForm.getId() == null) { BeanUtils.copyProperties(usuarioForm, usuario); } } return mapping.findForward("success"); }
protected void loadTree( HttpServletRequest request, String cteTree, String cteServiceTree, String start, int treeType) throws Exception { // Se obtiene la entidad Entidad entidad = new Entidad(); entidad.setIdentificador(MultiEntityContextHolder.getEntity()); String id = request.getParameter("id"); boolean borraCookies = false; ServiceTree serviceTree = null; NaryTree tree; if (id == null) { LdapConnection ldapConn = new LdapConnection(); // Obtener la información del servidor LdapConnCfg connCfg = UasConfigUtilLdap.createLdapConnConfig(entidad.getIdentificador()); ldapConn.open(connCfg); // Obtener la ruta de búsqueda String startNode = start; // Obtener el rootDn LdapURL Ldap_url = new LdapURL(ldapConn.getUrl()); String ldapRootDn = Ldap_url.getDN(); String ldapRootGroupStartDn = Ldap_url.getDN(); // Si el comienzo de grupos es distinto del rootDn cambiarlo if ((startNode != null) && (!"".equals(startNode))) { ldapRootGroupStartDn = startNode + "," + ldapRootGroupStartDn; } NodeImplLDAP nodoRaiz = new NodeImplLDAP(); tree = new NaryTree(null, nodoRaiz); int maxChildrenLdap = ((Integer) request .getSession() .getServletContext() .getAttribute(Constantes.MAX_CHILDREN_LDAP)) .intValue(); serviceTree = new ServiceTreeLdap(tree, maxChildrenLdap, ldapRootDn, treeType); request.getSession(false).setAttribute(cteServiceTree, serviceTree); nodoRaiz.setCodigo(ldapRootGroupStartDn); // Obtener el objectClass del nodo raíz y establecer si es válido para seleccionar o no IeciTdShortTextArrayList arrayList = LdapBasicFns.findEntryAttributeValues( ldapConn, ldapRootGroupStartDn, LdapAttribute.getObjectClassAttributeName(ldapConn)); nodoRaiz.setValidForSelection( ServiceTreeLdap.isValidForSelection(arrayList, ldapConn, treeType)); nodoRaiz.setTitle(ServiceTreeLdap.getLdapTitle(ldapRootGroupStartDn)); int hashCode = serviceTree.getHashCode(ldapRootGroupStartDn); nodoRaiz.setId(hashCode); LdapService ldapService = new LdapService(maxChildrenLdap, ldapRootDn, treeType); boolean hasChildren = ldapService.hasChildLdap(ldapRootGroupStartDn, entidad.getIdentificador()); nodoRaiz.setHasChild(hasChildren); // Añadir los hijos al árbol serviceTree.addChildren(hashCode, null, entidad, 0, false); request.getSession(false).setAttribute(cteTree, tree); borraCookies = true; } else { // Obtener un nodo ya cargado y añadirle sus hijos tree = (NaryTree) request.getSession(false).getAttribute(cteTree); if (tree == null) { logger.error("La estructura de Arbol deberia estar en memoria"); throw new Exception("La estructura de Arbol deberia estar en memoria"); } serviceTree = (ServiceTree) request.getSession(false).getAttribute(cteServiceTree); serviceTree.addChildren(Integer.parseInt(id), null, entidad, 0, false); } String arbol = serviceTree.getTreeString(0, false, LocaleFilterHelper.getCurrentLocale(request)); request.setAttribute(Constantes.TREE_STRING, arbol); Boolean b = new Boolean(borraCookies); request.setAttribute(Constantes.BORRA_COOKIES, b); request.setAttribute(Constantes.TYPE_TREE, String.valueOf(treeType)); }
public ActionForward executeAction( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ISicresServicioRPAdmin oServicio = new ISicresServicioRPAdminAdapter(); // Se obtiene la entidad Entidad entidad = new Entidad(); entidad.setIdentificador(MultiEntityContextHolder.getEntity()); String id = request.getParameter("id"); String idCampoFiltro = request.getParameter("idCampoFiltro"); boolean filtros; if (idCampoFiltro != null && !idCampoFiltro.equals("") && !idCampoFiltro.equals("null")) { filtros = true; } else { idCampoFiltro = ""; filtros = false; } boolean borraCookies = false; ServiceTree serviceTree = request.getSession(false).getAttribute("serviceTreeUnidades") != null ? (ServiceTree) request.getSession(false).getAttribute("serviceTreeUnidades") : null; ResourceBundle rb = ResourceBundle.getBundle( "ApplicationResource", LocaleFilterHelper.getCurrentLocale(request)); if (id == null) { NaryTree tree = NaryTree.getInstance(); Node nodoRaiz = new NodeImplBD(); tree = new NaryTree(null, nodoRaiz); serviceTree = new ServiceTreeDept(tree); nodoRaiz.setId(0); boolean hasChild = serviceTree.hasChildren(0, oServicio, entidad, Distribucion.TIPO_ORGANIZACION, filtros); nodoRaiz.setHasChild(hasChild); nodoRaiz.setTitle( rb.getString( "ieci.tecdoc.sgm.rpadmin.unidades.titulo.upperCase")); // Cambiar el properties if (hasChild) serviceTree.addChildren( nodoRaiz.getId(), oServicio, entidad, Distribucion.TIPO_ORGANIZACION, filtros); borraCookies = true; request.getSession(false).setAttribute("serviceTreeUnidades", serviceTree); } else { serviceTree.addChildren( Integer.parseInt(id), oServicio, entidad, Distribucion.TIPO_ORGANIZACION, filtros); } String arbol = serviceTree.getTreeStringOrg( Distribucion.TIPO_ORGANIZACION, filtros, LocaleFilterHelper.getCurrentLocale(request)); request.setAttribute("treeString", arbol); Boolean b = new Boolean(borraCookies); request.setAttribute("borraCookies", b); request.setAttribute("idCampoFiltro", idCampoFiltro); return mapping.findForward("success"); }