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.modificador.presentacion.importar.ImportarModificacionControllerImpl.java

/**
 * @see es.pode.modificador.presentacion.importar.ImportarModificacionController#importar(org.apache.struts.action.ActionMapping, es.pode.modificador.presentacion.importar.ImportarForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *///from   w  ww  .j ava 2s  .c  om
public final void importar(ActionMapping mapping, es.pode.modificador.presentacion.importar.ImportarForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    FormFile xml = form.getFichero();
    if (xml == null || xml.getFileSize() == 0) {
        throw new ValidatorException("{importarModificacion.error}");
    }
    //       convierto el FormFile en un DataHandler
    InternetHeaders ih = new InternetHeaders();
    MimeBodyPart mbp = null;
    DataSource source = null;
    DataHandler dFichero = null;
    mbp = new MimeBodyPart(ih, xml.getFileData());
    source = new MimePartDataSource(mbp);
    dFichero = new DataHandler(source);

    // Llamo al servicio para parsear el fichero XML
    ConfiguracionTarea configuracion;
    try {
        configuracion = this.getSrvHerramientaModificacion().importarModificacion(dFichero);
    } catch (Exception e) {
        throw new ValidatorException("{importarModificacion.error}");
    }

    // Creo el objeto de sesion para editar la tarea
    this.getConfigurarModificacionSession(request).setConfiguracion(configuracion);
}

From source file:es.pode.administracion.presentacion.repositoriosExternos.verRepositoriosExternos.VerNodoSQIControllerImpl.java

public void cargaNodoSQI(ActionMapping mapping, CargaNodoSQIForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    try {/*from w  w  w. ja v  a2s  . c o m*/

        Long id = Long.valueOf(request.getParameter("id"));
        Long[] ids = new Long[1];
        ids[0] = id;
        NodoSQIVO[] nodos = this.getSrvGestionSqiService().consultaNodosSQI(ids);
        NodoSQIVO nodo = nodos[0];

        form.setClave(nodo.getClave());
        form.setDescripcionNodo(nodo.getDescripcionNodo());
        form.setGestorSesion(nodo.getGestorSesion());
        form.setId(id);
        form.setIdentificadorSesion(nodo.getIdentificadorSesion());
        form.setLenguajeConsulta(nodo.getLenguajeConsulta());
        form.setLenguajeRespuesta(nodo.getLenguajeRespuesta());
        form.setNombreNodo(nodo.getNombreNodo());
        form.setUrlServicio(nodo.getUrlServicio());
        form.setUsuario(nodo.getUsuario());

    } catch (Exception e) {
        logger.error("Error: " + e);
        throw new ValidatorException("{errors.vernodoSQI}");
    }

}

From source file:es.pode.administracion.presentacion.planificador.listarTareasEjecutadas.TareasEjecutadasControllerImpl.java

/**
 * metodo que obtiene los trabajos ejecutados que se han seleccionado para ser eliminados
 *//*w  w  w .j a v  a2s .c  om*/
public final void obtenerIdsTrabajos(org.apache.struts.action.ActionMapping mapping,
        es.pode.administracion.presentacion.planificador.listarTareasEjecutadas.ObtenerIdsTrabajosForm form,
        javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
        throws java.lang.Exception {
    try {

        List lista = ((ListarEliminarFormImpl) form).getIdRowSelection();

        if (lista == null) {
            throw new ValidatorException("{tareas.errorEliminar}");
        } else {
            form.setIds((Collection) lista);
        }

    } catch (ValidatorException validator) {
        log.error("validator eception : " + validator);
        throw validator;
    } catch (Exception e) {
        log.error("Se produce una excepcion ", e);
        throw new ValidatorException("{tareas.error}");
    }
}

From source file:es.pode.modificador.presentacion.configurar.cambios.navegarArbolCurricular.NavegarArbolCurricularControllerImpl.java

/**
 * @see es.pode.modificador.presentacion.configurar.cambios.navegarArbolCurricular.NavegarArbolCurricularController#navegarETB(org.apache.struts.action.ActionMapping, es.pode.modificador.presentacion.configurar.cambios.navegarArbolCurricular.NavegarETBForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *//*from  w ww  .  jav a  2s.  c o  m*/

public String selectAction(ActionMapping mapping, SelectActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    //        tan simple como esto
    logger.debug("Accion en navegarController: " + form.getAction());
    if ("Aceptar".equals(form.getAction()) && form.getIdTermino() == null) {
        throw new ValidatorException("{navegarArbolCurricular.elemento.necesario}");
    }
    return form.getAction();
}

From source file:es.pode.administracion.presentacion.repositoriosExternos.bajaRepositoriosExternos.BajaNodoSQIControllerImpl.java

public void bajaNodoSQI(ActionMapping mapping, BajaNodoSQIForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    try {//from ww  w .  j a va2  s .  c  o  m
        if (form.getListaId() != null && !form.getListaId().equals("")) {
            String[] listIDsStrings = form.getListaId().split(",");
            if (logger.isDebugEnabled())
                logger.debug("La lista de identificadores:" + form.getListaId());
            Long[] listIDs = new Long[listIDsStrings.length];
            for (int i = 0; i < listIDsStrings.length; i++) {
                listIDs[i] = Long.valueOf(listIDsStrings[i]);
            }

            SrvGestionSqiService nodoService = this.getSrvGestionSqiService();
            NodoSQIVO[] nodo = nodoService.consultaNodosSQI(listIDs);
            form.setNodosSQIEliminarAsArray(nodo);
            nodoService.bajaNodosSQI(listIDs);

        } else {
            throw new ValidatorException("{errors.bajanodosSQI.idNulo}");
        }

    } catch (Exception e) {
        logger.error("Se ha producido un error al eliminar el nodoSQI: " + e);
        throw new ValidatorException("{errors.bajanodoSQI}");
    }

}

From source file:es.pode.administracion.presentacion.catalogacion.listarCatalogadores.listarCatalogadoresControllerImpl.java

/**
 * @see es.pode.administracion.presentacion.catalogacion.listarCatalogadores.listarCatalogadoresController#recuperarCatalogadores(org.apache.struts.action.ActionMapping, es.pode.administracion.presentacion.catalogacion.listarCatalogadores.RecuperarCatalogadoresForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *//*  w ww .  ja va2  s . c o m*/
public final void recuperarCatalogadores(ActionMapping mapping,
        es.pode.administracion.presentacion.catalogacion.listarCatalogadores.RecuperarCatalogadoresForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {

    try {

        GrupoTrabajoVO[] grupoTrabajoVO = this.getSrvAdminUsuariosService().listarGruposTrabajo();
        form.setGruposTrabajoAsArray(grupoTrabajoVO);

    } catch (Exception e) {
        log.error("Error: " + e);
        throw new ValidatorException("{listarGrupos.error}");
    }
}

From source file:es.pode.administracion.presentacion.planificador.listarTareasPendientes.TareasPendientesControllerImpl.java

public final void obtenerNombresTrabajos(org.apache.struts.action.ActionMapping mapping,
        es.pode.administracion.presentacion.planificador.listarTareasPendientes.ObtenerNombresTrabajosForm form,
        javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
        throws java.lang.Exception {
    String nombreTarea = "";
    List listaCodigoSeparador = new ArrayList();
    int i = 1;//from  w  w w . jav  a 2s  . c  o  m
    try {

        List lista = ((ListarEliminarFormImpl) form).getTrabajoRowSelection();

        if (lista == null) {
            throw new ValidatorException("{tareas.errorEliminar}");
        } else {
            form.setTrabajos(lista);
        }

    } catch (ValidatorException validator) {
        log.error("validator eception : " + validator);
        throw validator;
    } catch (Exception e) {
        log.error("Se produce una excepcion ", e);
        throw new ValidatorException("{tareas.error}");
    }
}

From source file:es.pode.empaquetador.presentacion.avanzado.recursos.importar.ImportarRecursosControllerImpl.java

public final void importarZIP(ActionMapping mapping,
        es.pode.empaquetador.presentacion.avanzado.recursos.importar.ImportarZIPForm 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("portalempaquetado.avanzado.recursos.aceptar"))) {

        FormFile fichero = form.getFichero();
        if (fichero.getFileName() == null || fichero.getFileName().equals("") || fichero.getFileSize() == 0) {
            throw new ValidatorException("{portalempaquetado.avanzado.recursos.importar.exception}");
            //tratar exception
        }//  ww w .  j a va  2  s  .co m
        try {

            InternetHeaders ih = new InternetHeaders();
            MimeBodyPart mbp = null;
            DataSource source = null;
            DataHandler dFichero = null;

            mbp = new MimeBodyPart(ih, fichero.getFileData());
            source = new MimePartDataSource(mbp);
            dFichero = new DataHandler(source);

            EmpaquetadorSession sesEmpaq = this.getEmpaquetadorSession(request);

            List listSubmPath = sesEmpaq.getSubmanifestPath();

            //cojo el primer elemento que dedberia ser el padre
            String identificador = sesEmpaq.getIdLocalizador();
            if (listSubmPath.size() == 1) {
                this.getSrvGestorManifestService().importarRecursos(identificador, dFichero, null);
            } else if (listSubmPath.size() > 1) {
                OdeVO odeultim = (OdeVO) listSubmPath.get(listSubmPath.size() - 1);
                String submanifestId = odeultim.getIdentifier();
                this.getSrvGestorManifestService().importarRecursos(identificador, dFichero, submanifestId);
            }
        } catch (Exception e) {
            throw new ValidatorException("{portalempaquetado.avanzado.recursos.importar.exception.validar}");

        }
    }

}

From source file:es.pode.visualizador.presentacion.agregaSlider.AgregaSliderControllerImpl.java

/**
 * Metodo que construye el codigo html que el usuario debe copiar en su web para aadir
 * la galeria de imagenes//from  w w  w . ja va 2  s . com
 * 
 * @param mapping
 * @param form Formulario con los datos necesarios
 * @param request
 * @param response
 * @throws Exception
 */
public final void construirCodigo(ActionMapping mapping,
        es.pode.visualizador.presentacion.agregaSlider.ConstruirCodigoForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    String keywords = form.getKeywords();
    String idioma = form.getIdiomasCombo();

    try {
        if (keywords == null || keywords == "") {
            //Lanzamos la excepcion porque las keywords estan vacias
            throw new ValidatorException("{agregaSlider.keywordVacia}");
        }

        boolean keywordsOK = comprobarKeywords(keywords);

        if (keywordsOK) {
            //Construimos el codigo html embebido
            String codigo = new String();

            ficheroRecursos = ResourceBundle.getBundle("application-resources", request.getLocale());

            String controller = ficheroRecursos.getString("agregaSlider.url.controller");
            String nodo = AgregaPropertiesImpl.getInstance().getProperty("host")
                    + AgregaPropertiesImpl.getInstance().getProperty("admin.ws.subdominio");

            String url = "http://" + nodo + "/" + ficheroRecursos.getString("agregaSlider.url.sfw");

            //rellenamos el codigo que le pasamos a la jsp para que el usuario lo recoja

            codigo = "<object width='400' height='400' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' "
                    + "codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0'>"
                    + "<param name='movie' value='" + url + "' />" + "<param name='Flashvars' value='palabras="
                    + keywords + "&amp;idioma=" + idioma + "&amp;nodo=" + nodo + "&amp;controller=" + controller
                    + "' />" + "<param name='bgcolor' value='#FFFFFF' /> " + "<embed src='" + url + "' "
                    + "type='application/x-shockwave-flash' " + "Flashvars='palabras=" + keywords
                    + "&amp;idioma=" + idioma + "&amp;nodo=" + nodo + "&amp;controller=" + controller + "' "
                    + "bgcolor='#FFFFFF' " + "pluginspage='http://www.macromedia.com/go/getflashplayer'"
                    + "width='400' " + "height='400'>" + "</embed>" + "</object> ";

            form.setCodigo(codigo);
        } else
            //Lanzamos la excepcion porque alguna keywords no esta bien metida
            throw new ValidatorException("{agregaSlider.keywordIncorrecta}");

    } catch (ValidatorException Ve) {
        log.error("Ve ->" + Ve);
        throw Ve;
    } catch (Exception e) {
        log.error("Error al crear el codigo embebido para el agregaSlider: " + e);
        throw new ValidatorException("{agregaSilder.errorCrearCodigoEmbebido}");
    }

}

From source file:es.pode.administracion.presentacion.monitorizarnodos.monitorizar.MonitorizarNodosControllerImpl.java

/**
 * @see es.pode.administracion.presentacion.monitorizarnodos.monitorizar.MonitorizarNodosController#estadoNodos(org.apache.struts.action.ActionMapping, es.pode.administracion.presentacion.monitorizarnodos.monitorizar.EstadoNodosForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *//*w  w w. j  ava  2  s  . co m*/
public final void estadoNodos(ActionMapping mapping,
        es.pode.administracion.presentacion.monitorizarnodos.monitorizar.EstadoNodosForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {

    try {

        SrvMonitorizarService service = this.getSrvMonitorizarService();
        EstadoNodoVO[] estados = service.obtenerEstadoNodos();
        prepararInformacion(estados, request.getLocale());
        form.setEstadosAsArray(estados);
    } catch (Exception e) {
        log.error("Se ha producido un error al monitorizar los nodos: " + e);
        throw new ValidatorException("{errors.monitorizarnodos}");
    }

}