X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=skyquake%2Fframework%2Fcore%2Fmodules%2Fapi%2FprojectManagementAPI.js;h=feedfc2200d0321c1f4c4289cb1c57c1b111f39e;hb=75a3c0cc557df2f51a79f9ee0bd61e037f4ada63;hp=44d2ac5f26e1599b79ac12668c286a20e5d376b5;hpb=0639632bc78cfc65b26624c20e6ce4cb81d8be8f;p=osm%2FUI.git diff --git a/skyquake/framework/core/modules/api/projectManagementAPI.js b/skyquake/framework/core/modules/api/projectManagementAPI.js index 44d2ac5f2..feedfc220 100644 --- a/skyquake/framework/core/modules/api/projectManagementAPI.js +++ b/skyquake/framework/core/modules/api/projectManagementAPI.js @@ -36,7 +36,7 @@ ProjectManagement.get = function(req) { uri: utils.confdPort(api_server) + '/api/operational/project', method: 'GET', headers: _.extend({}, constants.HTTP_HEADERS.accept.data, { - 'Authorization': req.get('Authorization') + 'Authorization': req.session && req.session.authorization }), forever: constants.FOREVER_ON, rejectUnauthorized: false, @@ -76,7 +76,7 @@ ProjectManagement.create = function(req) { uri: utils.confdPort(api_server) + '/api/config/project', method: 'POST', headers: _.extend({}, constants.HTTP_HEADERS.accept.data, { - 'Authorization': req.get('Authorization') + 'Authorization': req.session && req.session.authorization }), forever: constants.FOREVER_ON, json: data, @@ -107,16 +107,14 @@ ProjectManagement.update = function(req) { var self = this; var api_server = req.query['api_server']; var bodyData = req.body; - data = { - "project":[bodyData] - } + data = bodyData['project-config'] var updateTasks = []; var updateUser = rp({ - uri: utils.confdPort(api_server) + '/api/config/project', + uri: utils.confdPort(api_server) + '/api/config/project/' + bodyData.name + '/project-config', method: 'PUT', headers: _.extend({}, constants.HTTP_HEADERS.accept.data, { - 'Authorization': req.get('Authorization') + 'Authorization': req.session && req.session.authorization }), forever: constants.FOREVER_ON, json: data, @@ -158,7 +156,7 @@ ProjectManagement.delete = function(req) { _.extend(requestHeaders, constants.HTTP_HEADERS.accept.data, constants.HTTP_HEADERS.content_type.data, { - 'Authorization': req.get('Authorization') + 'Authorization': req.session && req.session.authorization }); rp({ url: url, @@ -178,17 +176,21 @@ ProjectManagement.delete = function(req) { } -ProjectManagement.getPlatform = function(req) { +ProjectManagement.getPlatform = function(req, userId) { var self = this; var api_server = req.query['api_server']; - + var user = req.params['userId'] || userId; return new Promise(function(resolve, reject) { + var url = utils.confdPort(api_server) + '/api/operational/rbac-platform-config'; + if(user) { + url = url + '/user/' + user; + } Promise.all([ rp({ - uri: utils.confdPort(api_server) + '/api/operational/rbac-platform-config', + uri: url, method: 'GET', headers: _.extend({}, constants.HTTP_HEADERS.accept.data, { - 'Authorization': req.get('Authorization') + 'Authorization': req.session && req.session.authorization }), forever: constants.FOREVER_ON, rejectUnauthorized: false, @@ -198,7 +200,11 @@ ProjectManagement.getPlatform = function(req) { var response = {}; response['data'] = {}; if (result[0].body) { - response['data']['platform'] = JSON.parse(result[0].body)['rw-rbac-platform:rbac-platform-config']; + if(user) { + response['data']['platform'] = JSON.parse(result[0].body)['rw-rbac-platform:user']; + } else { + response['data']['platform'] = JSON.parse(result[0].body)['rw-rbac-platform:rbac-platform-config']; + } } response.statusCode = constants.HTTP_RESPONSE_CODES.SUCCESS.OK @@ -220,13 +226,14 @@ ProjectManagement.updatePlatform = function(req) { var api_server = req.query['api_server']; var bodyData = req.body; data = bodyData; + data.user = JSON.parse(data.user) var updateTasks = []; var updateUser = rp({ uri: utils.confdPort(api_server) + '/api/config/rbac-platform-config', method: 'PUT', headers: _.extend({}, constants.HTTP_HEADERS.accept.data, { - 'Authorization': req.get('Authorization') + 'Authorization': req.session && req.session.authorization }), forever: constants.FOREVER_ON, json: data,