cfparam(name="rData", default=[]);
formatTypes = 'json,cfml,cfm';
cfmFileName = "allScripts.cfm";
jsonFileName = "allScripts.json";
// Set the default dataFileName
dataFileName = jsonFileName;
if ( !structKeyExists(request.params, "version") OR !Len(Trim(request.params.version)) )
request.params.version = application.ADF.ResourceService.getDefaultAllScriptsDataVersion(); // "1.0";
if ( !structKeyExists(request.params, "format") OR !Len(Trim(request.params.format)) )
request.params.format = 'json'; // json or cfml
// Parameter to check site for override data file
if ( !structKeyExists(request.params, "checkOverride") OR !IsBoolean(request.params.checkOverride) )
request.params.checkOverride = false;
if ( ListFindNoCase(formatTypes,request.params.format) NEQ 0 )
{
if ( request.params.format EQ 'cfml' OR request.params.format EQ 'cfm' )
dataFileName = cfmFileName;
else if ( request.params.format EQ 'json' )
dataFileName = jsonFileName;
}
if ( request.params.checkOverride )
{
scriptsDataFile = "/_cs_apps/config/#dataFileName#";
if ( NOT FileExists(ExpandPath("#request.site.csAppsURL#config/#dataFileName#")) )
{
WriteOutput("File Source: " & scriptsDataFile & " - LOCAL OVERRIDE DOES NOT EXIST!
");
exit;
}
}
else
scriptsDataFile = "/ADF/lib/scripts/data/#request.params.version#/#dataFileName#";
if ( ListLast(dataFileName,'.') EQ 'json' )
{
fileDir = ExpandPath(scriptsDataFile);
if ( NOT FileExists(fileDir) )
{
WriteOutput("File Source: " & scriptsDataFile & " - DATA FILE DOES NOT EXIST!
");
exit;
}
jsonStr = FileRead(fileDir);
if ( isJSON(jsonStr) )
jsonObj = deserializeJson(jsonStr);
// - From the ADF allScripts.JSON file get the data from the DATA key from the JSON object
if ( StructKeyExists(jsonObj,'data') AND IsArray(jsonObj.data) )
rData = jsonObj.data;
else if ( IsArray(jsonObj) )
rData = jsonObj;
}
else
include scriptsDataFile;
RenderHeader(Title="Resource Data File Validator");
WriteOutput("File Version: " & EncodeForHTML(request.params.version) & "
");
WriteOutput("File Format: " & EncodeForHTML(request.params.format) & "
");
WriteOutput("File Source: " & scriptsDataFile & "
");
WriteOutput("Valid Data File: " & IsArray(rData) & "
");
WriteDump(var=rData);
RenderFooter();