Session File read from the storage
This commit is contained in:
1 parent
3f6381be7a
commit
df34480ec6
6 files changed
+53
-40
No files matched your search
@@ -24,7 +24,7 @@
|
||||
|
||||
function getScript(pDevTeam, pSource, pRepo, pPath, callBackFunction) {
|
||||
|
||||
storage.getStorageData(pDevTeam + "/" + pSource, pRepo, pPath, false, onDataArrived);
|
||||
storage.getData(pDevTeam + "/" + pSource, pRepo, pPath, false, onDataArrived);
|
||||
|
||||
function onDataArrived(pData) {
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
*/
|
||||
|
||||
storage.getStorageData('AdvancedAlgos', 'AACloud', 'web.config.json', true, onDataArrived);
|
||||
storage.getData('AdvancedAlgos', 'AACloud', 'web.config.json', true, onDataArrived);
|
||||
|
||||
function onDataArrived(pData) {
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
|
||||
let webModule = pCloudWebConfig.webModules[i].name + '.js';
|
||||
|
||||
storage.getStorageData('AdvancedAlgos', 'AACloud', webModule, true, onDataArrived);
|
||||
storage.getData('AdvancedAlgos', 'AACloud', webModule, true, onDataArrived);
|
||||
|
||||
function onDataArrived(pData) {
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
|
||||
*/
|
||||
|
||||
storage.getStorageData('AdvancedAlgos', 'AAPlatform', 'ecosystem.json', true, onDataArrived);
|
||||
storage.getData('AdvancedAlgos', 'AAPlatform', 'ecosystem.json', true, onDataArrived);
|
||||
|
||||
function onDataArrived(pData) {
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
|
||||
requestsSent++;
|
||||
|
||||
storage.getStorageData(host.codeName + "/" + "competitions", competition.repo, competition.configFile, true, onDataArrived);
|
||||
storage.getData(host.codeName + "/" + "competitions", competition.repo, competition.configFile, true, onDataArrived);
|
||||
|
||||
function onDataArrived(pData) {
|
||||
|
||||
@@ -202,7 +202,7 @@
|
||||
|
||||
requestsSent++;
|
||||
|
||||
storage.getStorageData(host.codeName + "/" + "plotters", plotter.repo, plotter.configFile, true, onDataArrived);
|
||||
storage.getData(host.codeName + "/" + "plotters", plotter.repo, plotter.configFile, true, onDataArrived);
|
||||
|
||||
function onDataArrived(pData) {
|
||||
|
||||
@@ -291,7 +291,7 @@
|
||||
|
||||
requestsSent++;
|
||||
|
||||
storage.getStorageData(devTeam.codeName + "/" + "bots", bot.repo, bot.configFile, true, onDataArrived);
|
||||
storage.getData(devTeam.codeName + "/" + "bots", bot.repo, bot.configFile, true, onDataArrived);
|
||||
|
||||
function onDataArrived(pData) {
|
||||
|
||||
@@ -354,7 +354,7 @@
|
||||
|
||||
requestsSent++;
|
||||
|
||||
storage.getStorageData(devTeam.codeName + "/" + "plotters", plotter.repo, plotter.configFile, true, onDataArrived);
|
||||
storage.getData(devTeam.codeName + "/" + "plotters", plotter.repo, plotter.configFile, true, onDataArrived);
|
||||
|
||||
function onDataArrived(pData) {
|
||||
|
||||
|
||||
@@ -9,27 +9,35 @@
|
||||
|
||||
return thisObject;
|
||||
|
||||
function initialize(callBackFunction) {
|
||||
function initialize(pServerConfig, callBackFunction) {
|
||||
|
||||
readSessions();
|
||||
|
||||
function readSessions() {
|
||||
|
||||
try {
|
||||
let fs = require('fs');
|
||||
let filePath = '../' + 'Sessions' + '/' + 'Open.Sessions' + '.json';
|
||||
|
||||
let sessions = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
||||
const STORAGE = require('../Server/Storage');
|
||||
let storage = STORAGE.newStorage();
|
||||
|
||||
for (let i = 0; i < sessions.length; i++) {
|
||||
storage.initialize(undefined, pServerConfig);
|
||||
storage.getData("AdvancedAlgos", "AAPlatform", "Open.Sessions.json", false, onData);
|
||||
|
||||
let session = sessions[i];
|
||||
function onData(pText) {
|
||||
|
||||
activeSessions.set(session.sessionToken, session);
|
||||
let sessions = JSON.parse(pText);
|
||||
|
||||
for (let i = 0; i < sessions.length; i++) {
|
||||
|
||||
let session = sessions[i];
|
||||
|
||||
activeSessions.set(session.sessionToken, session);
|
||||
|
||||
}
|
||||
|
||||
callBackFunction();
|
||||
|
||||
}
|
||||
|
||||
callBackFunction();
|
||||
}
|
||||
catch (err) {
|
||||
console.log("[ERROR] readSessions -> err = " + err.message);
|
||||
|
||||
+25
-20
@@ -1,7 +1,7 @@
|
||||
exports.newStorage = function newStorage() {
|
||||
|
||||
let thisObject = {
|
||||
getStorageData: getStorageData,
|
||||
getData: getData,
|
||||
initialize: initialize
|
||||
}
|
||||
|
||||
@@ -17,26 +17,31 @@
|
||||
|
||||
}
|
||||
|
||||
function getStorageData(pOrg, pRepo, pPath, saveAtCache, callBackFunction) {
|
||||
function getData(pOrg, pRepo, pPath, saveAtCache, callBackFunction) {
|
||||
|
||||
try {
|
||||
|
||||
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); }
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getData -> Entering function."); }
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getData -> pOrg = " + pOrg); }
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getData -> pRepo = " + pRepo); }
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getData -> pPath = " + pPath); }
|
||||
|
||||
let cacheVersion = storageData.get(pOrg + '.' + pRepo + '.' + pPath)
|
||||
let cacheVersion;
|
||||
|
||||
if (storageData !== undefined) {
|
||||
|
||||
cacheVersion = storageData.get(pOrg + '.' + pRepo + '.' + pPath);
|
||||
}
|
||||
|
||||
if (cacheVersion !== undefined) {
|
||||
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getStorageData -> " + pOrg + '.' + pRepo + '.' + pPath + " found at cache."); }
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getData -> " + pOrg + '.' + pRepo + '.' + pPath + " found at cache."); }
|
||||
|
||||
callBackFunction(cacheVersion);
|
||||
|
||||
} else {
|
||||
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getStorageData -> " + pOrg + '.' + pRepo + '.' + pPath + " NOT found at cache."); }
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getData -> " + pOrg + '.' + pRepo + '.' + pPath + " NOT found at cache."); }
|
||||
|
||||
let storage = require('azure-storage');
|
||||
let connectionString;
|
||||
@@ -65,12 +70,12 @@
|
||||
|
||||
try {
|
||||
|
||||
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); }
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getData -> onFileReceived -> Entering function."); }
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getData -> onFileReceived -> err = " + JSON.stringify(err)); }
|
||||
if (LOG_FILE_CONTENT === true) { console.log("[INFO] Storage -> getData -> onFileReceived -> response = " + JSON.stringify(response)); }
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getData -> onFileReceived -> pOrg = " + pOrg); }
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getData -> onFileReceived -> pRepo = " + pRepo); }
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getData -> onFileReceived -> pPath = " + pPath); }
|
||||
|
||||
if (saveAtCache === true) {
|
||||
|
||||
@@ -80,9 +85,9 @@
|
||||
|
||||
if (err !== null || text === null) {
|
||||
|
||||
if (CONSOLE_LOG === true) { console.log("[ERROR] Storage -> getStorageData -> onFileReceived -> Error Received from Storage Library. "); }
|
||||
if (CONSOLE_LOG === true) { console.log("[ERROR] Storage -> getStorageData -> onFileReceived -> err = " + JSON.stringify(err)); }
|
||||
if (CONSOLE_LOG === true) { console.log("[ERROR] Storage -> getStorageData -> onFileReceived -> Returning an empty JSON object string. "); }
|
||||
if (CONSOLE_LOG === true) { console.log("[ERROR] Storage -> getData -> onFileReceived -> Error Received from Storage Library. "); }
|
||||
if (CONSOLE_LOG === true) { console.log("[ERROR] Storage -> getData -> onFileReceived -> err = " + JSON.stringify(err)); }
|
||||
if (CONSOLE_LOG === true) { console.log("[ERROR] Storage -> getData -> onFileReceived -> Returning an empty JSON object string. "); }
|
||||
|
||||
callBackFunction("");
|
||||
return;
|
||||
@@ -92,14 +97,14 @@
|
||||
callBackFunction(text);
|
||||
|
||||
} catch (err) {
|
||||
console.log("[ERROR] Storage -> getStorageData -> onFileReceived -> err.message = " + err.message);
|
||||
console.log("[ERROR] Storage -> getData -> onFileReceived -> err.message = " + err.message);
|
||||
callBackFunction("{}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.log("[ERROR] Storage -> getStorageData -> err.message = " + err.message);
|
||||
console.log("[ERROR] Storage -> getData -> err.message = " + err.message);
|
||||
callBackFunction("{}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ function initialize() {
|
||||
const SESSION_MANAGER = require('./Server/SessionManager');
|
||||
sessionManager = SESSION_MANAGER.newSessionManager();
|
||||
|
||||
sessionManager.initialize(onInitialized);
|
||||
sessionManager.initialize(serverConfig, onInitialized);
|
||||
|
||||
function onInitialized() {
|
||||
|
||||
@@ -800,7 +800,7 @@ function onBrowserRequest(request, response) {
|
||||
case "Plotters": // This means the plotter folder, not to be confused with the Plotters script!
|
||||
{
|
||||
|
||||
storage.getStorageData(requestParameters[2] + "/" + "plotters", requestParameters[3], requestParameters[4], true, onDataArrived);
|
||||
storage.getData(requestParameters[2] + "/" + "plotters", requestParameters[3], requestParameters[4], true, onDataArrived);
|
||||
|
||||
function onDataArrived(pData) {
|
||||
|
||||
@@ -812,7 +812,7 @@ function onBrowserRequest(request, response) {
|
||||
|
||||
case "PlotterPanels": // This means the PlotterPanels folder, not to be confused with the Plotter Panels scripts!
|
||||
{
|
||||
storage.getStorageData(requestParameters[2] + "/" + "plotters", requestParameters[3], requestParameters[4], true, onDataArrived);
|
||||
storage.getData(requestParameters[2] + "/" + "plotters", requestParameters[3], requestParameters[4], true, onDataArrived);
|
||||
|
||||
function onDataArrived(pData) {
|
||||
|
||||
|
||||
Reference in new issue
Block a user