List of usage examples for org.apache.commons.validator ValidatorException ValidatorException
public ValidatorException(String message)
From source file:es.pode.administracion.presentacion.planificador.modificarTarea.ObtenerTareaControllerImpl.java
/** * Metodo que guarda los cambios que se han echo en la tarea reindexado *//*ww w. java 2s .com*/ public final void modificarTareaReindexado(ActionMapping mapping, ModificarTareaReindexadoForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { if (tz == null) tz = utilidades.asignarZonaHoraria(); TrabajoVO trabajo = new TrabajoVO(); // Trabajo a modificar TareaReindexadoVO datosTarea = new TareaReindexadoVO(); // Datos a modificar try { trabajo.setTrabajo(((FormularioReindexadoIIAceptarFormImpl) form).getTrabajo()); trabajo.setGrupoTrabajo(((FormularioReindexadoIIAceptarFormImpl) form).getGrupoTrabajo()); datosTarea.setTrabajo(((FormularioReindexadoIIAceptarFormImpl) form).getTrabajo()); datosTarea.setGrupoTrabajo(((FormularioReindexadoIIAceptarFormImpl) form).getGrupoTrabajo()); datosTarea.setTrigger(((FormularioReindexadoIIAceptarFormImpl) form).getTrigger()); datosTarea.setGrupoTrigger(((FormularioReindexadoIIAceptarFormImpl) form).getGrupoTrigger()); datosTarea.setRepositorioIndices(((FormularioReindexadoIIAceptarFormImpl) form).getRepositorio()); datosTarea.setPeriodicidad(((FormularioReindexadoIIAceptarFormImpl) form).getPeriodicidad()); Calendar cal = Calendar.getInstance(tz); cal = new GregorianCalendar( new Integer(((FormularioReindexadoIIAceptarFormImpl) form).getAnio()).intValue(), new Integer(((FormularioReindexadoIIAceptarFormImpl) form).getMes()).intValue() - 1, new Integer(((FormularioReindexadoIIAceptarFormImpl) form).getDia()).intValue(), new Integer(((FormularioReindexadoIIAceptarFormImpl) form).getHora()).intValue(), new Integer(((FormularioReindexadoIIAceptarFormImpl) form).getMinutos()).intValue()); datosTarea.setFechaInicio(cal); datosTarea.setMsgReindexado(((FormularioReindexadoIIAceptarFormImpl) form).getMsgReindexado()); datosTarea.setMsgNoReindexado(((FormularioReindexadoIIAceptarFormImpl) form).getMsgNoReindexado()); datosTarea.setMsgDescripcionTrabajo( ((FormularioReindexadoIIAceptarFormImpl) form).getMsgDescReindexado()); datosTarea.setUsuario(LdapUserDetailsUtils.getUsuario()); TareaReindexadoVO tareaRecuperada = this.getSrvPlanificadorService() .modificarTareaReindexado(datosTarea, trabajo); form.setTareaModificada(tareaRecuperada.getTrabajo()); } catch (Exception e) { log.error("Error: " + e); throw new ValidatorException("{tareas.error}"); } }
From source file:jp.terasoluna.fw.validation.FieldChecks.java
/** * ???????????//w w w .ja v a 2 s .c o m * ??????????errors??? * false?? * * <p>???5???????true?? * ??? * * <h5>validation.xml?</h5> * <code><pre> * <form name="sample"> * * <field property="stringField" * depends="stringLength"> * <arg key="sample.stringField" position="0"/> * <var> * <var-name>stringLength</var-name> * <var-value>5</var-value> * </var> * </field> * * </form> * </pre></code> * <h5>validation.xml???<var>?</h5> * <table border="1"> * <tr> * <td><center><b><code>var-name</code></b></center></td> * <td><center><b><code>var-value</code></b></center></td> * <td><center><b></b></center></td> * <td><center><b>?</b></center></td> * </tr> * <tr> * <td> stringLength </td> * <td></td> * <td> false </td> * <td>? * ???<code>int</code>???</td> * </tr> * </table> * * @param bean ?JavaBean * @param va Validator????ValidatorAction * @param field * @param errors * @return ???? true * @throws ValidatorException validation?????? * ? */ public boolean validateStringLength(Object bean, ValidatorAction va, Field field, ValidationErrors errors) throws ValidatorException { // String value = extractValue(bean, field); if (StringUtils.isEmpty(value)) { return true; } // int length = Integer.MAX_VALUE; String lengthStr = field.getVarValue("stringLength"); try { length = Integer.valueOf(lengthStr).intValue(); } catch (NumberFormatException e) { String message = "Mistake on validation definition file. " + "- stringLength is not number. " + "You'll have to check it over. "; log.error(message, e); throw new ValidatorException(message); } // if (value.length() != length) { rejectValue(errors, field, va, bean); return false; } return true; }
From source file:es.pode.administracion.presentacion.planificador.modificarTarea.ObtenerTareaControllerImpl.java
/** * Metodo que guarda los cambios que se han echo en la tarea eliminar odes *///from w w w. j av a 2 s .co m public void modificarTareaNoDisponibles(org.apache.struts.action.ActionMapping mapping, es.pode.administracion.presentacion.planificador.modificarTarea.ModificarTareaNoDisponiblesForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception { if (tz == null) tz = utilidades.asignarZonaHoraria(); String dia = new String(((FormularioNoDisponiblesIIAceptarFormImpl) form).getDia()); String mes = new String(((FormularioNoDisponiblesIIAceptarFormImpl) form).getMes()); String anio = new String(((FormularioNoDisponiblesIIAceptarFormImpl) form).getAnio()); String hora = new String(((FormularioNoDisponiblesIIAceptarFormImpl) form).getHora()); String minutos = new String(((FormularioNoDisponiblesIIAceptarFormImpl) form).getMinutos()); String anioDesde = new String(((FormularioNoDisponiblesIIAceptarFormImpl) form).getAnioDesde()); String mesDesde = new String(((FormularioNoDisponiblesIIAceptarFormImpl) form).getMesDesde()); String diaDesde = new String(((FormularioNoDisponiblesIIAceptarFormImpl) form).getDiaDesde()); String anioHasta = new String(((FormularioNoDisponiblesIIAceptarFormImpl) form).getAnioHasta()); String mesHasta = new String(((FormularioNoDisponiblesIIAceptarFormImpl) form).getMesHasta()); String diaHasta = new String(((FormularioNoDisponiblesIIAceptarFormImpl) form).getDiaHasta()); TrabajoVO trabajo = new TrabajoVO(); // Trabajo a modificar TareaEliminaNoDisponiblesVO datosTarea = new TareaEliminaNoDisponiblesVO(); // Datos a modificar try { //Comprobamos que todos los campos de la fecha de inicio estn rellenos if (anioDesde.equalsIgnoreCase("") || mesDesde.equalsIgnoreCase("") || diaDesde.equalsIgnoreCase("")) throw new ValidatorException("{informes.crearInformes.fechaDesdeCampoVacio}"); //Comprobamos que todos los campos de la fecha fin estn rellenos if (anioHasta.equalsIgnoreCase("") || mesHasta.equalsIgnoreCase("") || diaHasta.equalsIgnoreCase("")) throw new ValidatorException("{informes.crearInformes.fechaHastaCampoVacio}"); //Comprobamos que los campos de las fechas son numeros if (log.isDebugEnabled()) log.debug("comprobamos si las fechas tiene caracteres no numericos"); try { new Integer(anioDesde).intValue(); new Integer(mesDesde).intValue(); new Integer(diaDesde).intValue(); } catch (Exception e) { log.error("Alguno de los campos de la fecha desde no son nmeros"); throw new ValidatorException("{tareas.eliminarOdes.fechaDesde}"); } try { new Integer(anioHasta).intValue(); new Integer(mesHasta).intValue(); new Integer(diaHasta).intValue(); } catch (Exception e) { log.error("Alguno de los campos de la fecha hasta no son nmeros"); throw new ValidatorException("{tareas.eliminarOdes.fechaHasta}"); } // Comprobamos si las fechas introducidas son correctas boolean fechaValidaDesde = utilidades.validacionFechaDDMMAAAAHHMM(diaDesde, mesDesde, anioDesde, "yyyyMMdd"); boolean fechaValidaHasta = utilidades.validacionFechaDDMMAAAAHHMM(diaHasta, mesHasta, anioHasta, "yyyyMMdd"); boolean comparacionFechaDesdeHasta = utilidades.comparacionFechas(anioDesde, mesDesde, diaDesde, anioHasta, mesHasta, diaHasta); if (!fechaValidaHasta && !fechaValidaDesde) throw new ValidatorException("{tareas.fechaDesdeHastaIncorrecta}"); if (!fechaValidaDesde) throw new ValidatorException("{tareas.fechaDesdeIncorrecta}"); if (!fechaValidaHasta) throw new ValidatorException("{tareas.fechaHastaIncorrecta}"); if (!comparacionFechaDesdeHasta) throw new ValidatorException("{tareas.fechaDesdeMasQueHasta}"); try { trabajo.setTrabajo(((FormularioNoDisponiblesIIAceptarFormImpl) form).getTrabajo()); trabajo.setGrupoTrabajo(((FormularioNoDisponiblesIIAceptarFormImpl) form).getGrupoTrabajo()); datosTarea.setTrabajo(((FormularioNoDisponiblesIIAceptarFormImpl) form).getTrabajo()); datosTarea.setGrupoTrabajo(((FormularioNoDisponiblesIIAceptarFormImpl) form).getGrupoTrabajo()); datosTarea.setTrigger(((FormularioNoDisponiblesIIAceptarFormImpl) form).getTrigger()); datosTarea.setGrupoTrigger(((FormularioNoDisponiblesIIAceptarFormImpl) form).getGrupoTrigger()); datosTarea.setPeriodicidad(((FormularioNoDisponiblesIIAceptarFormImpl) form).getPeriodicidad()); datosTarea.setMsgEliminado(((FormularioNoDisponiblesIIAceptarFormImpl) form).getMsgEliminado()); datosTarea.setMsgNoEliminado(((FormularioNoDisponiblesIIAceptarFormImpl) form).getMsgNoEliminado()); datosTarea.setMsgDescripcionTrabajo( ((FormularioNoDisponiblesIIAceptarFormImpl) form).getMsgDescTrabajo()); Calendar cal = Calendar.getInstance(tz); cal = new GregorianCalendar(new Integer(anio).intValue(), new Integer(mes).intValue() - 1, new Integer(dia).intValue(), new Integer(hora).intValue(), new Integer(minutos).intValue()); Calendar calFechaDesde = Calendar.getInstance(tz); calFechaDesde = new GregorianCalendar(new Integer(anioDesde).intValue(), new Integer(mesDesde).intValue() - 1, new Integer(diaDesde).intValue(), 0, 1); Calendar calFechaHasta = Calendar.getInstance(tz); calFechaHasta = new GregorianCalendar(new Integer(anioHasta).intValue(), new Integer(mesHasta).intValue() - 1, new Integer(diaHasta).intValue(), 23, 59); datosTarea.setFechaInicio(cal); datosTarea.setFechaDesde(calFechaDesde); datosTarea.setFechaHasta(calFechaHasta); datosTarea.setUsuario(LdapUserDetailsUtils.getUsuario()); TareaEliminaNoDisponiblesVO tareaRecuperada = this.getSrvPlanificadorService() .modificarTareaEliminarNoDisponibles(datosTarea, trabajo); form.setTareaModificada(tareaRecuperada.getTrabajo()); } catch (Exception e) { log.error("Error: " + e); throw new ValidatorException("{tareas.error}"); } } catch (ValidatorException ve) { log.error("error " + ve); throw ve; } catch (Exception e) { log.error("Error: " + e); //throw new ValidatorException("{tareas.error}"); } }
From source file:jp.terasoluna.fw.validation.FieldChecks.java
/** * ????????// w w w . j a v a2 s .c o m * ??????? * ??????????errors??? * false?? * * <p>?????????????true?? * ??? * * <h5>validation.xml?</h5> * <code><pre> * <form name="sample"> * * <field property="arrayField" * depends="arrayRange"> * <arg key="sample.arrayField" position="0"/> * <var> * <var-name>minArrayLength</var-name> * <var-value>4</var-value> * </var> * <var> * <var-name>maxArrayLength</var-name> * <var-value>7</var-value> * </var> * </field> * * </form> * </pre></code> * <h5>validation.xml???<var>?</h5> * <table border="1"> * <tr> * <td><center><b><code>var-name</code></b></center></td> * <td><center><b><code>var-value</code></b></center></td> * <td><center><b></b></center></td> * <td><center><b>?</b></center></td> * </tr> * <tr> * <td> minArrayLength </td> * <td>??</td> * <td>false</td> * <td>????? * ???????????</td> * </tr> * <tr> * <td> maxArrayLength </td> * <td>?</td> * <td>false</td> * <td>???? * ??????? * <code>int</code>???</td> * </tr> * </table> * * @param bean ?JavaBean * @param va Validator????ValidatorAction * @param field * @param errors * @return ???? true * @throws ValidatorException validation?????? * ? */ public boolean validateArrayRange(Object bean, ValidatorAction va, Field field, ValidationErrors errors) throws ValidatorException { // ??bean?null???ValidatorException if (bean == null) { String message = "target of validateArrayRange must be not null."; log.error(message); throw new ValidatorException(message); } try { Class<?> type = BeanUtil.getBeanPropertyType(bean, field.getProperty()); if (type == null) { String message = "Cannot get property type[" + bean.getClass().getName() + "." + field.getProperty() + "]"; log.error(message); throw new ValidatorException(message); } else if (!type.isArray() && !Collection.class.isAssignableFrom(type)) { String message = "property [" + bean.getClass().getName() + "." + field.getProperty() + "] must be instance of Array or Collection."; log.error(message); throw new ValidatorException(message); } } catch (PropertyAccessException e) { String message = "Cannot get property type[" + bean.getClass().getName() + "." + field.getProperty() + "]"; log.error(message, e); throw new ValidatorException(message); } // Object obj = null; try { obj = BeanUtil.getBeanProperty(bean, field.getProperty()); } catch (PropertyAccessException e) { String message = "Cannot get property [" + bean.getClass().getName() + "." + field.getProperty() + "]"; log.error(message, e); throw new ValidatorException(message); } // ???? int min = 0; String minStr = field.getVarValue("minArrayLength"); if (!GenericValidator.isBlankOrNull(minStr)) { try { min = Integer.parseInt(minStr); } catch (NumberFormatException e) { String message = "Mistake on validation definition file. " + "- minArrayLength is not number. " + "You'll have to check it over. "; log.error(message, e); throw new ValidatorException(message); } } // ??? int max = Integer.MAX_VALUE; String maxStr = field.getVarValue("maxArrayLength"); if (!GenericValidator.isBlankOrNull(maxStr)) { try { max = Integer.parseInt(maxStr); } catch (NumberFormatException e) { String message = "Mistake on validation definition file. " + "- maxArrayLength is not number. " + "You'll have to check it over. "; log.error(message, e); throw new ValidatorException(message); } } // try { if (!ValidationUtil.isArrayInRange(obj, min, max)) { rejectValue(errors, field, va, bean); return false; } } catch (IllegalArgumentException e) { log.error(e.getMessage()); throw new ValidatorException(e.getMessage()); } return true; }
From source file:es.pode.administracion.presentacion.planificador.modificarTarea.ObtenerTareaControllerImpl.java
/** * Metodo que guarda los cambios que se han echo en la tarea informeFecha *///from w w w.j a va 2 s. c o m public void modificarTareaInformeFecha(org.apache.struts.action.ActionMapping mapping, es.pode.administracion.presentacion.planificador.modificarTarea.ModificarTareaInformeFechaForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception { if (tz == null) tz = utilidades.asignarZonaHoraria(); TrabajoVO trabajo = new TrabajoVO(); // Trabajo a modificar TareaInformesVO datosTarea = new TareaInformesVO(); // Datos a modificar String dia = new String(((FormularioInformeFechaIIAceptarFormImpl) form).getDia()); String mes = new String(((FormularioInformeFechaIIAceptarFormImpl) form).getMes()); String anio = new String(((FormularioInformeFechaIIAceptarFormImpl) form).getAnio()); String hora = new String(((FormularioInformeFechaIIAceptarFormImpl) form).getHora()); String minutos = new String(((FormularioInformeFechaIIAceptarFormImpl) form).getMinutos()); try { if (((FormularioInformeFechaIIAceptarFormImpl) form).getPeriodicidad().equalsIgnoreCase("N")) { String anioDesde = new String(((FormularioInformeFechaIIAceptarFormImpl) form).getAnioDesde()); String mesDesde = new String(((FormularioInformeFechaIIAceptarFormImpl) form).getMesDesde()); String diaDesde = new String(((FormularioInformeFechaIIAceptarFormImpl) form).getDiaDesde()); String anioHasta = new String(((FormularioInformeFechaIIAceptarFormImpl) form).getAnioHasta()); String mesHasta = new String(((FormularioInformeFechaIIAceptarFormImpl) form).getMesHasta()); String diaHasta = new String(((FormularioInformeFechaIIAceptarFormImpl) form).getDiaHasta()); //Comprobamos que todos los campos de la fecha desde estn rellenos if (anioDesde.equalsIgnoreCase("") || mesDesde.equalsIgnoreCase("") || diaDesde.equalsIgnoreCase("")) throw new ValidatorException("{informes.crearInformes.fechaDesdeCampoVacio}"); //Comprobamos que todos los campos de la fecha hasta estn rellenos if (anioHasta.equalsIgnoreCase("") || mesHasta.equalsIgnoreCase("") || diaHasta.equalsIgnoreCase("")) throw new ValidatorException("{informes.crearInformes.fechaHastaCampoVacio}"); //Comprobamos que los campos de las fechas son numeros if (log.isDebugEnabled()) log.debug("comprobamos si las fechas tiene caracteres no numericos"); try { new Integer(anioDesde).intValue(); new Integer(mesDesde).intValue(); new Integer(diaDesde).intValue(); } catch (Exception e) { log.error("Alguno de los campos de la fecha desde no son nmeros"); throw new ValidatorException("{tareas.eliminarOdes.fechaDesde}"); } try { new Integer(anioHasta).intValue(); new Integer(mesHasta).intValue(); new Integer(diaHasta).intValue(); } catch (Exception e) { log.error("Alguno de los campos de la fecha hasta no son nmeros"); throw new ValidatorException("{tareas.eliminarOdes.fechaHasta}"); } // Comprobamos si las fechas introducidas son correctas boolean fechaValidaDesde = utilidades.validacionFechaDDMMAAAAHHMM(diaDesde, mesDesde, anioDesde, "yyyyMMdd"); boolean fechaValidaHasta = utilidades.validacionFechaDDMMAAAAHHMM(diaHasta, mesHasta, anioHasta, "yyyyMMdd"); boolean comparacionFechaDesdeHasta = utilidades.comparacionFechas(anioDesde, mesDesde, diaDesde, anioHasta, mesHasta, diaHasta); if (!fechaValidaHasta && !fechaValidaDesde) throw new ValidatorException("{tareas.fechaDesdeHastaIncorrecta}"); if (!fechaValidaDesde) throw new ValidatorException("{tareas.fechaDesdeIncorrecta}"); if (!fechaValidaHasta) throw new ValidatorException("{tareas.fechaHastaIncorrecta}"); if (!comparacionFechaDesdeHasta) throw new ValidatorException("{tareas.fechaDesdeMasQueHasta}"); Calendar calFechaDesde = Calendar.getInstance(tz); calFechaDesde = new GregorianCalendar(new Integer(anioDesde).intValue(), new Integer(mesDesde).intValue() - 1, new Integer(diaDesde).intValue(), 0, 1); Calendar calFechaHasta = Calendar.getInstance(tz); calFechaHasta = new GregorianCalendar(new Integer(anioHasta).intValue(), new Integer(mesHasta).intValue() - 1, new Integer(diaHasta).intValue(), 23, 59); datosTarea.setFechaDesde(calFechaDesde); datosTarea.setFechaHasta(calFechaHasta); } else { if (log.isDebugEnabled()) log.debug("es periodica"); } try { trabajo.setTrabajo(((FormularioInformeFechaIIAceptarFormImpl) form).getTrabajo()); trabajo.setGrupoTrabajo(((FormularioInformeFechaIIAceptarFormImpl) form).getGrupoTrabajo()); datosTarea.setTrabajo(((FormularioInformeFechaIIAceptarFormImpl) form).getTrabajo()); datosTarea.setGrupoTrabajo(((FormularioInformeFechaIIAceptarFormImpl) form).getGrupoTrabajo()); datosTarea.setTrigger(((FormularioInformeFechaIIAceptarFormImpl) form).getTrigger()); datosTarea.setGrupoTrigger(((FormularioInformeFechaIIAceptarFormImpl) form).getGrupoTrigger()); datosTarea.setPeriodicidad(((FormularioInformeFechaIIAceptarFormImpl) form).getPeriodicidad()); datosTarea.setFormato(((FormularioInformeFechaIIAceptarFormImpl) form).getFormato()); datosTarea.setInforme(((FormularioInformeFechaIIAceptarFormImpl) form).getInforme()); datosTarea.setMsgInforme(((FormularioInformeFechaIIAceptarFormImpl) form).getMsgInforme()); datosTarea.setMsgNoInforme(((FormularioInformeFechaIIAceptarFormImpl) form).getMsgNoInforme()); datosTarea.setMsgDescripcionTrabajo( ((FormularioInformeFechaIIAceptarFormImpl) form).getMsgDescTrabajo()); Calendar cal = Calendar.getInstance(tz); cal = new GregorianCalendar(new Integer(anio).intValue(), new Integer(mes).intValue() - 1, new Integer(dia).intValue(), new Integer(hora).intValue(), new Integer(minutos).intValue()); datosTarea.setFechaInicio(cal); datosTarea.setUsuario(LdapUserDetailsUtils.getUsuario()); TareaInformesVO tareaRecuperada = this.getSrvPlanificadorService() .modificarTareaInformes(datosTarea, trabajo); form.setTareaModificada(tareaRecuperada.getTrabajo()); } catch (Exception e) { log.error("Error: " + e); throw new ValidatorException("{tareas.error}"); } } catch (ValidatorException ve) { log.error("error " + ve); throw ve; } catch (Exception e) { log.error("Error: " + e); //throw new ValidatorException("{tareas.error}"); } }
From source file:jp.terasoluna.fw.validation.FieldChecks.java
/** * ???????????/*from www . j a va 2s .c om*/ * ?? * ??????????errors??? * false?? * * <p>????5?10??????? true * ????? * * <h5>validation.xml?</h5> * <code><pre> * <form name="sample"> * * <field property="stringField" * depends="byteRange"> * <arg key="sample.stringField" position="0"/> * <var> * <var-name>maxByteLength</var-name> * <var-value>10</var-value> * </var> * <var> * <var-name>minByteLength</var-name> * <var-value>5</var-value> * </var> * <var> * <var-name>encoding</var-name> * <var-value>Windows-31J</var-value> * </var> * </field> * * </form> * </pre></code> * <h5>validation.xml???<var>?</h5> * <table border="1"> * <tr> * <td><center><b><code>var-name</code></b></center></td> * <td><center><b><code>var-value</code></b></center></td> * <td><center><b></b></center></td> * <td><center><b>?</b></center></td> * </tr> * <tr> * <td> maxByteLength </td> * <td>?</td> * <td>false</td> * <td>?????? * ???<code>int</code>???</td> * </tr> * <tr> * <td> minByteLength </td> * <td>??</td> * <td>false</td> * <td>??????? * ???0??</td> * </tr> * <tr> * <td> encoding </td> * <td></td> * <td>false</td> * <td>?????? * ?????VM???</td> * </tr> * </table> * * @param bean ? * @param va Validator????ValidatorAction * @param field * @param errors * @return ???? true * @throws ValidatorException validation?????? * ? */ public boolean validateByteRange(Object bean, ValidatorAction va, Field field, ValidationErrors errors) throws ValidatorException { // String value = extractValue(bean, field); if (StringUtils.isEmpty(value)) { return true; } // String encoding = field.getVarValue("encoding"); // ?? int min = 0; String minStr = field.getVarValue("minByteLength"); if (!GenericValidator.isBlankOrNull(minStr)) { try { min = Integer.parseInt(minStr); } catch (NumberFormatException e) { String message = "Mistake on validation definition file. " + "- minByteLength is not number. " + "You'll have to check it over. "; log.error(message, e); throw new ValidatorException(message); } } // ? int max = Integer.MAX_VALUE; String maxStr = field.getVarValue("maxByteLength"); if (!GenericValidator.isBlankOrNull(maxStr)) { try { max = Integer.parseInt(maxStr); } catch (NumberFormatException e) { String message = "Mistake on validation definition file. " + "- maxByteLength is not number. " + "You'll have to check it over. "; log.error(message, e); throw new ValidatorException(message); } } // try { if (!ValidationUtil.isByteInRange(value, encoding, min, max)) { rejectValue(errors, field, va, bean); return false; } } catch (IllegalArgumentException e) { log.error("encoding[" + encoding + "] is not supported."); throw new ValidatorException("encoding[" + encoding + "] is not supported."); } return true; }
From source file:es.pode.catalogadorWeb.presentacion.categoriasAvanzado.anotacion.detalleAnotacion.DetalleAnotacionControllerImpl.java
public void guardarAnotacion(ActionMapping mapping, GuardarAnotacionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { boolean errorFaltaIdioma = false; boolean errorFaltaTexto = false; boolean errorDatosEntidad = false; boolean errorFechaObli = false; boolean errorFechaObliHorMin = false; boolean errorFechaZonaHoraria = false; boolean errorFechaComboZH = false; boolean errorFecha = false; boolean errorEmail = false; boolean errorNoNumero = false; boolean errorZHFueraRango = false; boolean errorFechaFueraRango = false; boolean errorFormatoFecha = false; CatalogadorAvSession catalogadorAvSession = this.getCatalogadorAvSession(request); InputStream is = null;/* w ww .j a va 2 s . c o m*/ Properties prop = new Properties(); LomAvanzadoVO auxAvanzado = new LomAvanzadoVO(); AvAnnotationVO[] anotaciones = null; AvAnnotationVO anotacionAux = new AvAnnotationVO(); EntidadVO entidad = null; FechaVO fecha = null; try { auxAvanzado.setAnotaciones(anotaciones); is = this.getClass().getResourceAsStream("/catalogadorAvanzado.properties"); prop.load(is); String usuario = LdapUserDetailsUtils.getUsuario(); String identificador = request.getParameter("identificador"); if (identificador == null) { identificador = catalogadorAvSession.getIdentificador(); } String returnURL = request.getParameter("returnURL"); if (returnURL == null) returnURL = catalogadorAvSession.getReturnURL(); catalogadorAvSession.setIdioma(this.getCatalogadorAvSession(request).getIdioma()); catalogadorAvSession.setIdentificador(identificador); catalogadorAvSession.setUsuario(usuario); // metemos en la sesion el parametro de vuelta al empaquetador catalogadorAvSession.setReturnURL(returnURL); //Recoge los valores y los cambios en el formulario Object valor = request.getSession().getAttribute("form"); //rellenamos los datos del formulario dependiendo del tipo de formulario que nos venga if (valor instanceof DetalleAnotacionCUFormImpl) { DetalleAnotacionCUFormImpl formulario = (DetalleAnotacionCUFormImpl) valor; form.setComboIdiomaLabelList(formulario.getComboIdiomaLabelList()); form.setComboIdiomaValueList(formulario.getComboIdiomaValueList()); form.setDescripcion(formulario.getDescripcion()); form.setDescripcionFecha(formulario.getDescripcionFecha()); form.setTituloAnotacion(formulario.getTituloAnotacion()); } else if (valor instanceof DetalleFormSubmitFormFormImpl) { DetalleFormSubmitFormFormImpl formulario = (DetalleFormSubmitFormFormImpl) valor; form.setComboIdiomaLabelList(formulario.getComboIdiomaLabelList()); form.setComboIdiomaValueList(formulario.getComboIdiomaValueList()); form.setDescripcion(formulario.getDescripcion()); form.setDescripcionFecha(formulario.getDescripcionFecha()); form.setTituloAnotacion(formulario.getTituloAnotacion()); } else if (valor instanceof AnotacionValidaVolverFormImpl) { AnotacionValidaVolverFormImpl formulario = (AnotacionValidaVolverFormImpl) valor; form.setComboIdiomaLabelList(formulario.getComboIdiomaLabelList()); form.setComboIdiomaValueList(formulario.getComboIdiomaValueList()); form.setDescripcion(formulario.getDescripcion()); form.setDescripcionFecha(formulario.getDescripcionFecha()); form.setTituloAnotacion(formulario.getTituloAnotacion()); } else if (valor instanceof AnotacionNoValidaVolverFormImpl) { AnotacionNoValidaVolverFormImpl formulario = (AnotacionNoValidaVolverFormImpl) valor; form.setComboIdiomaLabelList(formulario.getComboIdiomaLabelList()); form.setComboIdiomaValueList(formulario.getComboIdiomaValueList()); form.setDescripcion(formulario.getDescripcion()); form.setDescripcionFecha(formulario.getDescripcionFecha()); form.setTituloAnotacion(formulario.getTituloAnotacion()); } //en la descripcion tenems directamente los LangStringVO[] cambiar despues int longitudTextosDesc = 0; int longitudFechDesc = 0; longitudTextosDesc = form.getDescripcionAsArray().length; longitudFechDesc = form.getDescripcionFechaAsArray().length; //actualizamos los datos que hemos cambiado con este metodo cambioFormulario(request, longitudTextosDesc, longitudFechDesc, null); form.setNombre(nombre); form.setOrganizacion(organizacion); form.setEmail(email); form.setFechaCorta(fechaCorta); form.setThora(hora); form.setTminuto(minutos); form.setTsegundoP1(segP1); form.setTsegundoP2(segP2); //el combo y la fecha de la zona horaria solo se recogen si el checkbox esta activo form.setComboZonaH(((zona != null) && (zona.equals("1"))) ? comboZonaH : ""); form.setZhHora(((zona != null) && (zona.equals("1"))) ? zhHora : ""); form.setZhMinutos(((zona != null) && (zona.equals("1"))) ? zhMinutos : ""); form.setMeridianoCero(zona != null ? zona : ""); Fecha auxFecha = new Fecha(); auxFecha.setIdioma(this.getCatalogadorAvSession(request).getIdioma()); form.setFormato(auxFecha.getFormato()); form.setOffSet(auxFecha.getOffSet()); form.setDescripcionAsArray(descripcion.getTextos()); form.setDescripcionFechaAsArray(fechdescripcion.getTextos()); // despues de actualizar el formulario, lo hacemos del obj valor, por si hay algun error que mantenga los cambios Visibles if (valor instanceof DetalleAnotacionCUFormImpl) { DetalleAnotacionCUFormImpl formulario = (DetalleAnotacionCUFormImpl) valor; formulario.setNombre(nombre); formulario.setOrganizacion(organizacion); formulario.setEmail(email); formulario.setFechaCorta(fechaCorta); formulario.setThora(hora); formulario.setTminuto(minutos); formulario.setTsegundoP1(segP1); formulario.setTsegundoP2(segP2); formulario.setComboZonaH(((zona != null) && (zona.equals("1"))) ? comboZonaH : ""); formulario.setZhHora(((zona != null) && (zona.equals("1"))) ? zhHora : ""); formulario.setZhMinutos(((zona != null) && (zona.equals("1"))) ? zhMinutos : ""); formulario.setMeridianoCero(zona != null ? zona : ""); form.setFormato(auxFecha.getFormato()); form.setOffSet(auxFecha.getOffSet()); formulario.setDescripcionAsArray(descripcion.getTextos()); formulario.setDescripcionFechaAsArray(fechdescripcion.getTextos()); } else if (valor instanceof DetalleFormSubmitFormFormImpl) { DetalleFormSubmitFormFormImpl formulario = (DetalleFormSubmitFormFormImpl) valor; formulario.setNombre(nombre); formulario.setOrganizacion(organizacion); formulario.setEmail(email); formulario.setFechaCorta(fechaCorta); formulario.setThora(hora); formulario.setTminuto(minutos); formulario.setTsegundoP1(segP1); formulario.setTsegundoP2(segP2); formulario.setComboZonaH(((zona != null) && (zona.equals("1"))) ? comboZonaH : ""); formulario.setZhHora(((zona != null) && (zona.equals("1"))) ? zhHora : ""); formulario.setZhMinutos(((zona != null) && (zona.equals("1"))) ? zhMinutos : ""); formulario.setMeridianoCero(zona != null ? zona : ""); form.setFormato(auxFecha.getFormato()); form.setOffSet(auxFecha.getOffSet()); formulario.setDescripcionAsArray(descripcion.getTextos()); formulario.setDescripcionFechaAsArray(fechdescripcion.getTextos()); } else if (valor instanceof AnotacionValidaVolverFormImpl) { AnotacionValidaVolverFormImpl formulario = (AnotacionValidaVolverFormImpl) valor; formulario.setNombre(nombre); formulario.setOrganizacion(organizacion); formulario.setEmail(email); formulario.setFechaCorta(fechaCorta); formulario.setThora(hora); formulario.setTminuto(minutos); formulario.setTsegundoP1(segP1); formulario.setTsegundoP2(segP2); formulario.setComboZonaH(((zona != null) && (zona.equals("1"))) ? comboZonaH : ""); formulario.setZhHora(((zona != null) && (zona.equals("1"))) ? zhHora : ""); formulario.setZhMinutos(((zona != null) && (zona.equals("1"))) ? zhMinutos : ""); formulario.setMeridianoCero(zona != null ? zona : ""); form.setFormato(auxFecha.getFormato()); form.setOffSet(auxFecha.getOffSet()); formulario.setDescripcionAsArray(descripcion.getTextos()); formulario.setDescripcionFechaAsArray(fechdescripcion.getTextos()); } else if (valor instanceof AnotacionNoValidaVolverFormImpl) { AnotacionNoValidaVolverFormImpl formulario = (AnotacionNoValidaVolverFormImpl) valor; formulario.setNombre(nombre); formulario.setOrganizacion(organizacion); formulario.setEmail(email); formulario.setFechaCorta(fechaCorta); formulario.setThora(hora); formulario.setTminuto(minutos); formulario.setTsegundoP1(segP1); formulario.setTsegundoP2(segP2); formulario.setComboZonaH(((zona != null) && (zona.equals("1"))) ? comboZonaH : ""); formulario.setZhHora(((zona != null) && (zona.equals("1"))) ? zhHora : ""); formulario.setZhMinutos(((zona != null) && (zona.equals("1"))) ? zhMinutos : ""); formulario.setMeridianoCero(zona != null ? zona : ""); form.setFormato(auxFecha.getFormato()); form.setOffSet(auxFecha.getOffSet()); formulario.setDescripcionAsArray(descripcion.getTextos()); formulario.setDescripcionFechaAsArray(fechdescripcion.getTextos()); } //Comprobamos si los campos ha sido rellenados adecuadamente //Tenemos que componer nuestro AvAnnotationVO que ira dentro del array en la posicion tituloAnotacion!!!!!! //anotacion ///////////// ENTIDAD //8.1 RECURSO ->BEGIN:VCARD VERSION 3.0 FN:GT8/SC36/CT71 EMAIL;TYPE=INTERNET:GT8@aenor.es ORG:AENOR END:VCARD entidad = new EntidadVO(); String textoEnt = ""; if (!organizacion.equals("") || !email.equals("") || !nombre.equals("")) { if (!email.trim().equals("")) { if (validaEmail(email.trim())) { textoEnt = new StringBuffer("BEGIN:VCARD VERSION:3.0 FN:").append(nombre.trim()) .append(" EMAIL;TYPE=INTERNET:").append(email.trim()).append(" ORG:") .append(organizacion.trim()).append(" END:VCARD").toString(); } else errorEmail = true; } else { textoEnt = new StringBuffer("BEGIN:VCARD VERSION:3.0 FN:").append(nombre.trim()) .append(" EMAIL;TYPE=INTERNET:").append(email.trim()).append(" ORG:") .append(organizacion.trim()).append(" END:VCARD").toString(); } } if (textoEnt != null && !textoEnt.trim().equals("")) { entidad.setTexto(textoEnt.trim()); } else { entidad = null; } anotacionAux.setEntidad(entidad); //EntidadVO // EntidadVO entidad = new EntidadVO(); // String textoEnt=""; // textoEnt = new StringBuffer("BEGIN:VCARD VERSION 3.0 FN:").append(nombre).append(" EMAIL;TYPE=INTERNET:").append(email) // .append(" ORG:").append(organizacion).append(" END:VCARD").toString(); // entidad.setTexto(textoEnt); // anotacionAux.setEntidad(entidad); //EntidadVO ///////// FECHA // es obl al menos yyyy-MM-dd Fecha fechaAux = new Fecha(); fechaAux.setIdioma(this.getCatalogadorAvSession(request).getIdioma()); fechaAux.setFechaCorta(fechaCorta); fechaAux.setHora(hora); fechaAux.setMinutos(minutos); fechaAux.setSegundoP1(segP1); fechaAux.setSegundoP2(segP2); fechaAux.setMeridianoCero(zona); fechaAux.setMasOmenos(comboZonaH); fechaAux.setZhHora(zhHora); fechaAux.setZhMinutos(zhMinutos); Integer[] errores = fechaAux.validar(); if (errores.length > 0) { for (int i = 0; i < errores.length; i++) { if (errores[i].equals(Fecha.ErrorNoNumero) && !errorNoNumero) errorNoNumero = true; else if (errores[i].equals(Fecha.ErrorFechaFueraRango) && !errorFechaFueraRango) errorFechaFueraRango = true; else if (errores[i].equals(Fecha.ErrorZHFueraRango) && !errorZHFueraRango) errorZHFueraRango = true; else if (errores[i].equals(Fecha.ErrorFechaComboZH) && !errorFechaComboZH) errorFechaComboZH = true; else if (errores[i].equals(Fecha.ErrorFechaZonaHoraria) && !errorFechaZonaHoraria) errorFechaZonaHoraria = true; else if (errores[i].equals(Fecha.ErrorFechaObliHorMin) && !errorFechaObliHorMin) errorFechaObliHorMin = true; else if (errores[i].equals(Fecha.ErrorFechaObli) && !errorFechaObli) errorFechaObli = true; else if (errores[i].equals(Fecha.ErrorFormatoFecha) && !errorFormatoFecha) errorFormatoFecha = true; } } fecha = new FechaVO(); if (errores.length == 0) { fecha.setFecha(fechaAux.getFechaLomes()); } else { fecha.setFecha(null); } /// descripcion fecha if (fechdescripcion != null) { LangStringVO[] landFechDesc = fechdescripcion.getTextos(); ArrayList fechDescAux = new ArrayList(); String textoDesc = ""; String idioDesc = ""; for (int d = 0; d < landFechDesc.length; d++) { if (landFechDesc[d] != null) { textoDesc = landFechDesc[d].getTexto(); idioDesc = landFechDesc[d].getIdioma(); if (((textoDesc != null) && (!textoDesc.equals(""))) && ((idioDesc != null) && (!idioDesc.equals("")))) { LangStringVO lanDescAux = new LangStringVO(); lanDescAux.setTexto(textoDesc.trim()); lanDescAux.setIdioma(idioDesc); fechDescAux.add(lanDescAux); //lo metemos en el array auxiliar } else {//comprueba si alguno esta incompleto if (idioDesc.equals("") && !textoDesc.trim().equals("")) errorFaltaIdioma = true; if (!idioDesc.equals("") && textoDesc.trim().equals("")) errorFaltaTexto = true; } } } LangStringVO[] textos = null; if (fechDescAux.size() > 0) textos = (LangStringVO[]) fechDescAux.toArray(new LangStringVO[fechDescAux.size()]); if (textos != null) fechdescripcion.setTextos(textos); else fechdescripcion = null; } fecha.setDescripcion(fechdescripcion); //DescripcionVO if (fecha.getDescripcion() == null && fecha.getFecha() == null) fecha = null; anotacionAux.setFecha(fecha); //FechaVO ///////// DESCRIPCIONES if (descripcion != null) { LangStringVO[] landDesc = descripcion.getTextos(); ArrayList descAux = new ArrayList(); for (int d = 0; d < landDesc.length; d++) { if (landDesc[d] != null) { String textoDesc = landDesc[d].getTexto(); String idioDesc = landDesc[d].getIdioma(); if (((textoDesc != null) && (!textoDesc.trim().equals(""))) && ((idioDesc != null) && (!idioDesc.equals("")))) { LangStringVO lanDescAux = new LangStringVO(); lanDescAux.setTexto(textoDesc.trim()); lanDescAux.setIdioma(idioDesc); descAux.add(lanDescAux); //lo metemos en el array auxiliar } else {//comprueba si alguno esta incompleto if (idioDesc.equals("") && !textoDesc.trim().equals("")) errorFaltaIdioma = true; if (!idioDesc.equals("") && textoDesc.trim().equals("")) errorFaltaTexto = true; } } } LangStringVO[] textos = null; if (descAux.size() > 0) { textos = (LangStringVO[]) descAux.toArray(new LangStringVO[descAux.size()]); descripcion.setTextos(textos); } else { descripcion = null; } } anotacionAux.setDescripcion(descripcion); //DescripcionVO if (anotacionAux.getDescripcion() == null && anotacionAux.getEntidad() == null && anotacionAux.getFecha() == null) anotacionAux = null; } catch (org.acegisecurity.AccessDeniedException ad) { throw new java.lang.Exception("detalle.anotacion.cu", ad); } catch (Exception e) { logger.error("Error en Servicio de catalogacion avanzado, metodo guardarAnotacion" + e); throw new java.lang.Exception("detalle.anotacion.cu", e); } //Antes de guardar comprobamos que no haya habido errores if (!errorFaltaIdioma && !errorFaltaTexto && !errorFechaObli && !errorFechaObliHorMin && !errorFechaZonaHoraria && !errorFechaComboZH && !errorEmail && !errorNoNumero && !errorFechaFueraRango && !errorZHFueraRango && !errorFormatoFecha) { //Obtnemos los terminos de los ids seleccionados en todos los combos dameTerminoId(); //Cargamos el objeto de sesion if (catalogadorAvSession.getMDSesion() == null || catalogadorAvSession.getMDSesion().getAnotaciones() == null) { if (anotacionAux == null) anotaciones = new AvAnnotationVO[0]; else { ArrayList lisAnotaAux = new ArrayList(); lisAnotaAux.add(anotacionAux); anotaciones = (AvAnnotationVO[]) lisAnotaAux.toArray(new AvAnnotationVO[lisAnotaAux.size()]); } //auxAvanzado.setAnotaciones(anotaciones); // catalogadorAvSession.setMDSesion(auxAvanzado);//metemos lom entero catalogadorAvSession.getMDSesion().setAnotaciones(anotaciones); } else { //lo metemos en la posicion correspondiente anotaciones = catalogadorAvSession.getMDSesion().getAnotaciones(); if (indi < anotaciones.length) { ArrayList listaAnotaciones = new ArrayList(); for (int i = 0; i < anotaciones.length; i++) { if (i == indi) { if (anotacionAux != null) listaAnotaciones.add(anotacionAux); } else { listaAnotaciones.add(anotaciones[i]); } } anotaciones = (AvAnnotationVO[]) listaAnotaciones.toArray(new AvAnnotationVO[0]); catalogadorAvSession.getMDSesion().setAnotaciones(anotaciones); } else if (anotacionAux != null) { //tenemos que crearlo al final int newTam = anotaciones.length + 1; AvAnnotationVO[] AnotaAux = new AvAnnotationVO[newTam]; for (int i = 0; i < anotaciones.length; i++) AnotaAux[i] = anotaciones[i]; AnotaAux[newTam - 1] = anotacionAux; catalogadorAvSession.getMDSesion().setAnotaciones(AnotaAux); } } } else { if (errorFormatoFecha) throw new ValidatorException("{error.FormatoFecha}"); else if (errorNoNumero) throw new ValidatorException("{error.NoNumero}"); else if (errorFechaFueraRango) throw new ValidatorException("{error.fechaFueraRango}"); else if (errorFechaObli) throw new ValidatorException("{error.fechaIncompleta}"); else if (errorFechaObliHorMin) throw new ValidatorException("{error.fechaIncompletaHorMin}"); else if (errorFechaZonaHoraria) throw new ValidatorException("{error.fechaIncompletaZonaHora}"); else if (errorFechaComboZH) throw new ValidatorException("{error.fechaSelecionaCombo}"); else if (errorZHFueraRango) throw new ValidatorException("{error.ZonaHoraria}"); else if (errorEmail) throw new ValidatorException("{error.email}"); else if (errorFaltaIdioma && errorFaltaTexto) throw new ValidatorException("{general.error.idioma_texto}"); //throw new ValidatorException("{anotaciones.error.datosEntidad_obl}{general.error.idioma_texto}" ); // else if (errorFechaObli) // throw new ValidatorException("{anotaciones.error.fecha_obl}"); else if (!errorFaltaIdioma && errorFaltaTexto) throw new ValidatorException("{general.error.texto}"); else throw new ValidatorException("{general.error.idioma}"); } }
From source file:es.pode.administracion.presentacion.planificador.modificarTarea.ObtenerTareaControllerImpl.java
/** * Metodo que guarda los cambios que se han echo en la tarea informeFechaRango *///from w w w . ja v a 2 s .c o m public void modificarTareaInformeFechaRango(org.apache.struts.action.ActionMapping mapping, es.pode.administracion.presentacion.planificador.modificarTarea.ModificarTareaInformeFechaRangoForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception { if (tz == null) tz = utilidades.asignarZonaHoraria(); String dia = new String(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getDia()); String mes = new String(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getMes()); String anio = new String(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getAnio()); String hora = new String(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getHora()); String minutos = new String(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getMinutos()); TrabajoVO trabajo = new TrabajoVO(); // Trabajo a modificar TareaInformesVO datosTarea = new TareaInformesVO(); // Datos a modificar try { if (((FormularioInformeFechaRangoIIAceptarFormImpl) form).getPeriodicidad().equalsIgnoreCase("N")) { String anioDesde = new String(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getAnioDesde()); String mesDesde = new String(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getMesDesde()); String diaDesde = new String(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getDiaDesde()); String anioHasta = new String(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getAnioHasta()); String mesHasta = new String(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getMesHasta()); String diaHasta = new String(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getDiaHasta()); //Comprobamos que todos los campos de la fecha de inicio estn rellenos if (anioDesde.equalsIgnoreCase("") || mesDesde.equalsIgnoreCase("") || diaDesde.equalsIgnoreCase("")) throw new ValidatorException("{informes.crearInformes.fechaDesdeCampoVacio}"); //Comprobamos que todos los campos de la fecha fin estn rellenos if (anioHasta.equalsIgnoreCase("") || mesHasta.equalsIgnoreCase("") || diaHasta.equalsIgnoreCase("")) throw new ValidatorException("{informes.crearInformes.fechaHastaCampoVacio}"); //Comprobamos que los campos de las fechas son numeros if (log.isDebugEnabled()) log.debug("comprobamos si las fechas tiene caracteres no numericos"); try { new Integer(anioDesde).intValue(); new Integer(mesDesde).intValue(); new Integer(diaDesde).intValue(); } catch (Exception e) { log.error("Alguno de los campos de la fecha desde no son nmeros"); throw new ValidatorException("{tareas.eliminarOdes.fechaDesde}"); } try { new Integer(anioHasta).intValue(); new Integer(mesHasta).intValue(); new Integer(diaHasta).intValue(); } catch (Exception e) { log.error("Alguno de los campos de la fecha hasta no son nmeros"); throw new ValidatorException("{tareas.eliminarOdes.fechaHasta}"); } // Comprobamos si las fechas introducidas son correctas boolean fechaValidaDesde = utilidades.validacionFechaDDMMAAAAHHMM(diaDesde, mesDesde, anioDesde, "yyyyMMdd"); boolean fechaValidaHasta = utilidades.validacionFechaDDMMAAAAHHMM(diaHasta, mesHasta, anioHasta, "yyyyMMdd"); boolean comparacionFechaDesdeHasta = utilidades.comparacionFechas(anioDesde, mesDesde, diaDesde, anioHasta, mesHasta, diaHasta); if (!fechaValidaHasta && !fechaValidaDesde) throw new ValidatorException("{tareas.fechaDesdeHastaIncorrecta}"); if (!fechaValidaDesde) throw new ValidatorException("{tareas.fechaDesdeIncorrecta}"); if (!fechaValidaHasta) throw new ValidatorException("{tareas.fechaHastaIncorrecta}"); if (!comparacionFechaDesdeHasta) throw new ValidatorException("{tareas.fechaDesdeMasQueHasta}"); Calendar calFechaDesde = Calendar.getInstance(tz); calFechaDesde = new GregorianCalendar(new Integer(anioDesde).intValue(), new Integer(mesDesde).intValue() - 1, new Integer(diaDesde).intValue(), 0, 1); Calendar calFechaHasta = Calendar.getInstance(tz); calFechaHasta = new GregorianCalendar(new Integer(anioHasta).intValue(), new Integer(mesHasta).intValue() - 1, new Integer(diaHasta).intValue(), 23, 59); datosTarea.setFechaDesde(calFechaDesde); datosTarea.setFechaHasta(calFechaHasta); } else { if (log.isDebugEnabled()) log.debug("es periodica"); } try { trabajo.setTrabajo(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getTrabajo()); trabajo.setGrupoTrabajo(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getGrupoTrabajo()); datosTarea.setTrabajo(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getTrabajo()); datosTarea.setGrupoTrabajo(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getGrupoTrabajo()); datosTarea.setTrigger(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getTrigger()); datosTarea.setGrupoTrigger(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getGrupoTrigger()); datosTarea.setPeriodicidad(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getPeriodicidad()); datosTarea.setFormato(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getFormato()); datosTarea.setRango(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getRango()); datosTarea.setInforme(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getInforme()); datosTarea.setMsgInforme(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getMsgInforme()); datosTarea.setMsgNoInforme(((FormularioInformeFechaRangoIIAceptarFormImpl) form).getMsgNoInforme()); datosTarea.setMsgDescripcionTrabajo( ((FormularioInformeFechaRangoIIAceptarFormImpl) form).getMsgDescTrabajo()); Calendar cal = Calendar.getInstance(tz); cal = new GregorianCalendar(new Integer(anio).intValue(), new Integer(mes).intValue() - 1, new Integer(dia).intValue(), new Integer(hora).intValue(), new Integer(minutos).intValue()); datosTarea.setFechaInicio(cal); datosTarea.setUsuario(LdapUserDetailsUtils.getUsuario()); TareaInformesVO tareaRecuperada = this.getSrvPlanificadorService() .modificarTareaInformes(datosTarea, trabajo); form.setTareaModificada(tareaRecuperada.getTrabajo()); } catch (Exception e) { log.error("Error: " + e); throw new ValidatorException("{tareas.error}"); } } catch (ValidatorException ve) { log.error("error " + ve); throw ve; } catch (Exception e) { log.error("Error: " + e); //throw new ValidatorException("{tareas.error}"); } }
From source file:jp.terasoluna.fw.validation.FieldChecks.java
/** * ???????????/*from w ww . j a va 2s. c o m*/ * ??????????errors??? * false?? * * <p>???2000/01/01?2010/12/31???????? * ??? * * <h5>validation.xml?</h5> * <code><pre> * <form name="sample"> * * <field property="date" * depends="dateRange"> * <arg key="date" position="0"/> * <var> * <var-name>startDate</var-name> * <var-value>2000/01/01</var-value> * </var> * <var> * <var-name>endDate</var-name> * <var-value>2010/12/31</var-value> * </var> * </field> * * </form> * </pre></code> * <h5>validation.xml???<var>?</h5> * <table border="1"> * <tr> * <td><center><b><code>var-name</code></b></center></td> * <td><center><b><code>var-value</code></b></center></td> * <td><center><b></b></center></td> * <td><center><b>?</b></center></td> * </tr> * <tr> * <td> startDate </td> * <td></td> * <td>false</td> * <td>???? * ????????</td> * </tr> * <tr> * <td> endDate </td> * <td></td> * <td>false</td> * <td>???? * ????????</td> * </tr> * <tr> * <td> datePattern </td> * <td></td> * <td>false</td> * <td>???????? * ??????yyyy/MM/dd???2001/1/1????? * datePattern?datePatternStrict??????? * datePattern???? * </td> * </tr> * <tr> * <td> datePatternStrict </td> * <td></td> * <td>false</td> * <td>????? * ??????????? * ??????yyyy/MM/dd???2001/1/1??? * datePattern?datePatternStrict??????? * datePattern???? * </td> * </tr> * </table> * * @param bean ? * @param va Validator????ValidatorAction * @param field * @param errors * @return ???? true * @throws ValidatorException datePattern???datePatternStrict??? * ?????startDate???endDate???????? * ??? */ public boolean validateDateRange(Object bean, ValidatorAction va, Field field, ValidationErrors errors) throws ValidatorException { // String value = extractValue(bean, field); if (StringUtils.isEmpty(value)) { return true; } // String datePattern = field.getVarValue("datePattern"); String datePatternStrict = field.getVarValue("datePatternStrict"); // ? String startDateStr = field.getVarValue("startDate"); String endDateStr = field.getVarValue("endDate"); // try { if (!ValidationUtil.isDateInRange(value, startDateStr, endDateStr, datePattern, datePatternStrict)) { rejectValue(errors, field, va, bean); return false; } } catch (IllegalArgumentException e) { log.error(e.getMessage()); throw new ValidatorException(e.getMessage()); } return true; }
From source file:jp.terasoluna.fw.validation.FieldChecks.java
/** * ????????//from ww w . ja v a 2 s.c o m * ??????????errors??? * false?? * * <p>?????????? * ?????????validation.xml? * ??depends????Array??????? * depends="requiredArray" "required" ? * * @param bean ?JavaBean * @param va Validator????ValidatorAction * @param field * @param errors * @return ????????? true * @throws ValidatorException validation?????? * ???bean?null????? */ public boolean validateArraysIndex(Object bean, ValidatorAction va, Field field, ValidationErrors errors) throws ValidatorException { if (bean == null) { log.error("validation target bean is null."); throw new ValidatorException("validation target bean is null."); } @SuppressWarnings("rawtypes") Class[] paramClass = null; // ?? Method method = null; // try { paramClass = getParamClass(va); if (paramClass == null || paramClass.length == 0) { String message = "Mistake on validation rule file. " + "- Can not get argument class. " + "You'll have to check it over. "; log.error(message); throw new ValidatorException(message); } method = getMethod(va, paramClass); if (method == null) { String message = "Mistake on validation rule file. " + "- Can not get validateMethod. " + "You'll have to check it over. "; log.error(message); throw new ValidatorException(message); } } catch (RuntimeException e) { log.error(e.getMessage(), e); throw new ValidatorException(e.getMessage()); } try { // ??????????? Object[] argParams = new Object[paramClass.length]; argParams[0] = bean; argParams[1] = va; argParams[3] = errors; // ????? IndexedBeanWrapper bw = getIndexedBeanWrapper(bean); Map<String, Object> propertyMap = bw.getIndexedPropertyValues(field.getKey()); boolean isValid = true; // for (String key : propertyMap.keySet()) { // ?????????? Field indexedField = (Field) field.clone(); indexedField.setKey(key); indexedField.setProperty(key); argParams[2] = indexedField; // // ???? boolean bool = (Boolean) method.invoke(this, argParams); if (!bool) { isValid = false; } } return isValid; } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof ValidatorException) { throw (ValidatorException) t; } log.error(t.getMessage(), t); throw new ValidatorException(t.getMessage()); } catch (Exception e) { log.error(e.getMessage(), e); throw new ValidatorException(e.getMessage()); } }