Overview
The purpose of the plugin is to allow to set up a specific configuration for a Wedia portal application, by overriding a basic configuration provided by the product.
...
_portal
_portal@config
_portal@config@picker
The path _portal@$config@picker designates a configuration defined in 3 folders whose relative paths are successively :
...
options, JSON (optional)
withStatus, boolean(optional, default is false)
Expose status of mapping:OK: the mapping is existing and is valid
NO_FILE: the mapping exists but no base file has been found
INVALID: the configuration of the base path is invalid (probably the folder is outside the specific base location)
VARIABLE: the path associated to mapping is variable. This service could not handle variable bases.
withFileInfo, boolean (optional, default is false) if true, informations on base files are included (size and length)
sizeOfDirectory, boolean (optional, default is true) if true, the size of a folder is calculated by adding the size of all the files in it. If false, it is the size of the file-folder.Files and directories
...
layers
Gets a list of containers configuration layers (configuration layers layer root directorydirectories)
GET /api/portalconfig/containerslayers
(operation ID: containersList
layersList
)
parameters
pathMatcher (optional)
A filter to select containerslayers. See pathMatcher.options, JSON (optional)
withRights, boolean, (optional, default is true)
If true, we expose the writing rights in this containerlayeronlyIfExists, boolean, (optional, default is false)
If true, we expose that the containers layers that physically existwithMappings, boolean, (optional, default is false)
If true, we expose the list of mappings that include the layer stored in this containerlayerwithInfo, boolean (optional, default is false)
If true, we expose some information about the containerlayer:exists, a boolean: if true, the container layer physically exists
var, a boolean: if true, the container layer name has been calculated by postprocessors
restarting, a boolean: if true, the container layer name is relative (it has been cut by a $ during its resolution)
withFileinfo, boolean (optional, default is false)
If true, we expose the last modification date and the size of the container layer (if it exists)sizeOfDirectory, boolean (optional, default is false)
If true, the size of the folder is the total size of all the files it contains (otherwise, this information is what thejava.nio.file.Files.size()
method returns)outOfMappings, boolean (option, default is false)
if true, also retrieves the containers layers that are not used by a mapping (so all folders created in the configuration storage folder)
Panel | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
This service can be used to know if a container layer is used in a mapping. For example to know if
|
...
json
In this case, the json field (mandatory) contains the JSON value to compare.
Example:Code Block language json { "type":"json", "json": { "a": 1, "b": true, "c": "abc" } }
xjson (optional, default is false) if true, the JSON is a XJSON, if false the JSON will be converted to XJSON to compute differences.
form
In this case, the field field (mandatory) contains the name of the form field that contains the JSON (file or string)
Example:Code Block language json { type: form, field: json1, xjson: true }
xjson (optional, default is false) if true, the JSON is a XJSON, if false the JSON will be converted to XJSON to compute differences.
mapping
References a mapping.mappingID, string (mandatory), the mapping ID
wip, boolean (optional, default is false): true activates the wip mode
processorValues, JSON/map (optional, none by default) a set of processor values
surfer, instance reference (optional, none by default), a surfer
config
References a configuration containerlayerIn this case, the path field (mandatory) is the path of the configuration containerlayer
ExampleCode Block language json { type: config, path : '_portal@club-wed@role-4' }
base
References a configuration baseIn this case, the mappingID field is the mapping for which we want the base
ExampleCode Block { type: base, mappingID: portal }
...
path string (mandatory): the path of the desired container (a configuration path)layer
for exemple,_portal@club-wed@role-4
subpath, string (optional): a path relative to the containerlayer path
for example,boardsview
verbosity, JSON (optional):
includesFileInfos, boolean (optional, default is true): exports dates and file sizes
includesFileCounters, boolean (optional, default is true): exports the number of files and folders
options, JSON (optional):
depth: int (optional, default is -1=infinite depth)
pathMatcher: (optional) defines a filter on paths and file names. The filter is applied to the relative path and name: if it matches one of the two, then the file or folder is exported, and those that do not match one of the two are not. See pathMatcher.
...
path: string, multiple (mandatory, if mappingID is not present): a list of paths (base or configuration containerslayers). If mappingID is also present, it’s used as an inclusive filter. If mappingID is not present, it's the list of paths to get.
mappingID: string (mandatory, if path is not present), the mapping for which we want the configuration
wip: boolean (optional, false by default), activate the “wip” mode (if false, wip/inherit files are ignored, if true, wip/inherit files are taken into account
surfer, instance reference (optional, none by default), a substitute user/surfer to get the configuration that this surfer would have if he called the service. (See Instance reference parameter)
processorValues, JSON/map (optional, none by default), a processor/value association map to obtain the corresponding configuration
For example,Code Block language json { "surferRole": "role-31" }
maxLayers, int (optional, default is -1=infinite): only if mappingID present and resolve true, limits the numbers of paths
resolve, boolean (optional, default is true): only if mappingID present, if true, resolve the configuration layers against the context (so get only the involved paths), if false, get all possible paths
verbosity, JSON (optional):
includesErrors, boolean (optional, default is true): export the files or directories that caused read errors
includesIgnored, boolean (optional, default is true): export the files or directories ignored during the resolution of a mapping
includesNotFound, boolean (optional, default is true): export the configuration container layer folders that do not exist
includesFileInfos, boolean (optional, default is true): exports dates and file sizes
includesFileContent, boolean (optional, default is true): exports the content of files
options, JSON (optional):
depth: int (optional, default is -1=infinite depth)
pathMatcher: (optional) defines a filter on paths and file names. The filter is applied to the relative path and name: if it matches one of the two, then the file or folder is exported, and those that do not match one of the two are not. See pathMatcher.
...
Comming soon: locks per layer, by the container (or layer ) parameter
lock
POST /fs/lock
(operation ID: lockPut
)
...
Code Block | ||
---|---|---|
| ||
{ name: 'FS/CONTAINERLAYER/WRITE', parameters: { containerlayer: '_portal@test@role-4' } } |
Code Block |
---|
[ { id: 'writeMainContainerswriteMainLayers', name: 'FS/CONTAINERLAYER/WRITE', parameters: { containerlayer: ['_portal@test@role-4','portal@test@role-14'] } }, { id: 'role_4_displayNaturalSearch' name: 'FS/FILE/WRITE', parameters: { containerlayer: '_portal@test@role-4', path: [home,displayNaturalSearch], content: true, options: { mkDirs: true } } }, { id: 'role_14_displayNaturalSearch' name: 'FS/FILE/WRITE', parameters: [ { name: containerlayer, values: '_portal@test@role-14' }, { name: path, values: [[home,displayNaturalSearch]] }, { name: content, values: false }, { name: options, values: { mkDirs: true } } ] }, { id: 'role_16_displayNaturalSearch' name: 'FS/FILE/WRITE', parameters: [ { name: containerlayer, value: '_portal@test@role-16' }, { name: path, value: [home,displayNaturalSearch] }, { name: content, values: false }, { name: options, values: { mkcontainersmkLayers: true, mkdirsmkDirs: true, clear: true } } ] } ] |
...
With a few exceptions, these services operate on the same principle.
For write services, a configuration can be specified either as an XJSON (lenient) or as a list of paths (XJSONPATH), always in a specified configuration container layer (layer). If a path is specified together with an xjson, the path must be unique and constitute the complete path to the property being written. If the path is omitted, the root of the configuration container layer is addressed. You can write either configuration, wip files or delete files, but not all three at the same time in one call: this is handled by two boolean parameters named delete and wip.
In the XJSON, as in the paths, we do not put a file extension. The XJSON is called lenient because it accepts JSON arrays: in this case, the XJSON object is evaluated automatically (indexes are assigned automatically), and the property name does not have to end with empty brackets ([]
). In writing, only what is described in the XJSON is written, without modifying the other properties (but the properties referenced by the XJSON are well replaced: all siblings files for the property are deleted). The option merge allows you to specify that you want to delete the properties that are not described in the json.
...
service:
POST fs/config
(operation ID:configWrite
)parameters
content (mandatory): the XJSON
container layer (mandatory): the configuration layer container name
path (optional): an xjsonpath target subpath
...
service:
DELETE fs/config
(operation ID:configDelete
)parameters
content: none
container layer (mandatory): the configuration layer container name
path (at least one): one or several xjsonpath
...
service:
POST fs/config
(operation ID:configWrite
)parameters
content (mandatory): the XJSON
container layer (mandatory): the configuration layer container name
path (optional): an xjsonpath target subpath
options
merge: false
...
service:
DELETE fs/config
(operation ID:configDelete
)parameters
content (mandatory): the XJSON
In that mode, the XJSON is not lenient, because arrays are used to specify the mode. In this array, specify the desired options amongDELETE (or D, or DEL, insentive case)
to write a file with delete suffixREMOVE (or R, or REM, insentive case)
to remove the property
for example:Code Block { a: [delete], b: [remove], c: [delete, remove] }
the file a.delete will be created
all the files and directories for the property b will be removed
all the files and directories for the property c will be removed, then the file c.delete will be created
container layer (mandatory): the configuration layer container name
path (optional): an xjsonpath target subpath
...
This service allows to modify (patch or replace) the configuration in a containerlayer, or in a subfolder of a container.layer
Parameters
containerlayer, (see Basic file operatirons/Parameters for details), mandatory
denotes the configuration containerlayerpath, (see Basic file operatirons/Parameters for details), optional, can be single or multiple, depending on the presence of content
specifies the relative xjsonpath (to the configuration containerlayer) where to writecontent, string or file(multipart/formdata), optional
The XJSON (lenient) to write. If this parameter is not specified, multiple paths can be specified. If this parameter is specified, only one path or none can be specified (in this case, we write directly to the containerlayer)wip, boolean, optional(default is false)⛔
True to write to wip datadelete, boolean, optional(default is false)⛔
True to write delete overrides. In this mode, the primitive values in the xjson (if present) are ignored.options, JSON with the following properties
merge, boolean, optional (true by default)
True to keep the other properties already existing in the namespace we are writing. If false, All other properties in the written namespace will be removedFor example, the name space is currently
Code Block /a /b /c c1.json = "c1" c2.json = "c2" /d d1.json = "d1"
We write this XJSON:
Code Block language json { "a": "b": { "c": { "c2": "c2>modified", "c3": "new" } } } }
With merge=true, the result is
Code Block /a /b /c c1.json = "c1" c2.json = "c2>modified" c3.json = "new" /d d1.json = d1
With merge=false, the result is
Code Block /a /b /c c2.json = "c2>modified" c3.json = "new"
mkContainersmkLayers, boolean, optional(false by default)
True to create container layer if it doesn’t existskeepFormat, boolean, optional(false by default)
By default, only JSon is written to files (or empty content for .delete files). If keepFormat is true, and the JSon value is string, and the target file is already existing, the original format (from the suffix) is kept.
Example
Here the current file system:Code Block language json /a /b /c c1.json = "c1" c2.txt= c2 /d d1.json = "d1"
XJSON to write:
Code Block language json { "a": "b": { "c": { "c1": "c1>modified", "c2": "c2>modified" } } } }
Result with keepFormat=false
Code Block language json /a /b /c c1.json = "c1>modified" c2.json = "c2>modified" /d d1.json = "d1"
Result with keepFormat=true
Code Block /a /b /c c1.json = "c1>modified" c2.txt= c2>modified /d d1.json = "d1"
keepDelete, boolean (optional, true by default)
when a property is written, the files concerning this same property are deleted (the writing constitutes a replacement). This option indicates how the file with the delete extension is to be considered during this replacement: by default, it is not deleted (keepDelete=true). You can force the deletion by setting keepDelete to false.keepProperty, boolean (optional, true by default)
when you write .delete files in path mode, the files concerning the same property aren’t deleted. You can force deletion by setting keepProperty to false.
...
Command name: fs/config/delete
containerlayer, (see Basic file operatirons/Parameters for details), mandatory
denotes the configuration containerlayerpath, (see Basic file operatirons/Parameters for details), optional, can be single or multiple, depending on the presence of content
specifies the relative xjsonpath (to the configuration containerlayer) where to writecontent, string or file(multipart/formdata), optional
The XJSON to write. If this parameter is not specified, multiple paths can be specified. If this parameter is specified, only one path or none can be specified (in this case, we write directly to the containerlayer).
This XJSON is not lenient. Arrays are used to specify the operation (see details in the paragraph Delete configuration (write delete files and/or remove files) with a XJSON):DELETE
REMOVE
wip, boolean, optional(default is false)⛔
True to write to wip dataoptions, JSON with the following properties
deleteNotEmpty, boolean (optional, true by default)
if false, REMOVE option is not applyed on not empty directoriesmkContainersmkLayers, boolean (optional, false by default)
...
These are file manipulation operations, with minimal controls. An operation (a service call) is performed exclusively. Other concurrent operations are put on hold until the current operation is completed, or possibly rejected after a timeout.
Parameters
containerlayer, a string
denotes the configuration container layer (e.g._portal@club-wed@role-4
)path
specifies the relative path (to the configuration containerlayer) of the file. The suffix can be omitted: in this case, the best matching file will be used.string
There is no automatic escape or conversion: the value will be used as is. Slashes and backslashes can be used interchangeably and their successions are ignored. You can escape slashes o backslashes with a backslash before.
The path can't be an empty string or only made of spaces.
For examples:home/display-natural-search.json
home/display-natural-search
JSON array
Each value of the array is escaped (the method that is used isUtils.camel2Kebab()
(see Test.jsp), according to the rules indicated here). Then the path is reconstructed by joining these values, separating them with a slash. The JSON lenient syntax is supported. Values can be a string or an array of one string (in that case, the string is not escaped).
For examples:[home,[display-natural-search]]
[home,displayNaturalSearch]
JSON object
property path (mandatory)
string
JSON array
property suffix, string, the suffix of the file (optional, if ommited, the best matching file will be used)
property escape, boolean (optional, default is true)
if true, parts of file path will be escaped or converted.
...
This service allows you to read a file (its content). This service does not allow to retrieve the content of a folder (use the dir service for that).
Parameters
containerlayer, mandatory, single value
path, mandatory, single value
...
If a non-empty content is present, the file is a text file of one of the following types:
plain text
The suffix must betxt
(ortext
) (or specify the typetext/plain
)HTML
The suffix must behtm
(orhtml
) (or specify the typetext/html
)JSON
The suffix must bejson
(or specify the typeapplication/json
)ignored file are supported
if empty content is present, the file will be an empty file of one of the following types:
delete
The suffix must bedelete
ignored files are supported
if no content is present, the file will be a directory
Parameters
containerlayer, mandatory, single value
path, mandatory, single value
content, the file content if any
contentType, the content type
...
replace
, boolean (optional, false by default)
If false, if the file already exists, the operation returns an error. If true, the existing file (or directory) is replaced.mkdirs
mkDirs
, boolean (optional, false by default)
If false, if the directory doesn’t exists, the operation returns an error. If true, the directories are created.mkcontainers
mkLayers
, boolean (optional, false by default)
If false, if the container layer doesn’t exists, the operation returns an error. If true, the container layer directory is created.clear
, boolean (optional, false by default)
Other files with the same base name in the same directory will be deleted automatically.
...
Command name: fs/file/delete
Parameters
containerlayer, mandatory, single value
path, multiple values
pathMatcher, mutiple values
options
recursive
onlyDir
onlyFile
onlyContent
At least one path or one pathMatcher must be specified.
Create
...
layers
POST /api/portalconfig/fs/containerlayer
Command name: fs/containerlayer/write
(operation ID: containerWrite
layerWrite
)
This service allows you to create one or several container layer (root configuration directories)
Parameters
containerlayer, mandatory, multiple values
...
The response, when no error is returned, is a JSON array of objects with the following properties:
containerlayer: the name of the containerlayer
state: the state among:
INVALID: the container layer name contains invalid characters
BASE: the container layer name is identified as the base name
VARIABLE: the container layer name is identified as being dependent on variables (postprocessors)
ALREADY_EXISTS: a container layer of this name already exists
CREATED: the container layer has been created
ERROR: There was an error when creating the containerlayer
If at least one container layer has been created, the code 201 is returned. If all creations have failed, the code 400 is returned. Otherwise code 200 is returned.
...
Code Block | ||
---|---|---|
| ||
[ { "containerlayer": "_portal@testcreate", "state": "ALREADY_EXISTS" }, { "containerlayer": "_portal@testcreate1", "state": "ALREADY_EXISTS" }, { "containerlayer": "_portal@testcreate2", "state": "CREATED" } ] |
...
Some errors are not raised in error if there are several container layer
names. In this case, see the state property in the response.
HTTP status | When | State when several containerslayers |
---|---|---|
400 - Bad request | no container layer name (missing mandatory parameter) | |
400 - Bad request | a container layer name is a base | BASE |
400 - Bad request | a container layer name contains forbidden char (slash, backslash, dollars, or file forbidden chars) | INVALID |
500 - Internal Server error | An error occurred while creating the containerlayer | ERROR |
Example
Code Block |
---|
curl --request POST \ --url 'http://<host>/api/portalconfig/fs/containerlayer?containerlayer=_portal%40testcreate&containerlayer=_portal%40testcreate1&containerlayer=_portal%40testcreate2' |
Code Block |
---|
curl --request POST \ --url http://<host>/api/portalconfig/fs/containerlayer \ --data containerlayer=_portal@testcreate \ --data containerlayer=_portal@testcreate1 \ --data containerlayer=_portal@testcreate2 |
Delete
...
layers
DELETE /api/portalconfig/fs/containerlayer
(operation ID: containerDelete
layerDelete
)
Command name: fs/containerlayer/delete
This service allows you to create one or several container configuration layers (root configuration directoriesfolders).
Parameters
containerlayer, mandatory, multiple values
options:
recursive: boolean, default is false
if false, deleting a non-empty container layer will cause an error. if true, a non-empty container layer will be deleted with all its contents.
...
The response, when no error is returned, is a JSON array of objects with the following properties:
containerlayer: the name of the containerlayer
state: the state among:
INVALID: the container layer name contains invalid characters
BASE: the container layer name is identified as the base name (not deletable)
VARIABLE: the container layer name is identified as being dependent on variables (postprocessors)
NOT_FOUND: a container layer of this name hasn’t been found
DELETED: the container layer has been deleted
NOT_EMPTY: the container layer can’t be deleted because it’s not empty
ERROR: There was an error when deleting the containerlayer
Rename
...
layer
TO DOCUMENT
Convert JSON to XJSON
...
The configuration consists of configuration files and folders.
Configuration
...
layers
This is a folder that contains folders and configuration files. It is a configuration layer that will override a base or other configuration containers layers if eventually. It can be a file or a folder.
...
If it is a folder, we will load its components as indicated below, in the "folders and files" section.
Base configuration
...
It is a container folder or a file that is provided by the product, or projects. The bases are not modifiable by the API. They can be provided in the WXM_CONFIG_RESOLVER plugin or other plugins provided by the product. Projects can provide their own bases per plugin (see WXM_CONFIG_RESOLVER plugin configuration).
...
A final configuration, a JSON file, is the fusion of several configuration containersfolders. The base is used first, then different containers layers come to redefine or overload (add, delete, modify properties).
Folders and files
A configuration containerlayer, if it is a folder, contains folders and files, which will be
...
The following files are ignored:
Configuration containers layers that are not JSON objects
The JSON bases that are not compatible with the type (object or array) of the property that it defines
Folders or files that define an array value that is not an index (a number)
JSON bases in the form of a folder, or with a suffix, or as wip, or inherit
Hidden folders and files
i.e. whose name begins with a dot
including if they are marked wip or inherit (i.e. if their name starts with
~.
or^.
)
if the suffix starts with ignore
wip files (and thus inherit) outside a wip access context.
...
NOT_FOUND
occurs when you try to load a configuration directory (or file) that is not found (for example, you try to load the portal mapping defined by _portal@config@custom, and the _portal@config folder does not exist)NOT_JSON_OBJECT
occurs when you try to load a json base (a file with the name _json) in a folder that defines an object and the loaded JSON is not an object
occurs also when you try to load a configuration from a file configuration container layer and the JSON is not an object (a configuration container layer must always be an object, as the root configuration is an object).
NOT_JSON_ARRAY
occurs when you try to load a json base (a file with the name _json) in a folder that defines an array and the loaded JSON is not an arrayFILE_WITHOUT_SUFFIX
files that define properties of type primitive or null (so except array and object) must have a suffix to determine how to read the content: json, text (or txt) or html (or htm).DIR_WITH_SUFFIX
folders with suffix are ignored.FILE_WITH_UNKNOWN_SUFFIX
only the following suffixes are supported, others are ignored:json, text, txt, html, htm
delete
ignore
JSON_BASE_AS_DIR
a folder with name _json is always ignoredJSON_BASE_WIP_OR_INHERIT
json base (file with name _json) can’t be a wip or an inherit type.HIDDEN_FILE
all files and folders whose name starts with a dot are ignoredNOT_INDEX
a file or folder that defines a property in the context of an array must be a number, otherwise it will be ignored.IGNORE_SUFFIX
you can add the ignore suffix to any file or folder so that it is ignoredNOT_SUPPORTED
any file with an extension other than those supported (like jpeg for example, or rtf, or doc, zip, etc) are ignoredINHERITED
override cancelled by an inherit fileINHERIT_WITH_SUFFIX
an inherit file or folder must not have an extension. Preferably it should be an empty file, with a simple name, just preceded by the caret character (^
).INHERIT_ARRAY
an inherit file or folder must not end with[]
. Preferably it should be an empty file, with a simple name, just preceded by the caret character (^
).DUPLICATE_NAME
When there are multiple files that could be interpreted as defining the same property (for example, ana.json
file and a folder with namea[]
), they are all ignored.DUPLICATE_INDEX
When there are several files that point to the same array index (e.g.,1.json
,01.json
,0001.json
, etc.), they are all ignored)INHERIT_WITHOUT_NAME
an inherit file will be ignored if there is no corresponding property in the same folderWIP_AND_INHERIT_TOGETHER
you can only have either a wip file or an inherit file. If you have both at the same time, then they are both ignored.DUPLICATE_WIP
There should be only one wip for a property. If there are several, one is processed, the others are ignored.DUPLICATE_INHERIT
There should be only one inherit for a property. If there are several, one is processed, the others are ignored.ERROR
When a file cannot be read due to an error, the file is ignored. In this case, in addition to the reason, the error will be given (see ExplainVerbosity options for details).UNKNOWN
If the reason for ignoring a file cannot be determined.WIP_FILE
INHERIT_FILE
...
File tree (in a configuration containerlayer):
...
Final JSON:
Code Block | ||
---|---|---|
| ||
{ "a": { "b": 42 "c": true "d": "abc" }, "e": 3 } |
...
File tree (in a configuration containerlayer):
...
Merged temporary JSON:
Code Block | ||
---|---|---|
| ||
{ "a[]": { "000000500": 42, "000001000": 1, "000002000": true, "000003000": 3, "000004000": "abc" } } |
...
this path allows the access to the services accessible in user account, by extension of the path (we concatenate the URI of the user end point to the uri /api/portalconfig/tools). Not all services are accessible. Security is not applied in this type of invocation.
Services available:
POST /xjson/to (convert a JSON to XJSON)
GET /cache (get cache status)
POST /cache (flush cache)
Configuration file manipulation services
...
A page to test the escapement and the different conversions between file names and property names.
A page to test the detection of the type of a text (if the service considers it to be JSON, HTML or text).
A page allowing to see the files and folders contained in the different configuration containerslayers, and how these files are considered by the plugin
...