From 988fa778eb2415a7ae8f1b30df67ebc38eee4665 Mon Sep 17 00:00:00 2001 From: emartin Date: Tue, 2 Apr 2019 09:17:33 +0000 Subject: Fix mapping issue with type C files Change-Id: I698b84989dc928a09ff5e1c54adf236edd40b622 Issue-ID: DCAEGEN2-1038 Signed-off-by: emartin --- src/main/java/org/onap/dcaegen2/services/pmmapper/App.java | 2 +- .../java/org/onap/dcaegen2/services/pmmapper/mapping/Mapper.java | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/main') diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java index 03d42d5..b411fd7 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java @@ -71,7 +71,7 @@ public class App { MetadataFilter metadataFilter = new MetadataFilter(mapperConfig); MeasConverter measConverter = new MeasConverter(); MeasFilterHandler filterHandler = new MeasFilterHandler(measConverter); - Mapper mapper = new Mapper(mappingTemplate); + Mapper mapper = new Mapper(mappingTemplate, measConverter); MeasSplitter splitter = new MeasSplitter(measConverter); XMLValidator validator = new XMLValidator(xmlSchema); VESPublisher vesPublisher = new VESPublisher(mapperConfig); diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/mapping/Mapper.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/mapping/Mapper.java index 44bbc27..a9b7e86 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/mapping/Mapper.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/mapping/Mapper.java @@ -28,6 +28,7 @@ import lombok.NonNull; import org.onap.dcaegen2.services.pmmapper.exceptions.MappingException; import org.onap.dcaegen2.services.pmmapper.exceptions.XMLParseException; import org.onap.dcaegen2.services.pmmapper.model.Event; +import org.onap.dcaegen2.services.pmmapper.utils.MeasConverter; import org.onap.logging.ref.slf4j.ONAPLogAdapter; import org.slf4j.LoggerFactory; import org.xml.sax.InputSource; @@ -49,9 +50,11 @@ import java.util.UUID; public class Mapper { private static final ONAPLogAdapter logger = new ONAPLogAdapter(LoggerFactory.getLogger(Mapper.class)); private Template mappingTemplate; + private MeasConverter converter; - public Mapper(@NonNull Path pathToTemplate) { + public Mapper(@NonNull Path pathToTemplate, MeasConverter converter) { logger.unwrap().trace("Constructing Mapper from {}", pathToTemplate); + this.converter = converter; Configuration configuration = new Configuration(Configuration.VERSION_2_3_28); configuration.setTagSyntax(Configuration.ANGLE_BRACKET_TAG_SYNTAX); try { @@ -72,7 +75,8 @@ public class Mapper { logger.unwrap().info("Mapping event"); NodeModel pmNodeModel; try { - pmNodeModel = NodeModel.parse(new InputSource(new StringReader(event.getBody()))); + String measCollecFile = converter.convert(event.getMeasCollecFile()); + pmNodeModel = NodeModel.parse(new InputSource(new StringReader(measCollecFile))); } catch (IOException | SAXException | ParserConfigurationException exception) { logger.unwrap().error("Failed to parse input as XML", exception); throw new XMLParseException("Failed to parse input as XML", exception); -- cgit 1.2.3-korg