This is an automated email from the ASF dual-hosted git repository. jbonofre pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/main by this push: new 8704119eec KARAF-7736: fix PID/filename parsing for json cfg file new f31c0e7129 Merge pull request #1767 from jbonofre/KARAF-7736 8704119eec is described below commit 8704119eec4cece1f049a92bd1d992c289dfbc09 Author: JB Onofré <j...@nanthrax.net> AuthorDate: Thu Sep 7 18:09:37 2023 +0200 KARAF-7736: fix PID/filename parsing for json cfg file --- .../main/java/org/apache/karaf/config/command/EditCommand.java | 2 +- .../org/apache/karaf/config/core/impl/JsonConfigInstaller.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/src/main/java/org/apache/karaf/config/command/EditCommand.java b/config/src/main/java/org/apache/karaf/config/command/EditCommand.java index 5ecfcc3f51..fe3d1b2e0e 100644 --- a/config/src/main/java/org/apache/karaf/config/command/EditCommand.java +++ b/config/src/main/java/org/apache/karaf/config/command/EditCommand.java @@ -42,7 +42,7 @@ public class EditCommand extends ConfigCommandSupport { @Option(name = "--alias", aliases = {}, description = "Specifies the alias used for this factory config.", required = false, multiValued = false) String alias; - @Option(name = "--type", aliases = {}, description = "Specifies the configuration storage type (cfg or json).", required = false, multiValued = false) + @Option(name = "--type", aliases = {}, description = "Specifies the configuration storage type (cfg or cfg.json).", required = false, multiValued = false) String suffix; @Override diff --git a/config/src/main/java/org/apache/karaf/config/core/impl/JsonConfigInstaller.java b/config/src/main/java/org/apache/karaf/config/core/impl/JsonConfigInstaller.java index adaa794fbd..a1754195a9 100644 --- a/config/src/main/java/org/apache/karaf/config/core/impl/JsonConfigInstaller.java +++ b/config/src/main/java/org/apache/karaf/config/core/impl/JsonConfigInstaller.java @@ -46,7 +46,7 @@ public class JsonConfigInstaller implements ArtifactInstaller, ConfigurationList public final static String EXT_ENV_VAR = "KARAF_JSON_CONFIG_EXTENSION"; public final static String EXT_SYS_PROP = "karaf.json.config.extension"; - public final static String DEFAULT_EXTENSION = ".cfg.json"; + public final static String DEFAULT_EXTENSION = "cfg.json"; private final static Logger LOGGER = LoggerFactory.getLogger(JsonConfigInstaller.class); @@ -58,7 +58,7 @@ public class JsonConfigInstaller implements ArtifactInstaller, ConfigurationList @Override public boolean canHandle(File artifact) { - return artifact.getName().endsWith(getExtension()); + return artifact.getName().endsWith("." + getExtension()); } private String getExtension() { @@ -87,7 +87,7 @@ public class JsonConfigInstaller implements ArtifactInstaller, ConfigurationList private void setConfig(File artifact) throws Exception { final String filename = artifact.getName(); - final ConfigurationPID configurationPID = ConfigurationPID.parseFilename(filename); + final ConfigurationPID configurationPID = ConfigurationPID.parseFilename(filename, getExtension()); Configuration configuration = getConfiguration(toConfigKey(artifact), configurationPID); Dictionary<String, Object> props = configuration.getProperties(); Hashtable<String, Object> old = props != null ? new Hashtable<>(new DictionaryAsMap<>(props)) : null; @@ -138,7 +138,7 @@ public class JsonConfigInstaller implements ArtifactInstaller, ConfigurationList @Override public void configurationEvent(ConfigurationEvent event) { if (event.getType() == ConfigurationEvent.CM_DELETED) { - File file = new File(System.getProperty("karaf.etc"), event.getPid() + getExtension()); + File file = new File(System.getProperty("karaf.etc"), event.getPid() + "." + getExtension()); if (file.exists()) { file.delete(); }