UpdateSave functionality fixed 82/982/1
authorLaurence Maultsby <laurence.maultsby@riftio.com>
Thu, 19 Jan 2017 01:12:34 +0000 (20:12 -0500)
committerLaurence Maultsby <laurence.maultsby@riftio.com>
Thu, 19 Jan 2017 01:12:34 +0000 (20:12 -0500)
Signed-off-by: Laurence Maultsby <laurence.maultsby@riftio.com>
skyquake/plugins/composer/api/composer.js
skyquake/plugins/composer/routes.js

index 8df1a91..a2355ab 100644 (file)
@@ -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);
index 2c78cc9..3782209 100644 (file)
@@ -96,7 +96,7 @@ router.post('/api/catalog/:catalogType', cors(), function(req, res) {
     });
 });
 router.put('/api/catalog/:catalogType/:id', cors(), function(req, res) {
-    Composer.update(req).then(function(data) {
+    Composer.updateSave(req).then(function(data) {
         res.send(data);
     }, function(error) {
         res.status(error.statusCode);