Example usage for org.apache.commons.validator ValidatorException ValidatorException

List of usage examples for org.apache.commons.validator ValidatorException ValidatorException

Introduction

In this page you can find the example usage for org.apache.commons.validator ValidatorException ValidatorException.

Prototype

public ValidatorException(String message) 

Source Link

Document

Constructs an Exception with the specified detail message.

Usage

From source file:es.pode.administracion.presentacion.noticias.verNoticia.VerNoticiaControllerImpl.java

/**
 * @see es.pode.administracion.presentacion.noticias.verNoticia.VerNoticiaController#obtenerNoticias(org.apache.struts.action.ActionMapping, es.pode.administracion.presentacion.noticias.verNoticia.ObtenerNoticiasForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *//*  www. j a v  a  2s  .  c o m*/
public final void obtenerNoticias(ActionMapping mapping,
        es.pode.administracion.presentacion.noticias.verNoticia.ObtenerNoticiasForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    try {
        /**
         * **************************************************************************************************************************************
         * ****************************************** SE OBTIENEN LOS IDIOMAS TRADUCIBLES *******************************************************
         * **************************************************************************************************************************************
         * */
        if (logger.isDebugEnabled())
            logger.debug("Obtenemos los idiomas traducibles");

        String[] idiomasPlataforma = I18n.getInstance().obtenerIdiomasPlataforma();
        if (logger.isDebugEnabled())
            logger.debug("Hay [" + idiomasPlataforma.length + "] en la plataforma");

        String idiomaLogado = LdapUserDetailsUtils.getIdioma();
        String idiomaPrioritario = I18n.getInstance().obtenerIdiomaDefectoPlataforma();
        String idiomaSecundario = I18n.getInstance().obtenerIdiomaSecundarioPlataforma();
        if (logger.isDebugEnabled())
            logger.debug(
                    "El idioma del usuario es [" + idiomaLogado + "], idioma prioritario de la plataforma es ["
                            + idiomaPrioritario + "] y el secundario es [" + idiomaSecundario + "]");

        // Rellena el combo de categorias
        NoticiasControllerImpl noticiasController = new NoticiasControllerImpl();
        Collection categorias = Arrays.asList(this.getSrvNoticiasService()
                .obtenerCategoriasTraducidas(noticiasController.devuelveIdiomasTraducibles(idiomasPlataforma,
                        idiomaLogado, idiomaPrioritario, idiomaSecundario)));
        form.setCategoriaBackingList(categorias, "idCategoriaNoticia", "nombreCategoria");

        //      Se obtiene los datos de la noticia
        if (logger.isDebugEnabled())
            logger.debug("Se obtiene los datos de la noticia con identificador [" + form.getIdNoticia() + "]");
        NoticiaVO noticia = this.getSrvNoticiasService().obtenerNoticia(form.getIdNoticia());
        request.getSession().setAttribute(VERNOTICIAVO, noticia);
        form.setEstado(noticia.getActiva());
        form.setAlineamiento(noticia.getAlineamientoImg());
        form.setCategoria(noticia.getCategoria().getId());
        if (form.getActivarImagen() == null) {
            //No viene con valor
            //             Tratamiento de la imagen   
            String sURLImagen = noticia.getURLImagen();
            if (sURLImagen != null && sURLImagen.indexOf("/") != -1) {
                form.setActivarImagen(new Integer(1));
                String sToken[] = sURLImagen.split("/");
                form.setNombreImagen(sToken[sToken.length - 1]);

            } else
                form.setActivarImagen(new Integer(2));

        }

    } catch (Exception e) {
        logger.error("Error obteniendo la noticia a ver");
        throw new ValidatorException("{error.obteniendo.noticia.ver}");
    }

}

From source file:es.pode.administracion.presentacion.faqs.modificar.ModificarControllerImpl.java

/**
 * @see es.pode.administracion.presentacion.faqs.modificar.ModificarController#obtenerIdentificadores(org.apache.struts.action.ActionMapping, es.pode.administracion.presentacion.faqs.modificar.ObtenerIdentificadoresForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *//*from   w w  w  . j  a v a  2s .  c om*/
public final void obtenerIdentificadores(ActionMapping mapping,
        es.pode.administracion.presentacion.faqs.modificar.ObtenerIdentificadoresForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    try {
        /**
        * **************************************************************************************************************************************
        * ****************************************** SE OBTIENEN LOS IDIOMAS TRADUCIBLES *******************************************************
        * **************************************************************************************************************************************
        * */
        if (logger.isDebugEnabled())
            logger.debug("Obtenemos los idiomas traducibles");

        String[] idiomasPlataforma = I18n.getInstance().obtenerIdiomasPlataforma();
        if (logger.isDebugEnabled())
            logger.debug("Hay [" + idiomasPlataforma.length + "] en la plataforma");

        String idiomaLogado = LdapUserDetailsUtils.getIdioma();
        String idiomaPrioritario = I18n.getInstance().obtenerIdiomaDefectoPlataforma();
        String idiomaSecundario = I18n.getInstance().obtenerIdiomaSecundarioPlataforma();
        if (logger.isDebugEnabled())
            logger.debug(
                    "El idioma del usuario es [" + idiomaLogado + "], idioma prioritario de la plataforma es ["
                            + idiomaPrioritario + "] y el secundario es [" + idiomaSecundario + "]");

        // Rellena el combo de categorias
        NoticiasControllerImpl noticiasController = new NoticiasControllerImpl();

        Collection categorias = Arrays.asList(this.getSrvFaqService()
                .obtenerCategoriasTraducidas(noticiasController.devuelveIdiomasTraducibles(idiomasPlataforma,
                        idiomaLogado, idiomaPrioritario, idiomaSecundario)));
        form.setCategoriaBackingList(categorias, "id", "nombre");

        //      Se obtiene los datos de la faq
        if (logger.isDebugEnabled())
            logger.debug("Se obtiene los datos de la faq con identificador [" + form.getId() + "]");
        FaqVO faq = this.getSrvFaqService().consultaFaq(form.getId());
        request.getSession().setAttribute(VERFAQVO, faq);

        form.setCategoria(faq.getCategoria().getId());

    } catch (Exception e) {
        logger.error("Error obteniendo la faq");
        throw new ValidatorException("{errorObteniendoFaq}");
    }

}

From source file:es.pode.empaquetador.presentacion.secuencia.SecuenciaControllerImpl.java

public String selectAction(ActionMapping mapping, SelectActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    String resultado = null;//from   w w w  .jav a 2s. co m

    java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE);
    ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale);

    String accion = form.getAction();

    if (accion.equals(i18n.getString("portal_empaquetado_secuencia.aceptar"))) {
        if ((form.getChoice() == null) || (form.getChoiceExit() == null) || (form.getFlow() == null)
                || (form.getForwardOnly() == null)) {
            throw new ValidatorException("{portal_empaquetado.exception}");
        }
    }

    if (form.getAction() == (null)) {
        throw new ValidatorException("{portal_empaquetado.exception}");
    }

    else if (accion.equals(i18n.getString("portal_empaquetado_secuencia.cancelar"))) {
        resultado = "Cancelar";
    } else if (accion.equals(i18n.getString("portal_empaquetado_secuencia.aceptar"))) {
        resultado = "Aceptar";
    } else if (accion.equals(i18n.getString("secuencia.valorPorDefecto"))) {
        resultado = "Default";
    }

    return resultado;
}

From source file:es.pode.empaquetador.presentacion.avanzado.recursos.gestor.GestorRecursosControllerImpl.java

public final java.lang.String selectAction(ActionMapping mapping,
        es.pode.empaquetador.presentacion.avanzado.recursos.gestor.SelectActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    /*//from  w ww.  j a va 2 s . c o m
    * 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("{comunes.error.generico}");
    }

    else if (actionSubmit.equals(i18n.getString("presentacion.avanzado.recursos.gestor.submit.crear"))) {
        result = "Crear";
    } else if (actionSubmit.equals(i18n.getString("presentacion.avanzado.recursos.gestor.submit.importar"))) {
        result = "Importar";
    } else if (actionSubmit.equals(i18n.getString("presentacion.avanzado.recursos.gestor.submit.exportar"))) {
        result = "Exportar";
    } else if (actionSubmit.equals(i18n.getString("presentacion.avanzado.recursos.gestor.submit.eliminar"))) {
        result = "Eliminar";
    } else {

        Logger.getLogger(this.getClass())
                .error("El valor del submit no es correcto (actionSubmit = " + actionSubmit + ";");
    }
    return result;
}

From source file:es.pode.administracion.presentacion.logs.listar.ListarLogControllerImpl.java

public final void recuperarFicheroLog(org.apache.struts.action.ActionMapping mapping,
        es.pode.administracion.presentacion.logs.listar.RecuperarFicheroLogForm form,
        javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
        throws java.lang.Exception {
    try {/*from  w  w w .  ja va2s. c om*/
        String fichero = (String) form.getNombre();
        DataHandler dataHandler = null;
        SrvLogService logService = this.getSrvLogService();
        try {
            dataHandler = logService.recuperarFicheroLog(fichero);

        } catch (Exception e) {
            log.error("Error al recuperar el fichero");
        }
        if (dataHandler == null) {
            log.error("El fichero recuperado est vacio");
            throw new ValidatorException("{recuperarFicheroLog.FALLO}");
        }
        if (fichero.endsWith(".log")) {
            response.setContentType("application/text");
        } else {
            response.setContentType("application/zip");
        }
        response.setHeader("Content-Disposition", "attachment;filename=" + fichero);
        OutputStream out = response.getOutputStream();
        InputStream in = dataHandler.getInputStream();
        if (log.isDebugEnabled())
            log.debug("recuperando el fichero " + fichero);
        byte[] buffer = new byte[BUFFER_SIZE];
        int count;
        while ((count = in.read(buffer, 0, BUFFER_SIZE)) != -1) {
            out.write(buffer, 0, count);
        }

        out.flush();
        out.close();

    } catch (ValidatorException e) {
        throw e;
    } catch (Exception e) {
        log.error("Se ha producido el siguiente error: " + e);
        throw e;
    }

}

From source file:es.pode.empaquetador.presentacion.avanzado.organizaciones.elementos.crearelemento.CrearElementoControllerImpl.java

public final void submit01(ActionMapping mapping,
        es.pode.empaquetador.presentacion.avanzado.organizaciones.elementos.crearelemento.Submit01Form form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    CrearElementoSession sesElem = this.getCrearElementoSession(request);

    java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE);
    ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale);

    String tipo = form.getReferenciado();
    String titulo = form.getTitle();
    String[] selectPresentation = form.getSelectPresentation();
    String completionThreshold = form.getCompletionThreshold();
    String dataFromLMS = form.getDataFromLMS();
    String timeLimitAction = form.getTimeLimitAction();
    Boolean isVisible = form.getIsVisible();
    String accion = form.getAction();
    logger.debug("Datos del form tras el paso 01 de crear elemento : title = " + form.getTitle() + " : tipo = "
            + form.getReferenciado());//  w w  w. j  a v  a 2 s  . co  m
    if (accion.equals(i18n.getString("portal_empaquetado_crearElemento.continuar"))) {
        sesElem.setReferenciado(tipo);

        if (form.getTitle() == null || form.getTitle().trim().equals("")) {
            throw new ValidatorException("{portal_empaquetado_crearElemento.exception}");
        } else {
            sesElem.setTitle(titulo);
        }

        sesElem.setSelectPresentation(selectPresentation);
        Double content = null;
        if (!completionThreshold.equals("")) {
            //                 Pattern pattern = Pattern.compile("^[0-9]*(.[0-9]*)?$");
            Pattern pattern = Pattern.compile("^((0+(\\.[0-9]+)?)|(0*1(\\.0+)?))$");
            Matcher matcher = pattern.matcher(completionThreshold);

            if (matcher.find()) {
                content = new Double(completionThreshold);
            } else {
                throw new ValidatorException("{portal_empaquetado_crearElemento.exceptionCompletion}");
            }
        }
        sesElem.setCompletionThreshold(content);
        sesElem.setDataFromLMS(dataFromLMS);
        sesElem.setTimeLimitAction(timeLimitAction);
        sesElem.setSelectPresentation(selectPresentation);
        sesElem.setIsVisible(isVisible);
    }
}

From source file:es.pode.modificador.presentacion.configurar.cambios.navegarLom.NavegarLomControllerImpl.java

/**
 * @see es.pode.modificador.presentacion.configurar.cambios.navegarLom.NavegarLomController#guardarTermino(org.apache.struts.action.ActionMapping, es.pode.modificador.presentacion.configurar.cambios.navegarLom.GuardarTerminoForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *///from   w w  w.  ja  v a  2s .  com
public final void guardarTermino(ActionMapping mapping,
        es.pode.modificador.presentacion.configurar.cambios.navegarLom.GuardarTerminoForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    String actionSubmit = form.getAction();
    java.util.Locale locale = (java.util.Locale) request.getSession()
            .getAttribute(ConstantesAgrega.DEFAULT_LOCALE);
    ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale);

    if (!actionSubmit.equals(i18n.getString("comun.cancelar"))) {
        String idTermino = form.getIdTermino();
        String terminoLom = form.getTerminoLom();

        if (logger.isDebugEnabled())
            logger.debug("guardarTermino() : idTermino = " + idTermino + " : terminoLom = " + terminoLom
                    + " : action = " + form.getAction());

        if (idTermino == null || terminoLom == null) {
            logger.error("Error en guardarTermino");
            throw new ValidatorException("{navegarLom.error}");
        }

        this.getCambioSession(request).setIdLomTerm(idTermino);
        this.getCambioSession(request).setLomTerm(terminoLom);
    }

}

From source file:es.pode.administracion.presentacion.informes.listarInformesFederados.ListarInformesFederadosControllerImpl.java

/**
 * @see es.pode.administracion.presentacion.informes.listarInformesFederados.ListarInformesFederadosController#getInformesFederados(org.apache.struts.action.ActionMapping, es.pode.administracion.presentacion.informes.listarInformesFederados.GetInformesFederadosForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *//*from   w  ww. j a  va  2s  .  co m*/
public final void getInformesFederados(ActionMapping mapping,
        es.pode.administracion.presentacion.informes.listarInformesFederados.GetInformesFederadosForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    try {
        List lista = ((FormularioListarInformesFederadosEliminarFormImpl) form).getNombreRowSelection();
        if (lista == null) {
            throw new ValidatorException("{errors.eliminarInformes.nombreNuloFederado}");
        }
        form.setIds(lista);
        if (logger.isDebugEnabled())
            logger.debug("Se van a eliminar los siguientes informes federados: " + lista);
    } catch (Exception e) {
        logger.error(
                "Se ha producido un error al intentar recuperar los ids de los informes federados a borrar: "
                        + e);
        throw e;
    }
}

From source file:es.pode.gestorFlujo.presentacion.objetosDespublicados.ObjetosDespublicadosControllerImpl.java

/**
 * //from  w w  w.j  av a2  s. c om
 * Este mtodo sirve simplemente para resolver un bug de ibuilder: la
 * imposibilidad de enviar en la misma llamada un idoRowSelection y otro
 * parmetro.
 * 
 */

public void submitArchivos(ActionMapping mapping, SubmitArchivosForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    //       Comprobamos que hay odes seleccionados
    if (form.getIdODERowSelection() == null)
        throw new ValidatorException("{gestorFlujo.error.eliminar.seleccione}");
    form.setOrigen("despublicados");
    String[] lOdes = new String[form.getIdODERowSelection().size()];
    form.getIdODERowSelection().toArray(lOdes);
    form.setListODEs(lOdes);

}

From source file:es.pode.modificador.presentacion.configurar.objetos.resultados.ResultadosBuscarObjetoControllerImpl.java

/**
 * @see es.pode.modificador.presentacion.configurar.objetos.resultados.ResultadosBuscarObjetoController#buscar(org.apache.struts.action.ActionMapping,
 *      es.pode.modificador.presentacion.configurar.objetos.resultados.BuscarForm,
 *      javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse)
 *///ww  w. j  a  v  a 2 s  .c  o m
public final void buscar(ActionMapping mapping,
        es.pode.modificador.presentacion.configurar.objetos.resultados.BuscarForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    logger.debug("Recuperamos lista previa de resultados");
    BusquedaSession sesion = getBusquedaSession(request);
    List resultados = sesion.getResultados();
    if (resultados == null) {
        logger.debug("No se encontraron resultados previos");
        ParamAvanzadoVO parametros = new ParamAvanzadoVO();
        // Fecha desde
        String fecha = VACIA;
        String fromYear = sesion.getAnyoDesde();
        String fromMonth = sesion.getMesDesde();
        String fromDay = sesion.getDiaDesde();
        String untilYear = sesion.getAnyoHasta();
        String untilMonth = sesion.getMesHasta();
        String untilDay = sesion.getDiaHasta();
        if (!vacia(fromYear) && !vacia(fromMonth) && !vacia(fromDay) && !vacia(untilYear) && !vacia(untilMonth)
                && !vacia(untilDay)) {
            logger.debug("Se encontraron parmetros de busqueda para intervalo fecha");
            fecha = fromYear + fromMonth + fromDay + " " + untilYear + untilMonth + untilDay;
        }
        parametros.setFechaPublicacionRango(fecha);
        if (!vacia(sesion.getAutor())) {
            logger.debug("Se encontr parmetro de busqueda para autor");
            parametros.setAutor(sesion.getAutor());
        }
        if (!vacia(sesion.getTitulo())) {
            logger.debug("Se encontr parmetro de busqueda para ttulo");
            parametros.setTitulo(sesion.getTitulo());
        }
        if (!vacia(sesion.getIdentificador())) {
            logger.debug("Se encontr parmetro de busqueda para identificador");
            parametros.setIdentificadorODE(sesion.getIdentificador());
        }
        String idioma = sesion.getIdioma() == null ? "es" : sesion.getIdioma();
        //         String idioma = "es";
        parametros.setIdiomaBusqueda(idioma);
        parametros.setIdiomaNavegacion(idioma);
        parametros.setNumeroResultados(new Integer(-1));
        try {
            DocumentosVO resultado = getSrvBuscadorService().busquedaAvanzada(parametros);
            DocVO docs[] = resultado.getResultados();
            resultados = new ArrayList();
            if (docs != null) {
                logger.debug("Se recuperaron " + (docs.length) + " resultados");
                for (int i = 0; i < docs.length; i++) {
                    //Corregimos problema de localizadorODE,
                    // algunos Docs viene con "//" en path. Sustituimos por "/"
                    String localizadorODE = docs[i].getLocalizadorODE().replaceAll("//", "/");
                    docs[i].setLocalizadorODE(localizadorODE);
                    resultados.add(docs[i]);
                }
            } else
                logger.debug("Se recuperaron 0 resultados");
            // sesion.setResultados(Arrays.asList(docs));
            logger.debug("Guardamos los resultados en sesin");
            sesion.setResultados(resultados);
            setBusquedaSession(request, sesion);
        } catch (Exception e) {
            logger.debug("Capturada excepcin: " + e);
            throw new ValidatorException("{resultadosBusqueda.excepcion}");
        }
    }
    logger.debug("Pasamos lista de seleccionados a Form");
    form.setSeleccionados(sesion.getSeleccionados());
    // form.setResultados(Arrays.asList(docs));
    logger.debug("Pasamos lista de resultados a Form");
    form.setResultados(resultados);

    form.setIdiomaBuscadorBackingList(
            IdiomasBuscadorSingleton.getInstance().obtenerIdiomas(LdapUserDetailsUtils.getIdioma()),
            "idLocalizacion", "nombre");
}