diff --git a/Project.njsproj b/Project.njsproj index 0295f4eb0..ba464d3a2 100644 --- a/Project.njsproj +++ b/Project.njsproj @@ -63,6 +63,9 @@ Code + + Code + Code diff --git a/Server/CloudScripts.js b/Server/CloudScripts.js new file mode 100644 index 000000000..1ea8ae236 --- /dev/null +++ b/Server/CloudScripts.js @@ -0,0 +1,136 @@ +exports.newConfigReader = function newConfigReader() { + + let thisObject = { + loadCloudScripts: loadCloudScripts, + initialize: initialize + } + + const GITHUB = require('../Server/Github'); + let github = GITHUB.newGithub(); + + const STORAGE = require('../Server/Storage'); + let storage = STORAGE.newStorage(); + + let serverConfig; + let githubData; + let storageData; + let ecosystem; + let ecosystemObject; + + return thisObject; + + function initialize(pEcosystem, pEcosystemObject, pServerConfig, pGithubData, pStorageData, callBackFunction) { + + serverConfig = pServerConfig; + githubData = pGithubData; + storageData = pStorageData; + ecosystem = pEcosystem; + ecosystemObject = pEcosystemObject; + + } + + function loadCloudScripts(callBackfunction) { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] CloudScripts -> loadCloudScripts -> Entering function."); } + + /* + + First we will get a list of the scripts to be loaded, and then we will load them into the cache. + + */ + + switch (serverConfig.configAndPlugins.Location) { + + case 'Cloud': { + + if (CONSOLE_LOG === true) { console.log("[INFO] CloudScripts -> loadCloudScripts -> Cloud -> Entering Case."); } + + storage.getStorageData('AdvancedAlgos', 'AACloud', 'web.config.json', onDataArrived); + + function onDataArrived(pData) { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] CloudScripts -> loadCloudScripts -> Cloud -> onDataArrived -> Entering function."); } + + let data = pData.toString(); + data = data.trim(); // remove first byte with some encoding. + + dataObject = JSON.parse(data); + retrieveScripts(); + } + catch (err) { + console.log("[ERROR] CloudScripts -> loadCloudScripts -> Cloud -> onDataArrived -> Error = " + err); + } + } + + break; + } + + case 'File System': { + + if (CONSOLE_LOG === true) { console.log("[INFO] CloudScripts -> loadCloudScripts -> File System -> Entering Case."); } + + let fs = require('fs'); + try { + let fileName = '../AACloud/web.config.json'; + fs.readFile(fileName, onFileRead); + + function onFileRead(err, file) { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] CloudScripts -> loadCloudScripts -> File System -> onFileRead -> Entering function."); } + + let data = pData.toString(); + data = data.trim(); // remove first byte with some encoding. + + dataObject = JSON.parse(data); + retrieveScripts(); + } + catch (err) { + console.log("[ERROR] CloudScripts -> loadCloudScripts -> File System -> onFileRead -> File = " + fileName + " Error = " + err); + } + + } + } + catch (err) { + console.log("[ERROR] CloudScripts -> loadCloudScripts -> File System -> File = " + fileName + " Error = " + err); + } + break; + } + + case 'Github': { + + if (CONSOLE_LOG === true) { console.log("[INFO] CloudScripts -> loadCloudScripts -> Github -> Entering Case."); } + + github.getGithubData('AdvancedAlgos', 'AACloud', 'web.config.json', onDataArrived); + + function onDataArrived(pData) { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] CloudScripts -> loadCloudScripts -> Github -> onDataArrived -> Entering function."); } + + let data = pData.toString(); + data = data.trim(); // remove first byte with some encoding. + + dataObject = JSON.parse(data); + retrieveScripts(); + } + catch (err) { + console.log("[ERROR] CloudScripts -> loadCloudScripts -> Github -> onDataArrived -> Error = " + err); + } + } + break; + } + } + } + catch (err) { + console.log("[ERROR] CloudScripts -> loadCloudScripts -> Error = " + err); + } + } + +} \ No newline at end of file diff --git a/Server/ConfigReader.js b/Server/ConfigReader.js index 3bf5339cb..21c605894 100644 --- a/Server/ConfigReader.js +++ b/Server/ConfigReader.js @@ -33,7 +33,7 @@ try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readServerConfig -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readServerConfig -> Entering function."); } let fs = require('fs'); @@ -44,7 +44,7 @@ try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readServerConfig -> onFileRead -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readServerConfig -> onFileRead -> Entering function."); } let fileText; @@ -53,7 +53,7 @@ serverConfig = JSON.parse(fileText); - if (LOG_FILE_CONTENT === true) { console.log("[INFO] initialize -> readServerConfig -> onFileRead -> fileText = " + fileText); } + if (LOG_FILE_CONTENT === true) { console.log("[INFO] ConfigReader -> readServerConfig -> onFileRead -> fileText = " + fileText); } CONSOLE_LOG = serverConfig.webServerLog.console; LOG_FILE_CONTENT = serverConfig.webServerLog.fileContent; @@ -66,13 +66,13 @@ callBackFunction(serverConfig); } catch (err) { - console.log("[ERROR] initialize -> readServerConfig -> onFileRead -> File = " + fileName + " Error = " + err); + console.log("[ERROR] ConfigReader -> readServerConfig -> onFileRead -> File = " + fileName + " Error = " + err); } } } catch (err) { - console.log("[ERROR] initialize -> readServerConfig -> Error = " + err); + console.log("[ERROR] ConfigReader -> readServerConfig -> Error = " + err); } } } @@ -85,7 +85,7 @@ try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readEcosystemConfig -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readEcosystemConfig -> Entering function."); } /* @@ -99,15 +99,15 @@ case 'Cloud': { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readEcosystemConfig -> Cloud -> Entering Case."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readEcosystemConfig -> Cloud -> Entering Case."); } - storage.getStorageData('AdvancedAlgos', 'AAPlatform', 'ecosystem.json', onDataArrived) + storage.getStorageData('AdvancedAlgos', 'AAPlatform', 'ecosystem.json', onDataArrived); function onDataArrived(pData) { try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readEcosystemConfig -> Cloud -> onDataArrived -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readEcosystemConfig -> Cloud -> onDataArrived -> Entering function."); } ecosystem = pData.toString(); ecosystem = ecosystem.trim(); // remove first byte with some encoding. @@ -116,7 +116,7 @@ readHostsConfigs(); } catch (err) { - console.log("[ERROR] initialize -> readEcosystemConfig -> Cloud -> onDataArrived -> Error = " + err); + console.log("[ERROR] ConfigReader -> readEcosystemConfig -> Cloud -> onDataArrived -> Error = " + err); } } @@ -125,7 +125,7 @@ case 'File System': { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readEcosystemConfig -> File System -> Entering Case."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readEcosystemConfig -> File System -> Entering Case."); } let fs = require('fs'); try { @@ -136,7 +136,7 @@ try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readEcosystemConfig -> File System -> onFileRead -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readEcosystemConfig -> File System -> onFileRead -> Entering function."); } ecosystem = file.toString(); ecosystem = ecosystem.trim(); // remove first byte with some encoding. @@ -145,28 +145,28 @@ readHostsConfigs(); } catch (err) { - console.log("[ERROR] initialize -> readEcosystemConfig -> File System -> onFileRead -> File = " + fileName + " Error = " + err); + console.log("[ERROR] ConfigReader -> readEcosystemConfig -> File System -> onFileRead -> File = " + fileName + " Error = " + err); } } } catch (err) { - console.log("[ERROR] initialize -> readEcosystemConfig -> File System -> File = " + fileName + " Error = " + err); + console.log("[ERROR] ConfigReader -> readEcosystemConfig -> File System -> File = " + fileName + " Error = " + err); } break; } case 'Github': { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readEcosystemConfig -> Github -> Entering Case."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readEcosystemConfig -> Github -> Entering Case."); } - github.getGithubData('AdvancedAlgos', 'AAPlatform', 'ecosystem.json', onDataArrived) + github.getGithubData('AdvancedAlgos', 'AAPlatform', 'ecosystem.json', onDataArrived); function onDataArrived(pData) { try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readEcosystemConfig -> Github -> onDataArrived -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readEcosystemConfig -> Github -> onDataArrived -> Entering function."); } ecosystem = pData.toString(); ecosystem = ecosystem.trim(); // remove first byte with some encoding. @@ -175,7 +175,7 @@ readHostsConfigs(); } catch (err) { - console.log("[ERROR] initialize -> readEcosystemConfig -> Github -> onDataArrived -> Error = " + err); + console.log("[ERROR] ConfigReader -> readEcosystemConfig -> Github -> onDataArrived -> Error = " + err); } } break; @@ -183,7 +183,7 @@ } } catch (err) { - console.log("[ERROR] initialize -> readEcosystemConfig -> Error = " + err); + console.log("[ERROR] ConfigReader -> readEcosystemConfig -> Error = " + err); } } @@ -191,7 +191,7 @@ try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> Entering function."); } let requestsSent = 0; let responsesReceived = 0; @@ -207,7 +207,7 @@ try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getCompetitions -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getCompetitions -> Entering function."); } /* In this first section we will load the competitions configurations. */ @@ -221,18 +221,18 @@ case 'Cloud': { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getCompetitions -> Cloud -> Entering Case."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getCompetitions -> Cloud -> Entering Case."); } - storage.getStorageData(host.codeName, competition.repo, competition.configFile, onDataArrived) + storage.getStorageData(host.codeName, competition.repo, competition.configFile, onDataArrived); function onDataArrived(pData) { try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getCompetitions -> Cloud -> onDataArrived -> Entering function."); } - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getCompetitions -> Cloud -> onDataArrived -> host.codeName = " + host.codeName); } - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getCompetitions -> Cloud -> onDataArrived -> competition.repo = " + competition.repo); } - if (LOG_FILE_CONTENT === true) { console.log("[INFO] initialize -> readHostsConfigs -> getCompetitions -> Cloud -> onDataArrived -> pData = " + pData); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getCompetitions -> Cloud -> onDataArrived -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getCompetitions -> Cloud -> onDataArrived -> host.codeName = " + host.codeName); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getCompetitions -> Cloud -> onDataArrived -> competition.repo = " + competition.repo); } + if (LOG_FILE_CONTENT === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getCompetitions -> Cloud -> onDataArrived -> pData = " + pData); } responsesReceived++; @@ -256,7 +256,7 @@ } catch (err) { - console.log("[ERROR] initialize -> readHostsConfigs -> getCompetitions -> Cloud -> onDataArrived -> Error = " + err); + console.log("[ERROR] ConfigReader -> readHostsConfigs -> getCompetitions -> Cloud -> onDataArrived -> Error = " + err); } } break; @@ -265,7 +265,7 @@ case 'File System': { try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getCompetitions -> File System -> Entering Case."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getCompetitions -> File System -> Entering Case."); } let fs = require('fs'); @@ -276,8 +276,8 @@ try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getCompetitions -> File System -> onFileRead -> Entering function."); } - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getCompetitions -> File System -> onFileRead -> fileName = " + fileName); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getCompetitions -> File System -> onFileRead -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getCompetitions -> File System -> onFileRead -> fileName = " + fileName); } responsesReceived++; @@ -300,12 +300,12 @@ } } catch (err) { - console.log("[INFO] initialize -> readHostsConfigs -> getCompetitions -> File System -> onFileRead -> File = " + fileName + " Error = " + err); + console.log("[INFO] ConfigReader -> readHostsConfigs -> getCompetitions -> File System -> onFileRead -> File = " + fileName + " Error = " + err); } } } catch (err) { - console.log("[ERROR] initialize -> readHostsConfigs -> getCompetitions -> File System -> File = " + fileName + " Error = " + err); + console.log("[ERROR] ConfigReader -> readHostsConfigs -> getCompetitions -> File System -> File = " + fileName + " Error = " + err); } break; @@ -313,18 +313,18 @@ case 'Github': { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getCompetitions -> Github -> Entering Case."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getCompetitions -> Github -> Entering Case."); } - github.getGithubData(host.codeName, competition.repo, competition.configFile, onDataArrived) + github.getGithubData(host.codeName, competition.repo, competition.configFile, onDataArrived); function onDataArrived(pData) { try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getCompetitions -> Github -> onDataArrived -> Entering function."); } - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getCompetitions -> Github -> onDataArrived -> host.codeName = " + host.codeName); } - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getCompetitions -> Github -> onDataArrived -> competition.repo = " + competition.repo); } - if (LOG_FILE_CONTENT === true) { console.log("[INFO] initialize -> readHostsConfigs -> getCompetitions -> Github -> onDataArrived -> pData = " + pData); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getCompetitions -> Github -> onDataArrived -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getCompetitions -> Github -> onDataArrived -> host.codeName = " + host.codeName); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getCompetitions -> Github -> onDataArrived -> competition.repo = " + competition.repo); } + if (LOG_FILE_CONTENT === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getCompetitions -> Github -> onDataArrived -> pData = " + pData); } responsesReceived++; @@ -348,7 +348,7 @@ } catch (err) { - console.log("[ERROR] initialize -> readHostsConfigs -> getCompetitions -> Github -> onDataArrived -> Error = " + err); + console.log("[ERROR] ConfigReader -> readHostsConfigs -> getCompetitions -> Github -> onDataArrived -> Error = " + err); } } @@ -358,7 +358,7 @@ } } catch (err) { - console.log("[ERROR] initialize -> readHostsConfigs -> getCompetitions -> getCompetitions -> Error = " + err); + console.log("[ERROR] ConfigReader -> readHostsConfigs -> getCompetitions -> getCompetitions -> Error = " + err); } } @@ -366,7 +366,7 @@ try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getPlotters -> getPlotters -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getPlotters -> getPlotters -> Entering function."); } /* In this second section we will load the competition plotters configurations. */ @@ -380,18 +380,18 @@ case 'Cloud': { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getPlotters -> Cloud -> Entering Case."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getPlotters -> Cloud -> Entering Case."); } - storage.getStorageData(host.codeName, plotter.repo, plotter.configFile, onDataArrived) + storage.getStorageData(host.codeName, plotter.repo, plotter.configFile, onDataArrived); function onDataArrived(pData) { try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getPlotters -> Cloud -> onDataArrived -> Entering function."); } - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getPlotters -> Cloud -> onDataArrived -> host.codeName = " + host.codeName); } - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getPlotters -> Cloud -> onDataArrived -> plotter.repo = " + plotter.repo); } - if (LOG_FILE_CONTENT === true) { console.log("[INFO] initialize -> readHostsConfigs -> getPlotters -> Cloud -> onDataArrived -> pData = " + pData); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getPlotters -> Cloud -> onDataArrived -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getPlotters -> Cloud -> onDataArrived -> host.codeName = " + host.codeName); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getPlotters -> Cloud -> onDataArrived -> plotter.repo = " + plotter.repo); } + if (LOG_FILE_CONTENT === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getPlotters -> Cloud -> onDataArrived -> pData = " + pData); } responsesReceived++; @@ -415,7 +415,7 @@ } catch (err) { - console.log("[ERROR] initialize -> readHostsConfigs -> getPlotters -> Cloud -> onDataArrived -> Error = " + err); + console.log("[ERROR] ConfigReader -> readHostsConfigs -> getPlotters -> Cloud -> onDataArrived -> Error = " + err); } } @@ -424,7 +424,7 @@ case 'File System': { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getPlotters -> File System -> Entering Case."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getPlotters -> File System -> Entering Case."); } try { @@ -437,8 +437,8 @@ try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getPlotters -> File System -> onFileRead -> Entering function."); } - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getPlotters -> File System -> onFileRead -> fileName = " + fileName); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getPlotters -> File System -> onFileRead -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getPlotters -> File System -> onFileRead -> fileName = " + fileName); } responsesReceived++; @@ -461,13 +461,13 @@ } } catch (err) { - console.log("[ERROR] initialize -> readHostsConfigs -> getPlotters -> File System -> onFileRead -> File = " + fileName + " Error = " + err); + console.log("[ERROR] ConfigReader -> readHostsConfigs -> getPlotters -> File System -> onFileRead -> File = " + fileName + " Error = " + err); } } } catch (err) { - console.log("[ERROR] initialize -> readHostsConfigs -> getPlotters -> File System -> File = " + fileName + " Error = " + err); + console.log("[ERROR] ConfigReader -> readHostsConfigs -> getPlotters -> File System -> File = " + fileName + " Error = " + err); } break; @@ -475,18 +475,18 @@ case 'Github': { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getPlotters -> Github -> Entering Case."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getPlotters -> Github -> Entering Case."); } - github.getGithubData(host.codeName, plotter.repo, plotter.configFile, onDataArrived) + github.getGithubData(host.codeName, plotter.repo, plotter.configFile, onDataArrived); function onDataArrived(pData) { try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getPlotters -> Github -> onDataArrived -> Entering function."); } - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getPlotters -> Github -> onDataArrived -> host.codeName = " + host.codeName); } - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readHostsConfigs -> getPlotters -> Github -> onDataArrived -> plotter.repo = " + plotter.repo); } - if (LOG_FILE_CONTENT === true) { console.log("[INFO] initialize -> readHostsConfigs -> getPlotters -> Github -> onDataArrived -> pData = " + pData); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getPlotters -> Github -> onDataArrived -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getPlotters -> Github -> onDataArrived -> host.codeName = " + host.codeName); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getPlotters -> Github -> onDataArrived -> plotter.repo = " + plotter.repo); } + if (LOG_FILE_CONTENT === true) { console.log("[INFO] ConfigReader -> readHostsConfigs -> getPlotters -> Github -> onDataArrived -> pData = " + pData); } responsesReceived++; @@ -510,7 +510,7 @@ } catch (err) { - console.log("[ERROR] initialize -> readHostsConfigs -> getPlotters -> Github -> onDataArrived -> Error = " + err); + console.log("[ERROR] ConfigReader -> readHostsConfigs -> getPlotters -> Github -> onDataArrived -> Error = " + err); } } break; @@ -519,13 +519,13 @@ } } catch (err) { - console.log("[ERROR] initialize -> readHostsConfigs -> getPlotters -> getCompetitions -> Error = " + err); + console.log("[ERROR] ConfigReader -> readHostsConfigs -> getPlotters -> getCompetitions -> Error = " + err); } } } } catch (err) { - console.log("[ERROR] initialize -> readHostsConfigs -> Error = " + err); + console.log("[ERROR] ConfigReader -> readHostsConfigs -> Error = " + err); } } @@ -533,7 +533,7 @@ try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> Entering function."); } /* @@ -559,7 +559,7 @@ try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getBots -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getBots -> Entering function."); } /* In the next section we are loading the bots configurations. */ @@ -573,18 +573,18 @@ case 'Cloud': { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getBots -> Cloud -> Entering Case."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getBots -> Cloud -> Entering Case."); } - storage.getStorageData(devTeam.codeName, bot.repo, bot.configFile, onDataArrived) + storage.getStorageData(devTeam.codeName, bot.repo, bot.configFile, onDataArrived); function onDataArrived(pData) { try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getBots -> Cloud -> onDataArrived -> Entering function."); } - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getBots -> Cloud -> onDataArrived -> devTeam.codeName = " + devTeam.codeName); } - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getBots -> Cloud -> onDataArrived -> bot.repo = " + bot.repo); } - if (LOG_FILE_CONTENT === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getBots -> Cloud -> onDataArrived -> pData = " + pData); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getBots -> Cloud -> onDataArrived -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getBots -> Cloud -> onDataArrived -> devTeam.codeName = " + devTeam.codeName); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getBots -> Cloud -> onDataArrived -> bot.repo = " + bot.repo); } + if (LOG_FILE_CONTENT === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getBots -> Cloud -> onDataArrived -> pData = " + pData); } responsesReceived++; @@ -614,7 +614,7 @@ } catch (err) { - console.log("[ERROR] initialize -> readDevTeamsConfigs -> getBots -> Cloud -> onDataArrived -> Error = " + err); + console.log("[ERROR] ConfigReader -> readDevTeamsConfigs -> getBots -> Cloud -> onDataArrived -> Error = " + err); } } break; @@ -623,7 +623,7 @@ case 'File System': { try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getBots -> File System -> Entering Case."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getBots -> File System -> Entering Case."); } let fs = require('fs'); @@ -634,8 +634,8 @@ try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getBots -> File System -> onFileRead -> Entering function."); } - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getBots -> File System -> onFileRead -> fileName = " + fileName); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getBots -> File System -> onFileRead -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getBots -> File System -> onFileRead -> fileName = " + fileName); } responsesReceived++; @@ -660,13 +660,13 @@ } } catch (err) { - console.log("[ERROR] initialize -> readDevTeamsConfigs -> getBots -> File System -> onFileRead -> File = " + fileName + " Error = " + err); + console.log("[ERROR] ConfigReader -> readDevTeamsConfigs -> getBots -> File System -> onFileRead -> File = " + fileName + " Error = " + err); } } } catch (err) { - console.log("[ERROR] initialize -> readDevTeamsConfigs -> getBots -> File System -> File = " + fileName + " Error = " + err); + console.log("[ERROR] ConfigReader -> readDevTeamsConfigs -> getBots -> File System -> File = " + fileName + " Error = " + err); } break; @@ -674,18 +674,18 @@ case 'Github': { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getBots -> Github -> Entering Case."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getBots -> Github -> Entering Case."); } - github.getGithubData(devTeam.codeName, bot.repo, bot.configFile, onDataArrived) + github.getGithubData(devTeam.codeName, bot.repo, bot.configFile, onDataArrived); function onDataArrived(pData) { try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getBots -> Github -> onDataArrived -> Entering function."); } - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getBots -> Github -> onDataArrived -> devTeam.codeName = " + devTeam.codeName); } - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getBots -> Github -> onDataArrived -> bot.repo = " + bot.repo); } - if (LOG_FILE_CONTENT === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getBots -> Github -> onDataArrived -> pData = " + pData); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getBots -> Github -> onDataArrived -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getBots -> Github -> onDataArrived -> devTeam.codeName = " + devTeam.codeName); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getBots -> Github -> onDataArrived -> bot.repo = " + bot.repo); } + if (LOG_FILE_CONTENT === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getBots -> Github -> onDataArrived -> pData = " + pData); } responsesReceived++; @@ -711,7 +711,7 @@ } catch (err) { - console.log("[ERROR] initialize -> readDevTeamsConfigs -> getBots -> Github -> onDataArrived -> Error = " + err); + console.log("[ERROR] ConfigReader -> readDevTeamsConfigs -> getBots -> Github -> onDataArrived -> Error = " + err); } } break; @@ -721,7 +721,7 @@ } catch (err) { - console.log("[ERROR] initialize -> readDevTeamsConfigs -> getBots -> Error = " + err); + console.log("[ERROR] ConfigReader -> readDevTeamsConfigs -> getBots -> Error = " + err); } } @@ -729,7 +729,7 @@ try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getPlotters -> Entering Function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getPlotters -> Entering Function."); } /* In the next section we are loading the plotters configurations. */ @@ -743,18 +743,18 @@ case 'Cloud': { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getPlotters -> Cloud -> Entering Case."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getPlotters -> Cloud -> Entering Case."); } - storage.getStorageData(devTeam.codeName, plotter.repo, plotter.configFile, onDataArrived) + storage.getStorageData(devTeam.codeName, plotter.repo, plotter.configFile, onDataArrived); function onDataArrived(pData) { try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getPlotters -> Cloud -> onDataArrived -> Entering function."); } - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getPlotters -> Cloud -> onDataArrived -> devTeam.codeName = " + devTeam.codeName); } - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getPlotters -> Cloud -> onDataArrived -> plotter.repo = " + plotter.repo); } - if (LOG_FILE_CONTENT === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getPlotters -> Cloud -> onDataArrived -> pData = " + pData); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getPlotters -> Cloud -> onDataArrived -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getPlotters -> Cloud -> onDataArrived -> devTeam.codeName = " + devTeam.codeName); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getPlotters -> Cloud -> onDataArrived -> plotter.repo = " + plotter.repo); } + if (LOG_FILE_CONTENT === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getPlotters -> Cloud -> onDataArrived -> pData = " + pData); } responsesReceived++; @@ -781,7 +781,7 @@ } } catch (err) { - console.log("[ERROR] initialize -> readDevTeamsConfigs -> getPlotters -> Cloud -> onDataArrived -> Error = " + err); + console.log("[ERROR] ConfigReader -> readDevTeamsConfigs -> getPlotters -> Cloud -> onDataArrived -> Error = " + err); } } break; @@ -789,7 +789,7 @@ case 'File System': { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getPlotters -> File System -> Entering Case."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getPlotters -> File System -> Entering Case."); } try { @@ -802,8 +802,8 @@ try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getPlotters -> File System -> onFileRead -> Entering function."); } - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getPlotters -> File System -> onFileRead -> fileName = " + fileName); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getPlotters -> File System -> onFileRead -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getPlotters -> File System -> onFileRead -> fileName = " + fileName); } responsesReceived++; @@ -826,30 +826,30 @@ } } catch (err) { - console.log("[ERROR] initialize -> readDevTeamsConfigs -> getPlotters -> File System -> onFileRead -> File = " + fileName + " Error = " + err); + console.log("[ERROR] ConfigReader -> readDevTeamsConfigs -> getPlotters -> File System -> onFileRead -> File = " + fileName + " Error = " + err); } } } catch (err) { - console.log("[ERROR] initialize -> readDevTeamsConfigs -> getPlotters -> File = " + fileName + " Error = " + err); + console.log("[ERROR] ConfigReader -> readDevTeamsConfigs -> getPlotters -> File = " + fileName + " Error = " + err); } break; } case 'Github': { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getPlotters -> Github -> Entering Case."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getPlotters -> Github -> Entering Case."); } - github.getGithubData(devTeam.codeName, plotter.repo, plotter.configFile, onDataArrived) + github.getGithubData(devTeam.codeName, plotter.repo, plotter.configFile, onDataArrived); function onDataArrived(pData) { try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getPlotters -> Github -> onDataArrived -> Entering function."); } - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getPlotters -> Github -> onDataArrived -> devTeam.codeName = " + devTeam.codeName); } - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getPlotters -> Github -> onDataArrived -> plotter.repo = " + plotter.repo); } - if (LOG_FILE_CONTENT === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> getPlotters -> Github -> onDataArrived -> pData = " + pData); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getPlotters -> Github -> onDataArrived -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getPlotters -> Github -> onDataArrived -> devTeam.codeName = " + devTeam.codeName); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getPlotters -> Github -> onDataArrived -> plotter.repo = " + plotter.repo); } + if (LOG_FILE_CONTENT === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> getPlotters -> Github -> onDataArrived -> pData = " + pData); } responsesReceived++; @@ -873,7 +873,7 @@ } catch (err) { - console.log("[ERROR] initialize -> readDevTeamsConfigs -> getPlotters -> Github -> onDataArrived -> Error = " + err); + console.log("[ERROR] ConfigReader -> readDevTeamsConfigs -> getPlotters -> Github -> onDataArrived -> Error = " + err); } } break; @@ -883,7 +883,7 @@ } catch (err) { - console.log("[ERROR] initialize -> readDevTeamsConfigs -> getPlotters -> Error = " + err); + console.log("[ERROR] ConfigReader -> readDevTeamsConfigs -> getPlotters -> Error = " + err); } } } @@ -892,7 +892,7 @@ try { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> readDevTeamsConfigs -> addStoragePermissions -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readDevTeamsConfigs -> addStoragePermissions -> Entering function."); } if (pConfigObj.storage !== undefined) { return; } // If this information is at the config file, then we take it, otherwise, we define it here. @@ -925,16 +925,14 @@ } catch (err) { - console.log("[ERROR] initialize -> readDevTeamsConfigs -> addStoragePermissions -> Error = " + err); + console.log("[ERROR] ConfigReader -> readDevTeamsConfigs -> addStoragePermissions -> Error = " + err); } } } catch (err) { - console.log("[ERROR] initialize -> readDevTeamsConfigs -> Error = " + err); + console.log("[ERROR] ConfigReader -> readDevTeamsConfigs -> Error = " + err); } } } - - } \ No newline at end of file diff --git a/Server/Github.js b/Server/Github.js index 063abcc55..af9dac3b7 100644 --- a/Server/Github.js +++ b/Server/Github.js @@ -19,19 +19,19 @@ try { - if (CONSOLE_LOG === true) { console.log("[INFO] getGithubData -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] Github -> getGithubData -> Entering function."); } let cacheVersion = githubData.get(pOrg + '.' + pRepo + '.' + pPath) if (cacheVersion !== undefined) { - if (CONSOLE_LOG === true) { console.log("[INFO] getGithubData -> " + pOrg + '.' + pRepo + '.' + pPath + " found at cache."); } + if (CONSOLE_LOG === true) { console.log("[INFO] Github -> getGithubData -> " + pOrg + '.' + pRepo + '.' + pPath + " found at cache."); } callBackFunction(cacheVersion); } else { - if (CONSOLE_LOG === true) { console.log("[INFO] getGithubData -> " + pOrg + '.' + pRepo + '.' + pPath + " NOT found at cache."); } + if (CONSOLE_LOG === true) { console.log("[INFO] Github -> getGithubData -> " + pOrg + '.' + pRepo + '.' + pPath + " NOT found at cache."); } const octokit = require('@octokit/rest')() global.atob = require("atob"); @@ -50,11 +50,11 @@ try { - if (CONSOLE_LOG === true) { console.log("[INFO] getGithubData -> onContent -> Entering function."); } - if (CONSOLE_LOG === true) { console.log("[INFO] getGithubData -> onContent -> error = " + error); } - if (CONSOLE_LOG === true) { console.log("[INFO] getGithubData -> onContent -> Github.com responded to request " + pOrg + '.' + pRepo + '.' + pPath + " with result = " + result.toString().substring(0, 100)); } + if (CONSOLE_LOG === true) { console.log("[INFO] Github -> getGithubData -> onContent -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] Github -> getGithubData -> onContent -> error = " + error); } + if (CONSOLE_LOG === true) { console.log("[INFO] Github -> getGithubData -> onContent -> Github.com responded to request " + pOrg + '.' + pRepo + '.' + pPath + " with result = " + result.toString().substring(0, 100)); } - if (error !== null) { console.log("[ERROR] getGithubData -> onContent -> " + error); } + if (error !== null) { console.log("[ERROR] Github -> getGithubData -> onContent -> " + error); } let decoded = atob(result.data.content); @@ -83,7 +83,7 @@ try { jsonTest = JSON.parse(cleanString); } catch (err) { - console.log("[INFO] getGithubData -> onContent -> Could not clean the data received -> Data = " + decoded.substring(0, 50)); + console.log("[INFO] Github -> getGithubData -> onContent -> Could not clean the data received -> Data = " + decoded.substring(0, 50)); } } } @@ -94,14 +94,14 @@ callBackFunction(cleanString); } catch (err) { - console.log("[ERROR] getGithubData -> onContent -> err.message = " + err.message); + console.log("[ERROR] Github -> getGithubData -> onContent -> err.message = " + err.message); callBackFunction("{}"); } } } } catch (err) { - console.log("[ERROR] getGithubData -> err.message = " + err.message); + console.log("[ERROR] Github -> getGithubData -> err.message = " + err.message); callBackFunction("{}"); } } diff --git a/Server/Storage.js b/Server/Storage.js index eda2a80ef..1c242fcb1 100644 --- a/Server/Storage.js +++ b/Server/Storage.js @@ -21,22 +21,22 @@ try { - if (CONSOLE_LOG === true) { console.log("[INFO] getStorageData -> Entering function."); } - if (CONSOLE_LOG === true) { console.log("[INFO] getStorageData -> pOrg = " + pOrg); } - if (CONSOLE_LOG === true) { console.log("[INFO] getStorageData -> pRepo = " + pRepo); } - if (CONSOLE_LOG === true) { console.log("[INFO] getStorageData -> pPath = " + pPath); } + if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getStorageData -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getStorageData -> pOrg = " + pOrg); } + if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getStorageData -> pRepo = " + pRepo); } + if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getStorageData -> pPath = " + pPath); } let cacheVersion = storageData.get(pOrg + '.' + pRepo + '.' + pPath) if (cacheVersion !== undefined) { - if (CONSOLE_LOG === true) { console.log("[INFO] getStorageData -> " + pOrg + '.' + pRepo + '.' + pPath + " found at cache."); } + if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getStorageData -> " + pOrg + '.' + pRepo + '.' + pPath + " found at cache."); } callBackFunction(cacheVersion); } else { - if (CONSOLE_LOG === true) { console.log("[INFO] getStorageData -> " + pOrg + '.' + pRepo + '.' + pPath + " NOT found at cache."); } + if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getStorageData -> " + pOrg + '.' + pRepo + '.' + pPath + " NOT found at cache."); } let storage = require('azure-storage'); let connectionString; @@ -65,20 +65,20 @@ try { - if (CONSOLE_LOG === true) { console.log("[INFO] getStorageData -> onFileReceived -> Entering function."); } - if (CONSOLE_LOG === true) { console.log("[INFO] getStorageData -> onFileReceived -> err = " + JSON.stringify(err)); } - if (LOG_FILE_CONTENT === true) { console.log("[INFO] getStorageData -> onFileReceived -> response = " + JSON.stringify(response)); } - if (CONSOLE_LOG === true) { console.log("[INFO] getStorageData -> onFileReceived -> pOrg = " + pOrg); } - if (CONSOLE_LOG === true) { console.log("[INFO] getStorageData -> onFileReceived -> pRepo = " + pRepo); } - if (CONSOLE_LOG === true) { console.log("[INFO] getStorageData -> onFileReceived -> pPath = " + pPath); } + if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getStorageData -> onFileReceived -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getStorageData -> onFileReceived -> err = " + JSON.stringify(err)); } + if (LOG_FILE_CONTENT === true) { console.log("[INFO] Storage -> getStorageData -> onFileReceived -> response = " + JSON.stringify(response)); } + if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getStorageData -> onFileReceived -> pOrg = " + pOrg); } + if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getStorageData -> onFileReceived -> pRepo = " + pRepo); } + if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getStorageData -> onFileReceived -> pPath = " + pPath); } storageData.set(pOrg + '.' + pRepo + '.' + pPath, text); if (err !== null || text === null) { - console.log("[ERROR] getStorageData -> onFileReceived -> Error Received from Storage Library. "); - console.log("[ERROR] getStorageData -> onFileReceived -> err = " + JSON.stringify(err)); - console.log("[ERROR] getStorageData -> onFileReceived -> Returning an empty JSON object string. "); + console.log("[ERROR] Storage -> getStorageData -> onFileReceived -> Error Received from Storage Library. "); + console.log("[ERROR] Storage -> getStorageData -> onFileReceived -> err = " + JSON.stringify(err)); + console.log("[ERROR] Storage -> getStorageData -> onFileReceived -> Returning an empty JSON object string. "); callBackFunction("{}"); return; @@ -88,14 +88,14 @@ callBackFunction(text); } catch (err) { - console.log("[ERROR] getStorageData -> onFileReceived -> err.message = " + err.message); + console.log("[ERROR] Storage -> getStorageData -> onFileReceived -> err.message = " + err.message); callBackFunction("{}"); } } } } catch (err) { - console.log("[ERROR] getStorageData -> err.message = " + err.message); + console.log("[ERROR] Storage -> getStorageData -> err.message = " + err.message); callBackFunction("{}"); } } diff --git a/server.js b/server.js index 594b24b01..accd59105 100644 --- a/server.js +++ b/server.js @@ -3,7 +3,7 @@ CONSOLE_LOG = false; LOG_FILE_CONTENT = false; -if (CONSOLE_LOG === true) { console.log("[INFO] Node Server Starting."); } +if (CONSOLE_LOG === true) { console.log("[INFO] server -> Node Server Starting."); } let serverConfig; @@ -28,7 +28,7 @@ initialize(); function initialize() { - if (CONSOLE_LOG === true) { console.log("[INFO] initialize -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> initialize -> Entering function."); } /* Clear all cached information. */ @@ -64,7 +64,7 @@ function initialize() { function startHtttpServer() { - if (CONSOLE_LOG === true) { console.log("[INFO] startHtttpServer -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> startHtttpServer -> Entering function."); } try { @@ -75,14 +75,14 @@ function startHtttpServer() { } } catch (err) { - console.log("[ERROR] startHtttpServer -> Error = " + err); + console.log("[ERROR] server -> startHtttpServer -> Error = " + err); } } function onBrowserRequest(request, response) { - if (CONSOLE_LOG === true) { console.log("[INFO] onBrowserRequest -> Entering function."); } - if (CONSOLE_LOG === true) { console.log("[INFO] onBrowserRequest -> request.url = " + request.url); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> request.url = " + request.url); } var htmlResponse; var requestParameters = request.url.split("/"); @@ -115,7 +115,7 @@ function onBrowserRequest(request, response) { function onFileRead(err, file) { - if (CONSOLE_LOG === true) { console.log("[INFO] onBrowserRequest -> onFileRead -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> onFileRead -> Entering function."); } try { @@ -138,7 +138,7 @@ function onBrowserRequest(request, response) { function addToFileContent(pDevTeamsOrHosts) { - if (CONSOLE_LOG === true) { console.log("[INFO] onBrowserRequest -> onFileRead -> addToFileContent -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> onFileRead -> addToFileContent -> Entering function."); } for (let i = 0; i < pDevTeamsOrHosts.length; i++) { @@ -174,7 +174,7 @@ function onBrowserRequest(request, response) { } catch (err) { - console.log("[ERROR] onBrowserRequest -> File Not Found: " + fileName + " or Error = " + err); + console.log("[ERROR] server -> onBrowserRequest -> File Not Found: " + fileName + " or Error = " + err); } } @@ -203,7 +203,7 @@ function onBrowserRequest(request, response) { function onFileRead(err, file) { - if (CONSOLE_LOG === true) { console.log("[INFO] onBrowserRequest -> onFileRead -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> onFileRead -> Entering function."); } try { @@ -226,7 +226,7 @@ function onBrowserRequest(request, response) { function addToFileContent(pDevTeamsOrHosts) { - if (CONSOLE_LOG === true) { console.log("[INFO] onBrowserRequest -> onFileRead -> addToFileContent -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> onFileRead -> addToFileContent -> Entering function."); } for (let i = 0; i < pDevTeamsOrHosts.length; i++) { @@ -267,7 +267,7 @@ function onBrowserRequest(request, response) { } catch (err) { - console.log("[ERROR] onBrowserRequest -> File Not Found: " + fileName + " or Error = " + err); + console.log("[ERROR] server -> onBrowserRequest -> File Not Found: " + fileName + " or Error = " + err); } } @@ -295,7 +295,7 @@ function onBrowserRequest(request, response) { function onFileRead(err, file) { - if (CONSOLE_LOG === true) { console.log("[INFO] onBrowserRequest -> onFileRead -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> onFileRead -> Entering function."); } try { @@ -308,7 +308,7 @@ function onBrowserRequest(request, response) { } catch (err) { - console.log("[ERROR] onBrowserRequest -> File Not Found: " + fileName + " or Error = " + err); + console.log("[ERROR] server -> onBrowserRequest -> File Not Found: " + fileName + " or Error = " + err); } } } @@ -326,9 +326,9 @@ function onBrowserRequest(request, response) { case 'Cloud': { - if (CONSOLE_LOG === true) { console.log("[INFO] onBrowserRequest -> readEcosystemConfig -> Cloud -> Entering Case."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> readEcosystemConfig -> Cloud -> Entering Case."); } - storage.getStorageData(requestParameters[2], requestParameters[3], requestParameters[4], onDataArrived) + storage.getStorageData(requestParameters[2], requestParameters[3], requestParameters[4], onDataArrived); function onDataArrived(pData) { @@ -341,7 +341,7 @@ function onBrowserRequest(request, response) { case 'File System': { - if (CONSOLE_LOG === true) { console.log("[INFO] onBrowserRequest -> readEcosystemConfig -> File System -> Entering Case."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> readEcosystemConfig -> File System -> Entering Case."); } respondWithFile('../Plotters/' + requestParameters[2] + '/' + requestParameters[3] + '/' + requestParameters[4], response); @@ -350,9 +350,9 @@ function onBrowserRequest(request, response) { case 'Github': { - if (CONSOLE_LOG === true) { console.log("[INFO] onBrowserRequest -> readEcosystemConfig -> Github -> Entering Case."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> readEcosystemConfig -> Github -> Entering Case."); } - github.getGithubData(requestParameters[2], requestParameters[3], requestParameters[4], onDataArrived) + github.getGithubData(requestParameters[2], requestParameters[3], requestParameters[4], onDataArrived); function onDataArrived(pData) { @@ -373,9 +373,9 @@ function onBrowserRequest(request, response) { case 'Cloud': { - if (CONSOLE_LOG === true) { console.log("[INFO] onBrowserRequest -> readEcosystemConfig -> Cloud -> Entering Case."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> readEcosystemConfig -> Cloud -> Entering Case."); } - storage.getStorageData(requestParameters[2], requestParameters[3], requestParameters[4], onDataArrived) + storage.getStorageData(requestParameters[2], requestParameters[3], requestParameters[4], onDataArrived); function onDataArrived(pData) { @@ -388,7 +388,7 @@ function onBrowserRequest(request, response) { case 'File System': { - if (CONSOLE_LOG === true) { console.log("[INFO] onBrowserRequest -> readEcosystemConfig -> File System -> Entering Case."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> readEcosystemConfig -> File System -> Entering Case."); } respondWithFile('../Plotters/' + requestParameters[2] + '/' + requestParameters[3] + '/' + requestParameters[4], response); @@ -397,9 +397,9 @@ function onBrowserRequest(request, response) { case 'Github': { - if (CONSOLE_LOG === true) { console.log("[INFO] onBrowserRequest -> readEcosystemConfig -> Github -> Entering Case."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> readEcosystemConfig -> Github -> Entering Case."); } - github.getGithubData(requestParameters[2], requestParameters[3], requestParameters[4], onDataArrived) + github.getGithubData(requestParameters[2], requestParameters[3], requestParameters[4], onDataArrived); function onDataArrived(pData) { @@ -459,7 +459,7 @@ function onBrowserRequest(request, response) { function onFileRead(err, file) { - if (CONSOLE_LOG === true) { console.log("[INFO] onBrowserRequest -> onFileRead -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> onFileRead -> Entering function."); } try { @@ -470,7 +470,7 @@ function onBrowserRequest(request, response) { function addPlotters() { - if (CONSOLE_LOG === true) { console.log("[INFO] onBrowserRequest -> onFileRead -> addPlotters -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> onFileRead -> addPlotters -> Entering function."); } let htmlLinePlotter = '' + '\n' + ' ' @@ -486,7 +486,7 @@ function onBrowserRequest(request, response) { function addScript(pDevTeamsOrHosts) { - if (CONSOLE_LOG === true) { console.log("[INFO] onBrowserRequest -> onFileRead -> addPlotters -> addScript -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> onFileRead -> addPlotters -> addScript -> Entering function."); } for (let i = 0; i < pDevTeamsOrHosts.length; i++) { @@ -542,7 +542,7 @@ function onBrowserRequest(request, response) { function addImages() { - if (CONSOLE_LOG === true) { console.log("[INFO] onBrowserRequest -> onFileRead -> addImages -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> onFileRead -> addImages -> Entering function."); } const htmlLine = '' + '\n' + ' ' @@ -553,7 +553,7 @@ function onBrowserRequest(request, response) { function addScript(pDevTeams) { - if (CONSOLE_LOG === true) { console.log("[INFO] onBrowserRequest -> onFileRead -> addImages -> addScript -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> onFileRead -> addImages -> addScript -> Entering function."); } for (let i = 0; i < pDevTeams.length; i++) { @@ -629,7 +629,7 @@ function onBrowserRequest(request, response) { } catch (err) { - console.log("[ERROR] onBrowserRequest -> File Not Found: " + fileName + " or Error = " + err); + console.log("[ERROR] server -> onBrowserRequest -> File Not Found: " + fileName + " or Error = " + err); } } } @@ -645,7 +645,7 @@ function onBrowserRequest(request, response) { function sendResponseToBrowser(htmlResponse) { - if (CONSOLE_LOG === true) { console.log("[INFO] onBrowserRequest -> sendResponseToBrowser -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> sendResponseToBrowser -> Entering function."); } response.writeHead(200, { 'Content-Type': 'text/html' }); response.write(htmlResponse); @@ -656,7 +656,7 @@ function onBrowserRequest(request, response) { function respondWithContent(content, response) { - if (CONSOLE_LOG === true) { console.log("[INFO] respondWithContent -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> respondWithContent -> Entering function."); } try { @@ -678,7 +678,7 @@ function respondWithContent(content, response) { function respondWithFile(fileName, response) { - if (CONSOLE_LOG === true) { console.log("[INFO] respondWithFile -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> respondWithFile -> Entering function."); } let fs = require('fs'); try { @@ -687,7 +687,7 @@ function respondWithFile(fileName, response) { function onFileRead(err, file) { - if (CONSOLE_LOG === true) { console.log("[INFO] respondWithFile -> onFileRead -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> respondWithFile -> onFileRead -> Entering function."); } try { let htmlResponse = file.toString(); @@ -706,7 +706,7 @@ function respondWithFile(fileName, response) { catch (err) { returnEmptyArray(); console.log("File Not Found: " + fileName); - console.log("[ERROR] respondWithFile -> onFileRead -> File Not Found: " + fileName + " or Error = " + err); + console.log("[ERROR] server -> respondWithFile -> onFileRead -> File Not Found: " + fileName + " or Error = " + err); } } @@ -717,7 +717,7 @@ function respondWithFile(fileName, response) { function returnEmptyArray() { - if (CONSOLE_LOG === true) { console.log("[INFO] respondWithFile -> returnEmptyArray -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] server -> respondWithFile -> returnEmptyArray -> Entering function."); } response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1. response.setHeader("Pragma", "no-cache"); // HTTP 1.0.