Class PreferenceManager

java.lang.Object
de.spiritscorp.datasync.io.PreferenceManager

public final class PreferenceManager extends Object
Thread-safe global configurations orchestrator managing persistent JSON configurations. Coordinates multi-profile I/O read/write operations for independent replication synchronization tasks and global application states. Implements the Singleton pattern to ensure centralized state control.
  • Method Details

    • getInstance

      public static PreferenceManager getInstance()
      Gets the global Singleton instance.
      Returns:
      The singleton manager instance.
    • initGlobalRootConfigPath

      public void initGlobalRootConfigPath(Path customRoot)
      Reconfigures and overrides the global operational ecosystem workspace root coordinates. Re-initializes all system-dependent structural path mappings dynamically.

      Fallback at (user.home)/DataSync if the target path is not writeable or not valid

      Parameters:
      customRoot - The new target base directory path, or null to retain the home default context.
    • createProfile

      public Preference createProfile(String jobName)
      Allocates and provisions a new, distinct profile configuration data scope unit. Automatically appends the freshly constructed tracking unit block into active memory structures.
      Parameters:
      jobName - Unique target workspace identifier.
      Returns:
      An unpopulated, isolated configuration state segment tracker.
    • getProfile

      public Preference getProfile(String jobName)
      Retrieves an allocated configuration tracking state context signature via its workspace identifier.
      Parameters:
      jobName - The unique profile registry lookup key.
      Returns:
      The matching configuration instance state, or null if no mapping tracks the parameter.
    • renameProfile

      public boolean renameProfile(String oldName, String newName, Preference pref)
      Atomically handles profile rename routines inside the synchronization runtime context. Mutates the tracking key structural state identifier map and flushes changes to disk immediately.
      Parameters:
      oldName - Original task profile identifier key.
      newName - Target replacement unique identifier string.
      pref - Associated configuration parameters data segment instance.
      Returns:
      true if persistence succeeded; false if parameters were invalid or execution failed.
    • removeProfile

      public boolean removeProfile(SyncJobContext job)
      Atomically removes an active synchronization job context tracking assignment. Evicts cached properties from memory and updates the primary configuration storage file.
      Parameters:
      job - The high-level UI task context container targeted for decommissioning.
      Returns:
      true if structural extraction and serialization completed successfully.
    • getLoadedProfiles

      public Map<String, Preference> getLoadedProfiles()
      Exposes the active, in-memory configuration profile map registry. Wrapped in an unmodifiable view to preserve structural mutation thread safety bounds.
      Returns:
      An unmodifiable structural read-only view tracking live preference profiles.
    • saveAllPreferences

      public boolean saveAllPreferences()
      Compiles all active in-memory profile matrices and flushes them into a single unified JSON structure. Truncates any existing configuration state assets dynamically during filesystem stream allocation.
      Returns:
      true if structural file flushing and underlying persistence executed without errors.
    • loadAllPreferences

      public boolean loadAllPreferences()
      Hydrates the global storage matrix layer and multi-job profile cache records from the persistent disk token. Validates individual structural segments during structural ingestion parsing.
      Returns:
      true if filesystem parsing completed entirely; false if tracking token was absent or corrupt.
    • isGlobalAutoStart

      public boolean isGlobalAutoStart()
      Evaluates whether the application ecosystem is provisioned to launch automatically upon host operating system startup sequences.
      Returns:
      true if the global background autostart configuration sequence is enabled.
    • setGlobalAutoStart

      public void setGlobalAutoStart(boolean globalAutoStart)
      Modifies the global automation startup property state parameter. This execution updates the structural configuration variable memory cache layers.
      Parameters:
      globalAutoStart - Target state flag to determine automated deployment behavior.
    • getConfigPath

      public Path getConfigPath()
      Retrieves the persistent dynamic configuration storage path target locator.
      Returns:
      The absolute filesystem path directing to the primary 'conf.json' token.
    • getLogPath

      public Path getLogPath()
      Retrieves the persistent operational event synchronization logging path locator.
      Returns:
      The absolute filesystem path directing to the structural 'log.json' entity.
    • getDebugPath

      public Path getDebugPath()
      Retrieves the system console output debug log tracking path locator.
      Returns:
      The absolute filesystem path directing to the standard runtime 'debug.log' file.
    • getErrorPath

      public Path getErrorPath()
      Retrieves the localized tracking error diagnostic path locator.
      Returns:
      The absolute filesystem path directing to the critical runtime 'debug.err' stream dump.
    • setTheme

      public void setTheme(AppTheme theme)
      Sets the visual theme of the application.
    • getTheme

      public AppTheme getTheme()
      Gets the currently configured application theme.
      Returns:
      the active AppTheme
    • isCustomConfigDir

      public boolean isCustomConfigDir()