");
WriteOutput("
");
// === START: backup current set of registered resources === //
// backup files found in the /_cs_apps/resources/backups
if ( attributes.doBackup )
application.ADF.resourceService.backupRegisteredResources();
// === START: get update data === //
if ( LEN(TRIM(attributes.aliasList)) ) {
// Get the Scripts By AliasList
scriptsArr = application.ADF.resourceService.getScriptsByAliasList(aliasList=attributes.aliasList,source=attributes.scriptsSource);
}
else if ( LEN(TRIM(attributes.groupList)) ) {
// Get the Scripts By GroupList
scriptsArr = application.ADF.resourceService.getScriptsByGroupList(groupList=attributes.groupList,source=attributes.scriptsSource);
}
else {
// Get the All Scripts Data
scriptsArr = application.ADF.resourceService.getAllScripts(source=attributes.scriptsSource);
}
//WriteDump(var=attributes,label="attributes",expand=false);
//WriteDump(var=attributes.groupList,expand=false);
//WriteDump(var=scriptsArr,expand=false);
for ( i=1; i <= ArrayLen(scriptsArr); i++ ) {
regData = scriptsArr[i];
legacyLoadJSEarlyDefault = 0;
cssProps = [];
jsProps = [];
// Get the Default values from the resource data
if ( StructKeyExists(regData,"legacyLoadJsEarly") )
legacyLoadJSEarlyDefault = regData.legacyLoadJsEarly;
if ( StructKeyExists(regData,"cssSourceArray") )
cssProps = regData.cssSourceArray;
if ( StructKeyExists(regData,"jsSourceArray") )
jsProps = regData.jsSourceArray;
// If enabled, use the legacyLoadJSEarlyDefault
jsLoadEarly = attributes.useLegacyEarlyJs ? legacyLoadJSEarlyDefault : 0;
// Set the Early and Late Properties
propsEarly = [];
propsLate = [];
if ( ArrayLen(cssProps) )
propsEarly = cssProps;
if ( ArrayLen(jsProps) ) {
if ( jsLoadEarly OR attributes.loadingType EQ "early" )
ArrayAppend(propsEarly,jsProps,true);
else
propsLate = jsProps;
}
/*
required string name,
required string category,
required array earlyLoadSourceArray,
required array lateLoadSourceArray,
required string description,
required string installInstructions,
string aliasList="",
boolean redistributable=0,
boolean updateExisting=0,
boolean silent=0
boolan preserveAliases=1
*/
if ( attributes.outputInstallScripts ) {
WriteOutput("
");
WriteOutput(
'application.ADF.scriptsService.registerResource(
name = "#regData.name#",
category = "#regData.category#",
earlyLoadSourceArray = #SerializeJSON(propsEarly)#,
lateLoadSourceArray = #SerializeJSON(propsLate)#,
description = "#regData.description#",
installInstructions = "#regData.installInstructions#",
aliasList = "#regData.aliasList#",
redistributable = #regData.redistributable#,
updateExisting = #attributes.updateExisting#,
silent = #regData.silent#,
preserveAliases = #attributes.preserveAliases#
);'
);
WriteOutput("");
WriteOutput("
");
}
else {
try {
application.ADF.scriptsService.registerResource(
"#regData.name#", "#regData.category#",
propsEarly,
propsLate,
"#regData.description#", "#regData.installInstructions#", "#regData.aliasList#"
,regData.redistributable, attributes.updateExisting, regData.silent
,attributes.preserveAliases
);
}
catch (any ex) {
logMsg = "An error occurred when attempting to register: " & regData.name & " (" & regData.aliaslist & ")";
msg = " -- WARNING: " & logMsg;
if ( StructKeyExists(ex,"Message") ) {
msg = msg & "
-- " & ex.Message;
logMsg = logMsg & " - " & ex.Message;
}
writeOutput(msg & "
");
application.ADF.log.addLogEntry(message=logMsg,CFCatch=ex,forceStackTrace=false,useDatePrefix=true);
if ( attributes.verboseOutput )
WriteDump(ex);
}
}
}