List of usage examples for org.apache.commons.validator ValidatorException ValidatorException
public ValidatorException(String message)
From source file:es.pode.administracion.presentacion.planificador.descripcionTarea.DescripcionTareaControllerImpl.java
/** * /* w ww . j a v a 2 s . c om*/ */ public void obtenerTareaInformeFechaRango(org.apache.struts.action.ActionMapping mapping, es.pode.administracion.presentacion.planificador.descripcionTarea.ObtenerTareaInformeFechaRangoForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception { if (tz == null) tz = utilidades.asignarZonaHoraria(); TareaInformesVO tarea = new TareaInformesVO(); try { //cargamos la tarea con lo valores esenciales para recuperar los demas valores de esta misma tarea tarea.setTrabajo(((DescripcionTareaFormImpl) form).getTrabajo()); tarea.setGrupoTrabajo(((DescripcionTareaFormImpl) form).getGrupoTrabajo()); tarea.setTrigger(((DescripcionTareaFormImpl) form).getTrigger()); tarea.setGrupoTrigger(((DescripcionTareaFormImpl) form).getGrupoTrigger()); tarea.setPeriodicidad(((DescripcionTareaFormImpl) form).getPeriodicidad()); //llamamos al servicio para que carge los valores en la tarea del tipo correspondiente TareaInformesVO tareaInformes = this.getSrvPlanificadorService().obtenerTareaInformes(tarea); //asignamos a las fechas la franja horaria correspondiente tareaInformes.getFechaInicio().setTimeZone(tz); if (tareaInformes.getPeriodicidad().equalsIgnoreCase("N")) { if (log.isDebugEnabled()) log.debug("No es periodica"); tareaInformes.getFechaDesde().setTimeZone(tz); tareaInformes.getFechaHasta().setTimeZone(tz); ((DescripcionTareaFormImpl) form) .setDiaDesde(new Integer(tareaInformes.getFechaDesde().get(Calendar.DAY_OF_MONTH))); ((DescripcionTareaFormImpl) form) .setMesDesde(new Integer(tareaInformes.getFechaDesde().get(Calendar.MONTH) + 1)); ((DescripcionTareaFormImpl) form) .setAnioDesde(new Integer(tareaInformes.getFechaDesde().get(Calendar.YEAR))); ((DescripcionTareaFormImpl) form) .setDiaHasta(new Integer(tareaInformes.getFechaHasta().get(Calendar.DAY_OF_MONTH))); ((DescripcionTareaFormImpl) form) .setMesHasta(new Integer(tareaInformes.getFechaHasta().get(Calendar.MONTH) + 1)); ((DescripcionTareaFormImpl) form) .setAnioHasta(new Integer(tareaInformes.getFechaHasta().get(Calendar.YEAR))); } else { if (log.isDebugEnabled()) log.debug("es periodica"); } //rellenamos los datos especificos de este tipo de tarea ((DescripcionTareaFormImpl) form).setPeriodicidad(tareaInformes.getPeriodicidad()); ((DescripcionTareaFormImpl) form).setTipoTarea(tareaInformes.getInforme()); ((DescripcionTareaFormImpl) form).setFormato(tareaInformes.getFormato()); ((DescripcionTareaFormImpl) form).setInforme(tareaInformes.getInforme()); ((DescripcionTareaFormImpl) form).setRango(tareaInformes.getRango()); ((DescripcionTareaFormImpl) form) .setAnio(new Integer(tareaInformes.getFechaInicio().get(Calendar.YEAR))); ((DescripcionTareaFormImpl) form) .setMes(new Integer(tareaInformes.getFechaInicio().get(Calendar.MONTH) + 1)); ((DescripcionTareaFormImpl) form) .setDia(new Integer(tareaInformes.getFechaInicio().get(Calendar.DAY_OF_MONTH))); ((DescripcionTareaFormImpl) form) .setHora(new Integer(tareaInformes.getFechaInicio().get(Calendar.HOUR_OF_DAY))); ((DescripcionTareaFormImpl) form) .setMinutos(new Integer(tareaInformes.getFechaInicio().get(Calendar.MINUTE))); ((DescripcionTareaFormImpl) form).setMsgInforme(tareaInformes.getMsgInforme()); ((DescripcionTareaFormImpl) form).setMsgNoInforme(tareaInformes.getMsgNoInforme()); ((DescripcionTareaFormImpl) form).setMsgDescTrabajo(tareaInformes.getMsgDescripcionTrabajo()); } catch (Exception e) { log.error("Error: " + e); throw new ValidatorException("{tareas.error}"); } }
From source file:es.pode.empaquetador.presentacion.archivos.gestor.GestorArchivosControllerImpl.java
/** * @see es.pode.empaquetador.presentacion.archivos.gestor.GestorArchivosController#pegar(org.apache.struts.action.ActionMapping, es.pode.empaquetador.presentacion.archivos.gestor.PegarForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *///from w ww . ja v a 2 s . co m public final void pegar(ActionMapping mapping, es.pode.empaquetador.presentacion.archivos.gestor.PegarForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { GestorArchivosSession sesArch = this.getGestorArchivosSession(request); EmpaquetadorSession sesEmpaq = this.getEmpaquetadorSession(request); List<ArchivoVO> portapapeles = sesArch.getPortapapeles(); if (sesArch.isModoPegar() == true) { if (portapapeles != null && portapapeles.size() > 0) { //obtengo el identificador el ultimo ODEVO String identificador = sesEmpaq.getIdLocalizador(); List<ArchivoVO> path = sesArch.getPath(); ArchivoVO ultimoPath = path.get(path.size() - 1); //obtengo la carpetaDestino String carpetaDestino = VACIA; if (path.size() > 1 && ultimoPath.getCarpetaPadre() == null) { carpetaDestino = ultimoPath.getNombre(); } else if (path.size() > 1 && ultimoPath.getCarpetaPadre() != null) { carpetaDestino = ultimoPath.getCarpetaPadre().concat(BARRA).concat(ultimoPath.getNombre()); } //ficheros a copiar del portapapeles ArchivoVO[] ficheros = (ArchivoVO[]) portapapeles.toArray(new ArchivoVO[] {}); //Controlamos que las rutas origen/destino no coincidan for (int i = 0; i < ficheros.length; i++) { ArchivoVO archivoVO = ficheros[i]; //Realmente vale con comprobar slo carpetas if (!archivoVO.getEsFichero()) { String rutaCompleta = (archivoVO.getCarpetaPadre() != null ? archivoVO.getCarpetaPadre() + BARRA : VACIA) + archivoVO.getNombre(); if (carpetaDestino.startsWith(rutaCompleta)) { throw new ValidatorException("{portal_empaquetado.exception.recursivo}"); } } } if (sesArch.getAccion().equals(CORTAR_STR)) { this.getSrvEmpaquetadorBasicoService().cortar(identificador, carpetaDestino, ficheros); } else if (sesArch.getAccion().equals(COPIAR_STR)) { this.getSrvGestorArchivosService().copiar(identificador, carpetaDestino, ficheros); } } else { throw new ValidatorException(PORTAL_EMPAQUETADOR_EXCEPTION); } } else { throw new ValidatorException("{portal_empaquetado.exception}"); } }
From source file:es.pode.administracion.presentacion.adminusuarios.altaUsuario.AltaUsuarioControllerImpl.java
/** Metodo que asigna los grupos de trabajo seleccionados por el administrador al usuario * @param form formulario con los datos del usuario que se quiere dar de alta * @throws Exception// w w w .j a v a 2s . c om */ public void asignarGruposTrabajo(ActionMapping mapping, AsignarGruposTrabajoForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try { AltaUsuarioBSession altaUsuarioBSession = this.getAltaUsuarioBSession(request); UsuarioVO usuarioSesion = altaUsuarioBSession.getUsuario(); //recogemos los grupos que se han asigando al usuario y vemos que roles contienen GrupoVO[] grupos = usuarioSesion.getGrupos(); //comprobamos si ha pasado por la pantalla de grupos de catalogadores o no para validarlos if (validarRolesDocenteYCatalogador(grupos)) { String[] ids = form.getIdentificadorRowSelectionAsArray(); if (log.isDebugEnabled()) log.debug("Los identificadores seleccionados son los siguientes " + ids); SrvAdminUsuariosService srvAdminUsuariosService = this.getSrvAdminUsuariosService(); if (ids == null) { if (log.isDebugEnabled()) log.debug("No se ha seleccionado ningun grupo"); throw new ValidatorException("{errors.altausuario.gruposTrabajoVacio}"); } else { GrupoTrabajoVO[] grupoTrabajoVO = new GrupoTrabajoVO[ids.length]; if (log.isDebugEnabled()) log.debug("grupoTrabajoVO.length " + grupoTrabajoVO.length); Long idL = null; for (int i = 0; i < ids.length; i++) { idL = new Long(ids[i]); GrupoTrabajoVO grupoG = srvAdminUsuariosService.descripcionGrupoTrabajo(idL); grupoTrabajoVO[i] = grupoG; } usuarioSesion.setGrupoTrabajo(grupoTrabajoVO); } } //metemos en sesion el usuario this.getAltaUsuarioBSession(request).setUsuario(usuarioSesion); } catch (ValidatorException ve) { log.error("Se produce un error ValidatorException " + ve); throw ve; } catch (Exception e) { log.error("Error al obtener los grupos seleccionados ", e); } }
From source file:es.pode.empaquetador.presentacion.avanzado.recursos.crear.elementos.CrearRecursoAvanzadoElementosControllerImpl.java
@Override public final java.lang.String selectActionArchivos(ActionMapping mapping, es.pode.empaquetador.presentacion.avanzado.recursos.crear.elementos.SelectActionArchivosForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { /*//from w ww .j a v a 2s . com * Metodo de decision para el action. Analiza los parametros * actionSubmit (value de los botones submit) para redirigir al caso de uso * correspondiente. El actionSubmit llegara * internacionalizado, por lo que es necesario acceder al ResouceBundle * para obtener el valor correcto en la comparacion. */ String result = null; String actionSubmit = form.getAction(); java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE); ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale); if (form.getAction() == (null)) { throw new ValidatorException("{portal_empaquetado.exception}"); } else if (actionSubmit .equals(i18n.getString("portalempaquetado.avanzado.recursos.crear.paso2.archivos.eliminar"))) { result = "Eliminar"; } else if (actionSubmit .equals(i18n.getString("portalempaquetado.avanzado.recursos.crear.paso2.archivos.anadir"))) { result = "Crear"; } else if (actionSubmit .equals(i18n.getString("portalempaquetado.avanzado.recursos.crear.paso2.archivos.principal"))) { result = "Principal"; } else { Logger.getLogger(this.getClass()) .error("El valor del submit no es correcto (actionSubmit = " + actionSubmit + ";"); } return result; }
From source file:es.pode.empaquetador.presentacion.avanzado.organizaciones.elementos.gestor.GestorElementosControllerImpl.java
public final void eliminarPortapapeles(ActionMapping mapping, EliminarPortapapelesForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { EmpaquetadorSession sesEmpa = this.getEmpaquetadorSession(request); List portapapeles = sesEmpa.getPortapapeles(); String identificadorEliminar = form.getIdentifier(); //voy recorriendo el portapapeles comprobando el nombre a eliminar if (portapapeles != null && portapapeles.size() > 0) { for (int i = 0; i < portapapeles.size(); i++) { GrupoVO porta = (GrupoVO) portapapeles.get(i); if (porta.getIdentifier().equals(identificadorEliminar)) { portapapeles.remove(i);/* w w w . j av a 2 s . com*/ } } if (portapapeles.size() == 0) { sesEmpa.setAccion(NORMAL); sesEmpa.setModoPegar(false); } // inserto el portapapeles sin el elemento a eliminar sesEmpa.setPortapapeles(portapapeles); } else { throw new ValidatorException(PORTAL_EMPAQUETADO_EXCEPTION_SESSION); } }
From source file:es.pode.empaquetador.presentacion.basico.gestor.GestorBasicoControllerImpl.java
/** * @see es.pode.empaquetador.presentacion.basico.gestor.GestorBasicoController#bajar(org.apache.struts.action.ActionMapping, * es.pode.empaquetador.presentacion.basico.gestor.BajarForm, * javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */// w ww.j a v a 2 s.c om public final void bajar(ActionMapping mapping, es.pode.empaquetador.presentacion.basico.gestor.BajarForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String idODE = this.getEmpaquetadorSession(request).getIdLocalizador(); if (logger.isDebugEnabled()) logger.debug("Bajando el ODE : " + idODE); if (idODE != null && form.getIdentifier() != null) { try { this.getSrvGestorManifestService().bajarItem(idODE, form.getIdentifier()); } catch (Exception e) { throw new ValidatorException("{gestor_basico.error_bajar}"); } } }
From source file:es.pode.administracion.presentacion.planificador.crearTarea.CrearTareaControllerImpl.java
/** * Recoge los valores de la tarea y del informe y llama al metodo que crea una tarea(siempre no periodica) de informe fecha * @param mapping//from w w w . j a v a2 s .com * @param form * Formulario en el que se guardan los datos de la tarea * @param request * @param response * @throws Exception */ public void crearTareaInformesFecha(org.apache.struts.action.ActionMapping mapping, es.pode.administracion.presentacion.planificador.crearTarea.CrearTareaInformesFechaForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception { if (tz == null) tz = utilidades.asignarZonaHoraria(); String dia = new String(form.getDia()); String mes = new String(form.getMes()); String anio = new String(form.getAnio()); String hora = new String(form.getHora()); String minutos = new String(form.getMinutos()); try { //convertimos los datos de fecha de inicio en un calendar Calendar fechaInicio = Calendar.getInstance(tz); fechaInicio = new GregorianCalendar(new Integer(anio).intValue(), new Integer(mes).intValue() - 1, new Integer(dia).intValue(), new Integer(hora).intValue(), new Integer(minutos).intValue()); TareaInformesVO tareaInformeVO = new TareaInformesVO(); //Recogemos el usuario para mandarlo en el TareaInformesVO String usuario = LdapUserDetailsUtils.getUsuario(); if (log.isDebugEnabled()) log.debug("rellenamos los datos del VO desde el formulario"); //recogemos los valores del formulario y los metemos en el VO para lanzar el servicio tareaInformeVO.setTrabajo(form.getTrabajo()); tareaInformeVO.setTrigger(form.getTrigger()); tareaInformeVO.setTipoTarea(form.getTipoTarea()); tareaInformeVO.setInforme(form.getTipoTarea()); tareaInformeVO.setMsgDescripcionTrabajo(form.getMsgDescTrabajo()); tareaInformeVO.setMsgInforme(form.getMsgInforme()); tareaInformeVO.setMsgNoInforme(form.getMsgNoInforme()); tareaInformeVO.setPeriodicidad(form.getPeriodicidad()); tareaInformeVO.setFormato(form.getFormato()); tareaInformeVO.setFechaInicio(fechaInicio); tareaInformeVO.setUsuario(usuario); if ((form.getPeriodicidad()).equalsIgnoreCase("N")) { String diaDesde = new String(form.getDiaDesde()); String mesDesde = new String(form.getMesDesde()); String anioDesde = new String(form.getAnioDesde()); String diaHasta = new String(form.getDiaHasta()); String mesHasta = new String(form.getMesHasta()); String anioHasta = new String(form.getAnioHasta()); //Comprobamos si estan vacas las dos fechas(Desde y Hasta), si es asi, asignaramos fechas de un rango amplio if (log.isDebugEnabled()) log.debug("Se comprueba si la fecha Desde y Hasta estan vacias"); if (anioDesde.equalsIgnoreCase("") && mesDesde.equalsIgnoreCase("") && diaDesde.equalsIgnoreCase("") && anioHasta.equalsIgnoreCase("") && mesHasta.equalsIgnoreCase("") && diaHasta.equalsIgnoreCase("")) { if (log.isDebugEnabled()) log.debug("El rango de fechas esta vacio asignamos unas por defecto"); form.setAnioDesde("2007"); form.setMesDesde("1"); form.setDiaDesde("1"); form.setAnioHasta("2100"); form.setMesHasta("1"); form.setDiaHasta("1"); } else { //Comprobamos que todos los campos de la fecha desde estn rellenos if (anioDesde.equalsIgnoreCase("") || mesDesde.equalsIgnoreCase("") || diaDesde.equalsIgnoreCase("")) throw new ValidatorException("{informes.crearInformes.fechaDesdeCampoVacio}"); //Comprobamos que todos los campos de la fecha hasta estn rellenos if (anioHasta.equalsIgnoreCase("") || mesHasta.equalsIgnoreCase("") || diaHasta.equalsIgnoreCase("")) throw new ValidatorException("{informes.crearInformes.fechaHastaCampoVacio}"); } //Comprobamos que la fecha Desde es numerica if (log.isDebugEnabled()) log.debug("comprobamos si las fechas Desde y Hasta tienen caracteres no numericos"); try { new Integer(diaDesde).intValue(); new Integer(mesDesde).intValue(); new Integer(anioDesde).intValue(); } catch (Exception e) { log.error("Alguno de los campos de la fecha desde no son nmeros"); throw new ValidatorException("{tareas.eliminarOdes.fechaDesde}"); } //Comprobamos que la fecha Hasta es numerica try { new Integer(diaHasta).intValue(); new Integer(mesHasta).intValue(); new Integer(anioHasta).intValue(); } catch (Exception e) { log.error("Alguno de los campos de la fecha hasta no son nmeros"); throw new ValidatorException("{tareas.eliminarOdes.fechaHasta}"); } //Comprobamos si las fechas son correctas if (log.isDebugEnabled()) log.debug("Se comprueba si la fecha Desde es correcta"); boolean fechaDesdeValida = utilidades.validacionFechaDDMMAAAAHHMM(diaDesde, mesDesde, anioDesde, "yyyyMMdd"); if (!fechaDesdeValida) throw new ValidatorException("{informes.crearInformes.fechaDesdeIncorrecta}"); if (log.isDebugEnabled()) log.debug("Se comprueba si la fecha Hasta es correcta"); boolean fechaHastaValida = utilidades.validacionFechaDDMMAAAAHHMM(diaHasta, mesHasta, anioHasta, "yyyyMMdd"); if (!fechaHastaValida) throw new ValidatorException("{informes.crearInformes.fechaHastaIncorrecta}"); //Comprobamos que la fecha Hasta es mayor o igual que la fecha Desde if (log.isDebugEnabled()) log.debug("Se comprueba si la fecha Desde es menor que la fecha Hasta"); boolean comparacionFecha = utilidades.comparacionFechas(anioDesde, mesDesde, diaDesde, anioHasta, mesHasta, diaHasta); if (!comparacionFecha) throw new ValidatorException("{informes.crearInformes.fechasOrdenIncorrectas}"); if (log.isDebugEnabled()) log.debug("Comprobamos que los campos dia y mes (de Desde y Hasta) tengan dos digitos"); //Comprobamos si el dia y la hora tienen dos dgitos if (diaDesde.length() == 1) diaDesde = "0" + diaDesde; if (mesDesde.length() == 1) mesDesde = "0" + mesDesde; if (diaHasta.length() == 1) diaHasta = "0" + diaHasta; if (mesHasta.length() == 1) mesHasta = "0" + mesHasta; //convertimos los datos de fechas Desde y Hasta en un calendar Calendar fechaDesde = Calendar.getInstance(tz); fechaDesde = new GregorianCalendar(new Integer(anioDesde).intValue(), new Integer(mesDesde).intValue() - 1, new Integer(diaDesde).intValue(), 00, 00); Calendar fechaHasta = Calendar.getInstance(tz); fechaHasta = new GregorianCalendar(new Integer(anioHasta).intValue(), new Integer(mesHasta).intValue() - 1, new Integer(form.getDiaHasta()).intValue(), 23, 59); tareaInformeVO.setFechaDesde(fechaDesde); tareaInformeVO.setFechaHasta(fechaHasta); } else if (log.isDebugEnabled()) log.debug("La tarea es periodica y no se pasa fechaDesde y fechaHasta. El servicio lo rellena"); if (log.isDebugEnabled()) log.debug("Despues de rellenar el TareaInformeVO"); //Llamamos al servicio if (log.isDebugEnabled()) log.debug("LLamamos al servicio"); TareaInformesVO tareaRecuperada = this.getSrvPlanificadorService().crearTareaInformes(tareaInformeVO); form.setTareaModificada(tareaRecuperada.getTrabajo()); } catch (ValidatorException e2) { log.error("Se ha producido la siguiente excepcion" + e2); throw e2; } catch (Exception e) { if (log.isDebugEnabled()) log.debug("se ha producido una excepcion en cargarInformeFechas" + e); throw new ValidatorException("{errors.crearInformes.general}"); } }
From source file:es.pode.empaquetador.presentacion.avanzado.organizaciones.elementos.gestor.GestorElementosControllerImpl.java
public final void vaciarPortapapeles(ActionMapping mapping, VaciarPortapapelesForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { EmpaquetadorSession sesEmpa = this.getEmpaquetadorSession(request); List portapapeles = sesEmpa.getPortapapeles(); if (portapapeles != null && portapapeles.size() > 0) { portapapeles.clear();/*from w w w . jav a 2s. c o m*/ sesEmpa.setPortapapeles(portapapeles); sesEmpa.setAccion(NORMAL); sesEmpa.setModoPegar(false); } else { throw new ValidatorException(PORTAL_EMPAQUETADO_EXCEPTION_SESSION); } }
From source file:es.pode.empaquetador.presentacion.archivos.gestor.GestorArchivosControllerImpl.java
/** * @see es.pode.empaquetador.presentacion.archivos.gestor.GestorArchivosController#eliminar(org.apache.struts.action.ActionMapping, es.pode.empaquetador.presentacion.archivos.gestor.EliminarForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *///from ww w . j av a 2 s .c o m public final void eliminar(ActionMapping mapping, es.pode.empaquetador.presentacion.archivos.gestor.EliminarForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { EmpaquetadorSession sesEmpaq = this.getEmpaquetadorSession(request); boolean checked = true; ArchivoVO[] ficheros = (ArchivoVO[]) form.getArchivosVO().toArray(new ArchivoVO[] {}); //obtengo el identificador el ultimo ODEVO String identificador = sesEmpaq.getIdLocalizador(); if (ficheros != null && ficheros.length > 0) { this.getSrvEmpaquetadorBasicoService().eliminarFicheros(identificador, ficheros, checked); } else { throw new ValidatorException("{portalempaquetado.archivos.eliminar.error.noseleccionado}"); } }
From source file:es.pode.administracion.presentacion.adminusuarios.altaUsuario.AltaUsuarioControllerImpl.java
/** * Metodo que recupera todos los grupos de trabajo que existen en la plataforma * @param form formulario con los datos del usuario que se quiere dar de alta * @throws Exception// w w w . ja va 2s . co m */ public void recuperarGruposTrabajo(ActionMapping mapping, RecuperarGruposTrabajoForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try { GrupoTrabajoVO[] grupoTrabajoVO = this.getSrvAdminUsuariosService().listarGruposTrabajo(); form.setGruposTrabajoAsArray(grupoTrabajoVO); } catch (Exception e) { log.error("Error al obtener los grupos de trabajo " + e); throw new ValidatorException("{errors.altausuario}"); } }