Thesaurus
Thesaurus-tree
This relation targets the root of the thesaurus tree.
For each node in the thesaurus tree, children nodes are embedded in the representation as a child
.
To retrieve sub tree, retrieve the children nodes resource using the self
relation.
Get thesauruses
GET http://baobab.keepeek.com/api/dam/thesaurus-tree HTTP/1.1
[...]
HTTP/1.1 200 OK
Content-Type: application/hal+json;version=1;charset=UTF-8
[...]
{
"_links": {
"self": {
"href": "http://baobab.keepeek.com/api/dam/thesaurus-tree"
},
"curies": [{
"name": "kpk",
"href": "http://baobab.keepeek.com/api/doc/rels/{rel}",
"templated": true
}]
},
"_embedded": {
"child": [{
"id": 634,
"title": "activité",
"_links": {
"self": {
"href": "http://baobab.keepeek.com/api/dam/thesaurus-tree/634"
},
"kpk:thesaurus": {
"href": "http://baobab.keepeek.com/api/dam/thesauruses/634"
}
}
},
{
"id": 700,
"title": "adjectif",
"_links": {
"self": {
"href": "http://baobab.keepeek.com/api/dam/thesaurus-tree/700"
},
"kpk:thesaurus": {
"href": "http://baobab.keepeek.com/api/dam/thesauruses/700"
}
}
},
[...]
{
"id": 1208,
"title": "volume",
"_links": {
"self": {
"href": "http://baobab.keepeek.com/api/dam/thesaurus-tree/1208"
},
"kpk:thesaurus": {
"href": "http://baobab.keepeek.com/api/dam/thesauruses/1208"
}
}
}]
},
"childrenCount": 11
}
Get thesaurus
You can also get a specific thesaurus :
GET /api/dam/thesaurus-tree/{id}'
[...]
HTTP/1.1 200 OK
Content-Type: application/hal+json;charset=UTF-8;version=1
[...]
{
"id": id
"title": "Angleterre",
"_links": {
"self": {
"href": "http://baobab.keepeek.com/api/dam/thesaurus-tree/1314"
},
"curies": [
{
"name": "kpk",
"href": "http://baobab.keepeek.com/api/doc/rels/{rel}",
"templated": true
}
],
"kpk:thesaurus": {
"href": "http://baobab.keepeek.com/api/dam/thesauruses/1314"
}
},
"_embedded": {
"child": {
"id": 1346,
"title": "Londres",
"_links": {
"self": {
"href": "http://baobab.keepeek.com/api/dam/thesaurus-tree/1314/children/1346"
},
"kpk:thesaurus": {
"href": "http://baobab.keepeek.com/api/dam/thesauruses/1346"
}
}
}
},
"childrenCount": 1
}
Possible errors are :
-
404
(api-thesaurus-id-not-found) : Thesaurus not found
Create thesaurus
To create a thesaurus term:
POST /api/dam/thesaurus-tree/{id}/children
{
"nodes": [
{
"title": [
{
"lang": "FR",
"value": "Anvers"
},
{
"lang": "EN",
"value": "Anvers"
}
],
"description": [
{
"lang": "FR",
"value": "descriptionFrench"
},
{
"lang": "EN",
"value": "descriptionEnglish"
}
],
"synonyms": [
[
{
"lang": "FR",
"value": "synonyme1"
},
{
"lang": "EN",
"value": "synonym1"
}
],
[
{
"lang": "FR",
"value": "synonyme2"
},
{
"lang": "EN",
"value": "synonym2"
}
]
],
"children": [
{
"title": [
{
"lang": "FR",
"value": "Centre"
},
{
"lang": "EN",
"value": "Center"
}
]
}
]
}
]
}
[...]
HTTP/1.1 201 CREATED
Content-Type: application/hal+json;charset=UTF-8;version=2
[...]
{
"nodes": [
{
"id": id1,
"title": [
{
"lang": "FR",
"value": "Anvers"
},
{
"lang": "EN",
"value": "Anvers"
}
],
"description": [
{
"lang": "FR",
"value": "descriptionFrench"
},
{
"lang": "EN",
"value": "descriptionEnglish"
}
],
"synonyms": [
[
{
"lang": "FR",
"value": "synonyme1"
},
{
"lang": "EN",
"value": "synonym1"
}
],
[
{
"lang": "FR",
"value": "synonyme2"
},
{
"lang": "EN",
"value": "synonym2"
}
]
],
"children": [
{
"id": id2,
"title": [
{
"lang": "FR",
"value": "Centre"
},
{
"lang": "EN",
"value": "Center"
}
],
"description": [],
"synonyms": [],
"children": [],
"_links": {
"self": {
"href": "http://baobab.keepeek.com/api/dam/thesaurus-tree/8000/children/8030/children/8031"
},
"kpk:thesaurus": {
"href": "http://baobab.keepeek.com/api/dam/thesauruses/8031"
}
}
}
],
"_links": {
"self": {
"href": "http://baobab.keepeek.com/api/dam/thesaurus-tree/8000/children/8030"
},
"kpk:thesaurus": {
"href": "http://baobab.keepeek.com/api/dam/thesauruses/8030"
}
}
}
]
}
Possible errors are:
-
400
(api-thesaurus-descriptions-languages-null) : At least one language is not set in the descriptions -
400
(api-thesaurus-descriptions-language-empty) : At least one descriptions language is empty -
400
(api-thesaurus-descriptions-values-null) : At least one value is not set in the descriptions -
400
(api-thesaurus-descriptions-languages-not-in-locales) : At least one language in the descriptions is not in the locales -
400
(api-thesaurus-descriptions-null) : The description is null -
400
(api-thesaurus-synonyms-empty) : At least one synonym is empty -
400
(api-thesaurus-synonyms-value-null) : At least one synonym does not have a value -
400
(api-thesaurus-synonyms-languages-null) : At least one synonym does not have a language -
400
(api-thesaurus-synonyms-null) : At least one synonym is null -
400
(api-thesaurus-synonyms-languages-empty) : At least one language synonym is empty -
400
(api-thesaurus-synonyms-languages-not-in-locales) : At least one language in the synonyms is not in the locales -
400
(invalid-paylod-nothing-to-create) : Provided payload is invalid -
400
(invalid-body) : Provided payload is invalid -
400
(invalid-nodes-locale") : tree node list does not have a valid value for each locale -
400
(thesaurus-must-be-in-meta-field-for-creation) : Thesaurus must be associated with a meta field -
400
(api-thesaurus-title-not-set) : The title is not set -
400
(api-thesaurus-titles-languages-not-set) : At least one language title is not set -
400
(api-thesaurus-title-values-null) : At least one value title is not set -
400
(api-thesaurus-title-null) : The title is set to null -
400
(api-thesaurus-title-languages-null) : At least one language is null -
400
(api-thesaurus-title-language-empty) : At least one language title is empty -
400
(api-thesaurus-title-value-empty) : At least one value title is empty -
400
(api-thesaurus-title-languages-not-all-set) : You did not specified all the languages for the titles -
400
(api-thesaurus-maximum-depth) : Maximum depth of thesaurus is 25 -
400
(api-thesaurus-maximum-node) : Maximum number of node per create -
403
(operation-not-allowed) : User can not perform action -
404
(thesaurus-not-found) : Parent node does not exists -
500
(parent-thesauruses-not-found) : No parent found -
500
(parent-thesaurus-id-not-found) : id of the parent not found -
500
(root-thesaurus-id-not-found) : The root thesaurus id is not found -
500
(root-thesaurus-node-not-found) : The node root is not found -
500
(thesaurus-node-not-found) : Thesaurus node not found -
500
(thesaurus-internal-server-error) : server error
Delete thesaurus
You can delete a thesaurus term by using the verb DELETE, it will delete the term and recursively its children. You need to specify the id of the thesaurus in the uri (it takes the last id), the id need to not be a root term.
DELETE api/dam/thesauruses/{thesaurusTreeId}
DELETE api/dam/thesauruses/{thesaurusTreeId}/children/{thesaurusTreeId2}
Possible errors are:
-
400
(api-thesaurus-delete-root-forbidden) : You can not delete a thesaurus root term -
403
(operation-not-allowed) : User is not allowed to delete a thesaurus
4.0.1+
thesauruses
This relation targets the flat collection of thesauruses related to the current resource.
- dam --> thesauruses: all the declared thesaurus entries in the DAM instance
The targeted resource is provided for traversability purpose.
For each thesaurus entry, a representation is embedded as a thesaurus
Get thesauruses
GET /api/dam/thesauruses/
[...]
HTTP/1.1 200 OK
Content-Type: application/hal+json;charset=UTF-8;version=2
[...]
{
"_links": {
"self": {
"href": "http://baseUri/api/dam/thesauruses?page=1&size=20"
},
"curies": [
{
"name": "kpk",
"href": "http://baseUri/api/doc/rels/{rel}",
"templated": true
}
],
"next": {
"href": "http://baseUri/api/dam/thesauruses?page=2&size=20"
},
"last": {
"href": "http://baseUri/api/dam/thesauruses?page=64&size=20"
}
},
"_embedded": {
"thesaurus": [
{
"id": 634,
"title": "activité",
"_links": {
"self": {
"href": "http://baseUri/api/dam/thesauruses/634"
}
}
},
[...]
{
"id": 635,
"title": "action",
"_links": {
"self": {
"href": "http://baseUri/api/dam/thesauruses/635"
}
}
}
]
},
"totalCount": 1263
}
Update thesaurus
You can update a thesaurus term by using the verb PUT.
You need to specify the id of the thesaurus in the uri (it takes the last id), in the body you can specify:
- The title in all the languages (an error will be thrown if all the languages are not set)
- The description
- The synonyms
PUT /api/dam/thesauruses/{thesaurusTreeId}
[...]
HTTP/1.1 204 No Content
[...]
{
"title" : [
{"lang": "FR", "value": "nom"},
{"lang": "EN", "value": "name"}
],
"description" : [
{"lang": "FR", "value": "description"},
{"lang": "EN", "value": "description"}
],
"synonyms" : [
[
{"lang": "FR", "value": "synonyme1"},
{"lang": "EN", "value": "synonym1"}
],
[
{"lang": "FR", "value": "synonyme2"},
{"lang": "EN", "value": "synonym2"}
]
]
}
PUT /api/dam/thesauruses/{thesaurusTreeId}/children/{thesaurusTreeId2}
[...]
HTTP/1.1 204 No Content
[...]
{
"title" : [
{"lang": "FR", "value": "nom"},
{"lang": "EN", "value": "name"}
],
"description" : [
{"lang": "FR", "value": "description"},
{"lang": "EN", "value": "description"}
],
"synonyms" : [
[
{"lang": "FR", "value": "synonyme1"},
{"lang": "EN", "value": "synonym1"}
],
[
{"lang": "FR", "value": "synonyme2"},
{"lang": "EN", "value": "synonym2"}
]
]
}
Possible errors are:
-
400
(api-thesaurus-descriptions-languages-null) : At least one language is not set in the descriptions -
400
(api-thesaurus-descriptions-language-empty) : At least one descriptions language is empty -
400
(api-thesaurus-descriptions-values-null) : At least one value is not set in the descriptions -
400
(api-thesaurus-descriptions-languages-not-in-locales) : At least one language in the descriptions is not in the locales -
400
(api-thesaurus-descriptions-null) : The description is null -
400
(api-thesaurus-synonyms-empty) : At least one synonym is empty -
400
(api-thesaurus-synonyms-null) : At least one synonym is null -
400
(api-thesaurus-synonyms-value-null) : At least one synonym does not have a value -
400
(api-thesaurus-synonyms-languages-null) : At least one synonym does not have a language -
400
(api-thesaurus-synonyms-languages-not-in-locales) : At least one language in the synonyms is not in the locales -
400
(api-thesaurus-same-title-in-brothers) : Using the same title and languages of a term brother is forbidden -
400
(api-thesaurus-title-languages-null) : At least one language is null -
400
(api-thesaurus-title-not-set) : The title is not set -
400
(api-thesaurus-update-root-forbidden) : Update a thesaurus root term is forbidden -
400
(api-thesaurus-duplicates-lang) : You specified duplicates languages in one item -
400
(api-thesaurus-title-languages-not-all-set) : You did not specified all the languages for the titles -
400
(api-thesaurus-title-null) : The title is set to null -
400
(api-thesaurus-title-values-null) : At least one value title is not set -
400
(api-thesaurus-title-language-empty) : At least one language title is empty -
400
(api-thesaurus-title-value-empty) : At least one value title is empty -
400
(api-thesaurus-thesaurusapi-not-present) : No thesaurus specified to update -
403
(operation-not-allowed) : User is not allowed to update a thesaurus -
404
(api-thesaurus-id-not-found) : Requested thesaurus does not exists
4.0.0+
thesaurus
This relation targets the canonical representation of a thesaurus.
Get thesaurus
The parent path in thesaurus tree is returned in the representation in the parent
embedded property.
If you do not specify any header param or any query param, you will get the "version 1" of the representation. Meanwhile, you can get the "version n" (where n is 1 or 2) of the representation by :
- Add a QueryParam version with the value n
- Add a HeaderParam version witht the value application/hal+json;charset=UTF-8;version=n
GET /api/dam/thesauruses/{id}
application/hal+json;charset=UTF-8;version=1
[...]
HTTP/1.1 200 OK
Content-Type: application/hal+json;charset=UTF-8;version=1
[...]
{
"id": 8014,
"title": "nom",
"description": "description",
"synonyms": "synonyme2",
"_links": {
"self": {
"href": "http://baobab.keepeek.com/api/dam/thesauruses/8014"
},
"curies": [
{
"name": "kpk",
"href": "http://baseUri/api/doc/rels/{rel}",
"templated": true
}
],
"kpk:thesaurus-tree-node": {
"href": "http://baseUri/api/dam/thesaurus-tree/8000/children/8009/children/8014"
}
},
"_embedded": {
"parent": [
{
"title": "test5",
"_links": {
"self": {
"href": "http://baobab.keepeek.com/api/dam/thesauruses/8000"
}
}
},
{
"title": "tt",
"_links": {
"self": {
"href": "http://baobab.keepeek.com/api/dam/thesauruses/8009"
}
}
}
]
}
}
GET /api/dam/thesauruses/{id}?version=2
application/hal+json;charset=UTF-8
[...]
HTTP/1.1 200 OK
Content-Type: application/hal+json;charset=UTF-8;version=2
[...]
{
"id": 8014,
"title": [
{
"lang": "EN",
"value": "name"
},
{
"lang": "FR",
"value": "nom"
}
],
"description": [
{
"lang": "FR",
"value": "description"
},
{
"lang": "EN",
"value": "description"
}
],
"synonyms": [
[
{
"lang": "FR",
"value": "synonyme2"
},
{
"lang": "EN",
"value": "synonym2"
}
]
],
"_links": {
"self": {
"href": "http://baseUri/api/dam/thesauruses/8014?version=2"
},
"curies": [
{
"name": "kpk",
"href": "http://baseUri/api/doc/rels/{rel}",
"templated": true
}
],
"kpk:thesaurus-tree-node": {
"href": "http://baseUri/api/dam/thesaurus-tree/8000/children/8009/children/8014"
}
},
"_embedded": {
"parent": [
{
"title": "test5",
"_links": {
"self": {
"href": "http://baseUri/api/dam/thesauruses/8000?version=2"
}
}
},
{
"title": "tt",
"_links": {
"self": {
"href": "http://baseUri/api/dam/thesauruses/8009?version=2"
}
}
}
]
}
}
Possible errors are:
* `404` (api-thesaurus-id-not-found) : Requested thesaurus does not exists
* `400` (thesaurus-resource-version-different) : Version specified in the QueryParam and HeaderParam are different
* `400` (thesaurus-resource-version-incorrect) : You specified an non existent version of the representation
4.0.0+