Follow the instructions below to add a new sample asset for the asset type device, which is defined in the device.rxt
, at server startup:
Create a folder by the plural-name of the asset type (RXT), which is devices, in the Publisher sample artifacts
<ES_HOME>/repository/deployment/server/jaggeryapps/publisher/samples/assets
directory, where sample artifacts for each asset type are available in ES.- Add a parent installation script for the sample asset type
- Copy the asset specific
install.js
into the<ES_HOME>/repository/deployment/server/jaggeryapps/publisher/samples/assets/devices
directory.
Each sample contains a parent installation script, which is defined in theinstall.js
file, in the latter mentioned path. Theinstall.js
scripts found within sub-folders (e.g., devices, gadgets and sites) of this path will override the default parent script to perform any specific operations relevant to that asset type. Search and change the following tags appropriately in the copied script:
<ASSET_LIFECYCLE>
: Lifecycle definition to which the asset typedevice
is attached to, which is SampleLifeCycle2.
Note that the lifecycle should be one of the lifecycle definitions found inside the<ES_HOME>/repository/deployment/server/jaggeryapps/publisher/extensions/lifecycles
directory.<ASSET_RXT_NAME>
: The RXT name of the asset type for which the samples are made, which isdevice
.
Save and close the
install.js
file.
- Copy the asset specific
Create a folder by the name of the sample artifact, which is
firealarm
, inside the<ES_HOME>/repository/deployment/server/jaggeryapps/publisher/samples/assets/devices
directory, which is the asset specific parent directory.You can continue by adding any number of folders per sample artifact of the asset type (e.g., firearm, raspberryPi, arduino etc.). Artifact specific details go into these folders.The folder structure at the
<ES_HOME>/repository/deployment/server/jaggeryapps/publisher/samples
directory should look as follows:Define the asset specific attributes that need to be used when creating the sample
firealarm
artifact.You need to define the latter mentioned asset specific attributes in a JSON file, which has the same name as the asset type RXT (e.g.,
RXT_NAME.json
). In this case as the RXT file name for the asset type named device isdevice.rxt
the JSON file that defines the asset specific attributes need to be named as follows:device.json
Add the
device.json
file into the<ES_HOME>/repository/deployment/server/jaggeryapps/publisher/samples/assets/devices/firealarm
directory.Add any images used for the thumbnail and banner views of the sample artifact in the artifact specific directory, which is the
<ES_HOME>/repository/deployment/server/jaggeryapps/publisher/samples/assets/devices/firealarm
directory.Define the paths to the latter mentioned images in the
device.json
file.
Make the following additions in the
publisher-tenant.json
file, which is available in the<ES_HOME>/repository/deployment/server/jaggeryapps/publisher/config
directory.Add the asset type, which is
device
, to theassets
unit."assets":["gadget","site", "device"],
Add the plural name of the asset type, which is device, to the sub-unit
collections
, which is nested under theaccessible
unit."accessible": [{ "context": "/_system/governance", "collections": ["gadgets", "sites", "ebooks", "devices"], "actions": ["http://www.wso2.org/projects/registry/actions/get","http://www.wso2.org/projects/registry/actions/add", "http://www.wso2.org/projects/registry/actions/delete", "authorize"] }],
Add a new type by the same plural-name of the asset type, which is devices, for sub-unit
assetData
, which is nested under thedefaultAssets
unit."defaultAssets": { "root": "/samples/assets", "assetData": [{ "type": "gadgets", "ignore": ["agricultural-land", "intro-gadget-1", "intro-gadget-2", "gadget-template-explorer", "gadget-explorer", "co2-emission", "electric-power", "energy-use", "greenhouse-gas"] }, { "type": "ebooks" }, { "type": "sites" }, { "type": "devices" }] },
Restart the ES server.
The new sample artifact should get created for the specific asset type. This can be viewed via the Publisher. The artifact will be listed under the asset type in the Store according to the lifecycle state mentioned for theoverview_status
attribute in thedevice.json
file. In this tutorial, as we have set the lifecycle status toPublished
the artifact is visible in the Store.
The following are some useful tips that you need to keep in mind when working on the above tutorial:
- Be sure to add the lifecycle definition to the
<ES_HOME>/repository/deployment/server/jaggeryapps/publisher/extensions/lifecycles
directory. - Be sure to name the attributes (e.g.,
shortName,
singularLabel,
pluralLabel,
<storagePath>....</storagePath>
) appropriately in the asset type RXT file. - Be sure that the
name
attribute and theoverview_name
attribute both have the same value (e.g.,RaspberryPi
andRaspberry Pi
will not work). The attribute referred to asname
is the asset name and theoverview_name
is the value that is used when creating the resource path in the registry.