@Test public void testSubstFinalName() { final String karafBase = "/tmp/karaf.base"; final String karafEtc = karafBase + "/etc"; final String foo = "/foo"; System.setProperty("karaf.base", karafBase); System.setProperty("karaf.etc", karafEtc); System.setProperty("foo", foo); substEqual("etc/test.cfg", karafBase + File.separator + "etc/test.cfg"); substEqual("/etc/test.cfg", karafBase + File.separator + "/etc/test.cfg"); substEqual("${karaf.etc}/test.cfg", karafEtc + "/test.cfg"); substEqual("${karaf.base}/etc/test.cfg", karafBase + "/etc/test.cfg"); substEqual("etc/${foo}/test.cfg", karafBase + File.separator + "etc/" + foo + "/test.cfg"); substEqual("${foo}/test.cfg", foo + "/test.cfg"); substEqual("etc${bar}/${bar}test.cfg", karafBase + File.separator + "etc/test.cfg"); substEqual("${bar}/etc/test.cfg${bar}", karafBase + File.separator + "/etc/test.cfg"); substEqual("${karaf.base}${bar}/etc/test.cfg", karafBase + "/etc/test.cfg"); substEqual("etc${}/${foo}/test.cfg", karafBase + File.separator + "etc substEqual("${foo}${bar}/${bar}${foo}", foo + "/" + foo); }
protected static String substFinalName(String finalname) { final String markerVarBeg = "${"; final String markerVarEnd = "}"; boolean startsWithVariable = finalname.startsWith(markerVarBeg) && finalname.contains(markerVarEnd); final String dummyKey = ""; try { finalname = InterpolationHelper.substVars(finalname, dummyKey, null, null, null, true, true, false); } catch (final IllegalArgumentException ex) { LOGGER.info("Substitution failed. Skip substitution of variables of configuration final name ({}).", finalname); } if (!startsWithVariable || finalname.startsWith(markerVarBeg)) { final String basePath = System.getProperty("karaf.base"); finalname = basePath + File.separator + finalname; } while (finalname.contains(markerVarBeg) && finalname.contains(markerVarEnd)) { int beg = finalname.indexOf(markerVarBeg); int end = finalname.indexOf(markerVarEnd); final String rem = finalname.substring(beg, end + markerVarEnd.length()); finalname = finalname.replace(rem, ""); } return finalname; }
FeatureConfigInstaller { protected static String substFinalName(String finalname) { final String markerVarBeg = "${"; final String markerVarEnd = "}"; boolean startsWithVariable = finalname.startsWith(markerVarBeg) && finalname.contains(markerVarEnd); final String dummyKey = ""; try { finalname = InterpolationHelper.substVars(finalname, dummyKey, null, null, null, true, true, false); } catch (final IllegalArgumentException ex) { LOGGER.info("Substitution failed. Skip substitution of variables of configuration final name ({}).", finalname); } if (!startsWithVariable || finalname.startsWith(markerVarBeg)) { final String basePath = System.getProperty("karaf.base"); finalname = basePath + File.separator + finalname; } while (finalname.contains(markerVarBeg) && finalname.contains(markerVarEnd)) { int beg = finalname.indexOf(markerVarBeg); int end = finalname.indexOf(markerVarEnd); final String rem = finalname.substring(beg, end + markerVarEnd.length()); finalname = finalname.replace(rem, ""); } return finalname; } }
FeatureConfigInstaller { protected static String substFinalName(String finalname) { final String markerVarBeg = "${"; final String markerVarEnd = "}"; boolean startsWithVariable = finalname.startsWith(markerVarBeg) && finalname.contains(markerVarEnd); final String dummyKey = ""; try { finalname = InterpolationHelper.substVars(finalname, dummyKey, null, null, null, true, true, false); } catch (final IllegalArgumentException ex) { LOGGER.info("Substitution failed. Skip substitution of variables of configuration final name ({}).", finalname); } if (!startsWithVariable || finalname.startsWith(markerVarBeg)) { final String basePath = System.getProperty("karaf.base"); finalname = basePath + File.separator + finalname; } while (finalname.contains(markerVarBeg) && finalname.contains(markerVarEnd)) { int beg = finalname.indexOf(markerVarBeg); int end = finalname.indexOf(markerVarEnd); final String rem = finalname.substring(beg, end + markerVarEnd.length()); finalname = finalname.replace(rem, ""); } return finalname; } FeatureConfigInstaller(ConfigurationAdmin configAdmin);  FeatureConfigInstaller(ConfigurationAdmin configAdmin, boolean configCfgStore); }
FeatureConfigInstaller { protected static String substFinalName(String finalname) { final String markerVarBeg = "${"; final String markerVarEnd = "}"; boolean startsWithVariable = finalname.startsWith(markerVarBeg) && finalname.contains(markerVarEnd); final String dummyKey = ""; try { finalname = InterpolationHelper.substVars(finalname, dummyKey, null, null, null, true, true, false); } catch (final IllegalArgumentException ex) { LOGGER.info("Substitution failed. Skip substitution of variables of configuration final name ({}).", finalname); } if (!startsWithVariable || finalname.startsWith(markerVarBeg)) { final String basePath = System.getProperty("karaf.base"); finalname = basePath + File.separator + finalname; } while (finalname.contains(markerVarBeg) && finalname.contains(markerVarEnd)) { int beg = finalname.indexOf(markerVarBeg); int end = finalname.indexOf(markerVarEnd); final String rem = finalname.substring(beg, end + markerVarEnd.length()); finalname = finalname.replace(rem, ""); } return finalname; } FeatureConfigInstaller(ConfigurationAdmin configAdmin);  FeatureConfigInstaller(ConfigurationAdmin configAdmin, boolean configCfgStore); void installFeatureConfigs(Feature feature); void uninstallFeatureConfigs(Feature feature); }
FeatureConfigInstaller { protected static String substFinalName(String finalname) { final String markerVarBeg = "${"; final String markerVarEnd = "}"; boolean startsWithVariable = finalname.startsWith(markerVarBeg) && finalname.contains(markerVarEnd); final String dummyKey = ""; try { finalname = InterpolationHelper.substVars(finalname, dummyKey, null, null, null, true, true, false); } catch (final IllegalArgumentException ex) { LOGGER.info("Substitution failed. Skip substitution of variables of configuration final name ({}).", finalname); } if (!startsWithVariable || finalname.startsWith(markerVarBeg)) { final String basePath = System.getProperty("karaf.base"); finalname = basePath + File.separator + finalname; } while (finalname.contains(markerVarBeg) && finalname.contains(markerVarEnd)) { int beg = finalname.indexOf(markerVarBeg); int end = finalname.indexOf(markerVarEnd); final String rem = finalname.substring(beg, end + markerVarEnd.length()); finalname = finalname.replace(rem, ""); } return finalname; } FeatureConfigInstaller(ConfigurationAdmin configAdmin);  FeatureConfigInstaller(ConfigurationAdmin configAdmin, boolean configCfgStore); void installFeatureConfigs(Feature feature); void uninstallFeatureConfigs(Feature feature);  }