-
Notifications
You must be signed in to change notification settings - Fork 2
OpenContent Agent
The OC Agent Plugin is a easy way to communicate with an OpenContent. You communicate with the plugin using events on the namespace oc:
. There is prebuilt events to get search
, properties
and relations
, its also possible to send raw queries to OC via oc:raw.
Install Path
https://dashboard-plugins.s3.amazonaws.com/se-infomaker-ocagent/
The plugin needs to be configured in the plugin settings with an endpoint, username and password. The protocol and port should be included in the endpoint. When installed, activated and configured its ready to use from other plugins.
The plugins load in different order so if you want to start talking to OC directly the best practice is to use the ready
method on the dispatcher.
this.ready("se.infomaker.OCAgent", () => {
// Now the OC Agent is loaded and ready
})
To search in OC use the event name oc:search
this.send('oc:search', {
query: 'min sökfråga'
})
Attr | Type | Default | Description |
---|---|---|---|
query |
string | "" | The query to OC |
start |
int | 0 | Start index |
limit |
int | 20 | Number of items to retrieve |
parameters |
object | null | Custom parameters to be added to the URL, key/value object |
callback |
function | null | Callback on the request |
To get properties from an item in OC use the event name oc:properties
this.send('oc:properties', {
id 'o4k5jhbn43jh5b23po32kj4234jh2'
})
Attr | Type | Default | Description |
---|---|---|---|
id |
string | "" | The UUID of the item |
parameters |
object | null | Custom parameters to be added to the URL, key/value object |
callback |
function | null | Callback on the request |
To get relations to an item in OC use the event name oc:relations
this.send('oc:relations', {
id 'o4k5jhbn43jh5b23po32kj4234jh2'
})
Attr | Type | Default | Description |
---|---|---|---|
id |
string | "" | The UUID of the item for the relations |
parameters |
object | null | Custom parameters to be added to the URL, key/value object |
callback |
function | null | Callback on the request |
To send an raw query to OC use the event name oc:raw_query
this.send('oc:raw_query', {
id '/opencontent/search?start=0&limit=10&q=hello'
})
Attr | Type | Default | Description |
---|---|---|---|
endpoint |
string | "" | The endpoint in OC |
parameters |
object | null | Custom parameters to be added to the URL, key/value object |
callback |
function | null | Callback on the request |
To get the response of an query / request to open content is can be done in 3 ways.
All responses is dispatched with the event name oc:response
and a type is added to the userData.
this.on('oc:response', userData => {
console.log("Type", userData.type)
console.log("Response data", userData.data)
})
Responses is also sent out with a :response
suffix. For example oc:search:response
, oc:relations:response
this.on('oc:search:response', userData => {
console.log("Response data", userData.data)
})
All request events supports a callback to be added, this will run when the response is retrieved and called directly.
this.send('oc:search', {
query: 'hello',
start: 0,
limit: 10,
callback: data => {
console.log("Response from OC", data)
}
})