From 7271e1ea4071b863fa54138e1894701b902ad7e4 Mon Sep 17 00:00:00 2001 From: Bernd Ahlers Date: Wed, 16 Mar 2016 15:57:50 +0100 Subject: [PATCH] Fix import of Graylog 1.x extractors and fix export format The import/export format wrangling should be done on the server side instead of doing all of this in the browser. This is a minimal fix because refactoring this is too much at the moment. Fixes #1831 --- .../extractors/ExportExtractors.jsx | 25 ++++++++++++++++++- .../src/stores/extractors/ExtractorsStore.js | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/graylog2-web-interface/src/components/extractors/ExportExtractors.jsx b/graylog2-web-interface/src/components/extractors/ExportExtractors.jsx index 6a8f0f409957..808ef228503a 100644 --- a/graylog2-web-interface/src/components/extractors/ExportExtractors.jsx +++ b/graylog2-web-interface/src/components/extractors/ExportExtractors.jsx @@ -25,7 +25,30 @@ const ExportExtractors = React.createClass({ } const extractorsExportObject = { - extractors: this.state.extractors, + extractors: this.state.extractors.map((extractor) => { + const copy = {}; + + // Create Graylog 1.x compatible export format. + // TODO: This should be done on the server. + Object.keys(extractor).forEach((key) => { + switch (key) { + case 'type': + // The import expects "extractor_type", not "type". + copy.extractor_type = extractor[key]; + break; + case 'id': + case 'metrics': + case 'creator_user_id': + case 'exceptions': + case 'converter_exceptions': + break; + default: + copy[key] = extractor[key]; + } + }); + + return copy; + }), version: Version.getFullVersion(), }; diff --git a/graylog2-web-interface/src/stores/extractors/ExtractorsStore.js b/graylog2-web-interface/src/stores/extractors/ExtractorsStore.js index f08938b72828..b0b35fb2be1a 100644 --- a/graylog2-web-interface/src/stores/extractors/ExtractorsStore.js +++ b/graylog2-web-interface/src/stores/extractors/ExtractorsStore.js @@ -21,7 +21,7 @@ function getExtractorDTO(extractor) { cut_or_copy: extractor.cursor_strategy || 'copy', source_field: extractor.source_field, target_field: extractor.target_field, - extractor_type: extractor.type, + extractor_type: extractor.type || extractor.extractor_type, extractor_config: extractor.extractor_config, converters: converters, condition_type: extractor.condition_type || 'none',