コード例 #1
0
  @Override
  public void validate(DDMForm ddmForm) throws DDMFormValidationException {
    validateDDMFormLocales(ddmForm);

    validateDDMFormFields(
        ddmForm.getDDMFormFields(),
        new HashSet<String>(),
        ddmForm.getAvailableLocales(),
        ddmForm.getDefaultLocale());
  }
コード例 #2
0
  protected void validateDDMFormLocales(DDMForm ddmForm) throws DDMFormValidationException {

    Locale defaultLocale = ddmForm.getDefaultLocale();

    if (defaultLocale == null) {
      throw new DDMFormValidationException(
          "The default locale property was never set for DDM form");
    }

    validateDDMFormAvailableLocales(ddmForm.getAvailableLocales(), defaultLocale);
  }
コード例 #3
0
  @Override
  public String serialize(DDMForm ddmForm) {
    Document document = SAXReaderUtil.createDocument();

    Element rootElement = document.addElement("root");

    rootElement.addAttribute("available-locales", getAvailableLanguagesIds(ddmForm));
    rootElement.addAttribute("default-locale", LocaleUtil.toLanguageId(ddmForm.getDefaultLocale()));

    addDynamicElementElements(ddmForm.getDDMFormFields(), rootElement);

    return document.asXML();
  }