Class Settings

java.lang.Object
net.sf.basedb.util.extensions.DefaultFilter
net.sf.basedb.util.extensions.manager.Settings
All Implemented Interfaces:
ExtensionsFilter

public class Settings extends DefaultFilter implements ExtensionsFilter
Class for keeping settings for the extensions system. Settings are kept in the settings.xml file in the plug-ins directory.

Extension points and extensions can be disabled/enabled by enableExtensionPoint(String, boolean) and enableExtension(String, boolean).

This class also implements the ExtensionsFilter interface, and can be used on the Registry.useExtensions(net.sf.basedb.util.extensions.ClientContext, ExtensionsFilter, String...) method. This means that disabling/enabling extensions and extension points will immediately be visible in the web interface. Sorting is delegated to the DefaultFilter.

Version:
2.7
Author:
nicklas
Last modified
$Date:2008-03-20 12:15:25 +0100 (Thu, 20 Mar 2008) $
  • Field Details

  • Constructor Details

    • Settings

      Settings(ExtensionsManager manager, File file)
      Create a new Settings object. If the given file doesn't exists it will be created if save() is called. The settings file must be an XML file that can be read by the Presets class.
      Parameters:
      file - The file to load/save settings in. If null, settings only are kept in memory and are lost when the server is shutdown.
  • Method Details

    • isEnabled

      public boolean isEnabled(ExtensionPoint<?> extensionPoint)
      Description copied from interface: ExtensionsFilter
      Check if an extension point is enabled or disabled.
      Specified by:
      isEnabled in interface ExtensionsFilter
      Overrides:
      isEnabled in class DefaultFilter
      Parameters:
      extensionPoint - The extension point to check
      Returns:
      TRUE if the extension point is enabled, FALSE if it is disabled
    • isEnabled

      public boolean isEnabled(Extension<?> extension)
      Description copied from interface: ExtensionsFilter
      Check if an extension is enabled or disabled.
      Specified by:
      isEnabled in interface ExtensionsFilter
      Overrides:
      isEnabled in class DefaultFilter
      Parameters:
      extension - The extension to check
      Returns:
      TRUE if the extension is enabled, FALSE if it is disabled
    • enableExtension

      public void enableExtension(String extensionId, boolean enable)
      Enable/disable an extension.
      Parameters:
      extensionId - The ID of the extension to enable/disable
      enable - TRUE to enable the extension, FALSE to disable it
    • enableExtensionPoint

      public void enableExtensionPoint(String extensionPointId, boolean enable)
      Enable/disable an extension point.
      Parameters:
      extensionPointId - The ID of the extension point to enable/disable
      enable - TRUE to enable the extension point, FALSE to disable it
    • getSettingsForExtension

      public Presets.Preset getSettingsForExtension(String extensionId)
      Get a preset containing settings for the given extesion. If no settings exists, null is returned. Do not make modifications to the returned preset since the result is undefined. Use setSetting(String, String, String) to set values.
      Since:
      3.4
    • setSetting

      public void setSetting(String extensionId, String key, String value)
      Set a configuration setting for an extension. Do not forget to save().
      Parameters:
      extensionId - The ID of the extension to save a setting for
      key - The name of the setting
      value - The value of the setting, use null to remove
      Since:
      3.4
    • getSetting

      public String getSetting(String extensionId, String key)
      Get a configuration setting for an extension.
      Parameters:
      extensionId - The ID of the extension to save a setting for
      key - The name of the setting
      Returns:
      The value or null if it doesn't exists
      Since:
      3.4
    • toKey

      private String toKey(File file)
      A file is typically stored under the absolute path, but if it matches the plug-ins directory we replace it with {plugins.dir}.
      Since:
      3.19.6
    • toFile

      private File toFile(String key)
      A file is typically stored under the absolute path, but if it matches the plug-ins directory we replace it with {plugins.dir}.
      Since:
      3.19.6
    • fixPaths

      private Presets.Preset fixPaths(Presets.Preset preset)
      Fix paths in older config files. This code can be removed some time in the future when we are sure that everyone has upgraded. Eg. in BASE 3.21 since we must allow upgrades between BASE 3.19.x and BASE 3.20.x.
    • isInstalledFile

      public boolean isInstalledFile(File file)
      Check if the given file is marked as installed.
      Since:
      3.0
    • setInstalledFile

      public void setInstalledFile(File file)
      Mark the given file as installed by the extension system.
      Since:
      3.0
    • setUninstalledFile

      public void setUninstalledFile(File file)
      Mark the given file as uninstalled.
      Since:
      3.0
    • getInstalledFiles

      public List<File> getInstalledFiles()
      Get a list with all files that are installed.
      Since:
      3.0
    • isIgnoredFile

      public boolean isIgnoredFile(File file)
      Check if the given file is marked as ignored.
      Since:
      3.10
    • setIgnoredFile

      public void setIgnoredFile(File file, boolean ignore)
      Mark the given file as ignored/not ignored by the extension system.
      Since:
      3.10
    • getIgnoredFiles

      public List<File> getIgnoredFiles()
      Get a list with all files that are ignored.
      Since:
      3.10
    • save

      public void save()
      Save the settings to disk. If the settings has not been changed the file is not written.