Skip to content
This repository has been archived by the owner on Mar 25, 2020. It is now read-only.

OpenContent Agent

Johan Sundén edited this page Nov 6, 2017 · 8 revisions

⚠️ DEPRECATED ⚠️

Use LCC instead

OpenContent Agent Plugin

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.

Getting started

Installing

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.

Waiting for the OC Agent

The plugins load in different order so if you want to start talking to OC directly the best practice is to use the readymethod on the dispatcher.

this.ready("se.infomaker.OCAgent", () => {
    // Now the OC Agent is loaded and ready
})

Searching

To search in OC use the event name oc:search

Example

this.send('oc:search', {
	query: 'min sökfråga'
})

Parameters to oc:search

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

Properties

To get properties from an item in OC use the event name oc:properties

Example

this.send('oc:properties', {
	id 'o4k5jhbn43jh5b23po32kj4234jh2'
})

Parameters to oc:properties

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

Relations

To get relations to an item in OC use the event name oc:relations

Example

this.send('oc:relations', {
	id 'o4k5jhbn43jh5b23po32kj4234jh2'
})

Parameters to oc:relations

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

Raw query

To send an raw query to OC use the event name oc:raw_query

Example

this.send('oc:raw_query', {
	id '/opencontent/search?start=0&limit=10&q=hello'
})

Parameters to oc:raw_query

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

Getting the response

To get the response of an query / request to open content is can be done in 3 ways.

Alt 1: Global event

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)
})

Alt 2: Specified event

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)
})

Alt 3: Callback

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)
	}
})
Clone this wiki locally