X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fplugins%2Fcomposer%2Fapi%2Fcomposer.js;h=801873a36806cba841e34fb3293ebe0e39e3eb68;hp=864f2b06e0fe5862652041745441b8fb7731bcae;hb=64b803dbd876e15a0a2d4ca46d8ce81ac18915f6;hpb=5e37df206e5667d681be1b9b4c450024733c4617 diff --git a/skyquake/plugins/composer/api/composer.js b/skyquake/plugins/composer/api/composer.js index 864f2b06e..801873a36 100644 --- a/skyquake/plugins/composer/api/composer.js +++ b/skyquake/plugins/composer/api/composer.js @@ -272,36 +272,36 @@ Composer.create = function(req) { }); }); }; -// Composer.update = function(req) { -// var api_server = req.query['api_server']; -// var catalogType = req.params.catalogType; -// var id = req.params.id; -// var data = req.body; -// console.log('Updating', catalogType, 'id', id, 'on', api_server); -// var jsonData = {}; -// jsonData[catalogType] = {}; -// jsonData[catalogType] = data; -// return new Promise(function(resolve, reject) { -// var requestHeaders = {}; -// _.extend(requestHeaders, constants.HTTP_HEADERS.accept.data, constants.HTTP_HEADERS.content_type.data, { -// 'Authorization': req.get('Authorization') -// }); -// request({ -// uri: utils.confdPort(api_server) + APIVersion + '/api/config/' + catalogType + '-catalog' + '/' + catalogType + '/' + id, -// method: 'PUT', -// headers: requestHeaders, -// forever: constants.FOREVER_ON, -// rejectUnauthorized: false, -// json: jsonData -// }, function(error, response, body) { -// if (utils.validateResponse('Composer.update', error, response, body, resolve, reject)) { -// resolve({ -// statusCode: response.statusCode -// }); -// } -// }); -// }); -// +Composer.updateSave = function(req) { + var api_server = req.query['api_server']; + var catalogType = req.params.catalogType; + var id = req.params.id; + var data = req.body; + console.log('Updating', catalogType, 'id', id, 'on', api_server); + var jsonData = {}; + jsonData[catalogType] = {}; + jsonData[catalogType] = data; + return new Promise(function(resolve, reject) { + var requestHeaders = {}; + _.extend(requestHeaders, constants.HTTP_HEADERS.accept.data, constants.HTTP_HEADERS.content_type.data, { + 'Authorization': req.get('Authorization') + }); + request({ + uri: utils.confdPort(api_server) + APIVersion + '/api/config/' + catalogType + '-catalog' + '/' + catalogType + '/' + id, + method: 'PUT', + headers: requestHeaders, + forever: constants.FOREVER_ON, + rejectUnauthorized: false, + json: jsonData + }, function(error, response, body) { + if (utils.validateResponse('Composer.update', error, response, body, resolve, reject)) { + resolve({ + statusCode: response.statusCode + }); + } + }); + }); +} Composer.update = function(req) { console.log(' Updating file', req.file.originalname, 'as', req.file.filename); @@ -312,7 +312,7 @@ Composer.update = function(req) { var download_host = req.query['dev_download_server']; if (!download_host) { - download_host = req.protocol + '://' + req.headers.host; + download_host = api_server + ':' + utils.getPortForProtocol(req.protocol); } var input = { 'external-url': download_host + '/composer/update/' + req.file.filename, @@ -368,7 +368,7 @@ Composer.upload = function(req) { var download_host = req.query['dev_download_server']; if (!download_host) { - download_host = req.protocol + '://' + req.headers.host; + download_host = api_server + ':' + utils.getPortForProtocol(req.protocol); } return new Promise(function(resolve, reject) { @@ -425,7 +425,7 @@ Composer.addFile = function(req) { var package_type = req.query['package_type'].toUpperCase(); var package_path = req.query['package_path']; if (!download_host) { - download_host = req.protocol + '://' + req.headers.host; + download_host = api_server + ':' + utils.getPortForProtocol(req.protocol); } return new Promise(function(resolve, reject) {