Merge pull request #12 from AAMasters/develop

Minio Implemented
This commit is contained in:
benme authored and GitHub committed 2019-04-09 11:33:39 +02:00
commit c5dbccca5e
11 files changed
+522 -153

No files matched your search

-61
View File
@@ -1,61 +0,0 @@
exports.newBotCode = function newBotCode() {
let thisObject = {
saveBotCode: saveBotCode,
initialize: initialize
}
let storage;
return thisObject;
function initialize(pServerConfig) {
const STORAGE = require('../Server/Storage');
storage = STORAGE.newStorage();
storage.initialize(undefined, pServerConfig);
}
function saveBotCode(pDevTeam, pSource, pRepo, pPath, pSourceCode, callBackFunction) {
let blobText = nodify(pSourceCode.toString());
storage.writeData(pDevTeam + "/" + pSource, pRepo, pPath, blobText, onDataWritten);
function onDataWritten(err) {
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
console.log("[ERROR] API -> saveBotCode -> Source code file could not be saved. ");
console.log("[ERROR] API -> saveBotCode -> err.message = " + err.message);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
}
callBackFunction(global.DEFAULT_OK_RESPONSE);
}
}
function nodify(pData) {
let start = pData.indexOf('function') + 9;
let end = pData.indexOf('(') + 0;
let functionName = pData.substring(start, end);
let result = "exports." + functionName + " = " + pData;
result = replaceAll(result, "webRequire", "require");
result = replaceAll(result, "window", "global");
return result;
function replaceAll(text, search, replacement) {
return text.replace(new RegExp(search, 'g'), replacement);
}
}
}
+2 -5
View File
@@ -12,13 +12,10 @@
return thisObject;
function initialize(pServerConfig) {
function initialize(pServerConfig, pStorage) {
const STORAGE = require('../Server/Storage');
storage = STORAGE.newStorage();
masterAppServerURL = pServerConfig.masterAppServerURL;
storage = pStorage;
storage.initialize(undefined, pServerConfig);
}
function newTeam(pTeamCodeName, pTeamDisplayName, pUserName, pBotCodeName, pBotDisplayName, pUserId, callBackFunction) {
+4 -6
View File
@@ -30,9 +30,6 @@
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Compile Include="AABrowserAPI\BotCode.js">
<SubType>Code</SubType>
</Compile>
<Compile Include="AABrowserAPI\CopySimulator.js" />
<Compile Include="AABrowserAPI\TeamSetup.js">
<SubType>Code</SubType>
@@ -44,6 +41,7 @@
<Compile Include="Ecosystem.js" />
<Compile Include="Plotter.js" />
<Compile Include="PlotterPanel.js" />
<Compile Include="Server\BotsScripts.js" />
<Compile Include="Server\Exchange\ExchangeAPI.js" />
<Compile Include="Server\Exchange\exchangeUtils.js" />
<Compile Include="Server\Exchange\Wrappers\beautifier.js" />
@@ -57,13 +55,13 @@
<Compile Include="Scripts\AppPreLoader.js">
<SubType>Code</SubType>
</Compile>
<Compile Include="Server\BotsScripts.js">
<Compile Include="Server\MinioStorage.js">
<SubType>Code</SubType>
</Compile>
<Compile Include="Server\SessionManager.js">
<SubType>Code</SubType>
</Compile>
<Compile Include="Server\StorageAccessManager.js">
<Compile Include="Server\AzureStorageAccessManager.js">
<SubType>Code</SubType>
</Compile>
<Compile Include="Scripts\require.js" />
@@ -73,7 +71,7 @@
<Compile Include="Server\Github.js">
<SubType>Code</SubType>
</Compile>
<Compile Include="Server\Storage.js">
<Compile Include="Server\AzureStorage.js">
<SubType>Code</SubType>
</Compile>
<Compile Include="server.js" />
+47
View File
@@ -136,3 +136,50 @@ function callServer(pContentToSend, pPath, callBackFunction) {
}
}
}
function newFileStorage() {
thisObject = {
getBlobToText: getBlobToText
};
return thisObject;
function getBlobToText(pContainerName, pPath, callBackFunction) {
let xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState === 4 && this.status === 200) {
let response = JSON.parse(xhttp.responseText);
callBackFunction(response.err, response.text, "");
}
};
try {
let request = {
conatinerName: pContainerName,
path: pPath
};
request = JSON.stringify(request);
let path = "FileService";
let blob = new Blob([request], { type: 'text/plain' });
xhttp.open("POST", path, true);
xhttp.send(blob);
} catch (err) {
if (ERROR_LOG === true) { console.log(spacePad(MODULE_NAME, 50) + " : " + "[ERROR] getBlobToText -> err.message = " & err.message); }
}
}
}
+59 -3
View File
@@ -1,4 +1,4 @@
exports.newStorage = function newStorage() {
exports.newAzureStorage = function newAzureStorage() {
let thisObject = {
readData: readData,
@@ -12,13 +12,24 @@
let storageData;
let serverConfig;
let Minio = require('minio');
let minioClient;
return thisObject;
function initialize(pStorageData, pServerConfig) {
storageData = pStorageData;
serverConfig = pServerConfig;
minioClient = new Minio.Client({
endPoint: process.env.MINIO_END_POINT,
port: JSON.parse(process.env.MINIO_PORT),
useSSL: JSON.parse(process.env.MINIO_USE_SSL),
accessKey: process.env.MINIO_ACCESS_KEY,
secretKey: process.env.MINIO_SECRET_KEY
})
}
function readData(pOrg, pPath, pFile, saveAtCache, callBackFunction) {
@@ -67,7 +78,35 @@
let blobService = storage.createBlobService(connectionString);
blobService.getBlobToText('aaplatform', pOrg + "/" + pPath + "/" + pFile, onFileReceived);
let pParam1 = pOrg;
let pParam2 = pPath;
let pParam3 = pFile;
let container = 'aaplatform';
let azurePath = pOrg + "/" + pPath + "/" + pFile;
let bucketName = 'aaplatform';
let textFilename;
if (pParam1 === undefined) {
/* This is used when the requests come from the browser, for background compatibility. */
container = pParam3;
azurePath = pParam2;
bucketName = pParam3;
textFilename = pParam2.substring(pParam2.indexOf("/") + 1, pParam2.length);
} else {
/* This is used for internal requests within AAWeb, for background compatibility. */
bucketName = 'aaplatform';
textFilename = pParam1 + "/" + pParam2 + "/" + pParam3;
}
blobService.getBlobToText(container, azurePath, onFileReceived);
function onFileReceived(err, text, response) {
@@ -98,6 +137,23 @@
}
/* TEMPORARY CODE TO UPDATE THE MINIO SERVER DURING TRANSITION. */
try {
minioClient.putObject(bucketName, textFilename, text, 'text/plain', function (err) {
if (err) {
console.log("ERROR AT MINIO SERVER PUTTING OBJECT : " + err);
return;
}
console.log(textFilename + ' Successfully uploaded ' + textFilename + ' the MINIO SERVER');
})
} catch (err) {
console.log("ERROR UPDATING MINIO SERVER : " + err);
}
callBackFunction(global.DEFAULT_OK_RESPONSE, text);
} catch (err) {
@@ -1,4 +1,4 @@
exports.newStorageAccessManager = function newStorageAccessManager() {
exports.newAzureStorageAccessManager = function newAzureStorageAccessManager() {
let thisObject = {
getPermission: getPermission,
+4 -3
View File
@@ -5,15 +5,16 @@
initialize: initialize
}
const STORAGE = require('../Server/Storage');
let storage = STORAGE.newStorage();
let storage;
let serverConfig;
let storageData;
return thisObject;
function initialize(pServerConfig, callBackFunction) {
function initialize(pServerConfig, pStorage, callBackFunction) {
storage = pStorage;
let storageData = new Map(); // For backwards compatibility only. Not used.
+3 -3
View File
@@ -8,8 +8,7 @@
const GITHUB = require('../Server/Github');
let github = GITHUB.newGithub();
const STORAGE = require('../Server/Storage');
let storage = STORAGE.newStorage();
let storage;
let serverConfig;
let storageData;
@@ -18,8 +17,9 @@
return thisObject;
function initialize(pEcosystem, pEcosystemObject, pStorageData, callBackFunction) {
function initialize(pEcosystem, pEcosystemObject, pStorageData, pStorage, callBackFunction) {
storage = pStorage;
storageData = pStorageData;
ecosystem = pEcosystem;
ecosystemObject = pEcosystemObject;
+351
View File
@@ -0,0 +1,351 @@
exports.newMinioStorage = function newMinioStorage() {
let thisObject = {
readData: readData,
writeData: writeData,
createContainer: createContainer,
deleteContainer: deleteContainer,
deleteBlob: deleteBlob,
initialize: initialize
}
let storageData;
let serverConfig;
let Minio = require('minio');
let minioClient;
return thisObject;
function initialize(pStorageData, pServerConfig) {
storageData = pStorageData;
serverConfig = pServerConfig;
minioClient = new Minio.Client({
endPoint: process.env.MINIO_END_POINT,
port: JSON.parse(process.env.MINIO_PORT),
useSSL: JSON.parse(process.env.MINIO_USE_SSL),
accessKey: process.env.MINIO_ACCESS_KEY,
secretKey: process.env.MINIO_SECRET_KEY
})
}
function readData(pParam1, pParam2, pParam3, saveAtCache, callBackFunction) {
try {
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> readData -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> readData -> pParam1 = " + pParam1); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> readData -> pParam2 = " + pParam2); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> readData -> pParam3 = " + pParam3); }
let cacheVersion;
if (storageData !== undefined) {
cacheVersion = storageData.get(pParam1 + '.' + pParam2 + '.' + pParam3);
}
if (cacheVersion !== undefined) {
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> readData -> " + pParam1 + '.' + pParam2 + '.' + pParam3 + " found at cache."); }
callBackFunction(global.DEFAULT_OK_RESPONSE, cacheVersion);
} else {
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> readData -> " + pParam1 + '.' + pParam2 + '.' + pParam3 + " NOT found at cache."); }
let bucketName = 'aaplatform';
let textFilename;
if (pParam1 === undefined) {
/* This is used when the requests come from the browser, for background compatibility. */
bucketName = pParam3;
textFilename = pParam2.substring(pParam2.indexOf("/") + 1, pParam2.length);
} else {
/* This is used for internal requests within AAWeb, for background compatibility. */
bucketName = 'aaplatform';
textFilename = pParam1 + "/" + pParam2 + "/" + pParam3;
}
minioClient.getObject(bucketName, textFilename, function (err, dataStream) {
let data = '';
if (err) {
onFileReceived(err, null, "Error retrieving file " + textFilename + " from bucket " + bucketName);
return
}
dataStream.on('data', function (chunk) {
data += chunk
})
dataStream.on('end', function () {
onFileReceived(null, data, "Data retrieved.");
})
dataStream.on('error', function (err) {
onFileReceived(err, null, "Error on data stream while retrieving file " + textFilename + " from bucket " + bucketName);
})
})
function onFileReceived(err, text, response) {
try {
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> readData -> onFileReceived -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> readData -> onFileReceived -> err = " + JSON.stringify(err)); }
if (LOG_FILE_CONTENT === true) { console.log("[INFO] Storage -> readData -> onFileReceived -> response = " + JSON.stringify(response)); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> readData -> onFileReceived -> pParam1 = " + pParam1); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> readData -> onFileReceived -> pParam2 = " + pParam2); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> readData -> onFileReceived -> pParam3 = " + pParam3); }
if (saveAtCache === true) {
storageData.set(pParam1 + '.' + pParam2 + '.' + pParam3, text);
}
if (err !== null || text === null) {
if (CONSOLE_ERROR_LOG === true) { console.log("[ERROR] Storage -> readData -> onFileReceived -> Error Received from Storage Library. "); }
if (CONSOLE_ERROR_LOG === true) { console.log("[ERROR] Storage -> readData -> onFileReceived -> err = " + JSON.stringify(err)); }
if (CONSOLE_ERROR_LOG === true) { console.log("[ERROR] Storage -> readData -> onFileReceived -> Returning an empty JSON object string. "); }
if (err.code === 'NoSuchKey') {
let customErr = {
result: GLOBAL.CUSTOM_FAIL_RESPONSE.result,
message: 'FileNotFound',
code: 'FileNotFound'
}
callBackFunction(customErr);
return;
}
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
}
callBackFunction(global.DEFAULT_OK_RESPONSE, text);
} catch (err) {
console.log("[ERROR] Storage -> readData -> onFileReceived -> err.message = " + err.message);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
}
} catch (err) {
console.log("[ERROR] Storage -> readData -> err.message = " + err.message);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
function writeData(pParam1, pParam2, pParam3, pFileContent, callBackFunction) {
try {
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> writeData -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> writeData -> pParam1 = " + pParam1); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> writeData -> pParam2 = " + pParam2); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> writeData -> pParam3 = " + pParam3); }
let bucketName = 'aaplatform';
let text = pFileContent.toString();
let textFilename = pParam1 + "/" + pParam2 + "/" + pParam3;
minioClient.putObject(bucketName, textFilename, text, 'text/plain', onFileCreated)
function onFileCreated(err, text, response) {
try {
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> writeData -> onFileCreated -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> writeData -> onFileCreated -> err = " + JSON.stringify(err)); }
if (LOG_FILE_CONTENT === true) { console.log("[INFO] Storage -> writeData -> onFileCreated -> response = " + JSON.stringify(response)); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> writeData -> onFileCreated -> pParam1 = " + pParam1); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> writeData -> onFileCreated -> pParam2 = " + pParam2); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> writeData -> onFileCreated -> pParam3 = " + pParam3); }
if (err !== null || text === null) {
if (CONSOLE_ERROR_LOG === true) { console.log("[ERROR] Storage -> writeData -> onFileCreated -> Error Received from Storage Library. "); }
if (CONSOLE_ERROR_LOG === true) { console.log("[ERROR] Storage -> writeData -> onFileCreated -> err = " + JSON.stringify(err)); }
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
}
callBackFunction(global.DEFAULT_OK_RESPONSE);
} catch (err) {
console.log("[ERROR] Storage -> writeData -> onFileCreated -> err.message = " + err.message);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
} catch (err) {
console.log("[ERROR] Storage -> writeData -> err.message = " + err.message);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
function deleteBlob(pParam1, pParam2, pParam3, callBackFunction) {
try {
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> deleteBlob -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> deleteBlob -> pParam1 = " + pParam1); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> deleteBlob -> pParam2 = " + pParam2); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> deleteBlob -> pParam3 = " + pParam3); }
let bucketName = 'aaplatform';
let textFilename = pParam1 + "/" + pParam2 + "/" + pParam3;
minioClient.removeObject(bucketName, textFilename, onBlobDeleted)
function onBlobDeleted(err, text, response) {
try {
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> deleteBlob -> onBlobDeleted -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> deleteBlob -> onBlobDeleted -> err = " + JSON.stringify(err)); }
if (LOG_FILE_CONTENT === true) { console.log("[INFO] Storage -> deleteBlob -> onBlobDeleted -> response = " + JSON.stringify(response)); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> deleteBlob -> onBlobDeleted -> pParam1 = " + pParam1); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> deleteBlob -> onBlobDeleted -> pParam2 = " + pParam2); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> deleteBlob -> onBlobDeleted -> pParam3 = " + pParam3); }
if (err !== null || text === null) {
if (CONSOLE_ERROR_LOG === true) { console.log("[ERROR] Storage -> deleteBlob -> onBlobDeleted -> Error Received from Storage Library. "); }
if (CONSOLE_ERROR_LOG === true) { console.log("[ERROR] Storage -> deleteBlob -> onBlobDeleted -> err = " + JSON.stringify(err)); }
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
}
callBackFunction(global.DEFAULT_OK_RESPONSE);
} catch (err) {
console.log("[ERROR] Storage -> deleteBlob -> onBlobDeleted -> err.message = " + err.message);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
} catch (err) {
console.log("[ERROR] Storage -> deleteBlob -> err.message = " + err.message);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
function createContainer(pContainerName, callBackFunction) {
try {
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> createContainer -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> createContainer -> pContainerName = " + pContainerName); }
let containerName = pContainerName.toLowerCase();
minioClient.makeBucket(containerName, "", onContainerCreated)
function onContainerCreated(err) {
if (err) {
if (CONSOLE_ERROR_LOG === true) { console.log("[ERROR] Storage -> createContainer -> onContainerCreated -> Error Received from Storage Library. "); }
if (CONSOLE_ERROR_LOG === true) { console.log("[ERROR] Storage -> createContainer -> onContainerCreated -> err = " + JSON.stringify(err)); }
/* ContainerAlreadyExists check */
if (JSON.stringify(err).indexOf("ContainerAlreadyExists") > 0) {
let err = {
resutl: global.CUSTOM_FAIL_RESPONSE.result,
message: "ContainerAlreadyExists"
};
callBackFunction(err);
return;
} else {
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
}
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
}
callBackFunction(global.DEFAULT_OK_RESPONSE);
return;
}
} catch (err) {
console.log("[ERROR] Storage -> createContainer -> err.message = " + err.message);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
function deleteContainer(pContainerName, callBackFunction) {
try {
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> deleteContainer -> Entering function."); }
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> deleteContainer -> pContainerName = " + pContainerName); }
let containerName = pContainerName.toLowerCase();
minioClient.removeBucket(containerName, onContainerDeleted)
function onContainerDeleted(err) {
if (err) {
if (CONSOLE_ERROR_LOG === true) { console.log("[ERROR] Storage -> deleteContainer -> onContainerDeleted -> Error Received from Storage Library. "); }
if (CONSOLE_ERROR_LOG === true) { console.log("[ERROR] Storage -> deleteContainer -> onContainerDeleted -> err = " + JSON.stringify(err)); }
/* ContainerAlreadyExists check */
if (JSON.stringify(err).indexOf("ContainerNotFound") > 0) {
let err = {
resutl: global.CUSTOM_FAIL_RESPONSE.result,
message: "ContainerNotFound"
};
callBackFunction(err);
return;
} else {
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
}
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
}
callBackFunction(global.DEFAULT_OK_RESPONSE);
return;
}
} catch (err) {
console.log("[ERROR] Storage -> deleteContainer -> err.message = " + err.message);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
}
+1 -4
View File
@@ -9,7 +9,7 @@
return thisObject;
function initialize(pServerConfig, callBackFunction) {
function initialize(pServerConfig, storage, callBackFunction) {
readSessions();
@@ -17,9 +17,6 @@
try {
const STORAGE = require('../Server/Storage');
let storage = STORAGE.newStorage();
storage.initialize(undefined, pServerConfig);
storage.readData("AdvancedAlgos", "AAPlatform", "open.sessions.json", false, onData);
+50 -67
View File
@@ -36,34 +36,6 @@ global.CUSTOM_FAIL_RESPONSE = {
message: 'Custom Message'
}
/*
var Minio = require('minio')
var minioClient = new Minio.Client({
endPoint: 'niksadvancedalgos.ovh',
port: 80,
useSSL: false,
accessKey: 'luis1234',
secretKey: '123456789'
})
const stage = 'textUpload'
const bucketName = 'test-bucket'
const textFilename = 'test.json'
/*
if (stage === 'textUpload') {
var str = 'some string you want to save'
minioClient.putObject(bucketName, textFilename, str, 'text/plain', function (e) {
if (e) {
return console.log(e)
}
console.log('Successfully uploaded the string')
})
}
return
*/
let storageData = new Map()
let botScripts // This module is the one which grabs user bots scrips from the storage, and browserifys them.
@@ -77,8 +49,23 @@ let port = process.env.PORT || 1337
let isHttpServerStarted = false
const STORAGE = require('./Server/Storage')
let storage = STORAGE.newStorage()
const AZURE_STORAGE = require('./Server/AzureStorage')
const MINIO_STORAGE = require('./Server/MinioStorage')
switch (process.env.STORAGE_PROVIDER) {
case 'Azure': {
storage = AZURE_STORAGE.newAzureStorage();
break;
}
case 'Minio': {
storage = MINIO_STORAGE.newMinioStorage();
break;
}
default: {
console.log('[ERROR] server -> Storage Provider not supported -> process.env.STORAGE_PROVIDER = ' + process.env.STORAGE_PROVIDER)
return;
}
}
let sessionManager // This module have all authenticated active sessions.
let storageAccessManager // This module manages the SAS for user to access the cloud storage from the browser.
@@ -95,7 +82,7 @@ function initialize () {
const CONFIG_READER = require('./Server/ConfigReader')
let configReader = CONFIG_READER.newConfigReader()
configReader.initialize(ecosystem, ecosystemObject, storageData, onInitialized)
configReader.initialize(ecosystem, ecosystemObject, storageData, storage, onInitialized)
function onInitialized (err, pServerConfig) {
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
@@ -125,11 +112,11 @@ function initialize () {
const SESSION_MANAGER = require('./Server/SessionManager')
sessionManager = SESSION_MANAGER.newSessionManager()
sessionManager.initialize(serverConfig, onInitialized)
sessionManager.initialize(serverConfig, storage, onInitialized)
function onInitialized () {
const STORAGE_ACCESS_MANAGER = require('./Server/StorageAccessManager')
storageAccessManager = STORAGE_ACCESS_MANAGER.newStorageAccessManager()
const STORAGE_ACCESS_MANAGER = require('./Server/AzureStorageAccessManager')
storageAccessManager = STORAGE_ACCESS_MANAGER.newAzureStorageAccessManager()
storageAccessManager.initialize(serverConfig, onInitialized)
@@ -137,7 +124,7 @@ function initialize () {
const BOT_SCRIPTS = require('./Server/BotsScripts')
botScripts = BOT_SCRIPTS.newBotScripts()
botScripts.initialize(serverConfig, onInitialized)
botScripts.initialize(serverConfig, storage, onInitialized)
function onInitialized () {
startHtttpServer()
@@ -203,7 +190,32 @@ function onBrowserRequest (request, response) {
respondWithFile(filePath, response)
break;
}
}
case 'FileService':
{
processPost(request, response, onPostReceived)
function onPostReceived(pData) {
let request = JSON.parse(pData);
storage.readData(undefined, request.path, request.conatinerName, false, onReady)
function onReady(err, pFileContent) {
let responseToClient = {
err: err,
text: pFileContent
};
respondWithContent(JSON.stringify(responseToClient), response);
}
}
break;
}
case 'Plotter.js':
{
/*
@@ -475,35 +487,6 @@ function onBrowserRequest (request, response) {
{
switch (requestParameters[2]) {
case 'saveBotCode': {
const AABROWSER_API_BOT_CODE = require('./AABrowserAPI/' + 'BotCode')
let botCode = AABROWSER_API_BOT_CODE.newBotCode()
botCode.initialize(serverConfig)
processPost(request, response, onPostReceived)
function onPostReceived (pData) {
let devTeam = requestParameters[3]
let source = requestParameters[4] + '/' + requestParameters[5]
let repo = requestParameters[6]
let path
if (requestParameters[8] !== undefined) {
path = requestParameters[7] + '/' + requestParameters[8]
} else {
path = requestParameters[7]
}
botCode.saveBotCode(devTeam, source, repo, path, pData, onResponse)
function onResponse (err) {
respondWithContent(JSON.stringify(err), response)
}
}
break
}
case "authenticateUser": {
const AABROWSER_API_USER_AUTHENTICATION = require('./AABrowserAPI/' + 'UserAuthentication');
@@ -530,7 +513,7 @@ function onBrowserRequest (request, response) {
const AABROWSER_API_TEAM_SETUP = require('./AABrowserAPI/' + 'TeamSetup');
let teamSetup = AABROWSER_API_TEAM_SETUP.newTeamSetup();
teamSetup.initialize(serverConfig);
teamSetup.initialize(serverConfig, storage);
let devTeamCodeName = decodeURI(requestParameters[3]);
let devTeamDisplayName = decodeURI(requestParameters[4]);
@@ -575,7 +558,7 @@ function onBrowserRequest (request, response) {
const AABROWSER_API_TEAM_SETUP = require('./AABrowserAPI/' + 'TeamSetup')
let teamSetup = AABROWSER_API_TEAM_SETUP.newTeamSetup()
teamSetup.initialize(serverConfig)
teamSetup.initialize(serverConfig, storage)
let devTeamCodeName = decodeURI(requestParameters[3])
let userName = decodeURI(requestParameters[4])