Class FormSettingsService

java.lang.Object
sk.iway.iwcm.components.form_settings.rest.FormSettingsService

@Service public class FormSettingsService extends Object
Prepares form settings for administration and bridges persisted settings with legacy attribute maps. Also resolves available custom processors and upload restrictions for forms in the current domain.
  • Constructor Details

  • Method Details

    • prepareSettingsForSave

      public void prepareSettingsForSave(FormSettingsEntity formSettings, String formType)
    • prepareSettingsForSave

      public static void prepareSettingsForSave(FormSettingsEntity formSettings, String formType, FormSettingsRepository formSettingsRepository)
      Updates settings in place with the existing record ID, processor configuration, and selected page IDs. Assigns the current domain when none is set; does not persist the entity.
      Parameters:
      formSettings - settings to prepare, or null to do nothing
      formType - form type used to map the multistep processor field
      formSettingsRepository - repository used to find the existing settings ID in the current domain
    • prepareSettingsForEdit

      public static void prepareSettingsForEdit(FormSettingsEntity formSettings, String formType)
      Populates transient page selections and the multistep processor field for the settings editor.
      Parameters:
      formSettings - settings to update in place, or null to do nothing
      formType - form type determining whether the processor autocomplete is populated
    • getFormProcessorOptions

      public List<String> getFormProcessorOptions(String term)
      Finds registered processor class names matching a case-insensitive substring.
      Parameters:
      term - search text; null, blank, or % includes all registered processors
      Returns:
      matching fully qualified class names
    • load

      public static Map<String,String> load(String formName)
      Loads settings for the current domain as legacy form attributes, excluding technical and editor-only fields.
      Parameters:
      formName - logical form name
      Returns:
      attributes with nullable string values, or an empty map when the repository or settings are unavailable
    • loadEntity

      public static FormSettingsEntity loadEntity(String formName)
      Loads form settings in the current domain without converting them to legacy attributes.
      Parameters:
      formName - logical form name
      Returns:
      settings, or null when the repository or settings are unavailable
    • save

      public static void save(String formName, Map<String,String> parameters)
      Creates or updates settings selected by form name and current domain using entity field names as keys. Converts string, integer, long, and boolean fields; logs individual mapping failures and continues. Does nothing when the repository bean is unavailable.
      Parameters:
      formName - logical form name used to locate or initialize the settings
      parameters - field values to apply, leaving unspecified fields unchanged
    • filterAttributes

      public static Map<String,String> filterAttributes(Map<String,String[]> parameters)
      Extracts the first value of each request parameter whose name starts with attribute_.
      Parameters:
      parameters - request parameters with at least one value per matching name
      Returns:
      selected values keyed by names with attribute_ removed
    • getFileRestriction

      public static FormFileRestriction getFileRestriction(String formName)
      Loads upload restrictions for a form in the current domain through the repository bean.
      Parameters:
      formName - logical form name
      Returns:
      configured restrictions, defaults when settings are missing, or an empty restriction object when the repository bean is unavailable
    • getFileRestriction

      public static FormFileRestriction getFileRestriction(String formName, FormSettingsRepository formSettingsRepository)
    • getFileRestriction

      public static FormFileRestriction getFileRestriction(String formName, FormSettingsEntity formSettings)
      Builds upload restrictions from settings, treating unset numeric limits as zero. Without settings, uses a 5000 KB per-file limit and 3000 by 2000 pixel image limits, with no extension filter or combined-size limit.
      Parameters:
      formName - logical form name attached to the restrictions
      formSettings - settings to read, or null to use the default limits
      Returns:
      a new restriction object for the form