Class SimpleNodeSettingsService

java.lang.Object
net.solarnetwork.service.support.BasicIdentifiable
net.solarnetwork.node.service.support.BaseIdentifiable
net.solarnetwork.node.runtime.SimpleNodeSettingsService
All Implemented Interfaces:
InstructionHandler, net.solarnetwork.service.Identifiable

public class SimpleNodeSettingsService extends BaseIdentifiable implements InstructionHandler
Service to support node settings management.

This InstructionHandler responds to TOPIC_SYSTEM_CONFIGURATION requests where the PARAM_SERVICE value is SETTINGS_SERVICE_UID. At a minimum a PARAM_SETTING_UID value must also be provided, and optionally the PARAM_INSTANCE_ID value can be provided. Those two parameters determine the results returned, as outlined below. The result is always a JSON string on the PARAM_SERVICE_RESULT result parameter.

How the uid and id parameters control the result format.
uid id Operation
* List providers
{settingUid} List settings
* * List factories
{factoryUid} * List factory instances
{factoryUid} {instanceId} List factory instance settings

List all available non-factory setting UIDs

Pass a uid parameter value of * to generate a JSON array of objects, each representing a single provider, with the following properties:

id
The provider ID (settingUid).
title
The component title.

List the settings for a non-factory provider

Pass a uid parameter value of the specific setting UID you'd like to get the settings for. The result will be a JSON array of objects, each representing a single setting, with the following properties:

key
The setting key.
value
The setting value.
default
A boolean, true indicating that the value is a "default" value provided by SolarNode, not one a user has specifically configured. This property might be omitted entirely instead of appearing with a false value.

List all available factory setting UIDs

Pass a uid parameter value of * and a id parameter value of * to generate a JSON array of objects, each representing a single factory, as shown in the list providers section.

List the available instance IDs for a factory

To generate a JSON array of instance IDs for a specific factory UID, pass a uid parameter value of the factory UID you'd like the list for, and a id parameter value of *.

List the settings for a factory instance provider

Pass a uid parameter value of the specific factory UID and a id parameter value of the specific factory instance ID you'd like to list the settings for. The result will be a JSON array of objects, as shown in the list settings section.

Specification mode

By passing a spec parameter value of true, then instead of returning component setting values, setting specification objects will be returned instead. At a minimum, each specification object has a type property that is the setting type. Other specifications provide more properties, as listed below.

Group specification

A group specification has the type net.solarnetwork.settings.GroupSettingSpecifier. It will include a dynamic boolean property, where true represents a dynamic list of specifications. The groupSettings property will be an array of nested specification objects that make up the group.

Other specifications

Most specifications provide a key property representing the setting key for that specification.

Since:
3.3
Version:
1.0
Author:
matt
  • Field Details

    • SETTINGS_SERVICE_UID

      public static final String SETTINGS_SERVICE_UID
      The default UID for this service.
      See Also:
    • PARAM_SETTING_UID

      public static final String PARAM_SETTING_UID
      An optional instruction parameter containing a specific setting UID (or factory UID) to get the settings for.
      See Also:
    • PARAM_INSTANCE_ID

      public static final String PARAM_INSTANCE_ID
      An optional instruction parameter containing a specific setting factory instance ID to get the settings for.

      If this is provided, then the PARAM_SETTING_UID parameter must also be provided, and that will be interpreted as the factory UID.

      See Also:
    • PARAM_SPECIFICATION

      public static final String PARAM_SPECIFICATION
      An optional instruction parameter containing a boolean flag that, when true, means setting specifications should be returned instead of setting values.
      See Also:
    • PARAM_COMPRESSED

      public static final String PARAM_COMPRESSED
      An optional instruction parameter containing a boolean flag that, when true, means the result JSON should be gzip-compressed and encoded into a Base64 string representation.

      Note that only successful results will be compressed. If the compressed result is larger than the uncompressed JSON, the uncompressed JSON will be returned instead.

      See Also:
    • ID_LIST

      public static final String ID_LIST
      A special PARAM_SETTING_UID or PARAM_INSTANCE_ID value that signals to return the list of available IDs.
      See Also:
    • REDACTED_VALUE

      public static final String REDACTED_VALUE
      A redacted setting value.
      See Also:
  • Constructor Details

    • SimpleNodeSettingsService

      public SimpleNodeSettingsService(net.solarnetwork.service.OptionalService<SettingsService> settingsService)
      Constructor.
      Parameters:
      settingsService - the settings service
      Throws:
      IllegalArgumentException - if any argument is null
  • Method Details

    • handlesTopic

      public boolean handlesTopic(String topic)
      Description copied from interface: InstructionHandler
      Test if a topic is handled by this handler.
      Specified by:
      handlesTopic in interface InstructionHandler
      Parameters:
      topic - the topic
      Returns:
      true only if this handler can execute the job for the given topic
    • processInstruction

      public InstructionStatus processInstruction(Instruction instruction)
      Description copied from interface: InstructionHandler
      Process an instruction.
      Specified by:
      processInstruction in interface InstructionHandler
      Parameters:
      instruction - the instruction to process
      Returns:
      the status for the instruction, or null if the instruction was not handled