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.gestorFlujo.presentacion.objetosPropuestos.ObjetosPropuestosControllerImpl.java

/**
 * @see es.pode.gestorFlujo.presentacion.objetosPropuestos.ObjetosPropuestosController#cargarODESPropuestos(org.apache.struts.action.ActionMapping, es.pode.gestorFlujo.presentacion.objetosPropuestos.CargarODESPropuestosForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *//*w  w  w . ja va2s  .co m*/
public final void cargarODESPropuestos(ActionMapping mapping,
        es.pode.gestorFlujo.presentacion.objetosPropuestos.CargarODESPropuestosForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {

    SrvPublicacionService publi = this.getSrvPublicacionService();
    if (logger.isDebugEnabled())
        logger.debug("Cargando odes propuestos catalogacin y publicacin para: "
                + LdapUserDetailsUtils.getUsuario());

    try {

        int recorrido = publi.obtenODEsPropuestosPorUsuario(LdapUserDetailsUtils.getUsuario()).length;
        if (recorrido > 0) {
            form.setListaODESAsArray(publi.obtenODEsPropuestosPorUsuario(LdapUserDetailsUtils.getUsuario()));
            recorrido = publi
                    .obtenODESPropuestosCatalogacionPorUsuario(LdapUserDetailsUtils.getUsuario()).length;
            if (recorrido > 0) {
                ArrayList collect = new ArrayList(form.getListaODES());
                for (int i = 0; i < recorrido; i++) {
                    TransicionVO trVO = publi
                            .obtenODESPropuestosCatalogacionPorUsuario(LdapUserDetailsUtils.getUsuario())[i];
                    collect.add(trVO);
                }
                form.setListaODES(collect);
            }
        } else
            form.setListaODESAsArray(
                    publi.obtenODESPropuestosCatalogacionPorUsuario(LdapUserDetailsUtils.getUsuario()));

    } catch (Exception ex) {
        logger.error("Error inesperado cargando objetos propuestos. ", ex);
        throw new ValidatorException("{gestorFlujo.error.inesperado}");
    }
}

From source file:es.pode.empaquetador.presentacion.avanzado.organizaciones.principal.OrganizacionPrincipalControllerImpl.java

public final void fijarOrganizacionPrincipal(ActionMapping mapping,
        es.pode.empaquetador.presentacion.avanzado.organizaciones.principal.FijarOrganizacionPrincipalForm 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 action = form.getAction();
    if (action.equals(i18n.getString("portal_empaquetado_gestorOrganizaciones.principalAceptar"))) {
        String idOrganizacion = form.getIdentifier();
        EmpaquetadorSession sesEmpaq = this.getEmpaquetadorSession(request);
        List subman = sesEmpaq.getSubmanifestPath();

        if (subman != null && subman.size() > 0) {
            OdeVO ultimo = (OdeVO) subman.get(subman.size() - 1);
            Integer index = subman.size() - 1;
            String identificador = index == 0 ? sesEmpaq.getIdLocalizador() : ultimo.getIdentifier();

            this.getSrvGestorManifestService().fijarOrganizacionPorDefecto(identificador, idOrganizacion);
        } else {// ww  w .  j  a  v a 2s. c o  m
            throw new ValidatorException("{portal_empaquetado.exception}");
        }
    }
}

From source file:es.pode.gestorFlujo.presentacion.objetosPendientesCatalogacion.ObjetosPendientesCatalogacionControllerImpl.java

public void cargarODESPendientesCatalogacion(ActionMapping mapping, CargarODESPendientesCatalogacionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    if (logger.isDebugEnabled())
        logger.debug("Cargando objetos Pendientes catalogacion");
    SrvPublicacionService publi = this.getSrvPublicacionService();
    SrvAdminUsuariosService admin = this.getSrvAdminUsuariosService();
    try {/*from w ww.j  av a  2  s  .co m*/
        TransicionVO[] odes = null;
        String[] todosUsuariosGrupos = admin
                .obtenerListaUsuariosGrupoTrabajo(LdapUserDetailsUtils.getUsuario());
        //            
        //            String[] todosUsuariosGrupos=new String[] {LdapUserDetailsUtils.getUsuario()};
        if (todosUsuariosGrupos != null && todosUsuariosGrupos.length > 0) {
            logger.info("Obtenidos lista de usuarios de los grupos pertenecientes de usuario:["
                    + LdapUserDetailsUtils.getUsuario() + "Numero de usuarios:[" + todosUsuariosGrupos.length);
            odes = publi.obtenODEsPropuestosCatalogacionPorUsuarios(todosUsuariosGrupos);
            logger.info("Obtenidos odes de esos usuarios, numero de odes pendientes de catalogacion["
                    + odes.length);
        } else {
            logger.info("Obtenidos lista de todos los ODES, pues el usuario:["
                    + LdapUserDetailsUtils.getUsuario() + " es parte de todos los grupos");
            odes = publi.obtenODESPropuestosCatalogacion();
            logger.info("Obtenidos odes de todos los usuarios, numero de odes pendientes de catalogacion["
                    + odes.length);
        }
        form.setListaODESAsArray(odes);
    } catch (Exception ex) {
        logger.error("Imposible obtener los odes pendientes catalogacion", ex);
        throw new ValidatorException("{gestorFlujo.error.inesperado}");
    }
    form.setIdUsuario(LdapUserDetailsUtils.getUsuario());

    logger.info("Objetos Pendientes Catalogacion cargados correctamente");

}

From source file:es.pode.administracion.presentacion.estructuraseducativas.arboles.alta.AltaArbolesControllerImpl.java

public final void nuevoArbol(ActionMapping mapping, NuevoArbolForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    VdexVO[] resultado = null;//ww  w .  ja v  a  2s .  c o  m

    List ficheros = new ArrayList();
    if (form.getFichero1() != null && form.getFichero1().getFileName() != null
            && !form.getFichero1().getFileName().equals(""))//&& form.getFichero1().getFileSize()>0 
        ficheros.add(form.getFichero1());
    if (form.getFichero2() != null && form.getFichero2().getFileName() != null
            && !form.getFichero2().getFileName().equals(""))
        ficheros.add(form.getFichero2());
    if (form.getFichero3() != null && form.getFichero3().getFileName() != null
            && !form.getFichero3().getFileName().equals(""))
        ficheros.add(form.getFichero3());
    if (form.getFichero4() != null && form.getFichero4().getFileName() != null
            && !form.getFichero4().getFileName().equals(""))
        ficheros.add(form.getFichero4());
    if (form.getFichero5() != null && form.getFichero5().getFileName() != null
            && !form.getFichero5().getFileName().equals(""))
        ficheros.add(form.getFichero5());

    if (ficheros.size() == 0) {
        throw new ValidatorException("{estructuras.arboles.error.fichero.vacio}");
    }

    List arrayParam = new ArrayList();
    InternetHeaders ih = new InternetHeaders();
    MimeBodyPart mbp = null;
    DataSource source = null;
    DataHandler dh = null;
    for (int i = 0; i < ficheros.size(); i++) {
        try {
            FormFile ff = (FormFile) ficheros.get(i);
            mbp = new MimeBodyPart(ih, ff.getFileData());
            source = new MimePartDataSource(mbp);
            dh = new DataHandler(source);
            arrayParam.add(new ParamVdexVO(dh, ff.getFileName()));

        } catch (Exception e) {
            if (logger.isDebugEnabled()) {
                logger.debug("error al cargar la lista de paramVDEXVO");
            }
        }
    }
    try {
        SrvEstructurasEducativasService servicio = this.getSrvEstructurasEducativasService();
        resultado = servicio.subirArbolesCurriculares((ParamVdexVO[]) arrayParam.toArray(new ParamVdexVO[0]));

        for (int i = 0; i < resultado.length; i++) {
            String[] nombreVdex = new String[1];
            nombreVdex[0] = ((FormFile) ficheros.get(i)).getFileName();
            if (resultado[i].getCodigoError() != null && !resultado[i].getCodigoError().equals("")) {
                logger.debug("hubo un error al crear el nuevo arbol, se muestra el error en la jsp");
                this.saveErrorMessage(request, "estructuras.error.alta." + resultado[i].getCodigoError(),
                        nombreVdex);
            } else {
                this.saveSuccessMessage(request, "estructuras.arboles.alta.exito", nombreVdex);
            }
        }

    } catch (Exception e) {
        if (logger.isDebugEnabled()) {
            logger.debug("error al dar de alta lista de arboles");
        }
        this.saveErrorMessage(request, "estructuras.error.alta.0");
    }

}

From source file:es.pode.modificador.presentacion.configurar.cambios.add.TipoAnadirControllerImpl.java

/**
  * @see es.pode.modificador.presentacion.configurar.cambios.add.TipoAnadirController#selectAction(org.apache.struts.action.ActionMapping, es.pode.modificador.presentacion.configurar.cambios.add.SelectActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
  *//*www. j a v  a 2 s .  co  m*/
public final java.lang.String selectAction(ActionMapping mapping,
        es.pode.modificador.presentacion.configurar.cambios.add.SelectActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {

    String tipoAniadir = form.getTipoAniadir();
    Boolean alcance = form.getAlcance();
    String action = form.getAction();
    String result = "";
    String CONTINUAR = "Continuar";
    String CANCELAR = "Cancelar";
    java.util.Locale locale = (java.util.Locale) request.getSession()
            .getAttribute(ConstantesAgrega.DEFAULT_LOCALE);
    ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale);

    if (action.equals(i18n.getString("tipoAnadirAlcance.continuar"))) {
        if (tipoAniadir == null) {
            throw new ValidatorException("{tipoAnadirTipo.exception}");
        } else {
            this.getCambioSession(request).setTipoAniadir((form.getTipoAniadir()));
        }
        if (alcance == null) {
            throw new ValidatorException("{tipoAnadirAlcance.exception}");
        } else {
            this.getCambioSession(request).setAlcance(form.getAlcance());
        }
        result = CONTINUAR;
    }

    else {
        result = CANCELAR;
    }

    return result;
}

From source file:es.pode.administracion.presentacion.adminusuarios.listarGrupos.ListarGruposControllerImpl.java

/**
 * @see es.pode.administracion.presentacion.adminusuarios.listarUsuarios.ListarUsuariosController#obtenerIdentificadores(org.apache.struts.action.ActionMapping,
 *      es.pode.administracion.presentacion.adminusuarios.listarUsuarios.ObtenerIdentificadoresForm,
 *      javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse)
 *//* ww w  . jav  a  2 s . co  m*/
public final java.lang.String obtenerIdentificadores(ActionMapping mapping,
        es.pode.administracion.presentacion.adminusuarios.listarGrupos.ObtenerIdentificadoresForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {

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

    String resultado = "vacio";
    try {
        if (lista == null) {

            throw new ValidatorException("{errors.borrarGrupo.idNulo}");
        } else {
            // Validamos los grupos seleccionados para comprobar si tienen
            // usuarios asociados a ellos
            Long[] ids = new Long[lista.size()];
            Iterator iter = lista.iterator();
            SrvAdminUsuariosService srvAdminUsuariosService = this.getSrvAdminUsuariosService();
            int i = 0;
            while (iter.hasNext()) {

                Long id = new Long((String) iter.next());
                GrupoVO grupoVO = srvAdminUsuariosService.descripcionGrupo(id);

                if ((srvAdminUsuariosService.obtenerUsuariosGrupo(id)).booleanValue()) {
                    log.error("el grupo tiene un usuario " + grupoVO.getDescripcion());
                    throw new ValidatorException("{errors.borrarGrupo.GrupoConUsuarios}");

                } else {
                    ids[i] = id;
                    i++;
                }
            }

            // Comprobamos si se eliminan todos los grupos con rol
            // administrador
            Long[] gruposAdmin = srvAdminUsuariosService.obtenerGrupoAdministrador();
            List gruposAdminList = Arrays.asList(gruposAdmin);

            int num_Admin = gruposAdmin.length;
            int grupoDeleted = 0;

            for (int j = 0; j < ids.length; j++) {
                if (gruposAdminList.contains(ids[j])) {
                    if (log.isDebugEnabled())
                        log.debug("uno de los grupos seleccionados es administrador");
                    grupoDeleted = grupoDeleted + 1;
                }
            }
            if (grupoDeleted == num_Admin) {
                log.error("Se intenta eliminar todos los grupos administradores");
                throw new ValidatorException("{errors.borrarGrupo.todosUsuariosAdmin}");
            }
            form.setIds(lista);
            resultado = "identificadores";
            // return null;
        }
    } catch (ValidatorException validator) {
        log.error("Se ha producido la siguiente exception " + validator);
        throw validator;
    } catch (Exception e) {
        log.error("Se produce una excepcion ", e);
        throw new ValidatorException("{errors.borrarGrupo.idNulo}");
    }
    return resultado;
}

From source file:es.pode.administracion.presentacion.nodos.modificarNodo.ModificarNodoControllerImpl.java

/**
 * @see es.pode.administracion.presentacion.nodos.modificarNodo.ModificarNodoController#modificarNodo(org.apache.struts.action.ActionMapping, es.pode.administracion.presentacion.nodos.modificarNodo.ModificarNodoForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *///from ww  w . jav a2 s . co  m
public final void modificarNodo(ActionMapping mapping,
        es.pode.administracion.presentacion.nodos.modificarNodo.ModificarNodoForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {

    try {

        String nodo = form.getNodo();
        String url = form.getUrl();
        String puerto = form.getPuerto();
        Long ccaaId = form.getCcaa();
        Long id = form.getId();
        String urlWS = form.getUrlWS();
        String idNodo = form.getIdNodo();

        //cargamos el NodoVO con los datos originales que tiene antes de modificarlo
        NodoVO nodoCargado = new NodoVO();
        nodoCargado = this.getSrvNodoService().obtenerNodo(id);

        // Validaciones de los campos que recogemos del formulario
        Pattern mask = Pattern.compile("[^\\\\?\\\\!\\>\\#\\&\\<\\@\\$\\\'\\\"]+");
        Matcher matcher = null;

        //Validamos el nombre del nodo

        if (nodo == null || nodo.equals("")) {
            log.error("el nombre del nodo no puede estar vacio");
            throw new ValidatorException("{errors.modificarnodo.nodo}");
        }

        matcher = mask.matcher(nodo);
        if (!matcher.matches()) {
            if (log.isDebugEnabled())
                log.debug("nodo caracter ilegal");
            throw new ValidatorException("{errors.modificarnodo.nodo.caracterIlegal}");
        }

        //Validamos la url del nodo

        if (url == null || url.equals("")) {
            log.error("la url del nodo no puede estar vacio");
            throw new ValidatorException("{errors.modificarnodo.url}");
        }

        matcher = mask.matcher(url);
        if (!matcher.matches()) {
            if (log.isDebugEnabled())
                log.debug("nodo caracter ilegal");
            throw new ValidatorException("{errors.modificarnodo.url.caracterIlegal}");
        }

        //Validamos la url del Web Sevices

        if (urlWS == null || urlWS.equals("")) {
            log.error("la url del WebService no puede estar vacio");
            throw new ValidatorException("{errors.modificarnodo.urlWS}");
        }

        if (idNodo == null || idNodo.equals("")) {
            log.error("el identificador del nodo no puede estar vacio");
            throw new ValidatorException("{errors.modificarnodo.idNodo}");
        }

        matcher = mask.matcher(urlWS);
        if (!matcher.matches()) {
            if (log.isDebugEnabled())
                log.debug("nodo caracter ilegal");
            throw new ValidatorException("{errors.modificarnodo.urlWS.caracterIlegal}");
        }

        //Comprobamos que no existe ningun nodo con el nombre introducido para dar de alta

        if (!(nodoCargado.getNodo().equalsIgnoreCase(nodo))) {
            if (this.getSrvNodoService().existeNombreNodo(nodo).booleanValue())
                throw new ValidatorException("{errors.altanodo.nombreNodoYaExiste}");
        }

        //Comprobamos la url del nodo para evitar que un nodo se federe consigo mismo

        String urlHost = AgregaPropertiesImpl.getInstance().getProperty(AgregaProperties.HOST);
        if (log.isDebugEnabled())
            log.debug("El valor de urlHost es " + urlHost);
        if (urlHost.trim().equalsIgnoreCase(url.trim())) {
            if (log.isDebugEnabled())
                log.debug("Se esta intentando federar un nodo consigo mismo");
            throw new ValidatorException("{errors.altanodo.url.federadoConsigoMismo}");
        }

        //Compruebo si ya existen otro nodo en la BD con los mismos valores de url y urlWS

        if (!(nodoCargado.getUrl().equalsIgnoreCase(url))
                && !(nodoCargado.getUrlWS().equalsIgnoreCase(urlWS))) {
            Boolean estaDadoAlta = this.getSrvNodoService().estaDadoAlta(url, urlWS);
            if (log.isDebugEnabled())
                log.debug("estaDadoAlta " + estaDadoAlta);
            if (estaDadoAlta.booleanValue()) {
                if (log.isDebugEnabled())
                    log.debug("esta dado de alta");
                throw new ValidatorException("{errors.altanodo.url.yaEstaDadoAlta}");
            }
        }

        //Comprobamos si se introdcue puerto que este sea numerico
        if (puerto != null && !puerto.matches("[0-9]*"))
            throw new ValidatorException("{errors.altanodo.puerto.NoNumerico}");

        NodoVO nodoVO = new NodoVO();

        nodoVO.setId(id);
        nodoVO.setNodo(nodo);
        nodoVO.setUrl(url);
        nodoVO.setPuerto(puerto);
        nodoVO.setUrlWS(urlWS);
        nodoVO.setIdNodo(idNodo);
        if (ccaaId != null) {
            CcaaVO ccaa = new CcaaVO();
            ccaa.setId(ccaaId);
            nodoVO.setCcaa(ccaa);
        }

        //Comprobamos si al crear el nodo todo ha ido bien o se ha producido algun error
        Integer codigo_devuelto = this.getSrvNodoService().modificarNodo(nodoVO);

        if (codigo_devuelto.intValue() == 1)
            throw new ValidatorException("{errors.altanodo.urlWS.timeout}");

        form.setResultado("ok.modificarnodo");

    } catch (ValidatorException e) {
        throw e;
    } catch (Exception e) {
        log.error("Se ha producido un error al modificar el nodo: " + e);
        form.setResultado("fallo.modificarnodo");
    }

}

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

public final void obtenerTareasPendientes(ActionMapping mapping, ObtenerTareasPendientesForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {

    try {/* w  w  w  .  jav  a  2  s . com*/

        TareaVO[] tareas = this.getSrvPlanificadorService().obtenerTareasPendientes();
        TareaDate[] tareasDate = null;

        if (tareas != null) {
            tareasDate = cambiarFormatoTareas(tareas, request.getLocale());
            tareasDate = ordenaAscendente(tareasDate, form.getTareaModificada());
            ((ListarTareasPendientesFormImpl) form).setTareasPendientesAsArray(tareasDate);
        }
    } catch (Exception e) {
        log.error("Error: " + e);
        throw new ValidatorException("{tareas.error}");
    }
}

From source file:es.pode.administracion.presentacion.adminusuarios.listarUsuarios.ListarUsuariosControllerImpl.java

/**
 * @see es.pode.administracion.presentacion.adminusuarios.listarUsuarios.ListarUsuariosController#obtenerIdentificadores(org.apache.struts.action.ActionMapping,
 *      es.pode.administracion.presentacion.adminusuarios.listarUsuarios.ObtenerIdentificadoresForm,
 *      javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse)
 *///from   ww  w .j  a va  2s .c  o m

public final void getIds(ActionMapping mapping,
        es.pode.administracion.presentacion.adminusuarios.listarUsuarios.GetIdsForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {

    try {
        List lista = ((FormularioListadoUsuariosBajaFormImpl) form).getIdRowSelection();
        if (lista == null) {

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

            Long[] usuariosAdmin = this.getSrvAdminUsuariosService().obtenerUsuariosAdministrador();

            List gruposAdminList = Arrays.asList(usuariosAdmin);

            int num_Admin = usuariosAdmin.length;
            int usuarioDeleted = 0;
            Iterator iter = lista.iterator();
            while (iter.hasNext()) {
                Long identificador = new Long((String) iter.next());
                if (gruposAdminList.contains(identificador)) {
                    usuarioDeleted = usuarioDeleted + 1;
                }
            }

            if (usuarioDeleted == num_Admin) {
                if (log.isDebugEnabled())
                    log.debug("Se intenta eliminar todos los usuarios que son administrador no se permite");
                throw new ValidatorException("{errors.borrarUsuario.todosUsuariosAdmin}");
            }
            form.setIds(lista);
        }
    } catch (ValidatorException validator) {
        log.error("Se ha producido la siguiente exception " + validator);
        throw validator;
    } catch (Exception e) {
        log.error("Se produce una excepcion ", e);
        throw new ValidatorException("{errors.borrarUsuario}");
    }

}

From source file:es.pode.modificador.presentacion.informes.tarea.InformeTareaControllerImpl.java

/**
 * @see es.pode.modificador.presentacion.informes.tarea.InformeTareaController#restaurarODEs(org.apache.struts.action.ActionMapping, es.pode.modificador.presentacion.informes.tarea.RestaurarODEsForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *//*  www. j  a va  2  s  .  c om*/
public final void restaurarODEs(ActionMapping mapping,
        es.pode.modificador.presentacion.informes.tarea.RestaurarODEsForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    Long idModificacion = this.getInformeSession(request).getIdModificacion();
    if (idModificacion != null) {
        String idODE = form.getId();
        Boolean result = this.getSrvHerramientaModificacion().restaurar(idModificacion, Long.valueOf(idODE));
        if (Boolean.FALSE.equals(result)) {
            throw new ValidatorException("{tareas.error.restaurar}");
        }
        // Recupero la modificacion para reinsertarla en la sesion
        ResultadoModificacionVO[] odes = this.getSrvHerramientaModificacion()
                .obtenerResultadoModificacion(idModificacion);
        this.getInformeSession(request).setOdes(Arrays.asList(odes));
    } else {
        logger.debug("Se ha intentado restaurar un ODE desde el informe de simulacion. Ignorando");
    }

}