List of usage examples for org.apache.commons.validator ValidatorException ValidatorException
public ValidatorException(String message)
From source file:jp.terasoluna.fw.validation.FieldChecks.java
/** * ???float??????/* ww w.ja v a 2s. com*/ * ?????? * * <p>???10?100??????????? * true????? * * <h5>validation.xml?</h5> * <code><pre> * <form name="sample"> * * <field property="floatField" * depends="floatRange"> * <arg key="sample.floatField" position="0"/> * <var> * <var-name>floatRangeMin</var-name> * <var-value>10</var-value> * </var> * <var> * <var-name>floatRangeMax</var-name> * <var-value>100</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> floatRangeMin </td> * <td>?</td> * <td>false</td> * <td>????????Float??? * ? * ????????</td> * </tr> * <tr> * <td> floatRangeMax </td> * <td></td> * <td>false</td> * <td>???????Float?? * ? * ????????</td> * </tr> * </table> * * @param bean ?JavaBean * @param va ?<code>ValidatorAction</code> * @param field ?<code>Field</code> * @param errors ????? * ?? * @return ??????<code>true</code>? * ????<code>false</code>? * @throws ValidatorException validation?????? * ? */ public boolean validateFloatRange(Object bean, ValidatorAction va, Field field, ValidationErrors errors) throws ValidatorException { // String value = extractValue(bean, field); if (StringUtils.isEmpty(value)) { return true; } // float?? --- Float?????? float floatValue = 0; try { floatValue = Float.parseFloat(value); } catch (NumberFormatException e) { rejectValue(errors, field, va, bean); return false; } // --- ?Float?????? // ???? String strMin = field.getVarValue("floatRangeMin"); float min = Float.MIN_VALUE; if (!GenericValidator.isBlankOrNull(strMin)) { try { min = Float.parseFloat(strMin); } catch (NumberFormatException e) { String message = "Mistake on validation definition file. " + "- floatRangeMin is not number. " + "You'll have to check it over. "; log.error(message, e); throw new ValidatorException(message); } } String strMax = field.getVarValue("floatRangeMax"); float max = Float.MAX_VALUE; if (!GenericValidator.isBlankOrNull(strMax)) { try { max = Float.parseFloat(strMax); } catch (NumberFormatException e) { String message = "Mistake on validation definition file. " + "- floatRangeMax is not number. " + "You'll have to check it over. "; log.error(message, e); throw new ValidatorException(message); } } // if (!GenericValidator.isInRange(floatValue, min, max)) { rejectValue(errors, field, va, bean); return false; } return true; }
From source file:es.pode.administracion.presentacion.planificador.modificarTarea.ObtenerTareaControllerImpl.java
/** * metodo que valida los campos de la tarea reindexado(pantalla comun de la tareas) *//*from ww w . j a v a2s. c o m*/ public void validarFormularioReindexado(ActionMapping mapping, ValidarFormularioReindexadoForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { I18n i18n = I18n.getInstance(); //Recogemos el idioma por defecto para mostrar en ese idioma la lista desplegable de idiomas Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE); //recogemos un array de objetos con la lista de idiomas es.pode.soporte.i18n.LocalizacionIdiomaVO[] localizacionArray = i18n .obtenerIdiomasBuscablesLocalizados(locale.getLanguage()); //sacamos los idiomas del array de objetos y lo asignamos al combo form.setRepositorioBackingList(Arrays.asList(localizacionArray), "idLocalizacion", "name"); FormularioReindexadoIContinuarFormImpl formCarga = (FormularioReindexadoIContinuarFormImpl) form; String dia = new String(formCarga.getDia()); String mes = new String(formCarga.getMes()); String anio = new String(formCarga.getAnio()); String hora = new String(formCarga.getHora()); String minutos = new String(formCarga.getMinutos()); if (log.isDebugEnabled()) log.debug("Validamos el formulario de la tarea de reindexado"); if (dia.equalsIgnoreCase("") || mes.equalsIgnoreCase("") || anio.equalsIgnoreCase("") || hora.equalsIgnoreCase("") || minutos.equalsIgnoreCase("")) { log.error("Error al introducir la fecha."); throw new ValidatorException("{tareas.errors.dateHora.required}"); } try { new Integer(dia).intValue(); new Integer(mes).intValue(); new Integer(anio).intValue(); } catch (Exception e) { log.error("Alguno de los campos de la fecha desde no son nmeros"); throw new ValidatorException("{tareas.fechaIncorrecta}"); } try { new Integer(hora).intValue(); new Integer(minutos).intValue(); } catch (Exception e) { log.error("Alguno de los campos de la hora no son nmeros"); throw new ValidatorException("{tareas.horaIncorrecta}"); } Logger.getLogger(this.getClass()).debug("validamos la fecha"); boolean fechaValida = utilidades.validacionFechaDDMMAAAAHHMM(dia, mes, anio, "yyyyMMdd"); Logger.getLogger(this.getClass()).debug("validamos la hora"); boolean horaValida = utilidades.validacionHoraHHMM(hora, minutos); if (!fechaValida && !horaValida) throw new ValidatorException("{tareas.fechaYHoraIncorrectas}"); if (!horaValida) throw new ValidatorException("{tareas.horaIncorrecta}"); if (!fechaValida) throw new ValidatorException("{tareas.fechaIncorrecta}"); }
From source file:es.pode.administracion.presentacion.planificador.modificarTarea.ObtenerTareaControllerImpl.java
/** * metodo que valida los campos de la tarea eliminar odes *///from w ww . j a v a 2s . co m public void validarFormularioNoDisponibles(org.apache.struts.action.ActionMapping mapping, es.pode.administracion.presentacion.planificador.modificarTarea.ValidarFormularioNoDisponiblesForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception { FormularioNoDisponiblesIContinuarFormImpl formCarga = (FormularioNoDisponiblesIContinuarFormImpl) form; String dia = new String(formCarga.getDia()); String mes = new String(formCarga.getMes()); String anio = new String(formCarga.getAnio()); String hora = new String(formCarga.getHora()); String minutos = new String(formCarga.getMinutos()); if (log.isDebugEnabled()) log.debug("Validamos el formulario de la tarea de eliminar odes"); if (dia.equalsIgnoreCase("") || mes.equalsIgnoreCase("") || anio.equalsIgnoreCase("") || hora.equalsIgnoreCase("") || minutos.equalsIgnoreCase("")) { log.error("Error al introducir la fecha."); throw new ValidatorException("{tareas.errors.dateHora.required}"); } try { new Integer(dia).intValue(); new Integer(mes).intValue(); new Integer(anio).intValue(); } catch (Exception e) { log.error("Alguno de los campos de la fecha no son nmeros"); throw new ValidatorException("{tareas.fechaIncorrecta}"); } try { new Integer(hora).intValue(); new Integer(minutos).intValue(); } catch (Exception e) { log.error("Alguno de los campos de la hora no son nmeros"); throw new ValidatorException("{tareas.horaIncorrecta}"); } //Comprobamos si las fecha y la hora son correctas Logger.getLogger(this.getClass()).debug("validamos la fecha"); boolean fechaValida = utilidades.validacionFechaDDMMAAAAHHMM(dia, mes, anio, "yyyyMMdd"); Logger.getLogger(this.getClass()).debug("validamos la hora"); boolean horaValida = utilidades.validacionHoraHHMM(hora, minutos); if (!fechaValida && !horaValida) throw new ValidatorException("{tareas.fechaYHoraIncorrectas}"); if (!horaValida) throw new ValidatorException("{tareas.horaIncorrecta}"); if (!fechaValida) throw new ValidatorException("{tareas.fechaIncorrecta}"); }
From source file:es.pode.catalogadorWeb.presentacion.exportar.ExportarControllerImpl.java
public final void exportarLomes(ActionMapping mapping, ExportarLomesForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { CatalogadorAvSession catAv = this.getCatalogadorAvSession(request); final int BUFFER_SIZE = 2048; DataHandler dh;/*w ww . j ava 2 s . c o m*/ try { dh = this.getSrvCatalogacionAvanzadaService().exportarLomes(catAv.getIdentificador(), catAv.getUsuario(), catAv.getMDSesion(), catAv.getIdioma()); } catch (Exception e) { logger.error(e); throw new ValidatorException("{catalogadorAvanzado.exportar.error.fichero}"); } if (dh == null) { logger.error("Fichero vacio. Abortamos descarga."); throw new ValidatorException("{catalogadorAvanzado.exportar.error.fichero}"); } // asignamos el titulo del fichero que vamos a exportar response.setContentType("text/xml;charset=utf-8"); response.setHeader("Content-Disposition", "attachment;filename=metadataLOMES.xml"); OutputStream out = response.getOutputStream(); InputStream in = dh.getInputStream(); logger.debug("Descargando metadata.xml"); byte[] buffer = new byte[BUFFER_SIZE]; int count; while ((count = in.read(buffer, 0, BUFFER_SIZE)) != -1) { out.write(buffer, 0, count); } out.flush(); }
From source file:jp.terasoluna.fw.validation.FieldChecks.java
/** * ??????/* w ww .j ava 2 s . c o m*/ * * <p>???10??????? * true????? * * <h5>validation.xml?</h5> * <code><pre> * <form name="sample"> * * <field property="stringField" * depends="maxLength"> * <arg key="sample.stringField" position="0"/> * <var> * <var-name>maxlength</var-name> * <var-value>10</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> maxlength </td> * <td></td> * <td>true</td> * <td>?? * ????????</td> * </tr> * </table> * * @param bean ?JavaBean * @param va ?<code>ValidatorAction</code> * @param field ?<code>Field</code> * @param errors ????? * ?? * @return ??????<code>true</code>? * ????<code>false</code>? * @throws ValidatorException validation?????? * ? */ public boolean validateMaxLength(Object bean, ValidatorAction va, Field field, ValidationErrors errors) throws ValidatorException { // String value = extractValue(bean, field); if (StringUtils.isEmpty(value)) { return true; } // ? int max = 0; try { max = Integer.parseInt(field.getVarValue("maxlength")); } catch (NumberFormatException e) { String message = "Mistake on validation definition file. " + "- maxlength is not number. " + "You'll have to check it over. "; log.error(message, e); throw new ValidatorException(message); } // if (!GenericValidator.maxLength(value, max)) { rejectValue(errors, field, va, bean); return false; } return true; }
From source file:es.pode.catalogadorWeb.presentacion.catalogadorBasico.CatBasicoControllerImpl.java
public void validarExportar(ActionMapping mapping, ValidarExportarForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String ficheroProperties = "/catalogadorBasico.properties"; InputStream is;//from w w w .j ava2 s . c o m Properties prop = new Properties(); MDBasicosOblVO metadatosObl = new MDBasicosOblVO(); LomBasicoVO lomExportar = new LomBasicoVO(); LomBasicoVO lomDatosSesion = this.getCatalogadorBSession(request).getMBOSesion(); EducationalVO ed = new EducationalVO(); GeneralVO gn = new GeneralVO(); ClassificationVO cl = new ClassificationVO(); is = this.getClass().getResourceAsStream(ficheroProperties); prop.load(is); if (form.getTitulo() != null || form.getIdioma() != null || form.getDescripcion() != null || form.getTipoRecurso() != null || form.getIdiomaDestinatario() != null || form.getArboles() != null) { ed.setIdiomaDest(form.getIdiomaDestinatario()); ed.setTipo(form.getTipoRecurso()); ed.setContexto(""); ed.setEdad(""); ed.setProcesoCog(""); gn.setDesc(form.getDescripcion()); gn.setIdioma(form.getIdioma()); gn.setTitulo(form.getTitulo()); if (lomDatosSesion != null && lomDatosSesion.getEducational() != null) { lomDatosSesion.getEducational().setIdiomaDest(form.getIdiomaDestinatario()); lomDatosSesion.getEducational().setTipo(form.getTipoRecurso()); } if (lomDatosSesion != null && lomDatosSesion.getGeneral() != null) { lomDatosSesion.getGeneral().setDesc(form.getDescripcion()); lomDatosSesion.getGeneral().setIdioma(form.getIdioma()); lomDatosSesion.getGeneral().setTitulo(form.getTitulo()); } } else { ed.setIdiomaDest(lomDatosSesion.getEducational().getIdiomaDest() == null ? "" : lomDatosSesion.getEducational().getIdiomaDest()); ed.setTipo(lomDatosSesion.getEducational().getTipo() == null ? "" : lomDatosSesion.getEducational().getTipo()); ed.setContexto(""); ed.setEdad(""); ed.setProcesoCog(""); gn.setDesc(lomDatosSesion.getGeneral().getDesc() == null ? "" : lomDatosSesion.getGeneral().getDesc()); gn.setIdioma( lomDatosSesion.getGeneral().getIdioma() == null ? "" : lomDatosSesion.getGeneral().getIdioma()); gn.setTitulo( lomDatosSesion.getGeneral().getTitulo() == null ? "" : lomDatosSesion.getGeneral().getTitulo()); } //completo el objeto para validar metadatosObl.setTitulo(gn.getTitulo()); metadatosObl.setIdioma(gn.getIdioma()); metadatosObl.setDescripcion(gn.getDesc()); metadatosObl.setIdiomaDest(ed.getIdiomaDest()); metadatosObl.setTipoRecurso(ed.getTipo()); metadatosObl.setContexto(""); metadatosObl.setEdad(""); metadatosObl.setProcesoCog(""); // llamo al servicio validacion ValidaVO valida = null; try { valida = this.getSrvValidadorService().validarMDBasicosObl(metadatosObl); } catch (Exception e) { logger.error("CatalogadorBasico.validarExportar: error al llamar al servicio de validacion."); throw new ValidatorException("{catalogadorBasico.exportar.advertencia.error}"); } //traduccion para exportar String[] idxatraduc = new String[3]; for (int cont = 0; cont < idxatraduc.length; cont++) { switch (cont) { case 0: idxatraduc[0] = gn.getIdioma(); break; case 1: idxatraduc[1] = ed.getTipo(); break; case 2: idxatraduc[2] = ed.getIdiomaDest(); break; } } String[] l_id = { prop.getProperty("idioma"), prop.getProperty("tipoDeRecurso"), prop.getProperty("idiomaDestinatario") }; TerminoYPadreVO[] terminosTraduc = this.getSrvVocabulariosControladosService() .crearTraduccionAIngles(idxatraduc); for (int cont = 0; cont < terminosTraduc.length; cont++) {//Cambiado el identificador del termino al nombre del termino en ingles if (l_id[0].equals(terminosTraduc[cont].getIdVocabulario())) { gn.setIdioma(terminosTraduc[cont].getNomTermino()); } else if (l_id[1].equals(terminosTraduc[cont].getIdVocabulario())) { ed.setTipo(terminosTraduc[cont].getNomTermino()); } else if (l_id[2].equals(terminosTraduc[cont].getIdVocabulario())) { ed.setIdiomaDest(terminosTraduc[cont].getNomTermino()); } } //recogemos los arboles ArbolCurricularVO[] arboles = new ArbolCurricularVO[0]; if (this.getCatalogadorBSession(request) != null) {//Recogemos los arboles del objeto de sesion if (this.getCatalogadorBSession(request).getArbolesController() != null) { List dpr = Arrays.asList(this.getCatalogadorBSession(request).getArbolesController().toArray()); arboles = (ArbolCurricularVO[]) dpr.toArray(new ArbolCurricularVO[dpr.size()]); } } cl.setArbolesCurriculares(arboles); lomExportar.setEducational(ed); lomExportar.setGeneral(gn); lomExportar.setClassification(cl); form.setValida(valida); form.setLomExportar(lomExportar); }
From source file:es.pode.administracion.presentacion.planificador.modificarTarea.ObtenerTareaControllerImpl.java
/** * metodo que valida los campos de la tarea informeFecha(pantalla comun de la tareas) */// w w w. j av a 2 s. c om public void validarFormularioFecha(org.apache.struts.action.ActionMapping mapping, es.pode.administracion.presentacion.planificador.modificarTarea.ValidarFormularioFechaForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception { FormularioInformeFechaIContinuarFormImpl formCarga = (FormularioInformeFechaIContinuarFormImpl) form; String dia = new String(formCarga.getDia()); String mes = new String(formCarga.getMes()); String anio = new String(formCarga.getAnio()); String hora = new String(formCarga.getHora()); String minutos = new String(formCarga.getMinutos()); if (log.isDebugEnabled()) log.debug("Validamos el formulario de la tarea de informe con fechas"); if (dia.equalsIgnoreCase("") || mes.equalsIgnoreCase("") || anio.equalsIgnoreCase("") || hora.equalsIgnoreCase("") || minutos.equalsIgnoreCase("")) { log.error("Error al introducir la fecha."); throw new ValidatorException("{tareas.errors.dateHora.required}"); } try { new Integer(dia).intValue(); new Integer(mes).intValue(); new Integer(anio).intValue(); } catch (Exception e) { log.error("Alguno de los campos de la fecha no son nmeros"); throw new ValidatorException("{tareas.fechaIncorrecta}"); } try { new Integer(hora).intValue(); new Integer(minutos).intValue(); } catch (Exception e) { log.error("Alguno de los campos de la hora no son nmeros"); throw new ValidatorException("{tareas.horaIncorrecta}"); } Logger.getLogger(this.getClass()).debug("validamos la fecha"); boolean fechaValida = utilidades.validacionFechaDDMMAAAAHHMM(dia, mes, anio, "yyyyMMdd"); Logger.getLogger(this.getClass()).debug("validamos la hora"); boolean horaValida = utilidades.validacionHoraHHMM(hora, minutos); if (!fechaValida && !horaValida) throw new ValidatorException("{tareas.fechaYHoraIncorrectas}"); if (!horaValida) throw new ValidatorException("{tareas.horaIncorrecta}"); if (!fechaValida) throw new ValidatorException("{tareas.fechaIncorrecta}"); }
From source file:jp.terasoluna.fw.validation.FieldChecks.java
/** * ???????// w w w . jav a 2 s. c o m * * <p>???10??????? * true????? * * <h5>validation.xml?</h5> * <code><pre> * <form name="sample"> * * <field property="stringField" * depends="minLength"> * <arg key="sample.stringField" position="0"/> * <var> * <var-name>minlength</var-name> * <var-value>10</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> minlength </td> * <td>?</td> * <td>true</td> * <td>??? * ????????</td> * </tr> * </table> * * @param bean ?JavaBean * @param va ?<code>ValidatorAction</code> * @param field ?<code>Field</code> * @param errors ????? * ?? * @return ??????<code>true</code>? * ????<code>false</code>? * @throws ValidatorException validation?????? * ? */ public boolean validateMinLength(Object bean, ValidatorAction va, Field field, ValidationErrors errors) throws ValidatorException { // String value = extractValue(bean, field); if (StringUtils.isEmpty(value)) { return true; } // ?? int min = 0; try { min = Integer.parseInt(field.getVarValue("minlength")); } catch (NumberFormatException e) { String message = "Mistake on validation definition file. " + "- minlength is not number. " + "You'll have to check it over. "; log.error(message, e); throw new ValidatorException(message); } // if (!GenericValidator.minLength(value, min)) { rejectValue(errors, field, va, bean); return false; } return true; }
From source file:es.pode.administracion.presentacion.planificador.modificarTarea.ObtenerTareaControllerImpl.java
/** * metodo que valida los campos de la tarea informeFechaRango(pantalla comun de la tareas) *//*from w ww . jav a 2 s. c om*/ public void validarInformeFechaRango(org.apache.struts.action.ActionMapping mapping, es.pode.administracion.presentacion.planificador.modificarTarea.ValidarInformeFechaRangoForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception { FormularioInformesFechaRangoIContinuarFormImpl formCarga = (FormularioInformesFechaRangoIContinuarFormImpl) form; String dia = new String(formCarga.getDia()); String mes = new String(formCarga.getMes()); String anio = new String(formCarga.getAnio()); String hora = new String(formCarga.getHora()); String minutos = new String(formCarga.getMinutos()); if (log.isDebugEnabled()) log.debug("Validamos el formulario de la tarea de fechas rango"); if (dia.equalsIgnoreCase("") || mes.equalsIgnoreCase("") || anio.equalsIgnoreCase("") || hora.equalsIgnoreCase("") || minutos.equalsIgnoreCase("")) { log.error("Error al introducir la fecha."); throw new ValidatorException("{tareas.errors.dateHora.required}"); } try { new Integer(dia).intValue(); new Integer(mes).intValue(); new Integer(anio).intValue(); } catch (Exception e) { log.error("Alguno de los campos de la fecha no son nmeros"); throw new ValidatorException("{tareas.fechaIncorrecta}"); } try { new Integer(hora).intValue(); new Integer(minutos).intValue(); } catch (Exception e) { log.error("Alguno de los campos de la hora no son nmeros"); throw new ValidatorException("{tareas.horaIncorrecta}"); } Logger.getLogger(this.getClass()).debug("validamos la fecha"); boolean fechaValida = utilidades.validacionFechaDDMMAAAAHHMM(dia, mes, anio, "yyyyMMdd"); Logger.getLogger(this.getClass()).debug("validamos la hora"); boolean horaValida = utilidades.validacionHoraHHMM(hora, minutos); if (!fechaValida && !horaValida) throw new ValidatorException("{tareas.fechaYHoraIncorrectas}"); if (!horaValida) throw new ValidatorException("{tareas.horaIncorrecta}"); if (!fechaValida) throw new ValidatorException("{tareas.fechaIncorrecta}"); }
From source file:es.pode.catalogadorWeb.presentacion.categoriasAvanzado.relacion.detalleRelacion.DetalleRelacionControllerImpl.java
public final void guardarRelacion(ActionMapping mapping, GuardarRelacionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { boolean errorFaltaIdioma = false; boolean errorFaltaTexto = false; CatalogadorAvSession catalogadorAvSession = this.getCatalogadorAvSession(request); LomAvanzadoVO auxAvanzado = null;/*w ww. j a v a 2 s. c o m*/ auxAvanzado = new LomAvanzadoVO(); AvRelationVO relacion = new AvRelationVO(); AvRelationVO[] arrayRelacion = new AvRelationVO[1]; arrayRelacion[0] = relacion; auxAvanzado.setRelaciones(arrayRelacion); try { String source = AgregaPropertiesImpl.getInstance().getProperty("esquemaDeMetadatos"); String idiomaLdap = ((Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE)) .getLanguage(); String usuario = LdapUserDetailsUtils.getUsuario(); //String usuario="empaquetador"; String identificador = request.getParameter("identificador"); if (identificador == null) { identificador = catalogadorAvSession.getIdentificador(); } String returnURL = request.getParameter("returnURL"); if (returnURL == null) returnURL = catalogadorAvSession.getReturnURL(); catalogadorAvSession.setIdioma(idiomaLdap); catalogadorAvSession.setIdentificador(identificador); catalogadorAvSession.setUsuario(usuario); // metemos en la sesion el parametro de vuelta al empaquetador catalogadorAvSession.setReturnURL(returnURL); Object valor = request.getSession().getAttribute("form"); // Obtenemos la longitudes de los VOs, que pasamos a cambioFormulario para que se obtengan del request los cambios que hemos hecho //Pues en el form que nos viene como parametro no los guarda. int longitudDescripciones = 0; int[] longitudTextosDesc = new int[0]; if (valor instanceof DetalleRelacionCUFormImpl) { DetalleRelacionCUFormImpl valorDe = ((DetalleRelacionCUFormImpl) valor); Object[] desc = valorDe.getDescripcionAsArray(); longitudTextosDesc = new int[desc.length]; for (int i = 0; i < desc.length; i++) { longitudTextosDesc[i] = ((DescripcionVO) (desc[i])).getTextos().length; } longitudDescripciones = desc.length; } else if (valor instanceof DetalleRelacionFormSubmitFormFormImpl) { DetalleRelacionFormSubmitFormFormImpl valorGen = ((DetalleRelacionFormSubmitFormFormImpl) valor); Object[] desc = valorGen.getDescripcionAsArray(); longitudTextosDesc = new int[desc.length]; for (int i = 0; i < desc.length; i++) { longitudTextosDesc[i] = ((DescripcionVO) (desc[i])).getTextos().length; } longitudDescripciones = desc.length; } else if (valor instanceof RelacionValidaVolverFormImpl) { RelacionValidaVolverFormImpl valorGen = ((RelacionValidaVolverFormImpl) valor); Object[] desc = valorGen.getDescripcionAsArray(); longitudTextosDesc = new int[desc.length]; for (int i = 0; i < desc.length; i++) { longitudTextosDesc[i] = ((DescripcionVO) (desc[i])).getTextos().length; } longitudDescripciones = desc.length; } else if (valor instanceof RelacionNoValidaVolverFormImpl) { RelacionNoValidaVolverFormImpl valorGen = ((RelacionNoValidaVolverFormImpl) valor); Object[] desc = valorGen.getDescripcionAsArray(); longitudTextosDesc = new int[desc.length]; for (int i = 0; i < desc.length; i++) { longitudTextosDesc[i] = ((DescripcionVO) (desc[i])).getTextos().length; } longitudDescripciones = desc.length; } // actualizamos los datos que hemos cambiado con este metodo cambioFormulario(request, longitudTextosDesc, null); form.setTipo(tipo.getValor()); form.setCatalogo(catalogo); form.setEntrada(entrada); form.setDescripcionAsArray(lDescripciones); // TIPOS SourceValueVO tipoAux = new SourceValueVO(); SourceValueVO auxTipoRecurso = new SourceValueVO(); auxTipoRecurso.setValor(tipo.getValor()); auxTipoRecurso.setSource(source); tipoAux = auxTipoRecurso; // DESCRIPCIONES DescripcionVO[] descripcionesAux = new DescripcionVO[lDescripciones.length]; for (int i = 0; i < lDescripciones.length; i++) { DescripcionVO descripAux = new DescripcionVO(); LangStringVO[] langDescrip = lDescripciones[i].getTextos(); LangStringVO[] langDescripAux = new LangStringVO[langDescrip.length]; for (int j = 0; j < langDescrip.length; j++) { LangStringVO nuevoLang = new LangStringVO(); nuevoLang.setIdioma(langDescrip[j].getIdioma()); nuevoLang.setTexto(langDescrip[j].getTexto().trim()); langDescripAux[j] = nuevoLang; } descripAux.setTextos(langDescripAux); descripcionesAux[i] = descripAux; } if (valor instanceof DetalleRelacionCUFormImpl) { ((DetalleRelacionCUFormImpl) valor).setTipo(tipoAux.getValor()); ((DetalleRelacionCUFormImpl) valor).setCatalogo(catalogo); ((DetalleRelacionCUFormImpl) valor).setEntrada(entrada); ((DetalleRelacionCUFormImpl) valor).setDescripcionAsArray(descripcionesAux); } else if (valor instanceof DetalleRelacionFormSubmitFormFormImpl) { ((DetalleRelacionFormSubmitFormFormImpl) valor).setTipo(tipoAux.getValor()); ((DetalleRelacionFormSubmitFormFormImpl) valor).setCatalogo(catalogo); ((DetalleRelacionFormSubmitFormFormImpl) valor).setEntrada(entrada); ((DetalleRelacionFormSubmitFormFormImpl) valor).setDescripcionAsArray(descripcionesAux); } else if (valor instanceof RelacionValidaVolverFormImpl) { ((RelacionValidaVolverFormImpl) valor).setTipo(tipoAux.getValor()); ((RelacionValidaVolverFormImpl) valor).setCatalogo(catalogo); ((RelacionValidaVolverFormImpl) valor).setEntrada(entrada); ((RelacionValidaVolverFormImpl) valor).setDescripcionAsArray(descripcionesAux); } else if (valor instanceof RelacionNoValidaVolverFormImpl) { ((RelacionNoValidaVolverFormImpl) valor).setTipo(tipoAux.getValor()); ((RelacionNoValidaVolverFormImpl) valor).setCatalogo(catalogo); ((RelacionNoValidaVolverFormImpl) valor).setEntrada(entrada); ((RelacionNoValidaVolverFormImpl) valor).setDescripcionAsArray(descripcionesAux); } catalogo = form.getCatalogo(); entrada = form.getEntrada(); dameTerminoId(); // Comprobamos si los campos ha sido rellenados adecuadamente // DESCRIPCIONES ArrayList listaDesc = new ArrayList(); if (lDescripciones != null && lDescripciones.length != 0) { LangStringVO[] textos = lDescripciones[0].getTextos(); if (lDescripciones.length == 1 && textos.length == 1 & textos[0].getIdioma().equals("") && textos[0].getTexto().equals("")) { lDescripciones = null; } else { for (int i = 0; i < lDescripciones.length; i++) { if (lDescripciones[i] != null) { ArrayList listDesc = new ArrayList(); DescripcionVO lDesc = (DescripcionVO) (lDescripciones[i]); DescripcionVO lDescripciones = new DescripcionVO(); for (int j = 0; j < lDesc.getTextos().length; j++) { LangStringVO lang = lDesc.getTextos()[j]; LangStringVO lLang = new LangStringVO(); String idioma = lang.getIdioma(); String texto = lang.getTexto(); if (((idioma != null) && (!idioma.equals(""))) && ((texto != null) && (!texto.trim().equals("")))) { lLang.setIdioma(idioma); lLang.setTexto(texto.trim()); listDesc.add(lLang); } else { if (idioma.equals("") && !texto.trim().equals("")) errorFaltaIdioma = true; if (!idioma.equals("") && texto.trim().equals("")) errorFaltaTexto = true; } } if (listDesc.size() != 0) { LangStringVO[] langs = (LangStringVO[]) listDesc .toArray(new LangStringVO[listDesc.size()]); lDescripciones.setTextos(langs); listaDesc.add(lDescripciones); } } } if (listaDesc.size() == 0) lDescripciones = null; else lDescripciones = (DescripcionVO[]) listaDesc.toArray(new DescripcionVO[listaDesc.size()]); } } else { lDescripciones = null; } RecursoVO recurso = null; if ((catalogo != null && !catalogo.equals("")) || (entrada != null && !entrada.equals("")) || (lDescripciones != null && lDescripciones.length > 0)) { recurso = new RecursoVO(); IdentificadorVO identifica = new IdentificadorVO(); identifica.setCatalogo(catalogo); identifica.setEntrada(entrada); recurso.setIdentificador(identifica); recurso.setDescripciones(lDescripciones); } if (recurso != null || tipo.getValor() != null && !tipo.getValor().equals("")) { auxAvanzado.getRelaciones()[0].setRecurso(recurso); auxAvanzado.getRelaciones()[0].setTipo(tipo); } else auxAvanzado = null; } catch (org.acegisecurity.AccessDeniedException ad) { logger.error("Error de Acceso " + ad); throw new java.lang.Exception("detalle.relacion.cu", ad); } catch (Exception e) { logger.error("Error en catalogadorWeb, categora DetalleRelacin, metodo anadirContDescripcion " + e); throw new java.lang.Exception("detalle.relacion.cu", e); } if (!errorFaltaIdioma && !errorFaltaTexto) { try { // Cargamos el objeto de sesion if (catalogadorAvSession.getMDSesion() == null) { if (auxAvanzado != null) { catalogadorAvSession.setMDSesion(auxAvanzado); } } else { AvRelationVO[] relaciones = catalogadorAvSession.getMDSesion().getRelaciones(); // comprobamos que educaciones no sea null, si es null nos creamos uno if (relaciones == null) { if (auxAvanzado != null) catalogadorAvSession.getMDSesion().setRelaciones(auxAvanzado.getRelaciones()); } else { //creamos uno mas (cogemos la longitud de las educaciones pues el nuevo indice, si teniamos 4 educaciones los indices //iban de 0 a 3 el indice para la nueva educacion seria 4 y ahora tendriamos 5 educaciones con indices de 0 a 4) if (relaciones.length == iRel)//GUARDAR CUANDO HEMOS PULSADO BOTON CREAR { ArrayList listaRel = new ArrayList(); for (int i = 0; i < relaciones.length; i++) listaRel.add(relaciones[i]); if (auxAvanzado != null && auxAvanzado.getRelaciones()[0] != null) { listaRel.add(auxAvanzado.getRelaciones()[0]); } AvRelationVO[] relacionesAux = (AvRelationVO[]) listaRel.toArray(new AvRelationVO[0]); catalogadorAvSession.getMDSesion().setRelaciones(relacionesAux); } else {//GUARDAR CUANDO HEMOS PULSADO BOTON MODIFICAR ArrayList listaRel = new ArrayList(); for (int i = 0; i < relaciones.length; i++) { if (iRel == i) { if (auxAvanzado != null && auxAvanzado.getRelaciones()[0] != null) listaRel.add(auxAvanzado.getRelaciones()[0]); } else listaRel.add(relaciones[i]); } AvRelationVO[] relacionesAux = (AvRelationVO[]) listaRel.toArray(new AvRelationVO[0]); catalogadorAvSession.getMDSesion().setRelaciones(relacionesAux); } } } } catch (Exception e) { logger.error( "Error en catalogadorWeb, categora DetalleRelacin, metodo anadirContDescripcion " + e); throw new java.lang.Exception("detalle.relacion.cu", e); } } else { if (errorFaltaIdioma && errorFaltaTexto) throw new ValidatorException("{general.error.idioma_texto}"); else if (!errorFaltaIdioma && errorFaltaTexto) throw new ValidatorException("{general.error.texto}"); else if (errorFaltaIdioma && !errorFaltaTexto) throw new ValidatorException("{general.error.idioma}"); } }