List of usage examples for org.apache.commons.validator ValidatorException ValidatorException
public ValidatorException(String message)
From source file:com.core.validators.CommonValidator.java
/** * Throws a runtime exception if the value of the argument is "RUNTIME", * an exception if the value of the argument is "CHECKED", and a * ValidatorException otherwise.//from ww w.j a v a2 s.c om * * @throws RuntimeException with "RUNTIME-EXCEPTION as message" * if value is "RUNTIME" * @throws Exception with "CHECKED-EXCEPTION" as message * if value is "CHECKED" * @throws ValidatorException with "VALIDATOR-EXCEPTION" as message * otherwise */ public static boolean validateRaiseException(final Object bean, final Field field) throws Exception { final String value = ValidatorUtils.getValueAsString(bean, field.getProperty()); if ("RUNTIME".equals(value)) { throw new RuntimeException("RUNTIME-EXCEPTION"); } else if ("CHECKED".equals(value)) { throw new Exception("CHECKED-EXCEPTION"); } else { throw new ValidatorException("VALIDATOR-EXCEPTION"); } }
From source file:es.pode.administracion.presentacion.repositoriosExternos.listarRepositoriosExternos.ListarNodosSQIControllerImpl.java
public void getIds(ActionMapping mapping, GetIdsForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try {//from w w w.j av a 2 s . co m List lista = ((FormularioNodosSQIEliminarNodoSQIFormImpl) form).getIdNodoRowSelection(); if (logger.isDebugEnabled()) logger.debug("Los nodos que se van a eliminar son [" + lista); if (lista == null) { throw new ValidatorException("{errors.bajanodosSQI.idNulo}"); } form.setIds(lista); logger.info("Se van a eliminar los siguientes nodosSQI: " + lista); } catch (ValidatorException e) { throw e; } catch (Exception e) { logger.error("Se ha producido un error al intentar recuperar los ids para borrar: " + e); throw new ValidatorException("{errors.eliminarnodos.idError}"); } }
From source file:es.pode.administracion.presentacion.nodos.listarNodos.ListarNodosControllerImpl.java
public final void listarNodos(ActionMapping mapping, es.pode.administracion.presentacion.nodos.listarNodos.ListarNodosForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try {//from www . j a va 2s .c o m log.debug("Listar Nodos"); SrvNodoService service = this.getSrvNodoService(); NodoVO[] nodos = service.listarNodos(); form.setNodosAsArray(nodos); } catch (Exception e) { log.error("Se ha producido un error al listar los nodos: " + e); throw new ValidatorException("{errors.listarnodos}"); } }
From source file:es.pode.tagging.presentacion.adminTag.modificar.ModificarControllerImpl.java
/** * @see es.pode.tagging.presentacion.adminTag.modificar.ModificarController#modificar(org.apache.struts.action.ActionMapping, es.pode.tagging.presentacion.adminTag.modificar.ModificarForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *///from www . ja va2s. co m public final void modificar(ActionMapping mapping, es.pode.tagging.presentacion.adminTag.modificar.ModificarForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String newTag = form.getNewTag(); String oldTag = form.getTagOld(); //El nuevo valor del tag no puede ser vacio if (newTag != null && !newTag.trim().equals("")) { this.getSrvTaggingServer().modificarTag(oldTag, newTag); } else throw new ValidatorException("{tagging.modificarTag.exception}"); }
From source file:es.pode.modificador.presentacion.planificar.PlanificarControllerImpl.java
public final void planificar(ActionMapping mapping, es.pode.modificador.presentacion.planificar.PlanificarForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String actionSubmit = form.getAction(); int day, year, month, hour, minute; Calendar fechaHoy = Calendar.getInstance(); if (actionSubmit.equals("Aceptar")) { if (form.getFecha() == null || form.getFecha().equals("")) { throw new ValidatorException("{planificar.msgErrorFecha}"); } else if (form.getHoras() == null || form.getHoras().equals("")) { throw new ValidatorException("{planificar.msgErrorHora}"); } else if (form.getMinutos() == null || form.getMinutos().equals("")) { throw new ValidatorException("{planificar.msgErrorMinutos}"); } else {// w ww.j a va2 s . co m String idModificacion = form.getIdModificacion(); try { hour = Integer.valueOf(form.getHoras()).intValue(); minute = Integer.valueOf(form.getMinutos()).intValue(); } catch (Exception e) { throw new ValidatorException("{planificar.msgErrorFormato}"); } try { StringBuffer fechaStr = new StringBuffer(); fechaStr.append(form.getFecha()).append(guion).append(hour).append(guion); fechaStr.append(minute); SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy-HH-mm"); format.setLenient(false); Date fecha = format.parse(fechaStr.toString()); Calendar fechaEjecucion = Calendar.getInstance(); fechaEjecucion.setTime(fecha); if (fechaHoy.before(fechaEjecucion)) { Long idModificacionLong = Long.valueOf(idModificacion); this.getSrvHerramientaModificacion().planificarModificacion(idModificacionLong, fechaEjecucion); } else { throw new ValidatorException("{planificar.msgErrorFecha}"); } } catch (ParseException e1) { throw new ValidatorException("{planificar.msgErrorFormato}"); } catch (ValidatorException e2) { throw new ValidatorException("{planificar.msgErrorFecha}"); } catch (Exception e3) { throw new ValidatorException("{planificar.msgExcepcion}"); } } } }
From source file:es.pode.administracion.presentacion.repositoriosExternos.modificarRepositoriosExternos.ModificarNodoSQIControllerImpl.java
public void cargarNodoSQI(ActionMapping mapping, CargarNodoSQIForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try {/*w w w. ja va 2 s .com*/ Long id = new Long(request.getParameter("id")); if (id == null) { throw new ValidatorException("{errors.modificarnodoSQI.idNulo}"); } Long[] ids = new Long[1]; if (logger.isDebugEnabled()) logger.debug("Estamos en cargarNodoSQI con id [ " + id + " ]"); ids[0] = id; NodoSQIVO[] nodos = this.getSrvGestionSqiService().consultaNodosSQI(ids); NodoSQIVO nodo = nodos[0]; form.setId(id); form.setClave(nodo.getClave()); form.setDescripcionNodo(nodo.getDescripcionNodo()); form.setGestorSesion(nodo.getGestorSesion()); 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 (ValidatorException e) { logger.equals("Error al recuperar: " + e); throw e; } catch (Exception e) { logger.equals("Error al recuperar el nodoSQI: " + e); throw e; } }
From source file:es.pode.visualizador.presentacion.feeds.agregadorFeeds.AgregadorFeedsControllerImpl.java
/** * @see es.pode.visualizador.presentacion.feeds.agregadorFeeds.AgregadorFeedsController#obtenerFeeds(org.apache.struts.action.ActionMapping, es.pode.visualizador.presentacion.feeds.agregadorFeeds.ObtenerFeedsForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *///from w ww . j a va 2 s . c o m public final void obtenerFeeds(ActionMapping mapping, es.pode.visualizador.presentacion.feeds.agregadorFeeds.ObtenerFeedsForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try { FeedVO[] feeds = this.getSrvAgregadorRssService().devuelveFeeds(); if (log.isDebugEnabled()) log.debug("AgregadorFeedsControllerImpl - Se han recuperado " + feeds.length + " feeds"); form.setFeeds(feeds); } catch (Exception e) { log.error("AgregadorFeedsControllerImpl - Se ha producido un error al recuperar los feeds: " + e); throw new ValidatorException("{errors.obtenerFeeds}"); } }
From source file:es.pode.administracion.presentacion.catalogacion.verCatalogadores.verCatalogadoresControllerImpl.java
/** * @see es.pode.administracion.presentacion.catalogacion.verCatalogadores.verCatalogadoresController#recuperarDescripcion(org.apache.struts.action.ActionMapping, es.pode.administracion.presentacion.catalogacion.verCatalogadores.RecuperarDescripcionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *//*from www . jav a 2s .c o m*/ public final void recuperarDescripcion(ActionMapping mapping, es.pode.administracion.presentacion.catalogacion.verCatalogadores.RecuperarDescripcionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try { Long id = form.getId(); GrupoTrabajoVO grupoTrabajo = this.getSrvAdminUsuariosService().descripcionGrupoTrabajo(id); form.setNombre(grupoTrabajo.getNombre()); form.setDescripcion(grupoTrabajo.getDescripcion()); form.setId(id); } catch (Exception e) { log.error("Error: " + e); throw new ValidatorException("{verGrupo.error}"); } }
From source file:es.pode.modificador.presentacion.configurar.nombre.ConfigurarNombreControllerImpl.java
/** * @see es.pode.modificador.presentacion.configurar.nombre.ConfigurarNombreController#guardarNombre(org.apache.struts.action.ActionMapping, es.pode.modificador.presentacion.configurar.nombre.GuardarNombreForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *//*from w w w . j a va 2 s. c o m*/ public final void guardarNombre(ActionMapping mapping, es.pode.modificador.presentacion.configurar.nombre.GuardarNombreForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { if (form.getNombre() != null && !form.getNombre().equals("")) { this.getConfigurarModificacionSession(request).setNombre(form.getNombre()); } else { throw new ValidatorException("{configurarNombre.msgError}"); } }
From source file:es.pode.visualizador.presentacion.recuerdoUsuario.RecuerdoControllerImpl.java
/** * @see es.pode.visualizador.presentacion.recuerdoUsuario.RecuerdoController#nuevaClave(org.apache.struts.action.ActionMapping, * es.pode.visualizador.presentacion.recuerdoUsuario.NuevaClaveForm, * javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */// w ww . j a va 2s .c om public final void nuevaClave(ActionMapping mapping, es.pode.visualizador.presentacion.recuerdoUsuario.NuevaClaveForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String email = form.getEmail(); ResourceBundle ficheroRecursos = null; // El idioma se escogera del perfil del usuario Locale locale = request.getLocale(); ficheroRecursos = this.getFicherRecursos(locale); //String idiomaSelected = locale.getLanguage(); // El idioma se escogera del que tiene configurador en el navegador if (email.length() <= 0) { throw new ValidatorException("{errors.recuerdoUsuario.emailVacio}"); } String nif = (form.getNif()).toUpperCase(locale); if (nif.length() <= 0) { throw new ValidatorException("{errors.recuerdoUsuario.nifVacio}"); } UsuarioVO usuarioVO = (this.getSrvAdminUsuariosService()).obtenerUsuario(nif); if (usuarioVO == null) { throw new ValidatorException("{errors.recuerdoUsuario.nifNoExistente}"); } if (!(usuarioVO.getEmail().equalsIgnoreCase(email))) { throw new ValidatorException("{errors.recuerdoUsuario.emailDistinto}"); } log("Obtengo la informacion del administrador que esta gestionando el alta de usuario"); Boolean resultadoModificacion = this.getSrvAdminUsuariosService().nuevaClave(usuarioVO); if (resultadoModificacion == Boolean.FALSE) { form.setResultadoNuevaClave(ficheroRecursos.getString("errors.recuerdoUsuario")); } else { form.setResultadoNuevaClave(ficheroRecursos.getString("recuerdoUsuario.ok")); } }