List of usage examples for org.apache.commons.validator ValidatorException ValidatorException
public ValidatorException(String message)
From source file:es.pode.administracion.presentacion.informes.eliminarInformesFederados.EliminarInformesFederadosControllerImpl.java
/** * @see es.pode.administracion.presentacion.informes.eliminarInformesFederados.EliminarInformesFederadosController#eliminarInformeFederado(org.apache.struts.action.ActionMapping, es.pode.administracion.presentacion.informes.eliminarInformesFederados.EliminarInformeFederadoForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *//*from ww w .j av a 2 s . com*/ public final void eliminarInformeFederado(ActionMapping mapping, es.pode.administracion.presentacion.informes.eliminarInformesFederados.EliminarInformeFederadoForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try { String listaId = request.getParameter("listaId"); if (logger.isDebugEnabled()) logger.debug("los ids de los informes federados que se quieren eliminar son " + listaId); String[] informes = listaId.split(":"); if (logger.isDebugEnabled()) logger.debug("los ids de los informes federados que se quieren eliminar son " + listaId); SrvInformeService informeService = this.getSrvInformeService(); ValidaBajaInformeVO bajaInformeVO = informeService.eliminarInformeFederado(informes); form.setInformesBorrados(bajaInformeVO.getInformesBorrados()); form.setResultado(bajaInformeVO.getDescripcionBaja()); } catch (Exception e) { logger.error("Se ha producido un error al eliminar el informe federado: " + e); throw new ValidatorException("{errors.eliminarInformeFederado}"); } }
From source file:es.pode.empaquetador.presentacion.archivos.modificar.ModificarArchivoControllerImpl.java
/** * @see es.pode.empaquetador.presentacion.archivos.modificar.ModificarArchivoController#modificar(org.apache.struts.action.ActionMapping, es.pode.empaquetador.presentacion.archivos.modificar.ModificarForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *//* www . j a v a 2 s. co m*/ public final void modificar(ActionMapping mapping, es.pode.empaquetador.presentacion.archivos.modificar.ModificarForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { EmpaquetadorSession sesEmpaq = this.getEmpaquetadorSession(request); GestorArchivosSession sesArch = this.getGestorArchivosSession(request); java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE); ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale); String opcion = form.getAction(); if (opcion.equals(i18n.getString("portal_empaquetado.modificarNombre"))) { //nuevoNombre debe ser la concatenacin de la extensin y el nuevo nombre String extension = form.getExtension(); String nuevoNombre; if (extension.equals("")) { nuevoNombre = form.getNuevoNombre(); } else { StringBuffer nombre = new StringBuffer(form.getNuevoNombre()); nombre.append(".").append(extension); nuevoNombre = nombre.toString(); } GestorSesion gs = new GestorSesion(); gs.validarNombreFichero(nuevoNombre); ArchivoVO archivo = (ArchivoVO) request.getSession().getAttribute("archivoVO"); String nombre = archivo.getNombre(); if (!extension.equals("")) { nombre = nombre + "." + extension; } if (!nombre.equals(nuevoNombre)) { // obtengo el identificador del ODEVO String identificador = sesEmpaq.getIdLocalizador(); List path = sesArch.getPath(); ArchivoVO ultimoPath = (ArchivoVO) path.get(path.size() - 1); // obtengo la carpetaDestino String carpetaPadre = null; if (path.size() > 1 && ultimoPath.getCarpetaPadre() == null) { carpetaPadre = ultimoPath.getNombre(); } else if (path.size() > 1 && ultimoPath.getCarpetaPadre() != null) { carpetaPadre = ultimoPath.getCarpetaPadre().concat("/").concat(ultimoPath.getNombre()); } try { this.getSrvEmpaquetadorBasicoService().renombrar(identificador, carpetaPadre, nombre, nuevoNombre); } catch (Exception e) { throw new ValidatorException("{portalempaquetado.archivos.error.renombrar}"); } } } }
From source file:es.pode.visualizador.presentacion.descargas.DescargasControllerImpl.java
/** * @see es.pode.visualizador.presentacion.descargas.DescargasController#listadoDescargas(org.apache.struts.action.ActionMapping, es.pode.visualizador.presentacion.descargas.ListadoDescargasForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) */// w ww. j a v a 2s . com public final void listadoDescargas(ActionMapping mapping, es.pode.visualizador.presentacion.descargas.ListadoDescargasForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try { Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE); String idioma = locale.getLanguage(); logger.debug("Recuperado idioma :" + idioma); DescargaVO descargas[] = getSrvDescargas().obtenerDescargasActivas(); logger.debug("Recuperadas " + descargas.length != null ? descargas.length : 0 + " descargas"); ArrayList<DescargaInfo> listaDescargas = new ArrayList<DescargaInfo>(); if (descargas != null && descargas.length > 0) { DescDescargaVO[] descs = getSrvDescargas().obtenerDescDescargasIdioma(descargas, idioma); logger.debug("Recuperadas " + descs.length + " descripciones de descargas"); for (int i = 0; i < descargas.length; i++) { DescargaInfo info = new DescargaInfo(); info.setTitulo(descs[i] != null && descs[i].getTitulo() != null ? descs[i].getTitulo() : VACIA); info.setDescripcion( descs[i] != null && descs[i].getDescripcion() != null ? descs[i].getDescripcion() : VACIA); info.setIdentificador(descargas[i] != null && descargas[i].getIdentificador() != null ? descargas[i].getIdentificador().toString() : VACIA); info.setPeso( descargas[i] != null && descargas[i].getPeso() != null ? descargas[i].getPeso() : 0L, locale); info.setRuta(descargas[i] != null && descargas[i].getPath() != null ? request.getServerName() + "/" + descargas[i].getPath() : VACIA); listaDescargas.add(info); } } logger.debug("Lista de descargas construida"); form.setDescargas(listaDescargas); } catch (Exception e) { logger.debug("Error al recuperar descargas.", e); throw new ValidatorException("{listaDescargas.error}"); } }
From source file:es.pode.administracion.presentacion.adminusuarios.verUsuario.VerUsuarioControllerImpl.java
/** * @see es.pode.administracion.presentacion.adminusuarios.verUsuario.VerUsuarioController#recuperarUsuario(org.apache.struts.action.ActionMapping, es.pode.administracion.presentacion.adminusuarios.verUsuario.RecuperarUsuarioForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *//* w w w. j a va2s .co m*/ public final void recuperarUsuario(ActionMapping mapping, es.pode.administracion.presentacion.adminusuarios.verUsuario.RecuperarUsuarioForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try { Long id = Long.valueOf(request.getParameter("id")); if (log.isDebugEnabled()) log.debug("Recupero los datos del usuario cuyo id es " + id); UsuarioVO usuario = this.getSrvAdminUsuariosService().descripcionUsuario(id); form.setNombre(usuario.getNombre()); form.setApellido1(usuario.getApellido1()); form.setApellido2(usuario.getApellido2()); form.setUsuario(usuario.getUsuario()); form.setIdioma(usuario.getIdioma()); form.setTipoEmpaquetador(usuario.getTipoEmpaquetador()); form.setEmail(usuario.getEmail()); form.setNIF(usuario.getNIF()); form.setIdiomaBusqueda(usuario.getIdiomaBusqueda()); form.setTipoCatalogador(usuario.getTipoCatalogador()); form.setOpenIdUrl(usuario.getOpenIdUrl()); //convertimos los bytes de cuota a mbytes para mostrarlos por pantalla long cuota = (long) (usuario.getCuota() / 1048576); form.setCuota(Long.valueOf(cuota).toString()); form.setId(id); //recogemos los grupos para mostrarlos Set set = new HashSet(); GrupoVO[] grupos = this.getSrvAdminUsuariosService().descripcionUsuario(id).getGrupos(); for (int i = 0; i < grupos.length; i++) { set.add(grupos[i]); } if (log.isDebugEnabled()) log.debug("Tamanio de la lista de grupos del usuario seleccionado " + set.size()); form.setGrupos(set); //recogemos los grupos de trabajo para mostrarlos Set setGruposTrabajo = new HashSet(); GrupoTrabajoVO[] gruposTrabajo = this.getSrvAdminUsuariosService().descripcionUsuario(id) .getGrupoTrabajo(); for (int i = 0; i < gruposTrabajo.length; i++) { setGruposTrabajo.add(gruposTrabajo[i]); } if (log.isDebugEnabled()) log.debug("Tamanio de la lista de grupos de trabajo del usuario seleccionado " + setGruposTrabajo.size()); form.setGruposTrabajo(setGruposTrabajo); } catch (Exception e) { log.error("Error: " + e); throw new ValidatorException("{verUsuario.error}"); } }
From source file:es.pode.empaquetador.presentacion.avanzado.submanifiestos.desagregar.DesagregarSubmanifiestoControllerImpl.java
public void desagregarLocal(ActionMapping mapping, DesagregarLocalForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { List identificadores = this.getDesagregarSubmanifiestoSession(request).getIdentificadores(); EmpaquetadorSession sesEmpaq = this.getEmpaquetadorSession(request); List subman = sesEmpaq.getSubmanifestPath(); String submanifestId = null;/*from w w w . j a v a 2s. co m*/ OdeVO ode = (OdeVO) subman.get(subman.size() - 1); if (subman.size() == 1) { submanifestId = null; } else { submanifestId = ode.getIdentifier(); } String identificadorPrimero = sesEmpaq.getIdLocalizador(); OdeVO[] submanifList = ode.getSubmanifiestos(); List submanifiestos = Arrays.asList(submanifList); for (int i = 0; (i < submanifiestos.size()); i++) { if (identificadores.contains(((OdeVO) submanifiestos.get(i)).getIdentifier())) { DataHandler dh = this.getSrvGestorManifestService().desagregarSubmanifiestoLocal( identificadorPrimero, ((OdeVO) submanifiestos.get(i)).getIdentifier(), submanifestId); try { (new GestorSesion()).iniciarDescargaFichero(dh, response, ((OdeVO) submanifiestos.get(i)).getIdentifier()); } catch (Exception e) { logger.error("Error durante la generacion del submanifiesto desagregado."); if (logger.isDebugEnabled()) logger.debug(e); throw new ValidatorException("{presentacion.avanzado.submanifiestos.desagregar.error}"); } } } }
From source file:es.pode.administracion.presentacion.planificador.informeTrabajo.InformeControllerImpl.java
public final void obtenerInformeTrabajo(ActionMapping mapping, ObtenerInformeTrabajoForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try {//from w ww . ja va2 s . co m Long informe = null; ficheroRecursos = ResourceBundle.getBundle("application-resources", request.getLocale()); if (form instanceof InformeFormImpl) informe = ((InformeFormImpl) form).getId(); else informe = ((MostrarDescripcionVolverFormImpl) form).getId(); RegistroTareaEjecutadaVO[] informeTrabajo = this.getSrvPlanificadorService() .obtenerInformeTrabajo(informe); RegistroTareaEjecutadaDate[] registroTareasDate = null; if (informeTrabajo != null) { registroTareasDate = cambiarFormatoRegistroTareas(informeTrabajo, informe); form.setInformeTrabajoAsArray(registroTareasDate); } /* Cabecera del informe */ TareaEjecutadaVO cabecera = this.getSrvPlanificadorService().obtenerTrabajoEjecutado(informe); /** * Recortamos el nombre de la tarea quitandole lo agregado al * nombre original Lo agregado son dos # seguidas de la fecha en * la que se ejecuta la tarea La fecha se compone de * "ao+mes+dia+hora+minutos+segundos" */ int posicion = cabecera.getTrabajo().indexOf("!!"); if (posicion > 0) form.setTrabajo(cabecera.getTrabajo().substring(0, posicion)); else form.setTrabajo(cabecera.getTrabajo()); form.setDescripcion(cabecera.getDescripcion()); SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy, HH:mm"); if (log.isDebugEnabled()) log.debug("cabecera.getFechaInicio()" + cabecera.getFechaInicio()); String fechaInicio = formato.format(cabecera.getFechaInicio().getTime()); form.setFechaInicio(fechaInicio); //log("fecha inicio despues del set" + form.getFechaInicio()); if (cabecera.getFechaFin() != null) form.setFechaFin(formato.format(cabecera.getFechaFin().getTime())); } catch (Exception e) { log.error("Error: " + e); throw new ValidatorException("{tareas.error}"); } }
From source file:es.pode.empaquetador.presentacion.avanzado.recursos.exportar.ExportarRecursosControllerImpl.java
public final void exportar(ActionMapping mapping, es.pode.empaquetador.presentacion.avanzado.recursos.exportar.ExportarForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE); ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale); String opcion = form.getAction(); if (opcion.equals(i18n.getString("presentacion.avanzado.recursos.exportar.aceptar"))) { String nombre = form.getNombre(); GestorSesion gs = new GestorSesion(); gs.validarNombreFichero(nombre); List recursosVO = this.getExportarRecursosSession(request).getRecursosVO(); if (logger.isDebugEnabled()) logger.debug("Recursos recuperados de la sesion " + recursosVO); List recursosList = new ArrayList(); String identificadorRec = ""; String[] recursos = new String[recursosVO.size()]; for (int i = 0; i < recursosVO.size(); i++) { identificadorRec = ((RecursoVO) recursosVO.get(i)).getIdentifier(); recursosList.add(i, identificadorRec); recursos[i] = identificadorRec; }/*w ww. j a va 2s. co m*/ // String[] recursos=(String[]) recursosList.toArray(); EmpaquetadorSession sesEmpaq = this.getEmpaquetadorSession(request); List listSubmPath = sesEmpaq.getSubmanifestPath(); //cojo el primer elemento que dedberia ser el padre String identificador = sesEmpaq.getIdLocalizador(); DataHandler dh = null; if (listSubmPath.size() == 1) { dh = this.getSrvGestorManifestService().exportarRecursos(identificador, recursos, null, nombre); } else if (listSubmPath.size() > 1) { OdeVO odeultim = (OdeVO) listSubmPath.get(listSubmPath.size() - 1); String submanifestId = odeultim.getIdentifier(); dh = this.getSrvGestorManifestService().exportarRecursos(identificador, recursos, submanifestId, nombre); } // Introducir el Datahandler en el response para la descarga try { (new GestorSesion()).iniciarDescargaFichero(dh, response, nombre + ".zip"); } catch (Exception e) { logger.error("Error en la descarga de recursos exportados"); if (logger.isDebugEnabled()) logger.debug(e); throw new ValidatorException("{presentacion.avanzado.recursos.exportar.error}"); } } }
From source file:es.pode.administracion.presentacion.planificador.eliminarTarea.EliminarTareasControllerImpl.java
public void obtenerTareas(org.apache.struts.action.ActionMapping mapping, es.pode.administracion.presentacion.planificador.eliminarTarea.ObtenerTareasForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception { Object[] sTrabajo;/*from www.j av a2 s .c om*/ String[] listadoTrabajo = null; String listaTrabajoPlana = ""; try { sTrabajo = (Object[]) form.getTrabajosAsArray(); listadoTrabajo = new String[sTrabajo.length]; //Construimos la lista de nombres de las tareas que se van a eliminar for (int i = 0; i < sTrabajo.length; i++) { listadoTrabajo[i] = new String(); listadoTrabajo[i] = sTrabajo[i].toString(); if (i == sTrabajo.length) listaTrabajoPlana = listaTrabajoPlana + (String) sTrabajo[i]; else listaTrabajoPlana = listaTrabajoPlana + (String) sTrabajo[i] + "#"; } log.debug("lista de trabajos a eliminar: " + listadoTrabajo); form.setListaTrabajo(listadoTrabajo); form.setListaTrabajoPlana(listaTrabajoPlana); } catch (Exception e) { log.error("Error: " + e); throw new ValidatorException("{tareas.error}"); } }
From source file:es.pode.administracion.presentacion.adminusuarios.altaGrupo.AltaGrupoControllerImpl.java
/** * @see es.pode.adminusuarios.presentacion.altaGrupo.AltaGrupoController#recuperarRoles(org.apache.struts.action.ActionMapping, * es.pode.adminusuarios.presentacion.altaGrupo.RecuperarRolesForm, * javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) Obtiene los roles que * estan dados de alta en el sistema *///from ww w. ja va2 s. c o m public final void recuperarRoles(ActionMapping mapping, RecuperarRolesForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String descripcion = form.getDescripcion(); Pattern mask = Pattern.compile("[^\\\\?\\\\!\\>\\#\\&\\<\\@\\$\\/\\\'\\\"]+"); Matcher matcher = null; if ((descripcion == null) || (descripcion.length() == 0)) { if (log.isDebugEnabled()) log.debug("La descripcion introducida es nula"); throw new ValidatorException("{errors.altagrupo.descripcion}"); } else { matcher = mask.matcher(descripcion); if (!matcher.matches()) { if (log.isDebugEnabled()) log.debug("nombre caracter ilegal"); throw new ValidatorException("{errors.altagrupo.descripcion.caracterIlegal}"); } if ((this.getSrvAdminUsuariosService().existeDescripcion(descripcion, Long.valueOf("-1"))) .booleanValue()) { if (log.isDebugEnabled()) log.debug("ya existe la descripcion"); throw new ValidatorException("{errors.altagrupo.descripcionExistente}"); } else { this.getAltaGrupoBSession(request).setDescripcion(descripcion); if (log.isDebugEnabled()) log.debug("Guardamos en sesion la descripcion del grupo"); } } RolVO[] rolVO = this.getSrvAdminUsuariosService().listarRoles(); form.setRolesAsArray(rolVO); }
From source file:es.pode.administracion.presentacion.planificador.eliminarTrabajoEjecutado.EliminarTrabajoControllerImpl.java
/** * metodo que elimina los trabajos seleccionados *///from w w w .j a v a 2 s. c o m public final void eliminarTrabajoEjecutado(ActionMapping mapping, EliminarTrabajoEjecutadoForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Long[] trabajosIDs = null; Boolean resultado; String resultadoString = null; String mensaje = null; String listaID = form.getListaIds(); if (log.isDebugEnabled()) log.debug("los nombres de tareas que se quieren eliminar son " + listaID); String[] cadenaIds = listaID.split("#"); trabajosIDs = new Long[cadenaIds.length]; for (int i = 0; i < cadenaIds.length; i++) { trabajosIDs[i] = new Long(cadenaIds[i]); } ResourceBundle ficheroRecursos = null; try { Locale locale = request.getLocale(); ficheroRecursos = this.getFicheroRecursos(locale); resultado = this.getSrvPlanificadorService().eliminarTrabajoEjecutado(trabajosIDs); if (resultado.booleanValue() == true) { mensaje = ficheroRecursos.getString("eliminarTareasPendientes.tareasEliminadasOk"); resultadoString = ficheroRecursos.getString("tareas.OK"); } else if (resultado.booleanValue() == false) { mensaje = ficheroRecursos.getString("eliminarTareasPendientes.tareasEliminadasError"); resultadoString = ficheroRecursos.getString("tareas.ERROR"); } form.setDescripcionBaja(mensaje); form.setResultado(resultadoString); } catch (Exception e) { log.error("Error: " + e); throw new ValidatorException("{tareas.error}"); } }