Name
global.PPTGenerationExtensionPointGlobal
Description
Content-Generation This is the entry point for get/post request through Custom Client. Warning Customers should not modify this file.
Script
var PPTGenerationExtensionPointGlobal = Class.create();
PPTGenerationExtensionPointGlobal.prototype = {
initialize: function(tableName, tableSysID) {
this.REST_ERROR = '-1';
this.CONFIGURATION_ERROR = '-2';
this.tableName = tableName;
this.tableSysID = tableSysID;
},
executeHttp: function(httpMethod, urlSuffix, operationType) {
var response = {};
var responseBody;
// validate http method type
if (!(httpMethod === 'post' || httpMethod === 'get')) {
return this.getReturnObject("HTTP method must be either post or get", this.REST_ERROR, true, urlSuffix);
}
if (!urlSuffix) {
return this.getReturnObject("Missing URL suffix in parameters", this.REST_ERROR, true, urlSuffix);
}
var clientUtil;
try {
clientUtil = new SNC.POIMain();
} catch (ex) {
return this.getReturnObject(ex.message, this.CONFIGURATION_ERROR, true, urlSuffix);
}
try {
if (httpMethod === 'get') {
clientUtil.getHttpRequest(urlSuffix, requestBody);
}
if (httpMethod === 'post' && operationType === "generate") {
clientUtil.generate(urlSuffix, this.tableName, this.tableSysID, this.dataString, this.stepString);
response = JSON.parse(clientUtil.getGenerateResponse(urlSuffix, this.outputTableName, this.outputRecordSysID, this.fileName));
} else if (httpMethod === 'post' && operationType === "parse") {
clientUtil.parse(urlSuffix, this.tableName, this.tableSysID);
response = JSON.parse(clientUtil.getParseResponse(urlSuffix));
}
responseBody = response["isError"] ? response["errorMessage"] : response["responseBody"];
} catch (ex) {
responseBody = ex.message;
response["statusCode"] = this.REST_ERROR;
response["isError"] = true;
}
return this.getReturnObject(responseBody, response["statusCode"], response["isError"], urlSuffix);
},
get: function(urlSuffix, params/*it should be a map={}*/) {
return this.executeHttp("get", urlSuffix, params);
},
post: function(urlSuffix, operationType) {
return this.executeHttp("post", urlSuffix, operationType);
},
initializeGenerateRequest: function(body) {
this.outputTableName = body["outputTableName"];
this.outputRecordSysID = body["outputRecordSysID"];
this.fileName = body["fileName"];
this.dataString = body["dataString"];
this.stepString = body["stepString"];
},
getReturnObject: function(responseBody, status, is_error, urlSuffix) {
return {
response_body: responseBody,
status_code: status,
is_error: is_error,
url_suffix: urlSuffix,
};
},
type: 'PPTGenerationExtensionPointGlobal'
};
Sys ID
814c1ffb53e20110b595ddeeff7b126c