Interface ApplicationSettingsPlugin


public interface ApplicationSettingsPlugin
Makes the settings drawer of one portlet configurable by the layout tools: the addon owning the portlet contributes one plugin and registers it from its own @PostConstruct through ApplicationSettingsService.addPlugin(ApplicationSettingsPlugin). A plugin exposes exactly the drawer's options, reads and writes them only through the owning Service's permission-checked calls, as the user of the context, and never trusts a window preference as a right: any editor of a page can set any preference of its windows. A setting keyed by a window preference (a CMS setting name, an application id) is the live window's on a draft copy until the plugin re-keys it: it writes in place only when ApplicationSettingsService.isOwner(ApplicationSettingsContext) says the window owns its keys, and otherwise creates its own copy first, keyed on the live page reference, then marks the window through ApplicationSettingsService.markOwner(ApplicationSettingsContext, Map). Refusals are the texts the agent reads: IllegalArgumentException value is not accepted for <option>, ObjectNotFoundException does not exist: <object>; an IllegalAccessException is answered not allowed: application whatever its message.
  • Method Details

    • getPortletName

      String getPortletName()
      Returns:
      the portlet name, the second part of the application content id
    • getSettingsSchema

      Map<String,Object> getSettingsSchema()
      Returns:
      the JSON schema of the settings object, as the read tools expose it. A null never reaches the plugin, the service dropping it as "unchanged", so an option the drawer can clear names its non-null clearing value in its description: false to hide, an empty text to remove a link or a translation.
    • isConfigurableInSiteContainer

      default boolean isConfigurableInSiteContainer()
      Returns:
      whether a window placed in a site container is configurable: a setting keyed by a page reference hangs there on the site's home page the context carries, and the plugin refuses the write while the site has none
    • read

      Map<String,Object> read(ApplicationSettingsContext context) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
      Parameters:
      context - the window and the reading user
      Returns:
      the settings as the drawer shows them, null when none is stored yet
      Throws:
      IllegalAccessException - when the user may not read them
      org.exoplatform.commons.exception.ObjectNotFoundException - when the setting the window names does not exist
    • validate

      void validate(ApplicationSettingsContext context, Map<String,Object> settings) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
      Checks every given value against the drawer's vocabulary and the user's right to change the application, writing nothing
      Parameters:
      context - the window and the writing user
      settings - the settings to change, a key omitted keeping its stored value
      Throws:
      IllegalAccessException - when the application's own rule refuses the user
      org.exoplatform.commons.exception.ObjectNotFoundException - when a referenced object does not exist
    • apply

      void apply(ApplicationSettingsContext context, Map<String,Object> settings) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
      Writes validated settings through the owning Service, as the user
      Parameters:
      context - the window and the writing user
      settings - the settings validated by validate(ApplicationSettingsContext, Map)
      Throws:
      IllegalAccessException - when the owning Service refuses the user
      org.exoplatform.commons.exception.ObjectNotFoundException - when a referenced object disappeared