Class ThemeUpdateService

java.lang.Object
io.meeds.layout.service.ThemeUpdateService

@Service public class ThemeUpdateService extends Object
Updates one part of the theme the way the Branding page's Apply button does: the whole branding is loaded, the part's options and resets are merged into it, and the whole is submitted, so that every field the caller did not name keeps its stored value although the branding service replaces the whole. An untouched theme variable stored at its configured default is submitted absent, so that it keeps following that default. A page field's value is validated here against the Page drawer's vocabulary; a theme variable's value by the branding service before its first write, whose message code is answered as the option it names, or as the options refused when it names none; any other failure of the write is answered as the theme not saved, the service's own text staying in the server log.
  • Field Details

  • Constructor Details

    • ThemeUpdateService

      public ThemeUpdateService()
  • Method Details

    • updateTheme

      public Map<String,String> updateTheme(ThemePart part, Map<String,String> options, List<String> reset, String username) throws IllegalAccessException
      Parameters:
      part - the part of the theme
      options - the options to set, by name; a null value is ignored
      reset - the options returned to their default
      username - the acting user
      Returns:
      the part's options as stored after the update
      Throws:
      IllegalAccessException - when the user is not an administrator
      IllegalArgumentException - when an option is not one of the part, when a value is blank, a page value outside the Page drawer's vocabulary or a background image other than none or one gradient, when an option is both set and reset, when nothing is asked, or when the branding service refuses a value
      IllegalStateException - when the branding service fails to save the theme
    • describe

      public Map<String,String> describe(ThemePart part, Set<String> accepted)
      Parameters:
      part - the part of the theme
      accepted - the part's accepted options
      Returns:
      the part's options holding a value, stored or default
    • acceptedOptions

      public Set<String> acceptedOptions(ThemePart part, Set<String> declared)
      Parameters:
      part - the part of the theme
      declared - the theme variables the platform declares
      Returns:
      the part's drawer options the platform declares, and the part's branding fields