Class DashboardSettingsService

java.lang.Object
sk.iway.iwcm.components.welcome.DashboardSettingsService

@Service public class DashboardSettingsService extends Object
Validates and persists shared dashboard layouts and domain-specific options, preserving shortcuts during widget resets.
  • Constructor Details

  • Method Details

    • load

      public DashboardSettingsDto load(int userId, String domainKey)
      Reads the shared layout with only the requested domain's options.
      Parameters:
      userId - ID of the account that owns the settings
      domainKey - decimal root group ID identifying the active domain
      Returns:
      stored settings, or an unconfigured DTO when the stored layout is absent or invalid
      Throws:
      IllegalStateException - if the settings cannot be read from the database
    • save

      public DashboardSettingsDto save(int userId, String domainKey, DashboardSettingsDto settings)
      Validates and replaces the shared layout and current-domain options in one transaction.
      Parameters:
      userId - ID of the account that owns the settings
      domainKey - decimal root group ID identifying the active domain
      settings - settings to validate and persist; missing widget options are initialized in place
      Returns:
      the supplied settings with the layout and shortcuts marked as configured
      Throws:
      IllegalArgumentException - if the settings are invalid
      IllegalStateException - if the settings cannot be persisted
    • reset

      public DashboardSettingsDto reset(int userId)
      Clears widget preferences, all domain options and the news acknowledgement while retaining shortcuts. Shortcut configuration and migration flags are preserved; the layout is marked as unconfigured so the client can supply default widgets.
      Parameters:
      userId - ID of the account whose widget preferences are reset
      Returns:
      retained shortcuts and configuration flags after the reset
      Throws:
      IllegalStateException - if the reset cannot be persisted
    • reset

      public DashboardSettingsDto reset(int userId, String domainKey, DashboardSettingsDto layout)
      Replaces widget preferences atomically while preserving shortcuts read under the account lock. Existing domain options and the news acknowledgement are cleared. A supplied layout provides replacement widgets and current-domain options; its shortcuts are included only when the account's shortcuts have not been configured. The legacy bookmark migration flag is preserved.
      Parameters:
      userId - ID of the account whose widget preferences are reset
      domainKey - decimal root group ID identifying the active domain
      layout - replacement layout, or null to leave widgets unconfigured for client defaults
      Returns:
      persisted settings containing retained shortcuts and any supplied replacement widgets
      Throws:
      IllegalArgumentException - if the supplied or combined layout is invalid
      IllegalStateException - if the reset cannot be persisted