In some Governance use cases where we want to selectively attach a lifecycle for an artifact based on some custom logic.
Currently we attach a lifecycle for an artifact using below methods.
- Configuring in RXT.
- Configuring in asset.js using the properties(ex: meta.lifecycle.name) explained in here
- This is inherited from ES
- Manually attach lifecycles from Management console
As of now we only have option 3. to cater this requirement of selectively attaching a lifecycle.
But we need to automate that.
We can do this in two ways.
- Incorporate a custom handler to intercept artifact put method.
- Override asset.js ‘attachLifecycle’ method via publisher's asset extension.
In this blogpost I will explain how to achive this using above method 2.Override asset.js ‘attachLifecycle’ method via publisher's asset extension
As a sample let’s consider ‘soapservice’ artifact type in Governance Center.
- Remove Lifecycle reference from the soapservice rxt.
i.e: remove <lifecycle>ServiceLifeCycle</lifecycle> from soapservice.rxt
- Override ‘attachLifecycle’ method in [GREG_HOME]/repository/deployment/server/jaggeryapps/publisher/extensions/assets/soapservice/asset.js asset.manager section.
asset.manager = function(ctx) {. . . . . . . . .. . . . . . . . . , postCreate:function(){ },attachLifecycle:function(asset, lifecycle){var lifecycle = “”;/* write your custom logic to populate lifecycle** asset object that comes into this method has all the content of the artifact instance** there for you can implement a custom logic based on values of artifact metadata as well */if (lifecycle == '') {return success;}try {this.am.attachLifecycle(lifecycle, asset);success = true;} catch (e) {//handle exception}return success;} } };. . . . .. . . . .
No comments:
Post a Comment