From 64e760caf2a5d223cca7598b3ff8941ac37c7a96 Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Wed, 17 Aug 2016 13:12:31 -0400 Subject: [PATCH] Fix feature config pusher warning The feature config pusher assumes config files installed by features that have XML extension are CSS files and tries to parse them. On failure it prints a warning but ignores it and moves on. Up till now we've only had CSS XML files but we now have XML files related to the clustered-app-config. To avoid the warning I added an additional check for "opendaylight/karaf" present in the file path. To be complete we would open the file and inspect the first element but I didn't think that was worth the effort since all current CSS files are put under opendaylight/karaf and ODL is moving away from CSS. Change-Id: I1f0dcda9efa14db330a72e455fe4756c8fbfcaab Signed-off-by: Tom Pantelis --- .../internal/AbstractFeatureWrapper.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/AbstractFeatureWrapper.java b/opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/AbstractFeatureWrapper.java index 4f598aae80..f95f2b89fd 100644 --- a/opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/AbstractFeatureWrapper.java +++ b/opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/AbstractFeatureWrapper.java @@ -10,6 +10,7 @@ package org.opendaylight.controller.configpusherfeature.internal; import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.io.Files; +import java.io.File; import java.util.LinkedHashSet; import java.util.List; import javax.xml.bind.JAXBException; @@ -32,6 +33,7 @@ import org.slf4j.LoggerFactory; public class AbstractFeatureWrapper implements Feature { private static final Logger LOG = LoggerFactory.getLogger(AbstractFeatureWrapper.class); + private static final String CONFIG_FILE_PATH_SUFFIX = "opendaylight" + File.separator + "karaf"; protected static final String CONFIG_FILE_SUFFIX = "xml"; protected Feature feature = null; @@ -56,7 +58,7 @@ public class AbstractFeatureWrapper implements Feature { final LinkedHashSet snapShotHolders = new LinkedHashSet<>(); for(final ConfigFileInfo c: getConfigurationFiles()) { // Skip non xml files - if(Files.getFileExtension(c.getFinalname()).equals(CONFIG_FILE_SUFFIX)) { + if(isConfigXMLFile(c.getFinalname())) { final Optional featureConfigSnapshotHolder = getFeatureConfigSnapshotHolder(c); if(featureConfigSnapshotHolder.isPresent()) { snapShotHolders.add(featureConfigSnapshotHolder.get()); @@ -66,6 +68,12 @@ public class AbstractFeatureWrapper implements Feature { return snapShotHolders; } + private static boolean isConfigXMLFile(String fullName) { + String path = new File(fullName).getPath(); + return path.contains(CONFIG_FILE_PATH_SUFFIX) && + Files.getFileExtension(fullName).equals(CONFIG_FILE_SUFFIX); + } + protected Optional getFeatureConfigSnapshotHolder(final ConfigFileInfo c) { try { return Optional.of(new FeatureConfigSnapshotHolder(c, this)); @@ -86,7 +94,7 @@ public class AbstractFeatureWrapper implements Feature { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((feature == null) ? 0 : feature.hashCode()); + result = prime * result + (feature == null ? 0 : feature.hashCode()); return result; } @@ -252,4 +260,4 @@ public class AbstractFeatureWrapper implements Feature { return feature.getRegion(); } -} \ No newline at end of file +} -- 2.36.6