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.empaquetador.presentacion.archivos.creararchivo.CrearArchivoControllerImpl.java

private void operacionesFicheros(FormFile ficheroN, String tipo, GestorArchivosSession sesArch,
        EmpaquetadorSession sesEmpaq, ResourceBundle i18n) throws Exception {
    InternetHeaders ih = new InternetHeaders();
    MimeBodyPart mbp = null;/*from   w w w.j  a  v a  2 s .com*/
    DataSource source = null;
    DataHandler dFichero = null;

    if (ficheroN.getFileName() != null && !ficheroN.getFileName().equals("")) {
        FicheroVO fichero = new FicheroVO();
        fichero.setNombre(ficheroN.getFileName());
        mbp = new MimeBodyPart(ih, ficheroN.getFileData());
        source = new MimePartDataSource(mbp);
        dFichero = new DataHandler(source);
        fichero.setDatos(dFichero);
        fichero.setTipoMime(ficheroN.getContentType());

        //obtengo el identificador del ode
        String identificador = sesEmpaq.getIdLocalizador();

        List<ArchivoVO> path = sesArch.getPath();
        ArchivoVO ultimoPath = 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());
        }

        if (tipo.equals("FICHERO")) {
            try {
                this.getSrvGestorArchivosService().crearArchivo(identificador, carpetaPadre, fichero);
            } catch (Exception e) {
                logger.error(e.getMessage(), e);
                throw new ValidatorException("{presentacion.archivos.creararchivo.error.sobreescritura}");
            }

        } else if (tipo.equals("ZIP"))

        {
            try {
                this.getSrvGestorArchivosService().descomprimirArchivo(identificador, carpetaPadre, fichero);
            } catch (Exception noEsArchivo) {
                Logger.getLogger(this.getClass())
                        .error("Lanzando excepcion de validacion. Fichero no es un Archivo");
                throw new ValidatorException(ficheroN.getFileName() + DOSPUNTOS
                        + i18n.getString("portalempaquetado.archivos.error.importar.noeszip"));
            }

        }
    } else {
        Logger.getLogger(this.getClass()).error("Lanzando excepcion de validacion.");
        throw new ValidatorException("{portal_empaquetado.exception.crearArchivo}");
    }

}

From source file:es.pode.administracion.presentacion.catalogacion.modificarCatalogadores.modificarCatalogadoresControllerImpl.java

/**
 * @see es.pode.administracion.presentacion.catalogacion.modificarCatalogadores.modificarCatalogadoresController#modificarCatalogadores(org.apache.struts.action.ActionMapping, es.pode.administracion.presentacion.catalogacion.modificarCatalogadores.ModificarCatalogadoresForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */// w w w .j  ava2  s  .co m
public final void modificarCatalogadores(ActionMapping mapping,
        es.pode.administracion.presentacion.catalogacion.modificarCatalogadores.ModificarCatalogadoresForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    try {
        String nombre = form.getNombre();
        String descripcion = form.getDescripcion();

        log("El valor del nombre es " + nombre);

        //VALIDACION DE CARACTERES INCORRECTOS
        Pattern mask = Pattern.compile("[^\\\\?\\\\!\\>\\#\\&\\<\\@\\$\\/\\\'\\\"]+");
        Matcher matcher = null;

        matcher = mask.matcher(nombre);
        if (!matcher.matches()) {
            log("nombre caracter ilegal");
            throw new ValidatorException("{errors.altagrupo.descripcion.caracterIlegal}");
        }

        matcher = mask.matcher(descripcion);
        if (!matcher.matches()) {
            log("nombre caracter ilegal");
            throw new ValidatorException("{errors.altaGrupoTrabajo.caracterIlegal.descripcion}");
        }

        Long id = Long.valueOf(request.getParameter("id"));
        log("Chequeo si el nombre ya esta asociado a otro grupo de trabajo");
        GrupoTrabajoVO grupoTrabajoVO = this.getSrvAdminUsuariosService().descripcionGrupoTrabajo(id);

        if ((this.getSrvAdminUsuariosService().existeNombreTrabajo(nombre, id)).booleanValue()) {
            log("Ya existe un grupo en el sistema con este nombre");
            throw new ValidatorException("{errors.modificaciongrupo.descripcionExistente}");
        }

        if (descripcion.length() > 0) {
            grupoTrabajoVO.setNombre(nombre);
            grupoTrabajoVO.setDescripcion(descripcion);

            Long identificador = this.getSrvAdminUsuariosService().modificarGrupoTrabajo(grupoTrabajoVO);
            log("llamamos al servicio para modificar el grupo trabajo");
            form.setIdModificado(identificador);
        } else {
            log("La descripcion introducida es nula");
            throw new ValidatorException("{errors.modificaciongrupo.descripcion}");
        }
        form.setResultado("gruposTrabajo.modificar.OK");

    } catch (ValidatorException validator) {
        form.setResultado("gruposTrabajo.modificar.FALLO");
        throw validator;
    } catch (Exception e) {
        log.error("Error: " + e);
        form.setResultado("gruposTrabajo.modificar.FALLO");
        throw new ValidatorException("{modificarGrupo.errorRoles}");
    }
}

From source file:es.pode.administracion.presentacion.logs.eliminar.EliminarLogControllerImpl.java

/**
 * @see es.pode.administracion.presentacion.logs.eliminar.EliminarLogController#obtenerLogs(org.apache.struts.action.ActionMapping, es.pode.administracion.presentacion.logs.eliminar.ObtenerLogsForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *//*from ww  w.ja v  a2s . co m*/
public final void obtenerLogs(ActionMapping mapping,
        es.pode.administracion.presentacion.logs.eliminar.ObtenerLogsForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    try {

        Iterator iter = (form.getIds()).iterator();
        int i = 0;
        String listaId = "";
        while (iter.hasNext()) {
            String nombre = (String) iter.next();
            listaId = listaId + nombre + ":";
            i = i + 1;
        }
        form.setListaId(listaId.trim());
        form.setLogs((String[]) form.getIds().toArray(new String[0]));

    } catch (Exception e) {
        log.error("Se ha producido un error al recuperar los ficheros de log: " + e);
        throw new ValidatorException("{errors.obtenerLog}");
    }
}

From source file:es.pode.gestorFlujo.presentacion.objetosPendientes.Rechazar.RechazarControllerImpl.java

/**
 * @see es.pode.gestorFlujo.presentacion.objetosPendientes.Rechazar.RechazarController#rechazarODE(org.apache.struts.action.ActionMapping,
 *      es.pode.gestorFlujo.presentacion.objetosPendientes.Rechazar.RechazarODEForm,
 *      javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse)
 *///from w  ww. j av a  2s . co  m
public final void rechazarODE(ActionMapping mapping,
        es.pode.gestorFlujo.presentacion.objetosPendientes.Rechazar.RechazarODEForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    ResultadoOperacionVO resultado;
    logger.info("Rechazando ODE :" + form.getIdODE() + " de titulo: " + form.getTitulo());
    if (form.getComentarios() != null) {
        // ponemos 2500 pero en el mensaje 2000 para que el usuario no se
        // sienta estafado con falta de caracteres
        if ((form.getComentarios().trim().length() > 0) && (form.getComentarios().length() < 2500)) {
            try {
                if (logger.isDebugEnabled())
                    logger.debug("Comentarios correctos rechazando ODE :" + form.getIdODE() + " de titulo: "
                            + form.getTitulo() + " Comentarios: " + form.getComentarios() + ";");
                resultado = this.getSrvPublicacionService().rechazar(form.getIdODE(),
                        LdapUserDetailsUtils.getUsuario(), form.getComentarios(), form.getTitulo());
            } catch (Exception ex) {
                logger.error("ERROR (excepcin) rechazando el ODE con IdODE[" + form.getIdODE() + "] usuario["
                        + LdapUserDetailsUtils.getUsuario() + "]comentarios[" + form.getComentarios()
                        + "] y titulo[" + form.getTitulo() + "]" + "\nEXCEPCION: " + ex.getMessage());
                throw new ValidatorException("{gestorFlujo.excepcion.rechazar.rechazar}");
            }

            if (!resultado.getIdResultado().equals("0.0")) {
                logger.error("Error rechazando para publicacion el ODE con IdODE[" + form.getIdODE()
                        + "] usuario[" + LdapUserDetailsUtils.getUsuario() + "]comentarios["
                        + form.getComentarios() + "] y titulo[" + form.getTitulo() + "]");

                saveErrorMessage(request, "gestorFlujo.error.rechazar",
                        new String[] { form.getTitulo(), resultado.getDescripcion() });

            } else {
                logger.info("Rechazado correctamente: ODE con IdODE[" + form.getIdODE() + "] usuario["
                        + LdapUserDetailsUtils.getUsuario() + "]comentarios[" + form.getComentarios()
                        + "] y titulo[" + form.getTitulo() + "]");
            }
        } else {
            logger.warn("Longitud de comentario no vlida al rechazar el ODE con IdODE[" + form.getIdODE()
                    + "] usuario[" + LdapUserDetailsUtils.getUsuario() + "]comentarios[" + form.getComentarios()
                    + "] y titulo[" + form.getTitulo() + "]; longitud: " + form.getComentarios().length());
            throw new ValidatorException("{gestorFlujo.comentario.longitud}");
        }
    } else {
        logger.warn("No se han introducido comentarios al rechazar el ODE con IdODE[" + form.getIdODE()
                + "] usuario[" + LdapUserDetailsUtils.getUsuario() + "]comentarios[" + form.getComentarios()
                + "] y titulo[" + form.getTitulo() + "]");
        throw new ValidatorException("{gestorFlujo.comentario.obligatorio}");
    }
}

From source file:es.pode.gestorFlujo.presentacion.objetosPersonales.importarURL.ImportarURLControllerImpl.java

/**
 * @see es.pode.gestorFlujo.presentacion.objetosPersonales.importarURL.ImportarURLController#crear(org.apache.struts.action.ActionMapping, es.pode.gestorFlujo.presentacion.objetosPersonales.importarURL.CrearForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *//*from   w w  w . j a v a  2s  . c  om*/
public final void crear(ActionMapping mapping,
        es.pode.gestorFlujo.presentacion.objetosPersonales.importarURL.CrearForm form,
        HttpServletRequest request, HttpServletResponse response) throws ValidatorException {
    String VACIA = "";

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

    String url = VACIA;
    String comentarios = VACIA;
    String idiomaPpal = VACIA;
    String idiomaDestinatario = VACIA;
    String titulo = VACIA;
    String idUsuario = LdapUserDetailsUtils.getUsuario();
    ;
    String action = VACIA;
    String tipo = "thematic or corporate webs/web portals";

    if (form != null) {
        logger.debug("Recuperamos campos del formulario");
        url = form.getUrl() != null ? form.getUrl() : VACIA;
        comentarios = form.getComentarios() != null ? form.getComentarios() : VACIA;
        idiomaPpal = form.getIdioma() != null ? form.getIdioma() : VACIA;
        try {
            idiomaPpal = I18n.getInstance().obtenerIdiomaIso(idiomaPpal, idioma);
        } catch (Exception e1) {
            logger.error("No se ha podido recuperar traduccin de trmino " + idiomaPpal);
            throw new ValidatorException("{gestorFlujo.error.inesperado}");
        }
        idiomaDestinatario = form.getIdiomaDestinatario() != null ? form.getIdiomaDestinatario() : VACIA;
        try {
            idiomaDestinatario = I18n.getInstance().obtenerIdiomaIso(idiomaDestinatario, idioma);
        } catch (Exception e1) {
            logger.error("No se ha podido recuperar traduccin de trmino " + idiomaDestinatario);
            throw new ValidatorException("{gestorFlujo.error.inesperado}");
        }
        titulo = form.getTitulo() != null ? form.getTitulo() : VACIA;
        action = form.getAction() != null ? form.getAction() : VACIA;
        tipo = form.getTipo() != null ? form.getTipo() : tipo;
        try {
            TerminoYPadreVO termino = getSrvVocabulariosControladosService()
                    .crearTraduccionAIngles(new String[] { tipo })[0];
            tipo = termino.getNomTermino() != null ? termino.getNomTermino() : tipo;
        } catch (Exception e) {
            logger.error("No se ha podido recuperar traduccin al ingls de trmino " + tipo);
            throw new ValidatorException("{gestorFlujo.error.inesperado}");
        }
    }
    //Comprobamos entrada
    if (url.equals(VACIA) || comentarios.equals(VACIA) || idioma.equals(VACIA)
            || idiomaDestinatario.equals(VACIA) || titulo.equals(VACIA)) {
        logger.debug("No se introdujeron campos");
        throw new ValidatorException("{gestorFlujos.error.camposVacios}");
    }

    if (action.equals(i18n.getString("gestorFlujo.importarURL.guardar"))) {
        try {
            logger.debug("Llamamos a crearDesdeURL con url=" + url + ", usuario=" + idUsuario + ", comentarios="
                    + comentarios + ", titulo=" + titulo + ", idioma=" + idioma + ", idiomaDestinatario="
                    + idiomaDestinatario);
            ResultadoOperacionVO result = getSrvPublicacionService().crearDesdeURL(url, idUsuario, comentarios,
                    titulo, idioma, idiomaDestinatario, tipo);
            logger.debug(
                    "Resultado de crearDesdeURL = " + result.getIdResultado() + ", " + result.getDescripcion());
        } catch (Exception e) {
            logger.error("Excepcin al importar url: " + url + " ,error: " + e);
            throw new ValidatorException("{gestorFlujo.error.inesperado}");
        }
    }
}

From source file:es.pode.administracion.presentacion.adminusuarios.altaUsuarioPendiente.AltaUsuarioPendienteControllerImpl.java

/**
 * @see es.pode.administracion.presentacion.adminusuarios.altaUsuarioPendiente.AltaUsuarioPendienteController#recuperarGrupos(org.apache.struts.action.ActionMapping, es.pode.administracion.presentacion.adminusuarios.altaUsuarioPendiente.RecuperarGruposForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *//*w w  w  . jav a 2 s .  co  m*/
public final void recuperarGrupos(ActionMapping mapping,
        es.pode.administracion.presentacion.adminusuarios.altaUsuarioPendiente.RecuperarGruposForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {

    try {

        String nombre = request.getParameter("nombre");
        String apellido1 = request.getParameter("apellido1");
        Long id = Long.valueOf(request.getParameter("id"));
        String apellido2 = request.getParameter("apellido2");
        String email = request.getParameter("email");
        String idioma = request.getParameter("idioma");
        String idiomaBusqueda = request.getParameter("idiomaBusqueda");
        String tipoEmpaquetador = request.getParameter("tipoEmpaquetador");
        String clave = request.getParameter("clave");
        String repitaClave = request.getParameter("repitaClave");
        UsuarioVO usuarioVO = this.getSrvAdminUsuariosService().descripcionUsuario(id);
        // Validaciones de los campos que recogemos del formulario
        Pattern mask = Pattern.compile("[^\\\\?\\\\!\\>\\#\\&\\<\\@\\$\\/\\\'\\\"]+");
        // Validaciones para password
        Pattern maskPwd = Pattern.compile("[^\\\\?\\\\!\\>\\#\\&\\<\\@\\$\\/\\\'\\\"]+");

        Matcher matcher = null;

        if (nombre.length() <= 0) {
            log("nombre.length() <= 0");
            throw new ValidatorException("{errors.altaUsuarioPendiente.nombre}");
        }
        matcher = mask.matcher(nombre);
        if (!matcher.matches()) {
            log("nombre caracter ilegal");
            throw new ValidatorException("{errors.altaUsuarioPendiente.nombre.caracterIlegal}");
        }

        if (apellido1.length() <= 0) {
            log("apellido1.length() <= 0");
            throw new ValidatorException("{errors.altaUsuarioPendiente.apellido1}");
        }
        matcher = mask.matcher(apellido1);
        if (!matcher.matches()) {
            log("apellido1 caracter ilegal");
            throw new ValidatorException("{errors.altaUsuarioPendiente.apellido1.caracterIlegal}");
        }

        if (apellido2.length() > 0) {
            matcher = mask.matcher(apellido2);
            if (!matcher.matches()) {
                log("apellido2 caracter ilegal");
                throw new ValidatorException("{errors.altaUsuarioPendiente.apellido2.caracterIlegal}");
            }
        }

        if (email.length() <= 0) {
            log("email.length() <= 0");
            throw new ValidatorException("{errors.altaUsuarioPendiente.email}");
        }
        if (!((email.indexOf("@") > 0) && (email.indexOf(".") > 0))) {
            throw new ValidatorException("{errors.altaUsuarioPendiente.emailIncorrecto}");
        }
        if ((clave == null) || (clave.equalsIgnoreCase(""))) {
            log("La clave no se modifica");
        } else {
            if (clave.length() < 7) {
                log("clave .length() <= 7");
                throw new ValidatorException("{errors.altaUsuarioPendiente.clave}");
            }

            matcher = maskPwd.matcher(clave);
            if (!matcher.matches()) {
                log("contrasea caracter ilegal");
                throw new ValidatorException("{errors.altaUsuarioPendiente.clave.caracterIlegal}");
            }

            if (!(clave.equalsIgnoreCase(repitaClave))) {
                throw new ValidatorException("{errors.altaUsuarioPendiente.claveDistintas}");
            }
            usuarioVO.setClave(clave);
        }

        if (idiomaBusqueda == null) {
            throw new ValidatorException("{errors.altaUsuarioPendiente.idiomaBusqueda}");
        }
        if (idiomaBusqueda.length() <= 0) {
            log("empaquetador .length() <= 0");
            throw new ValidatorException("{errors.altaUsuarioPendiente.idiomaBusqueda}");
        }

        if (idioma == null) {
            throw new ValidatorException("{errors.altaUsuarioPendiente.idioma}");
        }
        if (idioma.length() <= 0) {
            log("empaquetador .length() <= 0");
            throw new ValidatorException("{errors.altaUsuarioPendiente.idioma}");
        }

        if (tipoEmpaquetador == null) {
            throw new ValidatorException("{errors.altaUsuarioPendiente.tipoEmpaquetador}");
        }
        if (tipoEmpaquetador.length() <= 0) {
            log("empaquetador .length() <= 0");
            throw new ValidatorException("{errors.altaUsuarioPendiente.tipoEmpaquetador}");
        }

        usuarioVO.setNombre(nombre);
        usuarioVO.setApellido1(apellido1);
        usuarioVO.setApellido2(apellido2);
        usuarioVO.setEmail(email);
        usuarioVO.setTipoEmpaquetador(tipoEmpaquetador);
        usuarioVO.setIdioma(idioma);
        usuarioVO.setIdiomaBusqueda(idiomaBusqueda);
        usuarioVO.setId(id);
        usuarioVO.setFechaAlta(new GregorianCalendar());
        usuarioVO.setFechaSolicitudAlta(null);

        this.getAltaUsuarioPendienteBSession(request).setUsuarioPendiente(usuarioVO);
        GrupoVO[] grupoVO = this.getSrvAdminUsuariosService().listarGrupos();
        form.setGruposAsArray(grupoVO);
    } catch (ValidatorException ve) {
        log.error("se ha producido una validatorException");
        throw ve;
    } catch (Exception e) {
        log.error("Error: " + e);
        throw new ValidatorException("{altaUsuarioPendiente.error}");
    }
}

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

public final java.lang.String selectAction(ActionMapping mapping,
        es.pode.empaquetador.presentacion.avanzado.organizaciones.elementos.secuencia.SelectActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    String result = null;//from   ww  w. j av  a2  s. co  m
    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("portal_empaquetado_secuencia.cancelar"))) {
        result = "Cancelar";
    } else if (actionSubmit.equals(i18n.getString("portal_empaquetado_secuencia.aceptar"))) {
        result = "aceptar";
    } else if (actionSubmit.equals(i18n.getString("secuencia.valorPorDefecto"))) {
        result = "default";
    }

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

    return result;
}

From source file:es.pode.administracion.presentacion.informes.listarInformes.ListarInformesControllerImpl.java

/**
 * @see es.pode.administracion.presentacion.informes.listarInformes.ListarInformesController#getInformes(org.apache.struts.action.ActionMapping, es.pode.administracion.presentacion.informes.listarInformes.GetInformesForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *//*from  w w w  . j a  v  a2 s.  c o m*/
public final void getInformes(ActionMapping mapping,
        es.pode.administracion.presentacion.informes.listarInformes.GetInformesForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    try {
        List lista = ((FormularioListarInformesEliminarFormImpl) form).getNombreRowSelection();
        if (lista == null) {
            throw new ValidatorException("{errors.eliminarInformes.nombreNulo}");
        }
        form.setIds(lista);
        if (log.isDebugEnabled())
            log.debug("Se van a eliminar los siguientes informes: " + lista);
    } catch (Exception e) {
        log.error("Se ha producido un error al intentar recuperar los ids de los informes a borrar: " + e);
        throw e;
    }

}

From source file:es.pode.administracion.presentacion.adminusuarios.listarUsuariosInactivos.ListarUsuariosInactivosControllerImpl.java

/**
 * @see es.pode.administracion.presentacion.adminusuarios.listarUsuariosInactivos.ListarUsuariosInactivosController#getIds(org.apache.struts.action.ActionMapping, es.pode.administracion.presentacion.adminusuarios.listarUsuariosInactivos.GetIdsForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *///from w  ww .  j  a  v  a2 s  .  co  m
public final void getIds(ActionMapping mapping,
        es.pode.administracion.presentacion.adminusuarios.listarUsuariosInactivos.GetIdsForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    try {
        List lista = ((FormularioListadoUsuariosInactivosBajaFormImpl) 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) {
                log("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.catalogadorWeb.presentacion.importar.ImportarControllerImpl.java

public String submit(ActionMapping mapping, SubmitForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    String resultado = "";
    String action = form.getAccion();

    //String idiomaLocale=((Locale)request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE)).getLanguage();
    ResourceBundle i18n = I18n.getInstance().getResource("application-resources",
            (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE));

    if (action != null) {
        if (action.equals(i18n.getString("catalogadorAvanzado.importar.aceptar"))) {
            resultado = "Aceptar";
            if (form.getFichero() == null || form.getFichero().getFileName().equals("")
                    || form.getFichero().getFileSize() == 0)
                throw new ValidatorException("{catalogadorAvanzado.importar.error.ficherovacio}");

            //crear el datahandler
            InternetHeaders ih = new InternetHeaders();
            MimeBodyPart mbp = null;/*from w ww.j  a va  2s  . c  om*/
            DataSource source = null;
            DataHandler dh = null;
            try {
                FormFile ff = (FormFile) form.getFichero();
                mbp = new MimeBodyPart(ih, ff.getFileData());
                source = new MimePartDataSource(mbp);
                dh = new DataHandler(source);
            } catch (Exception e) {
                if (logger.isDebugEnabled()) {
                    logger.debug("error al crear el datahandler");
                }
                throw new ValidatorException("{catalogadorAvanzado.importar.error}");
            }

            //validar el fichero
            Boolean valido = new Boolean(false);
            try {
                valido = this.getSrvValidadorService().obtenerValidacionLomes(dh);
            } catch (Exception e) {
                if (logger.isDebugEnabled()) {
                    logger.debug("error al llamar al servicio de validacin");
                }
                throw new ValidatorException("{catalogadorAvanzado.importar.error.novalido}");
            }

            if (!valido.booleanValue())
                throw new ValidatorException("{catalogadorAvanzado.importar.error.novalido}");

            //agregar el datahandler a sesion
            this.getCatalogadorAvSession(request).setLomesImportado(dh);

        } else if (action.equals(i18n.getString("catalogadorAvanzado.importar.cancelar")))
            resultado = "Cancelar";
    }
    return resultado;
}