Rest Interface Guide

Script execution

The script execution capabilities of the API allow application developers to execut Platform scripts and includes the following REST calls:

createScript

Function

Create a script.

Description

This request creates a new script with the given content and name at the platform server. In the script execution information it is mandatory to mention the trigger type and corresponding eventInfo or scheduleInfo depending upon the trigger type. Include the file in the request body or as file part.

Type

POST

URL Format

.../scripts/{scriptName}

Java API

Method Name

Class Name

createScript

com.quark.qpp.service.facade Class ScriptFacade

Parameters

Name

Type

Description

op=create

string

The op parameter allows you to specify which operation is to be performed. (Mandatory)This operation requires parent asset to be in a Checked-Out state.

language

long

The scripting language

scriptexecutioninfo =<xml/>

string

The set of attribute values. See "Request/Response parameter formats."

Returns

Returns an scriptInfo object containing metadata of the successfully created script.

Examples

URL:

http://serverName:serverPort/rest/service/scripts?op=create

Result:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<scriptInfo id="12">
    <name>abc.js</name>
    <language>javascript</language>
    <createdDate>2015-01-06T10:32:31Z</createdDate>
    <lastModified>2015-01-06T10:32:31Z</lastModified>
    <lastExecutionLog>NOT_RUN</lastExecutionLog>
    <creator id="1">Admin</creator>
    <lastModifiedBy id="1">Admin</lastModifiedBy>
    <scriptExecutionInfo triggerType="MANUAL"/>
</scriptInfo>

getScriptContent

Function

Get the content of a script.

Description

This request returns the content of the required script in text format.

Type

GET

URL Format

.../scripts/[script ID or name]

Java API

Method Name

Class Name

getScriptContent

com.quark.qpp.service.facade Class ScriptFacade

Parameters

This request requires no input parameters.

Returns

Returns the actual content of the required script in text format.

Examples

URL:

http://serverName:serverPort/rest/service/scripts/QppFunctions importPackage(Packages.com.quark.qpp.filetransfergateway.service); importPackage(Packages.java.io); importPackage(Packages.com.quark.qpp.core.asset.service.constants); importPackage(Packages.com.quark.qpp.core.query.service.dto); importPackage(Packages.com.quark.qpp.core.query.service.constants); importPackage(Packages.com.quark.qpp.core.content.service.constants); importPackage(com.quark.qpp.common.dto); importPackage(com.quark.qpp.common.constants); ........

Result:

The actual content of the required script in text format.

getAllScripts

Function

Get all scripts.

Description

This request returns all scripts stored at the platform server.

Type

GET

URL Format

.../scripts/

Java API

Method Name

Class Name

getAllScripts

com.quark.qpp.service.facade Class ScriptFacade

Parameters

This request requires no input parameters.

Returns

Returns a scriptInfoList object that contains the metadata of all scripts. See the table in the "Request/Response parameter formats" chapter.

Examples

URL:

http://serverName:serverPort/rest/service/scripts

Result:

<scriptInfoList>
    <scriptInfo id="11">
        <name>GetSavedSearchResults</name>
        <language>javascript</language>
        <createdDate>2015-01-06T10:23:37Z</createdDate>
        <lastModified>2015-01-06T10:23:37Z</lastModified>
        <lastExecutionLog>NOT_RUN</lastExecutionLog>
        <creator id="1">Admin</creator>
        <lastModifiedBy id="1">Admin</lastModifiedBy>
        <scriptExecutionInfo triggerType="MANUAL"/>
    </scriptInfo> ... </scriptInfoList>

executeScript

Function

Execute a script.

Description

This request executes a specified script that is already saved on the QPP Server.

Type

POST

URL Format

... /scripts/[script ID or name]

Java API

Method Name

Class Name

executeScript

com.quark.qpp.service.facade Class ScriptFacade

Parameters

Name

Type

Description

op=execute

string

The op parameter allows you to specify which operation is to be performed. (Mandatory) This operation executes the complete script.

Returns

The response depends upon the output of the script.

Examples

URL:

http://serverName:serverPort/rest/service/scripts/GetSavedSearchResults?op=execute

Result:

Total No Of Assets : 4 Name: Tulips Collection: Home Workflow: Workflow1 Status: Status1 Routed To: Admin Name: Duplicate_asset Collection: Home Workflow: Workflow1 Status: Status1 Routed To: Admin Name: 1quark2.jpg Collection: Home Workflow: Workflow1 Status: Status1 Routed To: Admin Name: 15116.qxp Collection: Home Workflow: Workflow1 Status: Status1 Routed To: Admin

Function

Execute a script method.

Description

This request executes a specified method of a specified script that is already saved on the QPP Server.

Type

POST

URL Format

.../scripts/[script ID or name]

Java API

Method Name

Class Name

executeScript

com.quark.qpp.service.facade Class ScriptFacade

Parameters

Name

Type

Description

op=execute&

string

The op parameter allows you to specify which operation is to be performed. (Mandatory)This operation executes given the method of the script along with the given parameters.

methodname=[method name]&

string

Specify the method name to be executed. (Mandatory)

parameters=x,y,z

long or string

Specify the method's parameters if required. (Optional)

Returns

The response depends upon the output of the script.

Examples

URL:

http://serverName:serverPort/rest/service/scripts/Sample?op=execute&methodname=abc

Result:

The response depends upon the output of the script.

deleteScript

Function

Delete a script.

Description

This request deletes the specified script.

Type

POST

URL Format

.../scripts/{scriptName}

Java API

Method Name

Class Name

deleteScript

com.quark.qpp.service.facade Class ScriptFacadeClass AssetFacade

Parameters

Name

Type

Description

op=delete

string

The op parameter allows you to specify which operation is to be performed. (Mandatory) This request will lock the asset internally and delete it from system.

Returns

A status of 200 is returned in response to a successful request execution.

Examples

URL:

http://serverName:serverPort/rest/service/scripts/12?op=delete