Skip to end of metadata
Go to start of metadata

Before attempting the instructions mentioned in the tutorial please ensure to complete the following prerequisites. For more information on how to execute these prerequisites before server start-up, see Adding an Asset Type and Lifecycle Before Server Start-up.

  • Add the asset type named device to ES before server start-up.
  • Add a lifecycle named DeviceLifeCycle2.xml to ES before server start-up.
  • Attach the lifecycle named DeviceLifeCycle2 to the asset type named device before server start-up.

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:

  1. 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. 

  2. Add a parent installation script for the sample asset type
    1. 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 the install.js file, in the latter mentioned path. The install.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.
    2. Search and change the following tags appropriately in the copied script:

      • <ASSET_LIFECYCLE> : Lifecycle definition to which the asset type device 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 is device.

    3. Save and close the install.js file.

  3. 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:

  4.  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 is device.rxt the JSON file that defines the asset specific attributes need to be named as follows: device.json

    1. Add the device.json file into the <ES_HOME>/repository/deployment/server/jaggeryapps/publisher/samples/assets/devices/firealarm directory.

    2. 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.

    3. Define the paths to the latter mentioned images in the device.json file.

  5. Make the following additions in the publisher-tenant.json file, which is available in the <ES_HOME>/repository/deployment/server/jaggeryapps/publisher/config directory.

    1. Add the asset type, which is device, to the assets unit.

      "assets":["gadget","site", "device"],
    2. Add the plural name of the asset type, which is device, to the sub-unit collections, which is nested under the accessible 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"]
    3. Add a new type by the same plural-name of the asset type, which is devices, for sub-unit assetData, which is nested under the defaultAssets 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"
  6. 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 the overview_status attribute in the device.json file. In this tutorial, as we have set the lifecycle status to Published 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 the overview_name attribute both have the same value (e.g., RaspberryPi and Raspberry Pi will not work). The attribute referred to as name is the asset name and the overview_name is the value that is used when creating the resource path in the registry. 
  • No labels