@doc>
A channel that provides a connection to a %PROD% server.
Instances of this class are created automatically by the system, and should
not be created directly.
(c) SAP AG 2003-2006. All rights reserved.
#INCLUDE[gml:defs.inc]
Class GkbChannel inherit BaseChannel;
static property userdata={};
static property MAX_TRANS=2000000;
///////////////////////////////////////////////////////////////////////
// GKB SERVICES
<@doc>
Copies an existing folder/model to another location
The urn of the folder/model to copy from
The urn of the folder/model to copy to
Returns ~true if the operation was successfull; otherwise, returns ~false
method copyFolder(from, to)
var response = this.executeService("LibManager", "actionCopyFolder", [from,to], null, null);
if (!response) return false;
return true;
end
<@doc>
Copies existing folders/models to another location
map of old:new urns
Returns a list of results for each model containing the original urn and the new urn or an error
method copyFolders(names)
var response = this.executeService("LibManager", "actionCopyFolders", [names], null, null);
return this.parseResponse(response);
end
<@doc>
Creates a new folder/model
The urn of the new folder/model
Indicates whether the model should be saved in the source control
Returns ~true if the operation was successfull; otherwise, returns ~false
method createFolder(urn, language, isSrcCtrlEnabled, softwareComp, develComp, activityDesc, dcPrefix, dcDomain , supportComponent)
if (!urn) return false;
if ((isSrcCtrlEnabled) &&
((!softwareComp) || (!develComp) || (!supportComponent) ))
return false;
var params=[];
params[0] = urn;
params[1] = isSrcCtrlEnabled || false;
params[2] = softwareComp || '';
params[3] = develComp || '';
params[4] = activityDesc || '';
params[5] = dcPrefix || '';
params[6] = language || 'en';
params[7] = dcDomain || '';
params[8] = supportComponent || '';
var response = this.executeService("LibManager", "actionCreateFolder", params, null, null);
if (!response) return false;
return response;
end
<@doc>
Fetches a specified list of files after preprocessing
A list of file urns to fetch
Returns an array of {urn, text} objects containing the fetched files in order
Use the @BaseChannel!error property to check for any errors
method fetchFiles(urnlist)
return this.fetchKit(urnlist);
end
<@doc>
Fetches a specified kit and returns all its files after preprocessing
The urn of the kit to fetch
Returns an array of {urn, text} objects containing the kit files in loading order
Use the @BaseChannel!error property to check for any errors
method fetchKit(urn)
var params=[(typeof urn == 'string' ? urn : JOIN(urn,';')),(typeof urn == 'string' ? "false" : "true")];
var response = this.executeService("LibManager", "fetchKit", params, null, null);
if (!response) return null;
var A = this.getKitFiles(response);
return A;
end
<@doc>
Fetches the content of requested kits.
If client cache is on the browser will attempt to take it from the cache, unless reinstall the kits was requested
If we can we'll send the kits list on the URL itself in one request to server.
If the list is too long then send the list in a different request to server
list of kits to fetch
production kit urn to be set on the URL (the URL is the cache key)
if reinstalling kit was requested - then make sure those kits are taken from server (and not cache)
call this function after the kits are retrieved
call this function in case of an error
method fetchKits(urnlist, productionKit, reinstalling, onsuccess, onfailure)
try {
var kitList = JOIN(urnlist,';'); //kits list parameter to be sent to server
var res = this.fetchKitsURL(kitList, productionKit, reinstalling);
var requestUrl = res.requestUrl;
var sendListToServer = res.sendListToServer;
var response;
//if kit list is too long to be sent in the URL, send the parameter to server and then perform a GET reuqest for fetching the kits
if(sendListToServer)
{
response = this.executeService("LibManager", "UpdateKitsList", [kitList, productionKit], null, null);
if(!response)
{
onfailure(response); //error occured in server
return;
}
}
this.executeServletAsync(null, null, null, onsuccess, onfailure, null, requestUrl, true);
} catch(e){
onfailure(null, e.description + " In GkbChannel.fetchKits");
}
end
<@doc scope="private">
the querystring on a URL has a limit of 1024 chars. If adding the kit list to the querystring does not extend 1024
then send the list via the GET request. o.w. send POST request for sending the kit list to server and then a regular GET request.
query string is built from fullUrl=Fetcher?ver=xxxxx , prod kit parameter and kit list parameter
list of kits to fetch
production kit urn to be set on the URL (the URL is the cache key)
if reinstalling kit was requested - then make sure those kits are taken from server (and not cache)
Return: an object with 2 parameters: the request URL and if there's a need to send the kits list to the server in different request
method fetchKitsURL(kitList, productionKit, reinstalling)
var fullUrl = '#SYS[FETCHER_URL]?prodKit=' + productionKit;
//if reinstall kits are requested then do not take it from cache
if(!reinstalling && BOOL(GETVAR('ClientCacheEnabled')))
fullUrl += escape(GETVAR('ClientCacheVersion'));
var kitsParam = '&kits=' + kitList; //querystring parameter name for kit list
var sendListToServer = false; //if sending the kits list to the server is needed in a different request
//check if the quesrystring is small enough to be sent in the URL of the GET request
if(fullUrl.length + kitsParam.length < #SYS[QUERY_STRING_LIMIT])
fullUrl += kitsParam;
else
sendListToServer = true;
return {requestUrl: fullUrl, sendListToServer: sendListToServer};
end
<@doc scope="private">
Gets the files of the given kit
method getKitFiles(kit)
var A=[], files=kit.selectNodes('FILE'), file;
var cdata1='<'+'!'+'['+'CDATA'+'[', cdata2=']'+']'+'>';
while (file = files.nextNode()) {
var urn = file.getAttribute('urn');
var err = file.getAttribute('error');
if (err) {
this.error += urn+' -> '+err+'\n';
} else {
var text=file.text || '';
text = text.replace(/(\<\!)?\[XDATA\[/g, cdata1);
text = text.replace(/\]XDATA\](\>)?/gm, cdata2);
A.push({urn:urn, text:text});
}
}
return A;
end
<@doc>
Gets the manifest of all kits installed on the library
The requested kits manifest XML
method getKitsManifestXML()
this.error = "";
if (!this.online) return null;
return this.executeService("LibManager", "actionKitsManifest", null, null, null);
end
<@doc>
Returns the manifest object
The requested kits manifest object
method getKitsManifest()
this.error = "";
if (!this.online) return null;
if (!this.manifest) {
var response = $ENV.kitsManifestXML;
if (response)
this.manifest = $ENV.createObject('env:KitsManifest', response);
}
return this.manifest;
end
<@doc>
Takes the result of processing the files in 'preCachedFiles' and sends it for storage
in the server cache
The type of cache to use for storing content
The urn of the current production kit
A list of urns of the files that were pre-processed, and
which should not be included in subsequent kit fetchings (by fetchKits())
The result of pre-processing the files that should be cached
The response of the save cache operation
method storeClientGeneratedCache(cacheType, productionKit, preCachedFiles, content)
if (!this.online) return null;
if (!cacheType || !content) return null;
var params=[];
params[0] = cacheType || '';
params[1] = productionKit || '';
params[2] = preCachedFiles || '';
params[3] = content || '';
var response = this.executeService("LibManager", "actionStoreClientGeneratedCache", params, null, null);
if (!response) return false;
// error from executeService is located in channel1.error (this), not always
return true;
end
<@doc>
Gets the sdk documentation contents for this library
The requested sdk contents
method getSdkContents()
if (!this.online) return null;
var response = this.executeService("LibManager", "actionSdkContents", null, null, null);
return response || null;
end
<@doc>
Saves the given user-data
Object containing name-value pairs for all parameters to be persisted
The response of the save operation
method saveUserData(paramMap)
if (!paramMap) return;
if (!this.online) return null;
var params = [{}];
for (var key in paramMap) {
params[0][key] = escape(paramMap[key]);
}
params[0]['_objectType'] = "HASHMAP";
var response = this.executeService("UserDataMgr", "saveUserdata", params, null, null);
if (response) {
this.userdata = paramMap;
}
return response || null;
end
<@doc>
Gets the user data map
Indicates whether the userdata should be retrieved
from the server, even if it was already retrieved
Returns a map of {key, value} containing the user-data
method getUserData(force)
if (!this.online) return null;
var userdataMap = this.userdata;
if ((!ISEMPTY(userdataMap)) && (!force))return userdataMap;
var response = this.executeService("UserDataMgr", "getUserdata", null, null, null);
if (!response)
{
WRITE(this.error);
return null;
}
var userdata=response.getAttribute('userdata');
if (userdata==null)
{
return null;
}
userdata=userdata.substring(1, userdata.length-1);
var map={};
while(userdata.length>0) {
index=userdata.indexOf(',');
entry=(index!=-1)? userdata.substring(0, index) : userdata;
var itemsSeparatorIndex=entry.indexOf('=');
var key=entry.substring(0,itemsSeparatorIndex);
var value=unescape(entry.substring(itemsSeparatorIndex+1, entry.length));
userdata=(index!=-1)? userdata.substring(index+2) : "";
map[key]=value;
}
this.setProperty('userdata', map); // update the userdata
return map;
end
method isJ2EE()
return this.protocol == 'j2ee/dev';
end
<@doc>
Resets the user-data
The reponse of the reset operation
method resetUserData()
if (!this.online) return null;
var response = this.executeService("UserDataMgr", "resetUserdata", null, null, null);
if (response)this.getUserData(true); // update the userdata
return response || null;
end
<@doc>
Enumerates all units under a specified model
The urn of the model to enumerate
Returns a sorted enumeration of the unit Ids
method listUnits(urn)
var response = this.executeService("LibManager", "actionListDiagrams", [urn], null, null);
if (!response) return [];
var items=response.childNodes, item, list=[];
while (item = items.nextNode) {
list.push(item.getAttribute('id'));
}
return list;
end
<@doc>
Enumerates all sub-folders/models under a specified folder
The urn of the parent folder
The type of items to enumerate
Indicates whether to retrieve information from NWDI server (true) or from cache (false) default=true
Returns a sorted enumeration of the requested items
method listFolders(parent, scope, refresh, onsuccess, onfailure)
var response = this.getFolders(parent, scope, refresh, onsuccess, onfailure);
return this.createFoldersList(response);
end
<@doc>
Public : creates list of folders
XML of the list
Returns a sorted enumeration of the requested items
method createFoldersList(response)
if (!response) return [];
var items=response.childNodes, item, folders=[], models=[];
while (item = items.nextNode) {
var obj = $ENV.createModelObj(item);
obj.type = item.nodeName;
// handle public parts
if (obj.type == 'PUBLIC') {
obj.icon = item.getAttribute('icon');
obj.classname = item.getAttribute('classname');
}
if (item.nodeName == 'MODEL') models.push(obj); else folders.push(obj);
}
if (parent != '') { // sort all but the local and DTR folders
SORT(folders, 'name');
}
SORT(models, 'name');
return folders.concat(models);
end
<@doc>
Enumerates all sub-folders/models under a specified folder
The urn of the parent folder
The type of items to enumerate
Indicates whether to retrieve information from NWDI server (true) or from cache (false) default=true
if to search models by name
required when searching a model in DTR: prefix
required when searching a model in DTR: vendor
required when searching a model in DTR: partial model name to search in given SC+prefix+vendor
method which will be called when the server returns results - only when search is done
method which will be called when there was a failue - only when search is done
method getFolders(parent, scope, refresh, onsuccess, onfailure)
var params=[];
params[0] = parent;
params[1] = PREF(scope||'M');
params[2] = (typeof refresh == 'undefined')?true:false;
var response = this.executeService("LibManager", "actionListFolders", params, onsuccess || null, onfailure || null);
return response;
end
method searchModels(parent, searchDTR)
var params=[];
params[0] = parent;
params[1] = searchDTR || "";
var response = this.executeService("LibManager", "actionSearchModels", params, null, null);
return response;
end
<@doc>
Moves existing folders/models to another location
map of old:new urns
Returns a list of results for each model containing the original urn and the new urn or an error
method moveFolders(names)
var response= this.executeService("LibManager", "actionMoveFolders", [names], null, null);
if (!response) return false;
response = this.parseResponse(response);
for (var i=0, len=response.length; i
Moves an existing folder/model to another location
The urn of the folder/model to move from
The urn of the folder/model to move to
Returns ~true if the operation was successfull; otherwise, returns ~false
method moveFolder(from, to)
var response = this.executeService("LibManager", "actionMoveFolder", [from,to], null, null);
if (!response) return false;
$ENV.updateModelsList(this.toModelHandle(from), this.toModelHandle(to));
return true;
end
<@doc>
Retrive from dev server the support info
The runtime url of the VC application
method getSupportInfo(applicationURL, api)
try {
var response = this.executeService("LibManager", "getSupportInfo", [applicationURL, api], null, null);
}
catch (e) {
alert(e.desctiption);
}
if (!response) return null;
return response;
end
<@doc>
Reads a specified file
The urn of the file to read
Indicates whether to return XML files as an XML object
Returns the file text
Use the @BaseChannel!error property to check for any errors
method readFile(urn, asXML)
return this.readFiles([urn], asXML)[0] || '';
end
<@doc>
Reads a specified list of files
A list of file urns to read
Indicates whether to return XML files as an XML object
Returns the list of files read, in corresponding order to the input urnlist
Use the @BaseChannel!error property to check for any errors
method readFiles(urnlist, asXML)
var files=new Array(urnlist.length);
var response = this.executeService("Reader", "actionReadFiles", [JOIN(urnlist,';')], null, null);
if (!response) return files;
var nodes=response.selectNodes('FILE'), node, i=0;
while (node = nodes.nextNode()) {
var urn = node.getAttribute('urn');
var err = node.getAttribute('error');
var mime = node.getAttribute('mime');
var text = (asXML ? null : '');
if (err) {
this.error += urn+' -> '+err+'\n';
} else if (mime == 'text/xml' && asXML) { //return XML object
//In case of asXML=false, we used to take node.firstChild.xml, but now we take node.text
//We take the text because it is double decoded. Since there is only one child, we can alternate between node.text and node.firstChild.xml.
//On the server, before sending files to the client, we must encode char sequences that harm XML parsing (security bug...).
//After we do this encoding (LibManager.java and Reader.java), DevServer does another 'round' of encoding such characters.
//So on the client we need to decode twice - the "text" is decoded twice, while the XML is decoded only once.
text = node.firstChild;
} else { // return text - this works because we take the text from the node that is the decoded version of the XML of the child
text = (node.text.replace(/\[XDATA\[/g, '[CDATA['));
}
files[i++] = text;
}
return files;
end
<@doc>
Removes an existing folder/model
The urn of the folder/model to remove
Returns ~true if the operation was successfull; otherwise, returns ~false
method removeFolder(urn)
if (!urn) return false;
$ENV.updateModelsList(this.toModelHandle(urn), null);
var response = this.executeService("LibManager", "actionRemoveFolder", [urn], null, null);
if (!response) return false;
return true;
end
<@doc>
Removes an array of existing folders/models
The urns of the folders/models to remove
Returns a list of results for each model containing the original urn and the new urn or an error
method removeFolders(urns)
if (!urns) return "";
var params = [];
var models=[];
for (var urnId in urns){
$ENV.updateModelsList(this.toModelHandle(urnId), null);
models.push(urnId);
}
params[0]=models;
var response = this.executeService("LibManager", "actionRemoveFolders", params, null, null);
if (!response) return false;
var items=response.childNodes, item, list=[];
while (item = items.nextNode) {
list.push({
urn: item.getAttribute('urn'),
error: item.getAttribute('error')
});
}
return list;
end
<@doc>
Searches for the units that meet the specified criteria in a given model
The urn of the model to search
Returns the list of units that were found
method searchUnits(urn, search, fulltext, samecase)
var params=[urn,(search||'*'),(fulltext ? "yes" : ''),(samecase ? "yes" : '')];
var response = this.executeService("LibManager", "actionSearchDiagram", params, null, null);
if (!response) return [];
var items=response.childNodes, item, list=[];
while (item = items.nextNode) {
list.push({
id: item.getAttribute('id'),
name: item.getAttribute('name'),
type: item.getAttribute('type')
});
}
return list;
end
<@doc>
Converts a bare file name to a full file urn for a given model
The model urn
The file name
Returns the full file urn
method toModelFile(modelUrn, filename)
return 'gkb:'+(modelUrn||'').replace(/.mdl$/i,'')+'.'+filename;
end
<@doc>
Converts the given model urn to a model handle, using the channel connection details
The model urn
The model's status
The requested model handle
method toModelHandle(modelUrn, modelStatus, isDTRModel, isCheckedOut, isSynced)
return $ENV.createObject('env:ModelInfo', modelUrn, null, modelStatus || null, null, isDTRModel, isCheckedOut, isSynced);
end
<@doc>
Writes a specified file
The file urn
The file text
Returns ~true if the operation was successfull; otherwise, returns ~false
Use the @BaseChannel!error property to check for any errors
method writeFile(urn, text)
var files={};
files[urn] = text||'';
this.writeFiles(files);
return !this.error;
end
<@doc>
Writes a specified list of files
A table of the files to write
does the model contains reusable units, when saving a whole model
Returns ~true if the operation was successfull; otherwise, returns ~false
Use the @BaseChannel!error property to check for any errors
method writeFiles(list, bReusablesModel)
//parse the files and split to chunks
var chunks = new Array()
var tmp = "";
for (var urn in list) {
var text = list[urn] || '';
if (typeof text != 'string') {
if (text.xml) text = text.xml; else text = text+'';
}
//text = text.replace(/\[CDATA\[/g, '[XDATA[');
//notice! Since the whole content will be wrapped with CDATA section in excecuteService,
//we cannot insert CDATA section here as well (XML doesn't allow nested CDATA),
//so we mark it with special tags - and
//these will be replaced to CDATA and ]]> in the server for reading the content inside FILE element
tmp = tmp + ''+text+'';
if (tmp.length>this.MAX_TRANS){
chunks.push(tmp);
tmp="";
}
}
// last chunk
if (tmp!="") chunks.push(tmp);
//send the chunks
var params=[];
params[0] = '';
for (var x = 0; x < chunks.length; x++)
{
params[0] = params[0]+chunks[x];
if (x==chunks.length-1) params[0] = params[0]+'';
params[1] = (!bReusablesModel? false: true);
params[2] = x+1;
PROGRESS('Sending data: chunk '+ (x+1)+'/'+chunks.length, 60+((40/chunks.length)*(x+1)), 'Saving Model');
var response = this.executeService("Writer", "actionWriteFiles", params, null, null);
params[0]="";
if (!response) return false;
}
PROGRESS('Save Completed', 100, 'Saving Model');
PROGRESS();
return true;
end
<@doc>
Returns checkout details of the given model. Call this function in case that the model is checked out in another server (not current) by this user
The urn of the development component to get its details
Returns checkout details
method getCheckoutDetails(urn)
if (!urn) return false;
var response = this.executeService("LibManager", "actionGetCheckoutDetails", [urn], null, null);
if (!response) return false;
var details = {};
details.serverId = response.getAttribute('serverId') || "";
details.clusterId = response.getAttribute('clusterId') || "";
return details;
end
////////////////DTR OPERATIONS ///////////////////////////////////
//////////////////////// CHECK OUT
<@doc>
Checkes out the given development component
The urn of the development component to checkout
The Activity description of the check-out
Returns ~true if the operation was successfull; otherwise, returns ~false
method checkoutModel(urn, activityDesc)
if (!urn) return false;
var params=[urn, (activityDesc || '')];
var response = this.executeService("LibManager", "actionCheckoutModel", params, null, null);
if (!response) return false;
//this.setReadonlyAttr(urn, "false");
$ENV.updateModelsList(this.toModelHandle(urn), this.toModelHandle(urn, #[CHECKED_OUT]));
if (($ENV.model) && ($ENV.model.urn == urn)) {
// checkout the current model
var mhandle = this.toModelHandle(urn, #[CHECKED_OUT], $ENV.model.isDTRModel);
$ENV.openModel(mhandle);
}
return true;
end
<@doc>
Checks out the given development components
The urn of the development component to checkout
The Activity description of the check-out
Returns a list of results for each model containing the original urn and the new urn or an error
method checkoutModels(urns, activityDesc)
if (!urns) return false;
var params=[urns, (activityDesc || '')];
var response = this.executeService("LibManager", "actionCheckoutModels", params, null, null);
if (!response) return false;
var items=response.childNodes, item, list=[];
if (!items) return list;
while (item = items.nextNode) {
list.push({
urn: item.getAttribute('urn'),
error: item.getAttribute('error')
});
}
for (var id in list){
var data = list[id]
var error = data["error"];
var urn = data["urn"]
if (!error) {
$ENV.updateModelsList(this.toModelHandle(urn), this.toModelHandle(urn, #[CHECKED_OUT]));
if (($ENV.model) && ($ENV.model.urn == urn)) {
// checkout the current model
var mhandle = this.toModelHandle(urn, #[CHECKED_OUT], $ENV.model.isDTRModel);
$ENV.openModel(mhandle);
}
}
}
return list;
end
//////////////////////// SYNC
<@doc>
Syncs models (the models's files will be in READONLY mode)
The urns of the development component to sync
Indicates whether to force a sync
Returns a list of results for each model containing the original urn and the new urn or an error
method syncModels(urns, force)
if (!urns) return false;
this.error = "";
if (typeof force == 'undefined')force = true;
var response = this.executeService("LibManager", "actionSyncModels", [urns,force], null, null);
if (!response) return false;
var items=response.childNodes, item, list=[];
if (!items) return list;
while (item = items.nextNode) {
list.push({
urn: item.getAttribute('urn'),
error: item.getAttribute('error')
});
}
return list;
end
<@doc>
Syncs a model (the model's files will be in READONLY mode)
The urn of the development component to sync
Indicates whether to force a sync
Returns ~true if the operation was successfull; otherwise, returns ~false
method syncModel(urn, force)
if (!urn) return false;
this.error = "";
if (typeof force == 'undefined')force = true;
var response = this.executeService("LibManager", "actionSyncModel", [urn,force], null, null);
if (!response) return false;
//this.setReadonlyAttr(urn, "true");
return true;
end
//////////////////////// REVERT
<@doc>
Reverts any changes done to the development component
The urn of the development component to revert
Indicates whether the model to revert is new repository model
Returns a list of results for each model containing the original urn and the new urn or an error
method revertChanges(urn, isNewRepositoryMdl)
if (!urn) return false;
var response = this.executeService("LibManager", "actionRevertChanges", [urn], null, null);
if (!response) return false;
//if (!isNewRepositoryMdl) this.setReadonlyAttr(response, "true");
var modelStatus = (isNewRepositoryMdl)? #[LOCAL] : #[CHECKED_IN];
$ENV.updateModelsList(this.toModelHandle(urn), this.toModelHandle(response, modelStatus));
if (($ENV.model) && ($ENV.model.urn == urn)) {
// revert the current model
var mhandle = this.toModelHandle(response, modelStatus, $ENV.model.isDTRModel);
$ENV.openModel(mhandle);
$ENV.saveModel(); // the model's name has changed so save it
}
return response;
end
<@doc>
Reverts any changes done to the development component
The urn of the development component to revert
Indicates whether the model to revert is new repository model
Returns the name of the model after revert if the operation was successfull; otherwise, returns ~false
method revertMultiChanges(urns,newRepModels)
if (!urns) return false;
var response = this.executeService("LibManager", "actionRevertMultiChanges", [urns], null, null);
var list = this.parseResponse(response);
for (var id in list){
var data = list[id]
var error = data["error"];
var urn = data["urn"];
var newurn = data["newurn"];
if (!error) {
var modelStatus = (newRepModels[id])? #[LOCAL] : #[CHECKED_IN];
$ENV.updateModelsList(this.toModelHandle(urn), this.toModelHandle(newurn, modelStatus));
if (($ENV.model) && ($ENV.model.urn == urn)) {
// revert the current model
var mhandle = this.toModelHandle(newurn, modelStatus, $ENV.model.isDTRModel);
$ENV.openModel(mhandle);
$ENV.saveModel(); // the model's name has changed so save it
}
}
}
return list;
end
//////////////////////// ADD TO DTR
<@doc>
Adds local models to DTR
The urns of the local models
The software component of the development component
The development component to create
The Activity description
The domain of the model (SAPInternalValue)
Returns a list of results for each model containing the original urn and the new urn or an error
method addMultiToDTR(urns, softwareComp, develComp, activityDesc, dcPrefix, dcDomain,modelNames,supportComponent)
if ((!urns) || (!softwareComp) || (!develComp)) return false;
var params=[];
params[0] = urns;
params[1] = softwareComp;
params[2] = develComp;
params[3] = activityDesc;
params[4] = dcPrefix;
params[5] = dcDomain;
params[6]= modelNames;
params[7]= supportComponent;
for (var id in modelNames) {
modelNames[id]=modelNames[id].substring(modelNames[id].lastIndexOf(".")+1,modelNames[id].length)
}
var response = this.executeService("LibManager", "actionAddMultiToDTR", params, null, null);
var list = this.parseResponse(response);
for (var id in list){
var data = list[id]
var error = data["error"];
var urn = data["urn"];
var newurn = data["newurn"];
if (!error) {
$ENV.updateModelsList(this.toModelHandle(urn), this.toModelHandle(newurn, #[ADDED_TO_DTR]));
if (($ENV.model) && ($ENV.model.urn == urn)) {
// add to dtr the current model
var mhandle = this.toModelHandle(response, #[ADDED_TO_DTR], $ENV.model.isDTRModel);
$ENV.openModel(mhandle);
$ENV.saveModel(); // the model's name has changed so save it
}
}
}
return list;
end
<@doc>
Adds a local model to DTR
The urn of the local model
The software component of the development component
The development component to create
The Activity description
The domain of the model (SAPInternalValue)
Returns the name of the added-to-DTR model if the operation was successfull; otherwise, returns ~false
method addToDTR(urn, softwareComp, develComp, activityDesc, dcPrefix, dcDomain,supportComponent)
if ((!urn) || (!softwareComp) || (!develComp)) return false;
var params=[];
params[0] = urn;
params[1] = softwareComp;
params[2] = develComp;
params[3] = activityDesc;
params[4] = dcPrefix;
params[5] = dcDomain;
params[6]= supportComponent;
var response = this.executeService("LibManager", "actionAddToDTR", params, null, null);
if (!response) return false;
$ENV.updateModelsList(this.toModelHandle(urn), this.toModelHandle(response, #[ADDED_TO_DTR]));
if (($ENV.model) && ($ENV.model.urn == urn)) {
// add to dtr the current model
var mhandle = this.toModelHandle(response, #[ADDED_TO_DTR], $ENV.model.isDTRModel);
$ENV.openModel(mhandle);
$ENV.saveModel(); // the model's name has changed so save it
}
// A local model is created with readonly attribute = false,
// so there is no need to update this attribute
return response;
end
//////////////////////// CHECKIN
<@doc>
Checkes in to the DTR the given development component
The urn of the development component to check-in
Returns a map with the name and activation-status of the checked-in model if the operation was successfull; otherwise, returns ~false
method checkinModel(urn)
var mn='';
if (!urn) return false;
var response = this.executeService("LibManager", "actionCheckinModel", [urn], null, null);
if (!response) return false;
var name = response.getAttribute('name');
var activationStatus = response.getAttribute('activationStatus');
//this.setReadonlyAttr(name, "true");
$ENV.updateModelsList(this.toModelHandle(urn), this.toModelHandle(name, #[CHECKED_IN]));
if (($ENV.model) && ($ENV.model.urn == urn)) {
// checkin the current model
var mhandle = this.toModelHandle(name, #[CHECKED_IN], $ENV.model.isDTRModel);
mn = mhandle.modelName;
$ENV.openModel(mhandle);
} else {
mn = urn.replace(/Local development\./gim, '').replace(/DTR\.[\w\-\!\~\$]+\./gim, '').replace(/\.\w+$/,'').replace(/0x([0-9][a-f])/gim,function(g1, g2) {return unescape('%'+g2);});
}
var response = this.getLatestActivation();
response=response[0];
WRITE("#TEXT[XMSG_ACT_REQUEST_INITIATED]." + (response ? " #TEXT[XMSG_ACTIVATION_ID_IS] ".replace('{0}', response) : ""));
return {name:name, activationStatus: activationStatus};
end
<@doc>
Checkes in to the DTR the given development component
The urn of the development component to check-in
Returns a list of results for each model containing the original urn and the new urn or an error
method checkinModels(urns)
var mn='';
if (!urns) return false;
var response = this.executeService("LibManager", "actionCheckinModels", [urns], null, null);
if (!response) return false;
var items=response.childNodes, item, list=[];
if (!items) return list;
while (item = items.nextNode) {
var child= item.childNodes;
var status = child.nextNode;
if (status){
list.push({
newurn: status.getAttribute('name'),
activationStatus: status.getAttribute('activationStatus'),
urn: item.getAttribute('urn'),
error: item.getAttribute('error')
});
}
else{
list.push({
urn: item.getAttribute('urn'),
error: item.getAttribute('error')
});
}
}
var numOfSuccessful = 0;
for (var id in list){
var data = list[id]
var error = data["error"];
var urn = data["urn"];
var name = data["newurn"];
if (!error) {
numOfSuccessful=numOfSuccessful+1;
$ENV.updateModelsList(this.toModelHandle(urn), this.toModelHandle(name, #[CHECKED_IN]));
if (($ENV.model) && ($ENV.model.urn == urn)) {
// checkin the current model
var mhandle = this.toModelHandle(name, #[CHECKED_IN], $ENV.model.isDTRModel);
mn = mhandle.modelName;
$ENV.openModel(mhandle);
} else {
mn = urn.replace(/Local development\./gim, '').replace(/DTR\.[\w\-\!\~\$]+\./gim, '').replace(/\.\w+$/,'').replace(/0x([0-9][a-f])/gim,function(g1, g2) {return unescape('%'+g2);});
}
}
}
var latest = this.getLatestActivation(numOfSuccessful);
for (var i in latest){
WRITE("#TEXT[XMSG_ACT_REQUEST_INITIATED] " +list[i].newurn+ (latest[i] ? " #TEXT[XMSG_ACTIVATION_ID_IS] ".replace('{0}', latest[i]) : ""));
}
return list;
end
///////////////////////////////////////////////////////////
<@doc>
Get the ID of the latest activation listed in the user workspace
Returns the ID of the laetst activation
method getLatestActivation(count)
if (!count && count!=0) count=1;
var IDs = this.executeService("LibManager", "getActivationIDs", null, null, null); // get the list of IDs from devserver
if (!IDs || 0==IDs.length) return null;
SORTF(IDs,function(a,b){return b-a});
IDs=IDs.splice(0,count);
return IDs;
end
<@doc>
Get or refresh activation details
Returns the ID of the laetst activation
method activationDetails(params)
var activationDetails = this.executeService("LibManager","activationDetails",params, null, null);
if (!activationDetails) {
return null;
}
return activationDetails;
end
<@doc>
Get activation details
Returns whether the operation ended successfully (no exception) or not)
method removeFromMonitorList(params)
var result = this.executeService("LibManager","removeFromMonitorList",params, null, null);
if (result && "" == result.xml) {
return true;
} else {
return false
}
end
<@doc>
Get the details of the given development component
The urn of the development component to get its details
Returns ~true if the operation was successfull; otherwise, returns ~false
method getDCDetails(urn)
if (!urn) return false;
var response = this.executeService("LibManager", "actionGetDCDetails", [urn], null, null);
if (!response) return false;
var items=response.childNodes, item, list=[];
while (item = items.nextNode) {
list.push({
rev: item.getAttribute('versionNum'),
activity: item.getAttribute('activity'),
id: item.getAttribute('id'),
isn: item.getAttribute('isn'),
user: item.getAttribute('user'),
date: item.getAttribute('date')
});
}
return list;
end
<@doc>
Get the details of the given development component
The urn of the development component
The number of revision to sync to
Returns ~true if the operation was successfull; otherwise, returns ~false
method syncToVersion(urn, revision)
if (!urn || !revision) return false;
var response = this.executeService("LibManager", "actionSyncToRevision", [urn,(''+revision)], null, null);
if (!response) return false;
return true;
end
<@doc>
Copies the given DCs to the given destinations
Destination path to copy to
Returns a list of results for each model containing the original urn and the new urn or an error
method copyToLocals(names)
if (ISEMPTY(names)) return false;
var response= this.executeService("LibManager", "actionCopyToLocals", [names], null, null);
return this.parseResponse(response);
end
method parseResponse(response)
if (!response) return false;
var items=response.childNodes, item, list=[];
if (!items) return list;
while (item = items.nextNode) {
list.push({
urn: item.getAttribute('urn'),
newurn: item.getAttribute('newurn'),
error: item.getAttribute('error')
});
}
return list;
end
<@doc>
Copies the given DC to the given destination
The urn of the development component
Destination path to copy to
Is the destination name complete (true) or does it need further manipulation on the server (false)
Returns ~true if the operation was successfull; otherwise, returns ~false
method copyToLocal(urn, destination, destComplete)
if (!urn || !destination) return false;
var response = this.executeService("LibManager", "actionCopyToLocal", [urn,destination,destComplete], null, null);
if (!response) return false;
//this.setReadonlyAttr(response, "false");
return response;
end
<@doc>
Overrides the content of the given DC (target) with the given local model
The urn of the local model
The urn of the development component
Returns ~true if the operation was successfull; otherwise, returns ~false
method copyToDTR(source, target)
if (!source || !target) return false;
var response = this.executeService("LibManager", "actionCopyToDTR", [source, target], null, null);
if (!response) return false;
return response;
end
<@doc>
Enumerates all the dtr details
Indicates whether to retrieve information from NWDI server (true) or from cache (false) default=true
Returns an enumeration of the dtr details
method listDTRDetails(refresh, onsuccess, onfailure)
if (typeof refresh == 'undefined') refresh=true;
var response = this.executeService("LibManager", "actionListDTRDetails", [refresh], onsuccess || null, onfailure || null);
if (!response) return false;
return response;
end
<@doc>
Enumerates all the vendors
Indicates whether to retrieve information from NWDI server (true) or from cache (false) default=true
Returns an enumeration of the vendors
method listVendors(refresh)
if (typeof refresh == 'undefined') refresh=true;
var response = this.executeService("LibManager", "actionListVendors", [refresh], null, null);
if (!response) return false;
return response;
end
<@doc>
Enumerates all the domains
Indicates whether to retrieve information from NWDI server (true) or from cache (false) default=true
Returns an enumeration of the domains
method listDomains(refresh)
if (typeof refresh == 'undefined') refresh=true;
var response = this.executeService("LibManager", "actionListDomains", [refresh], null, null);
if (!response) return false;
return response;
end
<@doc>
Enumerates all the prefixes which correspond to the given vendor
The vendor whose prefixes we wish to enumerate
Indicates whether to retrieve information from NWDI server (true) or from cache (false) default=true
Returns an enumeration of the prefixes
method listPrefixes(vendor, refresh)
if (!vendor) return false;
if (typeof refresh == 'undefined') refresh=true;
var response = this.executeService("LibManager", "actionListPrefixes", [vendor,refresh], null, null);
if (!response) return false;
return response;
end
<@doc scope="private">
Sets the readonly attribute of the given model to the specified value
The model to set its readonly attribute
The value of the readonly attribute to set
Returns ~false if the operation failed; otherwise, returns ~true
method setReadonlyAttr(urn, isReadonly)
if ((!urn) || (!isReadonly)) return false;
if (!this.online) return false;
// Read the 'config.xml' file, and update the readonly attribute in it
// according to the given readonly parameter
var xml = this.readFile(this.toModelFile(urn, '_config.xml'), true);
if (!xml) return false;
var manifest = $ENV.kitsManifest;
if (!manifest) return false;
var config = manifest.parseConfigXML(xml);
if (!config) return false;
config.readonly = xml.getAttribute('readonly');
// Check if the readonly attribute is already updated
if (config.readonly == isReadonly)
return true;
// TODO: check why I cannot remove the following line
//config.production = xml.getAttribute('production');
config.readonly = isReadonly;
var configUrn = this.toModelFile(urn, '_config.xml');
var configXml = manifest.printConfigXML(config);
var res = this.writeFile(configUrn, configXml);
return res;
end
<@doc scope="private">
Write log and trace messages to the J2EE server standard log
The special formatted XML containing the log/trace details (see below)
Returns a success XML string if operation succeeded
Log XML format:
<L loc="myLocation" msg="This is my log message" lvl="logLevel"/>
<L .../>
.
.
<T loc="myLocation" msg="This is my trace message" lvl="traceLevel"/>
<T .../>
.
.
This method should only be used by the infrastructure. In order to log, all kits should
use the HEX23LOG and HEX23TRACE pragmas.
method logToServer(logxml)
var response = this.executeService("ClientLogger", "writeClientLog", [logxml], null, null);
if (!response) return false;
return response;
end
<@doc scope="private">
Updates the status of the given model.
This function assumes that the given model is a development component.
The model to update its status
Returns an object with the refreshed status of the model
method updateMdlStatus(urn)
if (urn == null) return [];
var response = this.executeService("LibManager", "actionUpdateMdlStatus", [urn], null, null);
if (!response) return [];
var obj = {
isCheckedOut: response.getAttribute('isCheckedOut') || "false",
isCheckedOutByOtherUser: response.getAttribute('isCheckedOutByOtherUser') || "false",
isSynced: response.getAttribute('isSynced') || "false",
isCheckedOutInAnotherServer: response.getAttribute('isCheckedOutInAnotherServer') || "false"
};
return obj;
end
<@doc>
Gets the properties of the given GML class
The properties are returned in a map of pairs:(property, property-attribute)
while property-attribute is a map of pairs: (attributeName, attributeValue)
Full GML class name
Indicates whether to include inherited properties
Returns the properties of the given GML class
method getClassProps(fullClassname, includeInherited)
if (!fullClassname) return null;
var ns = this.getNsFromFullClassname(fullClassname);
var classname = this.getNameFromFullClassname(fullClassname);
if ((!ns) || (!classname)) return null;
if (includeInherited == undefined) includeInherited = true;
var response = this.executeService("GmlDataProvider", "getClassPropertiesAsXML", [ns, classname, includeInherited], null, null);
if (!response) return [];
var items=response.childNodes, item, propsMap=[];
while (item = items.nextNode) {
var attrMap=[];
var attr = item.attributes;
if (!attr) continue;
for (var i=1; i
Gets the metadata of the given GML class
The metadata is returned in a map of pairs: (metadata-name, metadata-value)
Full GML class name
Indicates whether to include inherited metadata
Returns the metadata of the given GML class
method getClassMetadata(fullClassname, includeInherited)
if (!fullClassname) return null;
var ns = this.getNsFromFullClassname(fullClassname);
var classname = this.getNameFromFullClassname(fullClassname);
if ((!ns) || (!classname)) return null;
if (includeInherited == undefined) includeInherited = true;
var response = this.executeService("GmlDataProvider", "getClassMetadataAsXML", [ns, classname, includeInherited], null, null);
if (!response) return [];
var items=response.childNodes, item, metaMap=[];
while (item = items.nextNode) {
var attrMap=[];
var attr = item.attributes;
if (!attr) continue;
for (var i=1; i
Gets the hierarchy of the given GML class
Returns an array of predecessors
Full GML class name
Returns an array of predecessors of the given GML class
method getClassHierarchy(fullClassname)
if (!fullClassname) return null;
var ns = this.getNsFromFullClassname(fullClassname);
var classname = this.getNameFromFullClassname(fullClassname);
if ((!ns) || (!classname)) return null;
var response = this.execute("GmlDataProvider", "getPredecessorsAsString", [ns, classname], true);
if (!response) return [];
var predecessors = SPLIT(response.text, ";");
return predecessors;
end
<@doc scope="private">
Returns the namespace of the given full class name
full class name (namespace + class name)
The namespace of the given full class name
method getNsFromFullClassname(classname)
var k = classname.indexOf(":");
if (k <= 0) return null;
return classname.substring(0, k);
end
<@doc scope="private">
Returns the class name of the given full class name
full class name (namespace + class name)
The classname of the given full class name
method getNameFromFullClassname(classname)
var k = classname.indexOf(":");
if (k <= 0) return null;
return classname.substring(k+1);
end
<@doc scope="private">
checks if the application session exists.
if got answer from server then it does exist.
true if session exist
method SessionExists()
var response = this.executeService("LibManager", "sessionTimeout", null, null, null);
//check if we got an XML from server and if it is the right one (contains SUCCESS)
if(response && response.nodeName == "SUCCESS")
return true;
return false;
end