DominikSuess commented on a change in pull request #88:
URL:
https://github.com/apache/sling-org-apache-sling-feature-cpconverter/pull/88#discussion_r663077141
##########
File path:
src/main/java/org/apache/sling/feature/cpconverter/handlers/AbstractConfigurationEntryHandler.java
##########
@@ -48,47 +48,52 @@ public final void handle(@NotNull String path, @NotNull
Archive archive, @NotNul
String runMode;
// we are pretty sure it matches, here
if (matcher.matches()) {
- String pid = matcher.group("pid");
-
- int idx = pid.lastIndexOf('/');
- if (idx != -1) {
- pid = pid.substring(idx + 1);
- }
- String factoryPid = null;
- String id;
- int n = pid.indexOf('~');
- if (n == -1) {
- n = pid.indexOf('-');
- }
- if (n > 0) {
- factoryPid = pid.substring(0, n);
- id = factoryPid.concat("~").concat(pid.substring(n + 1));
+ if (matcher.group("dir") != null) {
+ // preventing invalid results as the corresponding
configuration will be stripped from the resulting package causing the
+ logger.info("{} is only a dir folder next to config -
removing.", path);
} else {
- id = pid;
- }
+ String pid = matcher.group("pid");
- logger.info("Processing configuration '{}'.", id);
+ int idx = pid.lastIndexOf('/');
+ if (idx != -1) {
+ pid = pid.substring(idx + 1);
+ }
+ String factoryPid = null;
+ String id;
+ int n = pid.indexOf('~');
+ if (n == -1) {
+ n = pid.indexOf('-');
+ }
+ if (n > 0) {
+ factoryPid = pid.substring(0, n);
+ id = factoryPid.concat("~").concat(pid.substring(n + 1));
+ } else {
+ id = pid;
+ }
+
+ logger.info("Processing configuration '{}'.", id);
+
+ Dictionary<String, Object> configurationProperties;
+ try (InputStream input =
Objects.requireNonNull(archive.openInputStream(entry))) {
+ configurationProperties = parseConfiguration(id, input);
+ }
+
+ if (configurationProperties == null) {
+ logger.info("{} entry does not contain a valid OSGi
configuration, treating it as a regular resource", path);
+
Objects.requireNonNull(converter.getMainPackageAssembler()).addEntry(path,
archive, entry);
Review comment:
took over changed code during rebase
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]