From 7a4843b73864842888d9ddae37035ba2ef115282 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 30 Oct 2018 12:47:07 +0100 Subject: [PATCH] deleteTeam Method Implemented --- AABrowserAPI/TeamSetup.js | 494 ++++++++++++++++++++++++++++++++++++++ Project.njsproj | 2 - Server/Storage.js | 139 +++++++++++ server.js | 31 ++- 4 files changed, 663 insertions(+), 3 deletions(-) diff --git a/AABrowserAPI/TeamSetup.js b/AABrowserAPI/TeamSetup.js index 98a903ac8..f9051bfdc 100644 --- a/AABrowserAPI/TeamSetup.js +++ b/AABrowserAPI/TeamSetup.js @@ -2,6 +2,7 @@ let thisObject = { newTeam: newTeam, + deleteTeam: deleteTeam, initialize: initialize } @@ -658,4 +659,497 @@ } } + + function deleteTeam(pTeamCodeName, pUserName, pBotCodeName, pAuthId, callBackFunction) { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] TeamSetup -> deleteTeam -> Entering function."); } + + deleteContainer(); + + function deleteContainer() { + + if (CONSOLE_LOG === true) { console.log("[INFO] TeamSetup -> deleteTeam -> deleteContainer -> Entering function."); } + + storage.deleteContainer(pTeamCodeName, onContainerDeleted); + + function onContainerDeleted(err) { + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteContainer -> onContainerDeleted -> Could not delete the container. "); + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteContainer -> onContainerDeleted -> err.message = " + err.message); + + if (err.message === "ContainerNotFound") { + + let error = { + result: err.result, + message: "Team does not exist" + }; + + deleteBotCode(); // Even if the container does not exist we will try to delete the rest of the stuff related to the team. + + } else { + + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + + } + return; + } + + deleteBotCode(); + } + } + + function deleteBotCode() { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] TeamSetup -> deleteTeam -> deleteBotCode -> Entering function."); } + + let team = pTeamCodeName; + let filePath = "bots" + "/" + pBotCodeName + "-Trading-Bot/Trading-Process"; + let fileName = "User.Bot.js"; + + storage.deleteBlob(team, filePath, fileName, onBlobDeleted); + + function onBlobDeleted(err) { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] TeamSetup -> deleteTeam -> deleteBotCode -> onBlobDeleted -> Entering function."); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteBotCode -> onBlobDeleted -> Could not delete a file. "); + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteBotCode -> onBlobDeleted -> err.message = " + err.message); + + // Even if this failed we will try to delete the rest of the stuff related to the team. + } + + let team = pTeamCodeName; + let filePath = "members" + "/" + pUserName + "/" + pBotCodeName + "-Trading-Bot/Trading-Process"; + let fileName = "User.Bot.js"; + + storage.deleteBlob(team, filePath, fileName, onBlobDeleted); + + function onBlobDeleted(err) { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] TeamSetup -> deleteTeam -> deleteBotCode -> onBlobDeleted -> Entering function."); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteBotCode -> onBlobDeleted -> onBlobDeleted -> Could not delete a file. "); + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteBotCode -> onBlobDeleted -> onBlobDeleted -> err.message = " + err.message); + + // Even if this failed we will try to delete the rest of the stuff related to the team. + } + + deleteBotConfig(); + + } catch (err) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteBotCode -> onBlobDeleted -> err.message = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + + } + } + + } catch (err) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteBotCode -> onBlobDeleted -> err.message = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + + } + } + + } catch (err) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteBotCode -> err.message = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + + } + + } + + function deleteBotConfig() { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] TeamSetup -> deleteTeam -> deleteBotConfig -> Entering function."); } + + let team = pTeamCodeName; + let filePath = "bots" + "/" + pBotCodeName + "-Trading-Bot"; + let fileName = "this.bot.config.json"; + + storage.deleteBlob(team, filePath, fileName, onBlobDeleted); + + function onBlobDeleted(err) { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] TeamSetup -> deleteTeam -> deleteBotConfig -> onBlobDeleted -> Entering function."); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteBotConfig -> onBlobDeleted -> Could not delete a file. "); + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteBotConfig -> onBlobDeleted -> err.message = " + err.message); + + // Even if this failed we will try to delete the rest of the stuff related to the team. + } + + let team = pTeamCodeName; + let filePath = "members" + "/" + pUserName + "/" + pBotCodeName + "-Trading-Bot"; + let fileName = "this.bot.config.json"; + + storage.deleteBlob(team, filePath, fileName, onBlobDeleted); + + function onBlobDeleted(err) { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] TeamSetup -> deleteTeam -> deleteBotConfig -> onBlobDeleted -> Entering function."); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteBotConfig -> onBlobDeleted -> onBlobDeleted -> Could not delete a file. "); + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteBotConfig -> onBlobDeleted -> onBlobDeleted -> err.message = " + err.message); + + // Even if this failed we will try to delete the rest of the stuff related to the team. + } + + deleteAACloud(); + + } catch (err) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteBotConfig -> onBlobDeleted -> err.message = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + + } + } + + } catch (err) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteBotConfig -> onBlobDeleted -> err.message = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + + } + } + + } catch (err) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteBotConfig -> err.message = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + + } + + } + + function deleteAACloud() { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] TeamSetup -> deleteTeam -> deleteAACloud -> Entering function."); } + + let team = pTeamCodeName; + let filePath = "AACloud"; + let fileName = "this.config.json"; + + storage.deleteBlob(team, filePath, fileName, onBlobDeleted); + + function onBlobDeleted(err) { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] TeamSetup -> deleteTeam -> deleteAACloud -> onBlobDeleted -> Entering function."); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteAACloud -> onBlobDeleted -> Could not delete a file. "); + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteAACloud -> onBlobDeleted -> err.message = " + err.message); + + // Even if this failed we will try to delete the rest of the stuff related to the team. + } + + let team = pTeamCodeName; + let filePath = "members" + "/" + pUserName + "/" + "AACloud"; + let fileName = "this.config.json"; + + storage.deleteBlob(team, filePath, fileName, onBlobDeleted); + + function onBlobDeleted(err) { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] TeamSetup -> deleteTeam -> deleteAACloud -> onBlobDeleted -> Entering function."); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteAACloud -> onBlobDeleted -> onBlobDeleted -> Could not delete a file. "); + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteAACloud -> onBlobDeleted -> onBlobDeleted -> err.message = " + err.message); + + // Even if this failed we will try to delete the rest of the stuff related to the team. + } + + removeFromSessions(); + + } catch (err) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteAACloud -> onBlobDeleted -> err.message = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + + } + } + + } catch (err) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteAACloud -> onBlobDeleted -> err.message = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + + } + } + + } catch (err) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> deleteAACloud -> err.message = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + + } + + } + + function removeFromSessions() { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] TeamSetup -> deleteTeam -> removeFromSessions -> Entering function."); } + + storage.readData("AdvancedAlgos", "AAPlatform", "open.sessions.json", false, onDataRead); + + function onDataRead(err, pFileContent) { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] TeamSetup -> deleteTeam -> removeFromSessions -> onDataRead -> Entering function."); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> removeFromSessions -> onDataRead -> Could not read a file. "); + console.log("[ERROR] TeamSetup -> deleteTeam -> removeFromSessions -> onDataRead -> err.message = " + err.message); + + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + return; + } + + pFileContent = pFileContent.trim(); + let sessions = JSON.parse(pFileContent); + + for (let i = 0; i < sessions.length; i++) { + + let session = sessions[i]; + + if (session.userName === pUserName && session.devTeams[0].codeName === pTeamCodeName) { + + // Found it! Deleting... + + sessions.splice(i, 1); + break; + } + + } + + let fileContent = JSON.stringify(sessions); + + storage.writeData("AdvancedAlgos", "AAPlatform", "open.sessions.json", fileContent, onDataWritten); + + removeFromUserModuleDatabase(""); // NOTE that this function is not properly inserted on the sequence, so if it fails noone will know. + + function onDataWritten(err) { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] TeamSetup -> deleteTeam -> removeFromSessions -> onDataRead -> onDataWritten -> Entering function."); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> removeFromSessions -> onDataRead -> onDataWritten -> Could not write a file. "); + console.log("[ERROR] TeamSetup -> deleteTeam -> removeFromSessions -> onDataRead -> onDataWritten -> err.message = " + err.message); + + // Even if this failed we will try to delete the rest of the stuff related to the team. + } + + removeFromEcosystem(); + + } catch (err) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> removeFromSessions -> onDataRead -> onDataWritten -> err.message = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + + } + } + + } catch (err) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> removeFromSessions -> onDataRead -> err.message = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + + } + } + + } catch (err) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> removeFromSessions -> err.message = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + + } + } + + function removeFromUserModuleDatabase(pSessionToken) { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] TeamSetup -> deleteTeam -> removeFromUserModuleDatabase -> Entering function."); } + + + const graphqlClient = require('graphql-client') + + const usersModuleAPI = graphqlClient({ + //url: 'http://localhost:4000/graphql' + url: 'https://users-api.advancedalgos.net/graphql', + //headers: { + // Authorization: 'Bearer ' + authToken + //} + }); + + + let variables = { + authId: pAuthId, + sessionToken: pSessionToken + }; + + usersModuleAPI.query(` + mutation($authId: String, $sessionToken: String){ + updateSessionToken(authId: $authId, sessionToken: $sessionToken){ + id + alias + } + } + `, variables, function (req, res) { + if (res.status === 401) { + console.log('[ERROR] TeamSetup -> deleteTeam -> Error trying to delete the session token at the Users Module'); + console.log('[ERROR] TeamSetup -> deleteTeam -> res.status = 401'); + } + }).then(res => { + if (res.errors) { + console.log('[ERROR] TeamSetup -> deleteTeam -> Error trying to delete the session token at the Users Module'); + console.log('[ERROR] TeamSetup -> deleteTeam -> res.errors = ' + res.errors); + } + }).catch(error => { + console.log('Error trying to delete the session token at the Users Module'); + console.log('[ERROR] TeamSetup -> deleteTeam -> errors = ' + errors); + }); + + } catch (err) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> removeFromUserModuleDatabase -> err.message = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + + } + } + + function removeFromEcosystem() { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] TeamSetup -> deleteTeam -> removeFromEcosystem -> Entering function."); } + + storage.readData("AdvancedAlgos", "AAPlatform", "ecosystem.json", false, onDataRead); + + function onDataRead(err, pFileContent) { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] TeamSetup -> deleteTeam -> removeFromEcosystem -> onDataRead -> Entering function."); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> removeFromEcosystem -> onDataRead -> Could not read a file. "); + console.log("[ERROR] TeamSetup -> deleteTeam -> removeFromEcosystem -> onDataRead -> err.message = " + err.message); + + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + return; + } + + pFileContent = pFileContent.trim(); + let ecosystem = JSON.parse(pFileContent); + + for (let i = 0; i < ecosystem.devTeams.length; i++) { + + let team = ecosystem.devTeams[i]; + + if (team.codeName === pTeamCodeName) { + + // Found! Deleting it... + + ecosystem.devTeams.splice(i, 1); + break; + } + } + + let fileContent = JSON.stringify(ecosystem); + + storage.writeData("AdvancedAlgos", "AAPlatform", "ecosystem.json", fileContent, onDataWritten); + + function onDataWritten(err) { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] TeamSetup -> deleteTeam -> removeFromEcosystem -> onDataRead -> onDataWritten -> Entering function."); } + + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> removeFromEcosystem -> onDataRead -> onDataWritten -> Could not write a file. "); + console.log("[ERROR] TeamSetup -> deleteTeam -> removeFromEcosystem -> onDataRead -> onDataWritten -> err.message = " + err.message); + + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + return; + } + + callBackFunction(global.DEFAULT_OK_RESPONSE); + + } catch (err) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> removeFromEcosystem -> onDataRead -> onDataWritten -> err.message = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + + } + } + + } catch (err) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> removeFromEcosystem -> onDataRead -> err.message = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + + } + } + + } catch (err) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> removeFromEcosystem -> err.message = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + + } + } + + } catch (err) { + + console.log("[ERROR] TeamSetup -> deleteTeam -> err.message = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + + } + } + } diff --git a/Project.njsproj b/Project.njsproj index d49d6508c..c20eeb473 100644 --- a/Project.njsproj +++ b/Project.njsproj @@ -33,7 +33,6 @@ Code - Code @@ -233,7 +232,6 @@ - diff --git a/Server/Storage.js b/Server/Storage.js index 599433c56..f094c0fc7 100644 --- a/Server/Storage.js +++ b/Server/Storage.js @@ -4,6 +4,8 @@ readData: readData, writeData: writeData, createContainer: createContainer, + deleteContainer: deleteContainer, + deleteBlob: deleteBlob, initialize: initialize } @@ -179,6 +181,72 @@ } } + function deleteBlob(pOrg, pPath, pFile, callBackFunction) { + + try { + + if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> deleteBlob -> Entering function."); } + if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> deleteBlob -> pOrg = " + pOrg); } + if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> deleteBlob -> pPath = " + pPath); } + if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> deleteBlob -> pFile = " + pFile); } + + let storage = require('azure-storage'); + let connectionString; + + switch (serverConfig.environment) { + + case "Develop": { + + connectionString = serverConfig.configAndPlugins.Develop.connectionString; + break; + } + + case "Production": { + + connectionString = serverConfig.configAndPlugins.Production.connectionString; + break; + } + } + + let blobService = storage.createBlobService(connectionString); + let blobPath = pOrg + "/" + pPath + "/" + pFile; + + blobService.deleteBlob('aaplatform', blobPath, 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 -> pOrg = " + pOrg); } + if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> deleteBlob -> onBlobDeleted -> pPath = " + pPath); } + if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> deleteBlob -> onBlobDeleted -> pFile = " + pFile); } + + 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) { @@ -250,4 +318,75 @@ 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 storage = require('azure-storage'); + let connectionString; + + switch (serverConfig.environment) { + + case "Develop": { + + connectionString = serverConfig.configAndPlugins.Develop.connectionString; + break; + } + + case "Production": { + + connectionString = serverConfig.configAndPlugins.Production.connectionString; + break; + } + } + + let blobService = storage.createBlobService(connectionString); + + let containerName = pContainerName.toLowerCase(); + + blobService.deleteContainer(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); + } + } } \ No newline at end of file diff --git a/server.js b/server.js index 98f818a7b..c7c041cde 100644 --- a/server.js +++ b/server.js @@ -578,7 +578,7 @@ function onBrowserRequest(request, response) { break; } - case "teamSetup": { + case "newTeam": { const AABROWSER_API_TEAM_SETUP = require('./AABrowserAPI/' + 'TeamSetup'); let teamSetup = AABROWSER_API_TEAM_SETUP.newTeamSetup(); @@ -608,6 +608,35 @@ function onBrowserRequest(request, response) { } break; } + + case "deleteTeam": { + + const AABROWSER_API_TEAM_SETUP = require('./AABrowserAPI/' + 'TeamSetup'); + let teamSetup = AABROWSER_API_TEAM_SETUP.newTeamSetup(); + + teamSetup.initialize(serverConfig); + + let devTeamCodeName = decodeURI(requestParameters[3]); + let userName = decodeURI(requestParameters[4]); + let botCodeName = decodeURI(requestParameters[5]); + let authId = decodeURI(requestParameters[6]); + + teamSetup.deleteTeam(devTeamCodeName, userName, botCodeName, authId, onSetupFinished); + + function onSetupFinished(err) { + + if (err.result === global.DEFAULT_OK_RESPONSE.result) { + + /* We must re-load all the webserver caches.*/ + + initialize(); + + } + + respondWithContent(JSON.stringify(err), response); + } + break; + } } } break;