WSO2 Governance Registry Adding Custom Artifacts

Published by: 7

WSO2 governance registry is the SOA (Service Oriented Architecture) governance model of the wso2 product catalogue.  If you are an enterprise that has a lot of SOA artifacts to be stored or governed, you might find wso2 GREG as a handy tool. GReg provides SOA artifacts manipulation in two aspects – as a meta data repository and a governing software.

Out of the box it supports following artifact types to be stored.

  • SOAP services
  • REST services
  • WSDL
  • WADL
  • Policies
  • Schemas
  • Swaggers

(WSDL, WADL, Policy and Schemas are also known as content type artifacts.)

SOA governance might run beyond the limits of known ready to go artifacts. i.e: Different stages of SOA governance probably need more types of artifacts to be maintained. planning governance stage will probably ask you to store profiles of different supplements and then move them through different life cycle stages. Development artifacts probably run beyond the known descriptive models. But fret not, answer is just a tab ahead in GReg.

Governance registry supports extension of artifacts, life cycles and handlers. This post will describe how to use artifacts extension model of GReg to store more artifacts.

Customizing an existing artifact type

Registry extensions are defined in a file that has the extension .rxt (registry extension). You can edit the rxt file as you wish at Extension tab of management console.

i.e.: Adding another text area named “Department” to REST services.
Selection_013
  • Browse the Rest services RXT from Management console. (Extensions > Configure > RXT types)
  • Select View/Edit for Rest Services.
  • Add following after the version field and save the RXT.

[xml]

<field type="text-area" required="false">
<name>Department</name>
</field></div>
<div>  [/xml]

  • You will see the custom field when you add a new REST service next time and on asset overview page of existing rest service artifacts after version field.

Selection_014

  • To make the custom field visible on store you need to add it specifically on Store. (To make sure you make it visible for store users). Add following snippet to <GREG_HOME>/repository/deployment/server/jaggeryapps/store/extensions/app/greg-store-defaults/themes/store/partials/asset-attributes.hbs file after version.

[js]

{{#if this.attributes.overview_&lt;wbr /&gt;department}}
&lt;div class=&quot;col-lg-12 divrow&quot;&gt;
&lt;div class=&quot;col-lg-2&quot;&gt;{{t &quot;Department&quot;}}&lt;/div&gt;
&lt;div class=&quot;col-lg-10&quot;&gt;{{this.&lt;wbr /&gt;attributes.overview_&lt;wbr /&gt;department}}&lt;/div&gt;
&lt;/div&gt;
{{/if}}

[/js]

 

Selection_016

 

Adding a new artifact type

 

You might probably need to add different type of business governing artifacts considering the scenario. Suppose you need to add an newly arrived inventory to the GReg. (Well, you can use GReg as a inventory management software as well)

Move to Extensions -> Artifact Types of Carbon console and click on add new artifact.

Enter the following xml description for a new inventory.

[xml]

&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;artifactType type=&quot;application/vnd.wso2-inventory+xml&quot; shortName=&quot;inventory&quot; singularLabel=&quot;Inventory&quot; pluralLabel=&quot;Inventories&quot;
hasNamespace=&quot;false&quot; iconSet=&quot;10&quot;&gt;
&lt;storagePath&gt;/inventory/@{overview_supplier}/@{overview_item}/@{overview_date}&lt;/storagePath&gt;
&lt;nameAttribute&gt;overview_supplier&lt;/nameAttribute&gt;
&lt;ui&gt;
&lt;list&gt;
&lt;column name=&quot;Supplier&quot;&gt;
&lt;data type=&quot;path&quot; value=&quot;overview_supplier&quot; href=&quot;@{storagePath}&quot;/&gt;
&lt;/column&gt;
&lt;column name=&quot;Item&quot;&gt;
&lt;data type=&quot;path&quot; value=&quot;overview_item&quot; href=&quot;@{storagePath}&quot;/&gt;
&lt;/column&gt;
&lt;column name=&quot;Date&quot;&gt;
&lt;data type=&quot;path&quot; value=&quot;overview_date&quot; href=&quot;@{storagePath}&quot;/&gt;
&lt;/column&gt;
&lt;/list&gt;
&lt;/ui&gt;
&lt;content&gt;
&lt;table name=&quot;Overview&quot;&gt;
&lt;field type=&quot;text&quot; required=&quot;true&quot;&gt;
&lt;name&gt;Supplier&lt;/name&gt;
&lt;/field&gt;
&lt;field type=&quot;text&quot; required=&quot;true&quot; readonly=&quot;true&quot;&gt;
&lt;name&gt;Item&lt;/name&gt;
&lt;/field&gt;
&lt;field type=&quot;date&quot; required=&quot;true&quot; readonly=&quot;true&quot;&gt;
&lt;name&gt;Date&lt;/name&gt;
&lt;/field&gt;
&lt;field type=&quot;date&quot;&gt;
&lt;name&gt;Expire Date&lt;/name&gt;
&lt;/field&gt;
&lt;field type=&quot;options&quot;&gt;
&lt;name label=&quot;Category&quot;&gt;Category&lt;/name&gt;
&lt;values&gt;
&lt;value&gt;Manufacture&lt;/value&gt;
&lt;value&gt;Trading&lt;/value&gt;
&lt;value&gt;Services&lt;/value&gt;
&lt;/values&gt;
&lt;/field&gt;
&lt;field type=&quot;text&quot;&gt;
&lt;name&gt;Inventory Location&lt;/name&gt;
&lt;/field&gt;
&lt;field type=&quot;text-area&quot;&gt;
&lt;name&gt;Description&lt;/name&gt;
&lt;/field&gt;
&lt;/table&gt;
&lt;table name=&quot;Images&quot;&gt;
&lt;field type=&quot;text&quot;&gt;
&lt;name&gt;Thumbnail&lt;/name&gt;
&lt;/field&gt;
&lt;field type=&quot;text&quot;&gt;
&lt;name&gt;Banner&lt;/name&gt;
&lt;/field&gt;
&lt;/table&gt;
&lt;/content&gt;

&lt;/artifactType&gt;

[/xml]

 

Then save the artifact descriptor and go to the Governnace Publisher URL. (https://localhost:9443/publisher)

Log in as the carbon user admin (user:admin, pw:admin) and see if our newly added inventory asset type is available. Now you are ready to add new inventory to the repository.

 

Selection_017

 

Add new asset and view it on Governance Store. (https://localhost:9443/store)

Selection_018

Please note that you have to make the custom fields available by modifying <GREG_HOME>/repository/deployment/server/jaggeryapps/store/extensions/app/greg-store-defaults/themes/store/partials/asset-attributes.hbs file.

 

Cheers!