Hands-On With GEL Scripting, Xog and The Rest Api
Hands-On With GEL Scripting, Xog and The Rest Api
Hands-On With GEL Scripting, Xog and The Rest Api
KRITIKA RANA
2015 - TODAY
About Me
Clarity PPM Consultant with experience in
implementations, support & Integrating PPM with other
systems.
XOG
REST APIs
GEL Scripting
XOG
Hands-on with GEL Scripting, XOG and the REST API
XML OPEN GATEWAY
Session Outline
01 Introduction
02 Working with XOG
03 Limitations
04 Best Practices
05 Hands On Exercise
XML OPEN GATEWAY
Session Outline
01 Introduction
02 Working with XOG
03 Limitations
04 Best Practices
05 Hands On Exercise
What is XOG?
Basic Information
• Client makes a
SOAP call to
Clarity Server ClientClient Request
Clarity
• Clarity Server Client Clarity
processes the Response
Server
Server
request
• Sends a SOAP
1. Installed Client
response back to 2. Browser XOG Client
the client 3. External Applications
4. Programming
Languages
Sample XOG Requests
Read Request
• Read request
gives us filters to
be used to get
the required
data.
Sample XOG Requests
Write Request
• Write request
provide us
with the
ability to
modify the
data in Clarity.
XML OPEN GATEWAY
Session Outline
01 Introduction
02 Working with XOG
03 Limitations
04 Best Practices
05 Hands On Exercise
Working with XOG
Multiple ways to use XOG
• Browser XOG
• Command Line XOG
• Using XOG commands
• Using Properties file
• From external applications
• Programming Languages
• GEL, JAVA, C# etc.
Browser XOG
Enabling browser XOG
• Navigate to the file path to
enable browser XOG
[Clarity-Home]\META-INF\xog\wmd
• Take a backup of existing
xog.xml file
• Amend xog.xml as in screen
shot
• Flush the caches using
security.caches or restart
services
• Then try :
http://server/niku/nu#action:xog.client
Browser XOG
Browser Window
• Navigate to the
Clarity_home\bin
folder.
• Type the required
XOG command.
• To see the command
usage, issue the
following
command:
• bin\xog -?
Command Line XOG
Using Properties File
• Modify the test.properties
file.
• Location:
Clarity_Home\xog-
unzipped\bin
• Another option is to make
your own .properties file
and store it in the bin
directory.
• At the XOG
prompt(Clarity_home\bin)
issue the following
command
• bin\xog -propertyfile
bin/test.properties
• View the output
Command Line XOG
Sample Properties File
Other ways to use XOG
External Applications and Programming Languages
01 Introduction
02 Working with XOG
03 Limitations
04 Best Practices
05 Hands On Exercise
Limitations
Data Deletion
01 Introduction
02 Working with XOG
03 Limitations
04 Best Practices
05 Hands On Exercise
Best Practices
• Keep XOG requests as small as possible,
• Many smaller requests will usually execute faster than one large request
• XOG-read only what is necessary
• Use Filters while querying data
• Remove unnecessary tags while XOG-write
• XOG is very powerful, Be absolutely sure on what you are updating in the
system.
Make sure to specify an external ID when defining project tasks. This provides a cleaner project XOG,
especially when dealing with assignments.
XML OPEN GATEWAY
Session Outline
01 Introduction
02 Working with XOG
03 Limitations
04 Best Practices
05 Hands On Exercise
Hands on Exercise
Summarize XOG
Let’s take a look back on XOG session
Introduction
What is XOG
Why XOG
How XOG works
Sample XOG Requests
Summarize XOG
Let’s take a look back on XOG session
Limitations
Data Deletion
Limited Granularity
Performance
Summarize XOG
Let’s take a look back on XOG session
Best Practices
Small requests
XOG-read only what is necessary
Remove unnecessary tags
Summarize XOG
Let’s take a look back on XOG session
05
01 Introduction 04
03
02 Working with REST APIs 02
01
03 Limitations
04 Best Practices
05 Hands On Exercise
REST APIs
Session Outline
01 Introduction 05
04
03
02 Working with REST APIs 02
01
03 Limitations
04 Best Practices
05 Hands On Exercise
What is API
Getting Started
The Rest API documentation URL for Clarity can be found in System options → API → API Documentation URL.
Why Rest APIs
What makes the Rest APIs so popular
• GET request is
the read request
for REST
Sample REST Requests
PATCH Request
05
01 Introduction 04
03
02 Working with REST APIs 02
01
03 Limitations
04 Best Practices
05 Hands On Exercise
Working with Rest APIS
Demonstrate Rest APIs
• Rest API URL is : https://lab1.pemari.com/niku/rest/describe/index.html
Working with Rest APIS
Steps
05
01 Introduction 04
03
02 Working with REST APIs 02
01
03 Limitations
04 Best Practices
05 Hands On Exercise
Limitations
• Stateless APIs increase the latency in request processing times and
bandwidth usage
• The reason is that the client is sending all messages with redundant information.
• Limited options for processing the requests
• Rest APIs use the HTTP methods for processing data.
• Typically, the protocol has a limited number of methods to operate upon the data.
• HTTP combines application-level and transport-level status codes
• e.g., 304 Not Modified and 400 Bad Request are the HTTP codes
• 407 Proxy Authentication Required and 502 Bad Gateway are transport level
status codes
• Broadcom has not made the REST APIs available yet for public
consumption.
REST APIs
Session Outline
05
01 Introduction 04
03
02 Working with REST APIs 02
01
03 Limitations
04 Best Practices
05 Hands On Exercise
Best Practices
Clean Request
REST APIs is planned to be available for customer use from the next release 15.6.1.
Best Practices
Error Handling
05
01 Introduction 04
03
02 Working with REST APIs 02
01
03 Limitations
04 Best Practices
05 Hands On Exercise
Hands on Exercise
Practice makes a man perfect
Summarize REST
Let’s take a look back on Rest APIs session
Introduction
What is API
What are Rest APIs
Why Rest APIs
How Rest API Works
Sample Rest Requests
Summarize REST
Let’s take a look back on Rest APIs session
Limitations
Latency
Very Few Verbs
Combined Codes are confusing
Unavailability for Public Consumption
Summarize REST
Let’s take a look back on Rest APIs session
Best Practices
Clean Request
Error Handling
Overriding Methods
Summarize REST
Let’s take a look back on Rest APIs session
Introduction
What is API
Best Practices
What are Rest APIs
Clean Request
Why Rest APIs
Error Handling
How Rest API Works
Overriding Methods
Sample Rest Requests
01 Introduction
02 GEL Script Structure 08
03 Operations 07
06
04 XML Manipulation
05
05 Exception Handling
04
06 Limitations 03
07 Best Practices 02
01
08 Hands On Exercise
GEL Scripting
Session Outline
01 Introduction
02 GEL Script Structure 08
03 Operations 07
06
04 XML Manipulation
05
05 Exception Handling
04
06 Limitations 03
07 Best Practices 02
01
08 Hands On Exercise
What is GEL
Getting Started
• Generic Execution Language
• Can be used to turn XML into executable code.
• It is based on Jelly, a jakarta.apache.org Commons project.
• extended and embedded into Clarity PPM
• GEL run-time is packaged with XOG in the XOG client
• Additional references and information can be found in the CA Documentation
(Developer Guide) – https://docops.ca.com/ca-ppm/15-6/en
• At the Apache Jelly website at - http://jakarta.apache.org/commons/jelly/index.html
Capabilities of GEL
• GEL can be used in following areas
• Web services
• File system
• JDBC
• FTP
• email
GEL Scripting
Session Outline
01 Introduction
02 GEL Script Structure 08
03 Operations 07
06
04 XML Manipulation
05
05 Exception Handling
04
06 Limitations 03
07 Best Practices 02
01
08 Hands On Exercise
GEL Script Structure
• A typical GEL script
contains
• Header
• Namespaces
• Body/Code
• Tags
• Footer
GEL Script Structure
Header
• Inclusion of the
namespaces for any
library gives GEL the
ability to perform
operations defined in
that library.
• Many libraries are
contained as Clarity
OOTB libraries.
• Core
• GELTagLibrary
GEL Script Structure
Body/Code
• A GEL script is an
executable XML file
that is built from
qualified elements Regular Tag
bound to Java code
called tags.
• Every opening tag
contains its
corresponding closing
tag except for singular
tags.
Singular Tag
GEL Script Structure
Footer
• <gel:parameter>
• Allows values to be passed
into a GEL script from a
Clarity process.
• Inside the GEL script, a
parameter can be referred
as any other variable using
the ${variablename}
syntax.
The optional attribute secure="true" causes Clarity to hide the actual value in the user interface with
asterisks (*).
GEL Script Structure
Variables/Parameters
• <core:set>
• Used to set basic java
variables.
• ones those do not need to
be extracted from an XML
document.
• Refer to the variable using
the ${variablename}
syntax.
GEL Script Structure
Variables/Parameters
• <gel:set>
• Used when it is necessary to extract the value of the variable from an XML document.
• This tag differs from the <core:set> tag in that it takes a select attribute which in turn
requires an Xpath statement.
• If you are unfamiliar with XPath, think of it as a hierarchy mapping of the XML
document.
GEL Script Structure
Variables/Parameters
• <gel:persist>
• This tag allows you to set
variables with a scope that
extends beyond the
current script.
• There are three scopes:
• Process
• Instance
• Global
GEL Script Structure
Variables/Parameters
• <gel:parse>
• To create an XML document in memory.
• Used to generate an entire XML document, or specific nodes.
GEL Script Structure
Built-In Parameters
<core:forEach> <gel:forEach>
1. The core for-Each loop is used as a simple programming loop whereas the gel-for-each loop is a
special loop which is used to loop through tags inside a XML document.
2. In gel-For-each loop the select attribute contains the XPATH string as an input, which in-turn helps to
parse the XML document.
GEL Script Structure
Loop Tags
• <core:while>
• Similar to the while loop in other programming languages like JAVA, C, C++
GEL Script Structure
Conditional Tags
• <core:if>
• Similar to the if loop in
other programming
languages like JAVA, C,
C++
• <core:choose>
• Similar to the if-else loop
in other programming
languages like JAVA, C,
C++
GEL Script Structure
Conditional Tags
• <core:switch>
• Similar to the switch statement in other programming languages like JAVA, C, C++
GEL Scripting
Session Outline
01 Introduction
02 GEL Script Structure 08
03 Operations 07
06
04 XML Manipulation
05
05 Exception Handling
04
06 Limitations 03
07 Best Practices 02
01
08 Hands On Exercise
GEL Scripting
Various Operations
Logging Emails
Logging Emails
• <gel:setDataSource>
• Uses the connection
properties from Clarity
PPM’s properties (set in the
CSA)
• Var attribute is optional.
• If not specified and only one
datasource is set, then all
SQL calls will use that
• If a datasource variable is
set, it is required to
reference it in subsequent
tags.
Database Operations
Connect to DB
• <sql:setDataSource>
• To use any external
connection, by creating an
external connection entry in
the NSA
• Value of dbID is name of the
connection in NSA.
• To use the external database
connection; without having an
entry in NSA
Database Operations
Single Result Query
• Updates should be
done using the
transaction tag.
• This ensures that they
follow the all or none
update.
Database Operations
Binding Variables
Logging Emails
• <gel:log> tag is used to add logs in the process and to create the log data
in the log tables.
• Logs prove to be useful in debugging and troubleshooting
• Different levels of logging are:
• Info
• Warn
• Error
Logging
• Info
• Warning
• Error
GEL Scripting
Various Operations
Logging Emails
• Core library defines the JAVA methods that can be used inside GEL.
• Not all the JAVA methods are available inside the library.
JAVA Operations
Basic Methods
• <core:new>
• It is used to instantiate Java classes
JAVA Operations
Basic Methods
• <core:invoke>
• It is used to call a method on an instantiated object
JAVA Operations
Basic Methods
• <core:expr>
• It is used to call a method on an instantiated Java object where the access to the
result of the operation is not required.
JAVA Operations
Basic Methods
• <core:invokeStatic>
• It is used to call a static method of a Java class
JAVA Operations
Usage of JAVA in GEL
Logging Emails
• There are various operations that GEL can perform for handling files
• GEL can open a file
• read the file
• parse out all the nodes and attributes
• write to the file
• It can also perform FTP operations on files.
• Following are not allowed
• It cannot create a directory
• Move files around
• Delete files
• Following are the sample FTP read & write code blocks
Read Operation Write Operation
GEL Scripting
Various Operations
Logging Emails
Make Sure to choose the right type as per your requirement of content in the email being sent.
File Operations
FTP
Logging Emails
• SOAP & REST calls can be used to read and write the data in Clarity PPM.
• SOAP calls are generally done by XOG
• REST calls are performed by the REST APIs given by Clarity PPM
SOAP in GEL
Namespaces required for SOAP Call
SOAP Body
SOAP in GEL
Steps
• Steps:
SOAP Message : XML Document
• Login & Authenticate
SOAP Envelope
• Form & Send the Request
• Process the output
• Log out
SOAP Body
SOAP in GEL
Login & Authenticate using Session ID
SOAP Envelope
SOAP Body
SOAP in GEL
Form the request
SOAP Envelope
SOAP Body
SOAP in GEL
Processing the Response
SOAP Envelope
SOAP in GEL
Logging out
SOAP Envelope
REST in GEL
Using REST in GEL
SOAP Envelope
REST in GEL
Connect
SOAP Envelope
REST in GEL
Set Headers
SOAP Envelope
REST in GEL
Sample Request
SOAP Envelope
REST in GEL
Send the request
SOAP Envelope
REST in GEL
Process the output
01 Introduction
02 GEL Script Structure 08
03 Operations 07
06
04 XML Manipulation
05
05 Exception Handling
04
06 Limitations 03
07 Best Practices 02
01
08 Hands On Exercise
XML Manipulation
Different ways of Manipulating XML
• Delete a Node
XML Manipulation
Manipulating the Attributes
01 Introduction
02 GEL Script Structure 08
03 Operations 07
06
04 XML Manipulation
05
05 Exception Handling
04
06 Limitations 03
07 Best Practices 02
01
08 Hands On Exercise
Exception/Error Handling
Catch & Rectify the Exceptions/Errors
1. The exception handling of GEL is only meant for handling programming exceptions but if there
is an error in your script which is a parsing error then that will not be caught by Catch tag.
2. For example if you use symbols like ‘>’ ‘<’ or ‘&’ in your script which will cause parsing error ,
then these are these are not caught by catch tag.
REST APIs
Session Outline
01 Introduction
02 GEL Script Structure 08
03 Operations 07
06
04 XML Manipulation
05
05 Exception Handling
04
06 Limitations 03
07 Best Practices 02
01
08 Hands On Exercise
Limitations
Limited Functionality
01 Introduction
02 GEL Script Structure 08
03 Operations 07
06
04 XML Manipulation
05
05 Exception Handling
04
06 Limitations 03
07 Best Practices 02
01
08 Hands On Exercise
Best Practices
Syntax Related Practices
• Always make sure to use the proper name spaces and aliases
• Properly indent and format your script, which makes it readable
Best Practices
Avoid Impacting Business
01 Introduction
02 GEL Script Structure 08
03 Operations 07
06
04 XML Manipulation
05
05 Exception Handling
04
06 Limitations 03
07 Best Practices 02
01
08 Hands On Exercise
Hands on Exercise
Practice makes a man perfect
Summarize GEL Scripting
Introduction
What is GEL
Capabilities of GEL
Summarize GEL Scripting
• Introduction
What is GEL
Capabilities of GEL
• GEL Script
Structure
• Most Common &
WorkFlow Tags
Summarize GEL Scripting
• Introduction
• Operations
What is GEL
• DB Operations
Capabilities of GEL
• Logging
• JAVA Operations
• File Operations
• GEL Script • Emails
Structure • SOAP & REST in
• Most Common & GEL
WorkFlow Tags
Summarize GEL Scripting
• XML
• Introduction Manipulation
• Operations
What is GEL
• DB Operations
Capabilities of GEL
• Logging
• JAVA Operations
• File Operations
• GEL Script • Emails
Structure • SOAP & REST in
• Most Common & GEL
WorkFlow Tags
Summarize GEL Scripting
• XML
• Introduction Manipulation
• Operations
What is GEL
• DB Operations
Capabilities of GEL
• Logging
• JAVA Operations
• File Operations Exception
• GEL Script • Emails Handling
Structure • SOAP & REST in
• Most Common & GEL
WorkFlow Tags
Summarize GEL Scripting
• XML
• Introduction Manipulation
• Operations
What is GEL
• DB Operations
Capabilities of GEL
• Logging
• JAVA Operations Limitations
• File Operations Exception
• GEL Script • Emails Handling
Structure • SOAP & REST in
• Most Common & GEL
WorkFlow Tags
Summarize GEL Scripting
• XML
• Introduction Manipulation
• Operations
What is GEL
• DB Operations
Capabilities of GEL
• Logging
• JAVA Operations Limitations
• File Operations Exception
• GEL Script • Emails Handling Best
Structure • SOAP & REST in Practices
• Most Common & GEL
WorkFlow Tags
Questions?
Hands-on with GEL Scripting, XOG and the REST API
Thank you for attending
Hands-on with GEL Scripting, XOG and the REST API
Phone
+44 844 736 2500
Email
ppmacademy@pemari.com Let us know how we can
improve!
Don’t forget to fill out the
Website feedback forms!
www.pemari.com
References
Hands-on with GEL Scripting, XOG and the REST API
• https://supportcontent.ca.com/
• http://www.gelscripting.com
• https://www.restapitutorial.com/