Introduction
The tree structure views allow to get information from ta resource of the Wedia repository that are structured in a tree. Like usual views, it is a selection of the properties of a unit object and the properties of its related objects.
The tree structure views shows the structure from a selected object or from the root(s). It is also possible to show the path of an object until its roots (ascending) or the other way round (descending) for example to do a breadcrumb.
The tree structure is defined by an object that as a child type property which nature is the same as the object itself. This property is tagged with arbo_field tag. If this structure is not respected the call will return an error.
The mapping of those views are similar to the usual views: so beware not to share the same names between usual views and tree structure view.
Configuration
To each view are a name and a JSON configuration associated.
JSON example
{ "objectname": "section", "treefieldname": "section", "orderby": "", "props": [ "id", "name" ], "query": "pactivated='1'", "secured": true }
Properties and sections
objectname: String - Name of the object (type)
description: String - Short description of action
treefieldname: The property undertaking the link (not mandatory: it will be automatically retrieved if required)
query: Selection query (SQL Wedia)
since 11.19*parameterizedQuery: String or Object - Selection query (SQL syntax) as JSON Query (allowing among other things to make the query parameterisable)
orderby: Sorting algorithm (SQL)
since 11.10sortbyrelevance: Boolean - (Relevant only if query is fulltext) Indicate if results are sorted first by relevance (true) or not (false). Default to true
since 11.10sortbyrelevanceiforderby: Boolean - (Relevant only if query is fulltext) this property allows to deactivate sorting by relevance if an order by clause is configured. If this property is false, sortbyrelevance must be explicity to true to get result sorted by relevance if there is an order by set. Default to true.
secured: Define if we apply security
max: Maximum number of instance to export at each call
from: Number of the first instance to get
fulltext: Textual search criteria
props: Properties sections A table of properties names to be exported. It is possible to export the properties of an linked object by adding a ‘.’ between the name of the property and the property name of the related object.
E.g. for the name of the object, the status name of the object, and the status color HTML code:
[“name”, “status.name”, “status.color.name”].header: An open section that allows to get back as is to the call response
since 11.18queryPolicies: allows you to manage rights on the requestable fields
since 11.18queryPoliciesByRoles: allows you to manage rights on the requestable fields, depending of role of the surfer
EndPoints
There are three endpoints available:
To get a view
To get a branch
To get a list of available views
EndPoint: Get a view
since 11.14
GET http://host:port/app/api/json/tree/{viewName}{/id}
since 11.12
GET http//host:port/app/api/json/tree
Legacy endpoint:
http://host:port/app/_plugins/WXM_RESTAPI/page/tree.jspz
Supported methods: GET, HEAD
Parameters
viewName: String - View identifier
id (or form_id): Root object identifier, or void to have all the roots (objects without father)
withRoot: (false by default)
depth: Desired depth of the tree. For infinite depth use infinite or a negative value. By default the depth is 1. If depth is 0, only the requested object is visible (or roots if no object is requested)
props: Character string: Comma separated names and properties (only properties available in the view can be requested, if blank all properties will be displayed)
query: Character string: A selection request following JSON type specific language (to combine with the configured request). For long requests (above URL maximum lenght), request can be defined in the header X-WEDIA-QUERY, or in the body of the request (supported contenttypes: application/json, text/json)).
orderby: Character string (SQL): Sorting algorithm
since 11.10sortbyrelevance: Boolean - Overrides sortbyrelevance from configuration
secured: A boolean: To apply or not the security (if configuration is applied, then security must be applied)
fulltext: Character string: The text based search criteria
from: An integer: Number of the first requested object
max: An integer: Maximum number of the requested objects
rawValues: A boolean: Indicates if we apply the localization (false by default)
headers: A boolean: Indicates if headers are required (Cf. hereafter, response format) (false by default).
linkPrefix: Allows to indicate the prefix of the children property ($ by default)
Response format
{ "viewname": "name of the view", "headers": { "name of the property": { "name": "localized label of the property", "type": "type of the property" } }, "header": { }, //the header section of the configuration "request": { "context": { // the configuration information coming from the request "secured": false, "props": [] }, "parameters": { // request parameters "viewname": "name of the view", "headers": "true" } }, "response": { // the response "context": { "objectname": "type of the object ", // not visible in production mode "query": "the Wedia SQL Query", // not visible in production mode "orderby": "sorting algorithm", "props": { "name of the property" }, "secured": true, "max": 20, "from": 0 }, "data": [ // the data { // one object per instance "Name of the property": {}, //value of the property "$children": [ // children { "name of the property": {}, //value of the property "$children": [] } ] } ] } }
Example
Configuration
{ "objectname": "section", "treefieldname": "section", "orderby": "", "props": [ "id", "name" ], "query": "pactivated='1'", "secured": true }
Request
http://localhost:8080/Engine/_plugins/WXM_RESTAPI/page/tree.jspz?viewname=sectionview&headers=true&depth=infinite
Result
{ "viewname": "sectionview", "headers": { "id": { "name": "id", "type": "number" }, "name": { "name": "Nom", "type": "string" } }, "header": null, "request": { "context": { "secured": false, "props": [] }, "parameters": { "headers": "true", "viewname": "sectionview", "depth": "infinite" } }, "response": { "context": { "objectname": "section", "treefieldname": "section", "query": "pactivated='1'", "orderby": "", "props": [ "id", "name" ], "secured": true,"max": 20, "from": 0 }, "data": [ { "id": 10070, "name": "DAM", "$children": [ { "id": 10072, "name": "Media", "$children": [ { "id": 10102, "name": "create a new media", "$children": [] }, { "id": 10075, "name": "See media", "$children": [] } ] } ] }, { "id": 10001, "name": "Projects", "$children": [ { "id": 10002, "name": "all projects", "$children": [ { "id": 10004, "name": "Create a project from existing", "$children": [] }, { "id": 10003, "name": "See all projects", "$children": [] } ] }, { "id": 10005, "name": "New project", "$children": [ { "id": 10009, "name": "Create a website", "$children": [] }, { "id": 10008, "name": "Create an email", "$children": [] }, { "id": 10007, "name": "Create a print document", "$children": [] }, { "id": 10006, "name": "Start a creative project", "$children": [] } ] } ] }, { "id": 10014, "name": "Websites", "$children": [ { "id": 10015, "name": "Organization", "$children": [ { "id": 10016, "name": "Manage websites", "$children": [] } ] }, { "id": 10019, "name": "Menus and sections", "$children": [ { "id": 10020, "name": "Manage menus and sections", "$children": [] } ] }, { "id": 10021, "name": "Blocs", "$children": [ { "id": 10022, "name": "Create a new bloc", "$children": [] }, { "id": 10023, "name": "See existing blocs", "$children": [] }, { "id": 10024, "name": "Organize the blocs folders", "$children": [] } ] }, { "id": 10025, "name": "Web user", "$children": [ { "id": 10026, "name": "See registered users", "$children": [] } ] } ] }, { "id": 10027, "name": "Contents", "$children": [ { "id": 10028, "name": "Media library", "$children": [ { "id": 10030, "name": "Add a new media (photo, video, ...)", "$children": [] }, { "id": 10029, "name": "See videos and images", "$children": [] }, { "id": 10031, "name": "Organize medias folders", "$children": [] } ] }, { "id": 10032, "name": "Articles", "$children": [ { "id": 10034, "name": "Create a new article", "$children": [] }, { "id": 10033, "name": "See all articles", "$children": [] } ] }, { "id": 10060, "name": "News", "$children": [ { "id": 10061, "name": "Add a news", "$children": [] }, { "id": 10062, "name": "See all news", "$children": [] } ] } ] }, { "id": 10097, "name": "Analytics", "$children": [ { "id": 10098, "name": "Visit", "$children": [ { "id": 10100, "name": "Connection tracking", "$children": [] } ] } ] }, { "id": 10035, "name": "Models", "$children": [ { "id": 10036, "name": "Print Models", "$children": [ { "id": 10037, "name": "Add a new model", "$children": [] }, { "id": 10038, "name": "See the print models", "$children": [] } ] }, { "id": 10052, "name": "Webpages and email models", "$children": [ { "id": 10053, "name": "Add a new web page model", "$children": [] }, { "id": 10054, "name": "See the web pages models", "$children": [] }, { "id": 10067, "name": "Add a new email model", "$children": [] }, { "id": 10068, "name": "See the email models", "$children": [] } ] }, { "id": 10055, "name": "Website models", "$children": [ { "id": 10056, "name": "Add a new website model", "$children": [] }, { "id": 10057, "name": "See the website models", "$children": [] } ] }, { "id": 10058, "name": "Organize", "$children": [ { "id": 10059, "name": "Organize the models folder", "$children": [] } ] } ] }, { "id": 10044, "name": "Administration", "$children": [ { "id": 10045, "name": "Users", "$children": [ { "id": 10046, "name": "Manage users", "$children": [] }, { "id": 10047, "name": "Manage roles", "$children": [] } ] }, { "id": 10048, "name": "Projects", "$children": [ { "id": 10049, "name": "Manage brands", "$children": [] }, { "id": 10050, "name": "Manage the wedia communication channel", "$children": [] }, { "id": 10051, "name": "Organize the projects folder", "$children": [] } ] }, { "id": 10063, "name": "Manage contents", "$children": [ { "id": 10064, "name": "Manage content tags", "$children": [] } ] }, { "id": 10065, "name": "Language management", "$children": [ { "id": 10066, "name": "Manage available languages", "$children": [] } ] } ] } ] }, "links": { "href": "http://host:port/app/_plugins/WXM_RESTAPI/page/tree.jspz?viewName=sectionview&headers=true&depth=infinite", "previous": null, "next": "http://host:port/app/_plugins/WXM_RESTAPI/page/tree.jspz?viewName=sectionview&from=20&headers=true&depth=infinite" }, "status": 200, "time": 708 }
Security
The tree action of the RESTAPI domain allows to manage the endpoint call authorisation. There are two parameters:
surfer: surfer
viewName: the view identifier
Errors codes
HTTP Code | API Code | Definition |
---|---|---|
404 | 404/500 | Unknown view |
403 | 403/500 | Unreachable view (or forbidden) |
422 | 422/500 | Unreachable view (configuration problem) |
EndPoint: Get a branch
since 11.14
GET http://host:port/app/api/json/treepath/{viewName}{/id}
HEAD http://host:port/app/api/json/treepath/{viewName}{/id}
since 11.12
http//host:port/app/api/json/treepath
Legacy endpoint:
http://host:port/app/_plugins/WXM_RESTAPI/page/branch.jspz
Supported methods: GET, HEAD
Parameters
viewName: Character string, view identifier
id (or form_id): Initial node identifier
depth: Number of element to get. For an infinite depth use infinite or a negative valuer. The default depth is 1. The depth 0 allows to see only the current object
ascendant: Sorting order
true (default value): branch is ascending, specified object to its root parent,
false: branch is descending (breadcrumb order).
props: Character string: Comma separated names and properties (only properties available in the view can be requested, if blank all properties will be displayed)
query: Character string: A selection request following JSON type specific language (to combine with the configured request). For long requests (above URL maximum lenght), request can be defined in the header X-WEDIA-QUERY, or in the body of the request (supported contenttypes: application/json, text/json)).
orderby: Character string (SQL): Sorting algorithm
secured: A boolean: To apply or not the security (if configuration is applied, then security must be applied)
fulltext: Character string: The text based search criteria
from: An integer: Number of the first requested object
max: An integer: Maximum number of the requested objects
rawValues: A boolean: Indicates if we apply the localization (false by default)
headers: A boolean: Indicates if headers are required (Cf. hereafter, response format) (false by default).
Response format
{ "viewname": "name of the view", "headers": { "name of the property": { "name": "localized label of the property", "type": "type of the property" }, "name of the tree structure property": { "name": "localized label of the property", "type": "type of the object", "view": “view associated with the mapping”, "treefield": true } }, "header": null, "request": { "context": { "secured": false, "props": [], "max": 1, "from": 0 }, "parameters": { "headers": "true", "id": "10075", "viewname": "test", "depth": "infinite" } }, "response": { "context": { "objectname": "section", "treefieldname": "section", "query": "pactivated='1'", "orderby": "", "props": [ "id", "name" ], "secured": true, "max": 1, "from": 0 }, "data": [ { "id": 10075, "name": "See media", "rubrique": { "id": 10072, "name": "Media", "rubrique": { "id": 10070, "name": "DAM", "rubrique": null } } } ] }, "links": { "href": "http://localhost:8080/Engine/_plugins/WXM_RESTAPI/page/branch.jspz?viewName=test&headers=true&id=10075&depth=infinite" }, "status": 200, "time": 79 }
Example
Configuration
{ "objectname": "section", "treefieldname": "section", "orderby": "", "props": [ "id", "name" ], "query": "pactivated='1'", "secured": true }
Request
http://localhost:8080/Engine/_plugins/WXM_RESTAPI/page/branch.jspz?viewname=sectionview&id=10075&headers=true&depth=infinite
Result
{ "viewname": "sectiontreeview", "headers": { "id": { "name": "id", "type": "number" }, "name": { "name": "Name", "type": "string" }, "rubrique": { "name": "section", "type": "object", "view": null, "treefield": true } }, "header": null, "request": { "context": { "secured": false, "props": [], "max": 1, "from": 0 }, "parameters": { "headers": "true", "id": "10075", "viewname": "sectiontreeview", "depth": "infinite" } }, "response": { "context": { "objectname": "section", "treefieldname": "section", "query": "pactivated='1'", "orderby": "", "props": [ "id", "name" ], "secured": true, "max": 1, "from": 0 }, "data": [ { "id": 10075, "name": "See media", "rubrique": { "id": 10072, "name": "Media", "rubrique": { "id": 10070, "name": "DAM", "rubrique": null } } } ] }, "links": { "href": "http://host:port/app/_plugins/WXM_RESTAPI/page/branch.jspz?viewName=sectiontreeview&headers=true&id=10075&depth=infinite" }, "status": 200, "time": 79 }
Security
The branch action of the RESTAPI domain allows the management of endpoint call authorisation. There are two parameters:
surfer: surfer
viewName: the view identifier
Errors codes
HTTP Code | API Code | Definition |
---|---|---|
404 | 404/500 | Unknown view |
403 | 403/500 | Unreachable view (or forbidden) |
422 | 422/500 | Unreachable view (configuration problem) |
EndPoint: available views list
since 11.12
http//host:port/app/api/json/catalog/tree
http//host:port/app/api/json/catalog/branch
Legacy endpoint:
http//host:port/app/_plugins/WXM_RESTAPI/page/catalog/tree.jspz
Supported methods: GET, HEAD
Parameters
viewName: Character string, an optional Regular Expression type filter (by default, all accessible views are displayed)
headers: a boolean that indicates if headers are required or not (Cf. hereafter, response format) (false by default).
Response format
{ "catalog": "list of tree structure views", "request": { "parameters": { "headers": "true" } }, "response": { "data": [ { "name": "name of the view", "properties": [ "name of property 1", "name of property 2", "name of property 3" ], "headers": { "name of property": { "name": "localized label of the property", "type": "type of the property" } } } ] }, "links": { "href": "http://host:port/app/_plugins/WXM_RESTAPI/page/catalog/tree.jspz" }, "status": 200, "time": 29 }
Security
The catalog action of RESTAPI domain allows the management of the endpoint call authorisation. There are two parameters:
surfer: surfer
endPoint: tree value.
Errors codes
HTTP Code | API Code | Definition |
---|---|---|
403 | 403/501 | Unreachable catalog (or forbidden) |