com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_link3' is unknown.

Using Registry Resources for Output Mapping

WSO2 DAS allows you to map custom content from registry for the XML, JSON and Text mapping  types. Custom mapping is stored as a registry resource to be used by the publisher instead of being specified as inline input. WSO2 DAS caches this resource at runtime, and the cache is updated after every cache timeout specified in minutes. If caching is not required, specify the cache timeout as 0.

The following tutorial illustrates how to carry out custom mapping using a registry resource.

  1. Save the following configuration as an XML file in a preferred location in your machine.

    <eventPublisher ... xmlns="http://wso2.org/carbon/eventpublisher">
      <from ... />
      <mapping customMapping="enable" type="text">
        <registry cacheTimeoutDuration="15">conf:/templates/en/message</registry>
      </mapping>
      <to ... />
    </eventPublisher>
  2. Log into the WSO2 DAS Management Console.
  3. Define an event stream as follows. For detailed instructions to create event streams, see Understanding Event Streams and Event Tables.

    1. Enter basic information for the stream as follows.

      ParameterValue
      Event Stream Namesensorsteam
      Event Stream Version1.0.0

      Add attributes as follows.

      Attribute CategoryAttribute NameAttribute Type
      Meta DatasensorIdint
       sensorNamestring
       languagestring
      Correlation Datalongitudedouble
       latitudedouble
      Payload DatasensorValuedouble
  4. Add the XML file you created as a registry resource as follows. For more information about the registry, see Registry.
    1. In the Main tab expand the Registry section and click Browse.
    2. Under Tree View, navigate to /_system/config directory and click Detail View. Click Add Collection. In the Name field, enter Template and click Add. This creates a new sub directory named Template in the /_system/config directory.
    3. Navigate to the /_system/config/Template sub directory and click Add Resource. Then enter information as shown in the table below, and click Add.

      FieldValue
      MethodUpload content from file
      FileBrowse and select the XML file you saved in step 1.
      NameCustomOutputMapping
      Media Typeapplication/xml
  5. Create a new publisher as follows. For more information, see Creating Alerts - Creating event publishers.

    FieldValue
    Event Publisher Namesamplelogger
    Event Sourcesensorstream
    Output Event Adapter Typelogger
  6. Under Mapping Configuration, select Text for the Message Format field. Then click Advanced. This expands the Create a New Event Publisher page to display the Text Mapping section. Select the Pick from Registry option. In the Registry Path field, navigate to the registry location where you saved the registry resource created in step 3.

    In this example, the default value of 15 is left unchanged for the Cache Timeout (in minutes) field. Therefore, this resource will be cached every 15 minutes.

  7. Click Add Event Publisher.
  8. In the Tools tab, click Event Simulator. In the Event Stream Name field, select sensorstream . Enter the following values for the parameters displayed, and then click Send to simulate a single event.

    ParameterValue
    sensorid10
    sensorNameTemperature
    languageen
    longitude79.861256
    latitude6.927131
    sensorValue23.0

     

    The output for this event is logged in the terminal as follows. 
     

Using custom registry paths

The registry resource path itself can be parameterized using runtime attribute values. e.g., If the event stream to which the logger publisher in the example above is connected has an attribute named meta_language, a different registry source is selected depending on the runtime value of the meta_language attribute.

The following tutorial illustrates how to change the registry resource path from which a custom output mapping is picked based on the value of an attribute.

The sensor stream event stream used in the previous tutorial is also used in this tutorial.

 

  1. Log into the DAS Management Console.

  2. Create two sub directories in the Template directory you created in the previous tutorial, and add a resource to each of these sub directories as described below. For more information about the registry, see Registry.
    1. In the Main tab expand the Registry section and click Browse.
    2. Under Tree View, navigate to the /_system/config/Template sub directory. Create two more sub directories in it named en and fr.
    3. Navigate to the /_system/config/Template/en sub directory and click Add Resource. Then enter information as shown in the table below, and click Add.

      FieldValue
      MethodCreate Text content
      Namemessage
      Media Typetext/plain
      Content
      Welcome to sensor data
      Sensor ID : {{meta_sensorId}}
      Sensor Name : {{meta_sensorName}}
      Sensor located at ({{correlation_longitude}}, {{correlation_latitude}})
      Value : {{sensorValue}}
      Humidity : {{humidity}}
    4. Navigate to the /_system/config/Template/fr sub directory and click Add Resource. Then enter information as shown in the table below, and click Add.

      FieldValue
      MethodCreate Text content
      Namemessage
      Media Typetext/plain
      Content
      Bienvenue to capteur données
      Sensor ID : {{meta_sensorId}}
      Sensor Name : {{meta_sensorName}}
      Sensor located at ({{correlation_longitude}}, {{correlation_latitude}})
      Value : {{sensorValue}}
      Humidity : {{humidity}}
    After adding both the resources, the registry tree view should look as follows.
  3. Delete the publisher named sample logger and redefine it as follows. For more information, see Creating Alerts - Creating event publishers.

    FieldValue
    Event Publisher Namesamplelogger
    Event Source

    sensorstream

    Output Event Adapter Typelogger

     

  4. Under Mapping Configuration, select Text for the Message Format field. Then click Advanced. This expands the Create a New Event Publisher page to display the Text Mapping section. Select the Pick from Registry option. Then enter information as follows.

    FieldValue
    Registry Pathconf:/templates/{{meta_language}}/message
    Cache Timeout (in minutes)15
  5. Log into the DAS Management Console.

  6. In the Tools tab, click Event Simulator. In the Event Stream Name field, select sensorstream. Send three events with the following values.

    ParameterValue for Event 1Value for Event 2Value for Event 3
    sensorid101010
    sensorNameTemperatureTemperature
    Temperature
    languageenfrru
    longitude79.861256 79.861256 79.861256
    latitude6.927131 6.927131 6.927131
    sensorValue23.0 23.0 23.0


    The three events are logged as follows. 
    Note that an error is returned for the third event. This is because no output mapping was done for the ru language.

com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.