diff --git a/AABrowserAPI/TeamSetup.js b/AABrowserAPI/TeamSetup.js index 1f9f32e02..24b8b15cc 100644 --- a/AABrowserAPI/TeamSetup.js +++ b/AABrowserAPI/TeamSetup.js @@ -1,8 +1,5 @@ exports.newTeamSetup = function newTeamSetup() { - CONSOLE_LOG = true; - LOG_FILE_CONTENT = false; - let thisObject = { newTeam: newTeam, initialize: initialize @@ -61,11 +58,24 @@ console.log("[ERROR] TeamSetup -> newTeam -> createContainer -> onContainerCreated -> Could not create the container. "); console.log("[ERROR] TeamSetup -> newTeam -> createContainer -> onContainerCreated -> err.message = " + err.message); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + if (err.message === "ContainerAlreadyExists") { + + let err = { + resutl: global.CUSTOM_FAIL_RESPONSE.result, + message: "Team Name already taken" + }; + + callBackFunction(err); + + } else { + + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + + } return; } - callBackFunction(global.DEFAULT_OK_RESPONSE); + addToEcosystem(); } } diff --git a/Server/Storage.js b/Server/Storage.js index 3bc36571c..451843a92 100644 --- a/Server/Storage.js +++ b/Server/Storage.js @@ -87,9 +87,9 @@ if (err !== null || text === null) { - if (CONSOLE_LOG === true) { console.log("[ERROR] Storage -> readData -> onFileReceived -> Error Received from Storage Library. "); } - if (CONSOLE_LOG === true) { console.log("[ERROR] Storage -> readData -> onFileReceived -> err = " + JSON.stringify(err)); } - if (CONSOLE_LOG === true) { console.log("[ERROR] Storage -> readData -> onFileReceived -> Returning an empty JSON object string. "); } + 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. "); } callBackFunction(global.DEFAULT_FAIL_RESPONSE); return; @@ -157,8 +157,8 @@ if (err !== null || text === null) { - if (CONSOLE_LOG === true) { console.log("[ERROR] Storage -> writeData -> onFileCreated -> Error Received from Storage Library. "); } - if (CONSOLE_LOG === true) { console.log("[ERROR] Storage -> writeData -> onFileCreated -> err = " + JSON.stringify(err)); } + 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; @@ -180,7 +180,7 @@ } - function createContainer(pContainerName, pPath, pFile, pFileContent, callBackFunction) { + function createContainer(pContainerName, callBackFunction) { try { @@ -207,22 +207,42 @@ let blobService = storage.createBlobService(connectionString); - pContainerName.toLowerCase(); + let containerName = pContainerName.toLowerCase(); - blobService.createContainer(pContainerName, onContainerCreated); + blobService.createContainer(containerName, onContainerCreated); function onContainerCreated(err) { if (err) { - if (CONSOLE_LOG === true) { console.log("[ERROR] Storage -> createContainer -> onContainerCreated -> Error Received from Storage Library. "); } - if (CONSOLE_LOG === true) { console.log("[ERROR] Storage -> createContainer -> onContainerCreated -> err = " + JSON.stringify(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) { diff --git a/server.js b/server.js index 0208ea36f..b22cf1b8f 100644 --- a/server.js +++ b/server.js @@ -1,6 +1,7 @@ /* These 2 are global variables, that is why they do not have a let or var */ CONSOLE_LOG = true; +CONSOLE_ERROR_LOG = true; LOG_FILE_CONTENT = false; if (CONSOLE_LOG === true) { console.log("[INFO] server -> Node Server Starting."); }