How to leverage the sample API Plug-ins for use as a template.

book

Article ID: 39757

calendar_today

Updated On:

Products

CA Service Catalog CA Service Management - Asset Portfolio Management CA Service Management - Service Desk Manager

Issue/Introduction

Question:

How to copy, modify and compile/package the sample API Plugins for use as a template?

 

Answer: 

 

Prerequisite: Please refer to TEC1876136 for the steps to install Apache Ant which we will use to compile and package the plug-in.

 

1) Extract the contents of ..\Service Catalog\filestore\plugins\ca.catalog.samples.select-plugin

to:

..\Service Catalog\filestore\plugins\ca.catalog.custom.select-plugin

 

2) Rename ..\Service Catalog\filestore\plugins\ca.catalog.custom.select-plugin\select.sample-src

to:

..\Service Catalog\filestore\plugins\ca.catalog.custom.select-plugin\select.custom-src

 

3) Rename ..\Service Catalog\filestore\plugins\ca.catalog.custom.select-plugin\select.sample-src\src\java\com\ca\usm\plugins\samples

to:

Service Catalog\filestore\plugins\ca.catalog.custom.select-plugin\select.sample-src\src\java\com\ca\usm\plugins\custom

 

4) Rename ..\Service Catalog\filestore\plugins\ca.catalog.custom.select-plugin\select.sample-src\src\java\com\ca\usm\plugins\custom\select\SampleSelectPlugin.java

to:

CustomSelectPlugin.java

 

5) Edit ..\Service Catalog\filestore\plugins\ca.catalog.custom.select-plugin\select.sample-src\src\java\com\ca\usm\plugins\custom\select\CustomSelectPlugin.java:

      a) Update the package reference on line 1 to reflect the change made in step 3 above:

package com.ca.usm.plugins.samples.select;

to:

package com.ca.usm.plugins.custom.select;

 

    b) Update the class reference on line 14 to reflect the change made in step 4 above:

public class SampleSelectPlugin implements FDSelectDataProvider {

to:

public class CustomSelectPlugin implements FDSelectDataProvider {

 

     c) Update the class reference on line 23:

this.log = this.context.getLogger(SampleSelectPlugin.class);

to:

this.log = this.context.getLogger(CustomSelectPlugin.class);

 

     d) Save your changes

 

6) Update ..\Service Catalog\filestore\plugins\ca.catalog.custom.select-plugin\select.custom-src\plugin.properties to reference the correct class and id similar to the following:

 

plugin_class=com.ca.usm.plugins.custom.select.CustomSelectPlugin

#make sure to change the id so it's unique for your plug-in 

id=ca.catalog.custom.select-plugin

classloader.type=private

 

name=Custom Select Plug-in

description=Custom implementation of a Select plug-in.

version=1.0

type=Form select field data provider

author=<insert name here>

 

7) From a command prompt change directory into select.custom-src (i.e. cd C:\Program Files\CA\Service Catalog\filestore\plugins\ca.catalog.custom.select-plugin\select.custom-src)

8) Run 'ant' as follows:

 

C:\Program Files\CA\Service Catalog\filestore\plugins\ca.catalog.custom.select-plugin\select.custom-src>ant

 

This will return the following upon successful compiling and packaging:

 

BUILD SUCCESSFUL

Total time: 1 secondinstalledPlugins.PNG

 

9) Copy ..\Program Files\CA\Service Catalog\filestore\plugins\ca.catalog.custom.select-plugin\select.custom-src\plugin.jar and plugin.properties

to:

..\Program Files\CA\Service Catalog\filestore\plugins\ca.catalog.custom.select-plugin

 

10) Login to the Catalog UI and navigate to Administration > Tools > Plug-ins

11) Select 'Reload Plugins' to activate the plugin and ensure it is displayed in the list of installed plugins:

<Please see attached file for image>

installedPlugins.PNG

 

12) Verify the plugin by entering the id (i.e. ca.catalog.custom.select-plugin) into the 'Report/Plug-in Id' parameter of a select field and ensure the dropdown is populated with the options from CustomSelectPlugin.java:

<Please see attached file for image>

verifyPlugin.PNG

 

Additional Information:

For additional information on using Catalog API Plug-ins please refer to the following:

https://docops.ca.com/ca-service-management/14-1/en/building/building-ca-service-catalog/use-api-plug-ins-to-load-data-into-policies-and-forms

Environment

Release: CASVCT99000-12.9-Service Catalog
Component:

Attachments

1558719726647000039757_sktwi1f5rjvs16vez.png get_app
1558719724591000039757_sktwi1f5rjvs16vey.png get_app