Session File read from the storage

This commit is contained in:
Luis Fernando Molina committed 2018-06-30 11:23:57 +02:00
1 parent 3f6381be7a
commit df34480ec6
6 files changed
+53 -40

No files matched your search

+25 -20
View File
@@ -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("{}");
}
}