From: Laurence Maultsby Date: Fri, 21 Oct 2016 01:39:20 +0000 (-0400) Subject: RIFT-14874: Allow deny of duplicate events in loggin X-Git-Tag: v1.0.1~10^2~4 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F58%2F558%2F1;p=osm%2FUI.git RIFT-14874: Allow deny of duplicate events in loggin Signed-off-by: Laurence Maultsby --- diff --git a/skyquake/plugins/logging/api/logging.js b/skyquake/plugins/logging/api/logging.js index c2f56f834..3ef9027d9 100644 --- a/skyquake/plugins/logging/api/logging.js +++ b/skyquake/plugins/logging/api/logging.js @@ -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, diff --git a/skyquake/plugins/logging/api/transforms.js b/skyquake/plugins/logging/api/transforms.js index eb17b7abc..5f6501020 100644 --- a/skyquake/plugins/logging/api/transforms.js +++ b/skyquake/plugins/logging/api/transforms.js @@ -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; diff --git a/skyquake/plugins/logging/src/loggingSource.js b/skyquake/plugins/logging/src/loggingSource.js index dc28aa4cc..c83b322d3 100644 --- a/skyquake/plugins/logging/src/loggingSource.js +++ b/skyquake/plugins/logging/src/loggingSource.js @@ -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'),