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,
/*
- *
+ *
* Copyright 2016 RIFT.IO Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* 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;
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'),