X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-persister-feature-adapter%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfigpusherfeature%2Finternal%2FAbstractFeatureWrapper.java;h=4f598aae80e2ac2678902e8367f3bce9fb7950ba;hp=d18928d06c1f09ac9dd3af62846a8bcf9b08a07d;hb=e811e0590846e41f514ab2bea7b3f17d112036ae;hpb=eb3ebced9d3471644dece3e4e27cca9451db0685 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 d18928d06c..4f598aae80 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 @@ -7,10 +7,13 @@ */ 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.util.LinkedHashSet; import java.util.List; import javax.xml.bind.JAXBException; +import javax.xml.stream.XMLStreamException; import org.apache.karaf.features.BundleInfo; import org.apache.karaf.features.Conditional; import org.apache.karaf.features.ConfigFileInfo; @@ -28,6 +31,9 @@ import org.slf4j.LoggerFactory; */ public class AbstractFeatureWrapper implements Feature { private static final Logger LOG = LoggerFactory.getLogger(AbstractFeatureWrapper.class); + + protected static final String CONFIG_FILE_SUFFIX = "xml"; + protected Feature feature = null; protected AbstractFeatureWrapper() { @@ -47,17 +53,35 @@ public class AbstractFeatureWrapper implements Feature { * from the underlying Feature Config files */ public LinkedHashSet getFeatureConfigSnapshotHolders() throws Exception { - final LinkedHashSet snapShotHolders = new LinkedHashSet(); + final LinkedHashSet snapShotHolders = new LinkedHashSet<>(); for(final ConfigFileInfo c: getConfigurationFiles()) { - try { - snapShotHolders.add(new FeatureConfigSnapshotHolder(c,this)); - } catch (final JAXBException e) { - LOG.debug("{} is not a config subsystem config file",c.getFinalname()); + // Skip non xml files + if(Files.getFileExtension(c.getFinalname()).equals(CONFIG_FILE_SUFFIX)) { + final Optional featureConfigSnapshotHolder = getFeatureConfigSnapshotHolder(c); + if(featureConfigSnapshotHolder.isPresent()) { + snapShotHolders.add(featureConfigSnapshotHolder.get()); + } } } return snapShotHolders; } + protected Optional getFeatureConfigSnapshotHolder(final ConfigFileInfo c) { + try { + return Optional.of(new FeatureConfigSnapshotHolder(c, this)); + } catch (final JAXBException e) { + LOG.warn("Unable to parse configuration snapshot. Config from '{}' will be IGNORED. " + + "Note that subsequent config files may fail due to this problem. " + + "Xml markup in this file needs to be fixed, for detailed information see enclosed exception.", + c.getFinalname(), e); + } catch (final XMLStreamException e) { + // Files that cannot be loaded are ignored as non config subsystem files e.g. jetty.xml + LOG.debug("Unable to read configuration file '{}'. Not a configuration snapshot", + c.getFinalname(), e); + } + return Optional.absent(); + } + @Override public int hashCode() { final int prime = 31;