Import/Export & Dry-Run

Common Contract

Most configuration domains implement:

  • POST /<domain>/import (multipart file upload) – validates and persists.

  • POST /<domain>/import/dry-run – validates and reports changes/errors without persisting.

  • GET /<domain>/export – exports DB state into a domain format.

  • Import mode query parameter: ImportMode (REPLACE or MERGE) (src/main/java/com/friendly/ftconfigsservice/utils/ImportMode.java).

Import Modes

MERGE

  • Upserts items found in the import payload.

  • Keeps existing DB rows not present in the payload.

REPLACE

  • Makes DB state match the payload.

  • For northbound configuration specifically, missing keys must be reset to defaults (not deleted).

Dry-run semantics

Dry-run is required as a pre-flight check:

  • If dry-run reports errors, import must be blocked by the caller (UI/backend integration).

  • Imports still perform validation and can fail even when dry-run is skipped.

Domain Example: Tabs JSON import

Implementation: TabImportService (src/main/java/com/friendly/ftconfigsservice/angular/tabs/service/TabImportService.java).

  • Input: JSON array of TabGroupDto objects containing group path and nested items.

  • Dry-run: compares incoming payload against DB state using business keys (group path, item path) and emits DryRunResult.

  • Import: recomputes the diff and applies create/update/delete operations depending on ImportMode.

Important note: the Hazelcast tabs map is not refreshed by this flow today (see Caching Strategy).

Domain Example: Northbound api.properties / Settings.xml

Implementation: NorthboundImportService (src/main/java/com/friendly/ftconfigsservice/northbound/importing/NorthboundImportService.java).

  • Accepts either:

    • api.properties (Java properties format)

    • legacy Settings.xml (auto-detected by filename or leading < bytes)

  • Resolves aliases (NorthboundAliasResolver) and normalizes values (NorthboundValueNormalizer).

  • Validates values against entry metadata (NorthboundConfigValidator) and produces a list of errors during dry-run.

  • In REPLACE mode: any entries missing from the upload are reset to their default_value (or blank).

  • Changes are classified by effective value — the stored value, or default_value when the stored value is blank, which is what northbound-api receives. An entry whose effective value does not change is neither reported nor written, so a blank value is not overwritten with an identical explicit default.

  • Dry-run is side-effect free: no saveAll, no Hazelcast publish (the snapshot is read with getConfiguration).

Legacy Settings.xml value rules

A legacy value is imported with the meaning the .NET northbound service gave it at runtime, so a migrated installation keeps its behaviour. Values are trimmed first (unlike .NET, which compared the raw text, so <Push> true</Push> was false there and is true here).

Legacy tag Entry Rule

LoginAuthentication, IsUsernamePasswordMandatoryForCreateDevice, CheckProductClassBeforeCreate, CheckParameterExists, Push, ProcessLogDb, ProcessLogFile, WriteProcessStat

the matching boolean entries

only the exact string true is true; True, 1 and anything else are false

AddToProvision

api.settings.request.provision-add

only 1 is true; true, 0 and anything else are false

FTGetDeviceParametersLogic

api.device.parameters.retrieval.method

only the exact string Directly is Directly; anything else is Polling

GetStatusInterval, CreateDeviceTimeout

the request timeouts

milliseconds in the file, seconds in the entry

any tag, empty node

its entry

the entry’s default_value (an empty node fell back to the default in .NET); an optional entry without a default keeps an empty value

  • REPLACE resets apply the entry’s default_value as is; the rules above never touch a default.

  • An ENUM value is stored in the exact spelling of the allowed value it matches ignoring case (INFO is stored as info), for every import source and for PUT, because northbound-api compares enum values case-sensitively. A value that matches no allowed value is still rejected. A value stored in another spelling before this rule existed is not migrated; it stays as it is until it is saved or imported again.

  • Known differences from .NET, by decision: the Java defaults, not the .NET ones, apply to an empty or absent node for AddToProvision, IspEnable, KickDeviceTimeOut, CreateDeviceTimeout, ProcessLogLevel, Priority, GetStatusInterval, LogFolder (~/ in .NET) and HttpUrlUpload / FtpUrlUpload (empty in .NET, a localhost URL here). The semantics of ProcessLogMethodsExclude / ProcessLogColumnsExclude also differ and are out of scope.

Import result contract (northbound)

POST /northbound/config/dry-run, POST /northbound/config/import/xml and POST /northbound/config/import/xml/dry-run return NorthboundImportResultDto. POST /northbound/config/import still returns only the configuration snapshot.

Field Type Meaning

applied

boolean

true when changes were persisted (false for dry-run)

errors

string[]

Blocking errors collected during dry-run (validation, unknown keys)

configuration

object

Configuration snapshot (current state for dry-run); secrets are write-only, see Write-only secrets (northbound)

updatedCount

int

Keys from the file whose effective value changes

resetToDefaultCount

int

REPLACE only: keys absent from the file whose effective value changes to the default

unchangedCount

int

Evaluated entries (file keys, plus REPLACE candidates) without an effective change or error

changes

object[]

One item per changed entry; unchanged entries and entries with errors are omitted

Each changes item (NorthboundConfigChangeDto):

Field Type Meaning

code

string

Configuration code (api.properties key)

groupKey

string

Key of the group the entry belongs to

changeType

enum

Always UPDATED (shared ChangeType; northbound import never creates or deletes entries)

resetToDefault

boolean

true when REPLACE resets an absent key to its default

secret

boolean

true when the values are masked

currentValue

string

Effective value before the import; <redacted> for secret entries

incomingValue

string

Effective value after the import; <redacted> for secret entries

Dry-run response, mode=REPLACE
{
  "applied": false,
  "errors": [],
  "configuration": { "groups": [ ... ], "updatedAt": "2026-09-15T12:00:00" },
  "updatedCount": 1,
  "resetToDefaultCount": 1,
  "unchangedCount": 30,
  "changes": [
    { "code": "api.settings.request.timeout.device-create", "groupKey": "timeouts", "changeType": "UPDATED",
      "resetToDefault": false, "secret": false, "currentValue": "5", "incomingValue": "30" },
    { "code": "api.settings.upload.ftp.password", "groupKey": "upload", "changeType": "UPDATED",
      "resetToDefault": true, "secret": true, "currentValue": "<redacted>", "incomingValue": "<redacted>" }
  ]
}

Write-only secrets (northbound)

Entries with secret=true (seeded: api.settings.upload.http.password, api.settings.upload.ftp.password) never leave the service in clear text through the UI API. The marker is the single constant SensitiveFieldRedactor.REDACTED (<redacted>).

  • GET /northbound/config, the PUT /northbound/config response and every import/dry-run configuration: a non-blank value or defaultValue of a secret entry is <redacted>; a blank one stays blank. Every entry carries hasValue (true when a non-blank value is stored), which tells a set secret from an unset one.

  • PUT /northbound/config, per item of a secret entry:

    • value equals <redacted> → skipped: not validated, not written, stored value kept (a round-tripped GET never overwrites a secret);

    • value is "" → clears the secret (subject to required validation);

    • any other value → validated and stored.

  • Import (/import, /import/xml, both dry-runs): a secret key whose file value is <redacted> is treated the same way — counted as unchanged, not written, and not reset by REPLACE.

  • GET /northbound/config/export and the Hazelcast snapshot keep real values — they feed northbound-api deployment.

Secret entry in GET /northbound/config
{ "id": 30, "code": "api.settings.upload.ftp.password", "label": "FTP password", "description": "...",
  "value": "<redacted>", "defaultValue": "", "valueType": "PASSWORD", "allowedValues": [],
  "minValue": null, "maxValue": null, "validationPattern": null,
  "secret": true, "required": false, "editable": true, "displayOrder": 60,
  "updatedAt": "2026-09-15T12:00:00", "updatedBy": "admin", "hasValue": true }

Sequence: Dry-run import (northbound)

ft-configs-seq-import-dryrun

Sequence: Import (northbound)

ft-configs-seq-import-apply