Skip to content

Commit b9be058

Browse files
committed
Do not prepend /jcr_root at the beginning of the pattern. instead it has to be provided explicitly
1 parent 01ffb2b commit b9be058

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/configreader/ConfigFilesRetrieverImpl.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ public Map<String, String> getConfigFileContentFromPackage(Archive archive, Coll
5858
return configurations;
5959
}
6060

61-
private Map<String, String> getConfigurations(PackageEntryOrNode configFileOrDir, Collection<String> configFilePatterns) throws Exception {
61+
private Map<String, String> getConfigurations(PackageEntryOrNode configFileOrDir, Collection<String> configFilePatterns)
62+
throws Exception {
6263
Map<String, String> configs = new TreeMap<String, String>();
6364

6465
for (PackageEntryOrNode entry : configFileOrDir.getChildren()) {
@@ -67,18 +68,16 @@ private Map<String, String> getConfigurations(PackageEntryOrNode configFileOrDir
6768
configs.putAll(resultsFromDir);
6869
continue;
6970
}
70-
7171
if (isRelevantConfiguration(entry, configFileOrDir.getName(), slingSettingsService, configFilePatterns)) {
7272
LOG.debug("Found relevant YAML file {}", entry.getName());
7373
configs.put(entry.getPath(), entry.getContentAsString());
7474
}
75-
7675
}
7776
return configs;
7877
}
7978

8079
static boolean isRelevantConfiguration(final PackageEntryOrNode entry, final String parentName,
81-
ExtendedSlingSettingsService slingSettings, Collection<String> configFilePatterns) throws Exception {
80+
ExtendedSlingSettingsService slingSettings, Collection<String> configFilePatterns) throws Exception {
8281
boolean matchPattern = configFilePatterns.isEmpty();
8382
for (String pathPattern : configFilePatterns) {
8483
if (entry.getPath().matches(pathPattern)) {
@@ -90,9 +89,8 @@ static boolean isRelevantConfiguration(final PackageEntryOrNode entry, final Str
9089
return false;
9190
}
9291
String entryName = entry.getName();
93-
if (!entryName.endsWith(".yaml") && !entryName.equals("config") /*
94-
* name 'config' without .yaml allowed for backwards compatibility
95-
*/) {
92+
// name 'config' without .yaml allowed for backwards compatibility
93+
if (!entryName.endsWith(".yaml") && !entryName.equals("config")) {
9694
return false;
9795
}
9896

accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/installhook/impl/AcToolInstallHookServiceImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ public PersistableInstallationLogger installYamlFilesFromPackage(VaultPackage va
4848
Set<Object> propertiesKeys = packageProperties.keySet();
4949
for (Object property : propertiesKeys) {
5050
if (property.toString().matches(ACL_HOOK_PATHS)) {
51-
// archive paths have a /jcr_root prefix which users shouldnt worry about
52-
configPathPatterns.add("/jcr_root" + packageProperties.getProperty(property.toString()));
51+
configPathPatterns.add(packageProperties.getProperty(property.toString()));
5352
}
5453
}
5554

accesscontroltool-bundle/src/test/java/biz/netcentric/cq/tools/actool/configreader/ConfigFilesRetrieverImplTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,16 @@ public void testIsRelevantConfigurationsFiltered() throws Exception {
9797
Set<String> currentRunmodes = new HashSet<String>(
9898
Arrays.asList("author"));
9999
slingSettings = new ExtendedSlingSettingsServiceImpl(currentRunmodes);
100-
Assert.assertTrue((ConfigFilesRetrieverImpl.isRelevantConfiguration(new StubEntry("/conf", "file.yaml"), "config.author",
100+
Assert.assertTrue((ConfigFilesRetrieverImpl.isRelevantConfiguration(new StubEntry("/jcr_root/conf", "file.yaml"), "config.author",
101101
slingSettings, ImmutableList.<String> of())));
102-
Assert.assertTrue((ConfigFilesRetrieverImpl.isRelevantConfiguration(new StubEntry("/conf", "file.yaml"), "config.author",
103-
slingSettings, ImmutableList.<String> of("/noMatch", "/conf/.*"))));
104-
Assert.assertFalse((ConfigFilesRetrieverImpl.isRelevantConfiguration(new StubEntry("/conf", "file.yaml"), "config.author",
105-
slingSettings, ImmutableList.<String> of("/conf/test.*.yaml"))));
106-
Assert.assertTrue((ConfigFilesRetrieverImpl.isRelevantConfiguration(new StubEntry("/conf", "file.yaml"), "config.author",
107-
slingSettings, ImmutableList.<String> of("/conf/.*\\.yaml", "/noMatch"))));
108-
Assert.assertFalse((ConfigFilesRetrieverImpl.isRelevantConfiguration(new StubEntry("/conf", "file.yaml"), "config.author",
109-
slingSettings, ImmutableList.<String> of("/nonconf.*"))));
102+
Assert.assertTrue((ConfigFilesRetrieverImpl.isRelevantConfiguration(new StubEntry("/jcr_root/conf", "file.yaml"), "config.author",
103+
slingSettings, ImmutableList.<String> of("/noMatch", "/jcr_root/conf/.*"))));
104+
Assert.assertFalse((ConfigFilesRetrieverImpl.isRelevantConfiguration(new StubEntry("/jcr_root/conf", "file.yaml"), "config.author",
105+
slingSettings, ImmutableList.<String> of("/jcr_root/conf/test.*.yaml"))));
106+
Assert.assertTrue((ConfigFilesRetrieverImpl.isRelevantConfiguration(new StubEntry("/jcr_root/conf", "file.yaml"), "config.author",
107+
slingSettings, ImmutableList.<String> of("/jcr_root/conf/.*\\.yaml", "/noMatch"))));
108+
Assert.assertFalse((ConfigFilesRetrieverImpl.isRelevantConfiguration(new StubEntry("/jcr_root/conf", "file.yaml"), "config.author",
109+
slingSettings, ImmutableList.<String> of("/jcr_root/nonconf.*"))));
110110

111111
}
112112

docs/ApplyConfig.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ If you would rather use the filevault-package-maven-plugin for building the pack
6969
</plugin>
7070
```
7171

72-
The `*.yaml` files are installed directly from the package content and respect the [run mode semantics](Configuration.md). Otherwise there is no limitation, so the YAML files will be picked up from anywhere in the package (as long as the parent node does not contain a `.` followed by one or multiple not matching run modes). If you wish to limit where the YAML files are looked upon you can add one or more package properties with a regular expression to match the desired paths. The properties names should start with `actool.hook.paths.patterns`:
72+
The `*.yaml` files are installed directly from the package content and respect the [run mode semantics](Configuration.md). Otherwise there is no limitation, so the YAML files will be picked up from anywhere in the package (as long as the parent node does not contain a `.` followed by one or multiple not matching run modes).
73+
74+
If you wish to limit which YAML files are picked up by the installation hook, you can add one or more regular expressions as package properties that start with the prefix `actool.hook.paths.patterns`. If the path of a file within the package matches any of the provided patterns, it will be picked up by the installation hook:
7375

7476
```
7577
<plugin>
@@ -78,8 +80,8 @@ The `*.yaml` files are installed directly from the package content and respect t
7880
<configuration>
7981
<properties>
8082
<installhook.actool.class>biz.netcentric.cq.tools.actool.installhook.AcToolInstallHook</installhook.actool.class>
81-
<actool.hook.paths.patterns.groups>/apps/myapp/acl/groups.*</actool.hook.paths.patterns.groups>
82-
<actool.hook.paths.patterns.users>/apps/myapp/acl/users.*</actool.hook.paths.patterns.users>
83+
<actool.hook.paths.patterns.groups>/jcr_content/apps/myapp/acl/groups.*</actool.hook.paths.patterns.groups>
84+
<actool.hook.paths.patterns.users>/jcr_content/apps/myapp/acl/users.*</actool.hook.paths.patterns.users>
8385
</properties>
8486
</configuration>
8587
</plugin>

0 commit comments

Comments
 (0)