You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2023/09/08 03:46:24 UTC
[karaf] branch karaf-4.3.x updated: KARAF-7736: fix PID/filename parsing for json cfg file
This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch karaf-4.3.x
in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/karaf-4.3.x by this push:
new 7ab5365110 KARAF-7736: fix PID/filename parsing for json cfg file
7ab5365110 is described below
commit 7ab53651100168ea1b4e14a93d6e600ef2e82158
Author: JB Onofré <jb...@nanthrax.net>
AuthorDate: Thu Sep 7 18:09:37 2023 +0200
KARAF-7736: fix PID/filename parsing for json cfg file
(cherry picked from commit 8704119eec4cece1f049a92bd1d992c289dfbc09)
---
.../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();
}