A resource element allows for the use of external objects as attributes in workflows created independently of vRealize Orchestrator. For example, items such as JSON templates. By importing the external object as a resource element allows for changes to the object and for those changes to be propagated to all workflows that use the resource elements.
When importing the external object as a resource element, the mime type is set from the content of the external object. In some instances, the mime type maybe incorrectly set during the initial import of the external object as a resource. So how do you we update this to be the correct type?
Unfortunately this is not available from vRealize Orchestrator UI, so for my use case I created a module action that will allow for the mime type to updated and set to the correct type. The module action requires for the resource element and the mime type to be specified as input parameters. For a valid list of mime types, refer to Basics of HTTP – Mime Types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|// Retrieves the resource element as a mime attachment from the specified input parameter (resourceElement).|
|var content = resourceElement.getContentAsMimeAttachment();|
|System.debug('The resource element ' + resourceElement.name + ' has been returned with the mime type ' + content.mimeType)|
|content.mimeType = mime;|
|// Sets the mime attachement to the type specifed from the input parameter (mime).|
|System.log('The resource element ' + resourceElement.name + ' mime type type has been set to ' + mime)|
In this instance I am going to run the workflow that executes the module action, to set an existing resource element that has been previously imported named ‘Test Resource Element.json’ which has the mime type set to ‘application/octect-stream’ to a mime type of ‘text/plain’.
Following successful execution of the workflow, we can confirm that the mime type of the resource element has now been updated to ‘text/plain’ as per the console log output from the mime type of the resource element.
[2017-09-13 17:19:21.130] [D] The resource element Test Resource Element.json has been returned with the mime type application/octet-stream
[2017-09-13 17:19:21.156] [I] The resource element Test Resource Element.json mime type type has been set to text/plain
The package which contains the module action and workflow item is available at com.deangrant.library.vro