RIFT-14874: Allow deny of duplicate events in loggin 58/558/1
authorLaurence Maultsby <laurence.maultsby@riftio.com>
Fri, 21 Oct 2016 01:39:20 +0000 (21:39 -0400)
committerLaurence Maultsby <laurence.maultsby@riftio.com>
Fri, 21 Oct 2016 01:39:20 +0000 (21:39 -0400)
Signed-off-by: Laurence Maultsby <laurence.maultsby@riftio.com>
skyquake/plugins/logging/api/logging.js
skyquake/plugins/logging/api/transforms.js
skyquake/plugins/logging/src/loggingSource.js

index c2f56f8..3ef9027 100644 (file)
@@ -369,15 +369,14 @@ Config.deleteDefaultSyslogSeverity = function(req) {
 Config.setAllowDuplicateEvents = function(req) {
   // TODO: verify there is one key at root of data: 'default-severity'
   // OR just filter on the request body
-
-  if (req.body.hasOwnProperty('allowDuplicateEvents') &&
-    typeof req.body.allowDuplicateEvents == 'boolean') {
-    if (req.body.allowDuplicateEvents) {
-      return handlePutRequest(req, APIVersion + '/api/config/logging/allow', {
+console.log(req.body)
+  if (req.body.hasOwnProperty('allowDuplicateEvents')) {
+    if (req.body.allowDuplicateEvents.toUpperCase() == "TRUE") {
+      return handlePutRequest(req, '/api/config/logging/allow', {
         "duplicate": "events"
       });
     } else { // false, remove entry from logging config
-      return handleDeleteRequest(req, APIVersion + '/api/config/logging/allow/duplicate');
+      return handleDeleteRequest(req, '/api/config/logging/allow/duplicate');
     }
   } else {
     return handleReject(statusCode=400,
index eb17b7a..5f65010 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 
+ *
  *   Copyright 2016 RIFT.IO Inc
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
@@ -168,7 +168,7 @@ LoggingConfigEncoder.prototype.denyEvents = function(data) {
  * or absence of the { "allow": { "duplicate": "events" }} key/value hierarchy
  */
 LoggingConfigEncoder.prototype.allow = function(data) {
-  if (data.allowDuplicateEvents) {
+  if (data.allowDuplicateEvents.toUpperCase() == "TRUE") {
     return { duplicate: "events" };
   } else {
     return null;
index dc28aa4..c83b322 100644 (file)
@@ -66,6 +66,30 @@ export default {
         return new Promise(function(resolve, reject) {
           let promises = [];
           let remove = null;
+          // $.ajax({
+          //   url: 'https://10.66.202.130:8008/api/config/logging/allow/duplicate',
+          //   type: 'DELETE',
+          //   beforeSend: Utils.addAuthorizationStub
+          // })
+          if(loggingConfig.hasOwnProperty('allowDuplicateEvents')) {
+            promises.push($.ajax({
+              // url: apiUrl('api/config/default-severity'),
+              url: apiUrl('api/config/allow-duplicate-events'),
+              type: 'PUT',
+              beforeSend: Utils.addAuthorizationStub,
+              data: {
+                allowDuplicateEvents: loggingConfig.allowDuplicateEvents
+              },
+              success: function(data) {
+                resolve(data);
+              },
+              error: function(error) {
+                console.log("There was an error updating the logging config data",
+                  error);
+                reject(error);
+              }
+            }))
+          }
           // if(nulledCategories.length > 0) {
           //   remove = $.ajax({
           //     // url: apiUrl('api/config/default-severity'),