Partial commit for saweb-api migration

This commit is contained in:
Matias authored and Matias committed 2019-05-24 20:09:11 -03:00
1 parent 19044bda86
commit e4fc210f11
12 files changed
+193 -771

No files matched your search

+44 -38
View File
@@ -9,49 +9,55 @@
return thisObject;
function initialize(pServerConfig, storage, callBackFunction) {
function initialize(ecosystem, storage, callBackFunction) {
readSessions();
try {
// TODO Sessions need to be handled by the master app
function readSessions() {
const sessions = require('./config/sessions.json');
try {
storage.initialize(undefined, pServerConfig);
storage.readData("AdvancedAlgos", "AAPlatform", "open.sessions.json", false, onData);
function onData(err, pText) {
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
console.log("[ERROR] SessionManager -> initialize -> readSessions -> onData -> Could not read a file. ");
console.log("[ERROR] SessionManager -> initialize -> readSessions -> onData -> err.message = " + err.message);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
}
let sessions = JSON.parse(pText);
for (let i = 0; i < sessions.length; i++) {
let session = sessions[i];
activeSessions.set(session.sessionToken, session);
}
callBackFunction(global.DEFAULT_OK_RESPONSE);
}
for (let i = 0; i < sessions.length; i++) {
let session = sessions[i];
activeSessions.set(session.sessionToken, session);
}
catch (err) {
console.log("[ERROR] readSessions -> err = " + err.message);
console.log("[HINT] You need to have a file at this path -> " + filePath);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
callBackFunction(global.DEFAULT_OK_RESPONSE);
// storage.initialize(undefined, ecosystem);
// storage.readData("AdvancedAlgos", "AAPlatform", "open.sessions.json", false, onData);
// function onData(err, pText) {
// if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
// console.log("[ERROR] SessionManager -> initialize -> readSessions -> onData -> Could not read a file. ");
// console.log("[ERROR] SessionManager -> initialize -> readSessions -> onData -> err.message = " + err.message);
// callBackFunction(global.DEFAULT_FAIL_RESPONSE);
// return;
// }
// let sessions = JSON.parse(pText);
// for (let i = 0; i < sessions.length; i++) {
// let session = sessions[i];
// activeSessions.set(session.sessionToken, session);
// }
// callBackFunction(global.DEFAULT_OK_RESPONSE);
// }
}
catch (err) {
console.log("[ERROR] readSessions -> err = " + err.message);
console.log("[HINT] You need to have a file at this path -> " + filePath);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
function getSession(pSessionToken) {
@@ -59,4 +65,4 @@
return activeSessions.get(pSessionToken);
}
}
}