Name
global.SAMLClusterPreProcessing
Description
Handle Parameter Specific Pre Processing for Various Process Types.
Script
var SAMLClusterPreProcessing = Class.create();
SAMLClusterPreProcessing.prototype = {
initialize: function() {
},
addProcessSpecificParameters: function(processName, parameters, normalizedString, maxFieldLength) {
// property to enable and disable processes specific pre processing.
if (!GlideProperties.getBoolean("sa_ml.enable.process.specific.preprocessing", true)) {
return normalizedString;
}
// property to prevent process specific pre processing to exceed certain length.
var maxOnAddingCharacters = isNaN(maxFieldLength) ? GlideProperties.getInt("process.clustering.max.vtable.field.custom.preprocessing.size", 1000) : Math.min(GlideProperties.getInt("process.clustering.max.vtable.field.custom.preprocessing.size", 1000), maxFieldLength);
switch (true) {
case ("wwp" == processName):
return this.handleWWPPreProcessing(parameters, normalizedString, maxOnAddingCharacters);
case (processName.indexOf("java") != -1):
return this.handleJavaPreProcessing(parameters, normalizedString, maxOnAddingCharacters);
default:
return normalizedString;
}
},
// identify application pool for the IIS Process and append it to normalized string until we reach maxlength.
handleWWPPreProcessing: function(parameters, normalizedString, maxFieldLength) {
var applicationPool;
var split = parameters.split("-");
for (var i = 0; i < split.length; i++) {
if (split[i].startsWith("ap")) {
applicationPool = split[i].substring(2).replace(/\s/g, '').replace(/"|'/g, '');
break;
}
}
if (applicationPool) {
var count = (parseInt(maxFieldLength) - normalizedString.length) / (applicationPool.length + 1);
for (var j = 0; j < Math.floor(count); j++) {
normalizedString = normalizedString + " " + applicationPool;
}
}
return normalizedString;
},
// identify JARS present in normalized string and append it to normalized string till we reach max length
// if the JARS cannot be appended at least 10 times due to max length reached we create a new string only with repetitive jar string till max length and return that repeated jar string
// if we are not able to keep the jars itself more than once we return the normalized string as it is.
// if no jars found in normalized string we return normalized string.
handleJavaPreProcessing: function(parameters, normalizedString, maxFieldLength) {
var split = normalizedString.split(" ");
var jars = [];
for (var i = 0; i < split.length; i++) {
if (split[i].endsWith(".jar"))
jars.push(split[i]);
}
if (jars.length > 0) {
var jarsJoin = jars.join(" ");
var jarsString = "";
var count = (parseInt(maxFieldLength) - normalizedString.length) / (jarsJoin.length + 1);
if (Math.floor(count) > 10) {
jarsString = jarsString + normalizedString;
} else {
count = (parseInt(maxFieldLength)) / (jarsJoin.length + 1) - 1;
jarsString = jarsString + jarsJoin;
}
if (Math.floor(count) > 0) {
for (var k = 0; k < Math.floor(count); k++) {
jarsString = jarsString + " " + jarsJoin;
}
return jarsString;
}
}
return normalizedString;
},
type: 'SAMLClusterPreProcessing'
};
Sys ID
56acefab77d2301039fca1b35b5a99eb