Skip to content

Commit 9420458

Browse files
authored
Compile for Java 11 (#828)
Adjust AEM dependencies to 6.5.18 Get rid of commons-io dependency This closes #777
1 parent f3c091c commit 9420458

File tree

20 files changed

+92
-497
lines changed

20 files changed

+92
-497
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ See also our talk at [adaptTo() 2016](https://adapt.to/2016/en/schedule/ac-tool.
2626

2727
# Requirements
2828

29-
The AC Tool requires **Java 8 and AEM 6.4** or above (use v2.x for older AEM versions which runs on Java 7 and AEM 6.1 SP1 or above) for on-premise installations. Since v2.5.0 **[AEM as a Cloud Service](https://business.adobe.com/products/experience-manager/cloud-service.html)** is supported, see [Startup Hook](https://github.com/Netcentric/accesscontroltool/blob/develop/docs/ApplyConfig.md#startup-hook) for details.
29+
The AC Tool requires **Java 11 and AEM 6.5.18** or above (use v3.x for older AEM versions which runs on Java 8 and AEM 6.4 or above) for on-premise installations. Since v2.5.0 **[AEM as a Cloud Service](https://www.adobe.com/marketing/experience-manager/cloud-service.html)** is supported, see [Startup Hook](https://github.com/Netcentric/accesscontroltool/blob/develop/docs/ApplyConfig.md#startup-hook) for details.
3030

31-
It is also possible to run the AC Tool on **Apache Sling 11** or above (ensure system user `actool-service` has `jcr:all` permissions on root). When using the AC Tool with Sling, actions in ACE definitions and encrypted passwords cannot be used. To use the `externalId` attribute, ensure bundle `oak-auth-external` installed (not part of default Sling distribution).
31+
It is also possible to run the AC Tool on **Apache Sling 12** or above (ensure system user `actool-service` has `jcr:all` permissions on root). When using the AC Tool with Sling, actions in ACE definitions and encrypted passwords cannot be used. To use the `externalId` attribute, ensure bundle `oak-auth-external` installed (not part of default Sling distribution).
3232

3333
# Installation
3434

accesscontroltool-apps-package/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<parent>
1616
<groupId>biz.netcentric.cq.tools.accesscontroltool</groupId>
1717
<artifactId>accesscontroltool</artifactId>
18-
<version>3.6.3-SNAPSHOT</version>
18+
<version>4.0.0-SNAPSHOT</version>
1919
</parent>
2020

2121
<!-- ====================================================================== -->

accesscontroltool-bundle/maximum-aem.bndrun

Lines changed: 0 additions & 17 deletions
This file was deleted.

accesscontroltool-bundle/pom.xml

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<parent>
1212
<groupId>biz.netcentric.cq.tools.accesscontroltool</groupId>
1313
<artifactId>accesscontroltool</artifactId>
14-
<version>3.6.3-SNAPSHOT</version>
14+
<version>4.0.0-SNAPSHOT</version>
1515
</parent>
1616

1717
<!-- ====================================================================== -->
@@ -26,6 +26,7 @@
2626
<properties>
2727
<tomcat.el.version>9.0.104</tomcat.el.version>
2828
<oak.testing.version>1.48.0</oak.testing.version><!-- ITs require a newer version of Oak otherwise it won't work with Java 11 and certain classes for running the IT are not available -->
29+
2930
</properties>
3031

3132
<dependencies>
@@ -112,14 +113,9 @@
112113
<artifactId>commons-collections4</artifactId>
113114
<scope>provided</scope>
114115
</dependency>
115-
<dependency>
116-
<groupId>commons-io</groupId>
117-
<artifactId>commons-io</artifactId>
118-
<scope>provided</scope>
119-
</dependency>
120116
<dependency>
121117
<groupId>org.apache.jackrabbit</groupId>
122-
<artifactId>jackrabbit-api</artifactId>
118+
<artifactId>oak-jackrabbit-api</artifactId>
123119
<scope>provided</scope>
124120
</dependency>
125121
<dependency>
@@ -177,6 +173,7 @@
177173
<artifactId>org.apache.sling.hc.api</artifactId>
178174
<scope>provided</scope>
179175
</dependency>
176+
<!-- mainly constants and some principal impls -->
180177
<dependency>
181178
<groupId>org.apache.jackrabbit</groupId>
182179
<artifactId>oak-security-spi</artifactId>
@@ -294,7 +291,6 @@
294291
<dependency>
295292
<groupId>org.osgi</groupId>
296293
<artifactId>org.osgi.util.converter</artifactId>
297-
<version>1.0.9</version>
298294
<scope>test</scope>
299295
</dependency>
300296
<!-- IT dependencies -->
@@ -348,7 +344,12 @@
348344
<version>2.16.0</version>
349345
<scope>test</scope>
350346
</dependency>
351-
347+
<!-- transitive dependency of oak-security-spi-->
348+
<dependency>
349+
<groupId>com.google.guava</groupId>
350+
<artifactId>guava</artifactId>
351+
<scope>test</scope>
352+
</dependency>
352353
<!-- END: Test Dependencies -->
353354
</dependencies>
354355

@@ -445,19 +446,7 @@
445446
</bndruns>
446447
</configuration>
447448
</execution>
448-
<execution>
449-
<id>resolve-against-maximum</id>
450-
<goals>
451-
<goal>resolve</goal>
452-
</goals>
453-
<phase>verify</phase>
454-
<configuration>
455-
<useMavenDependencies>false</useMavenDependencies>
456-
<bndruns>
457-
<include>maximum-aem.bndrun</include>
458-
</bndruns>
459-
</configuration>
460-
</execution>
449+
<!-- resolving against the maximum, i.e. AEMaaCS version happens separately in the aemanalyser-maven-plugin -->
461450
</executions>
462451
<configuration>
463452
<useMavenDependencies>true</useMavenDependencies>

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import java.io.InputStream;
1717
import java.io.StringWriter;
18+
import java.nio.charset.StandardCharsets;
1819
import java.util.Collection;
1920
import java.util.Collections;
2021
import java.util.Iterator;
@@ -27,7 +28,6 @@
2728
import javax.jcr.Session;
2829
import javax.jcr.nodetype.NodeType;
2930

30-
import org.apache.commons.io.IOUtils;
3131
import org.apache.commons.lang3.StringUtils;
3232
import org.apache.jackrabbit.commons.JcrUtils;
3333
import org.apache.jackrabbit.vault.fs.io.Archive;
@@ -189,9 +189,7 @@ public boolean isDirectory() throws Exception {
189189
@Override
190190
public String getContentAsString() throws Exception {
191191
try (InputStream configInputStream = JcrUtils.readFile(node)) {
192-
StringWriter writer = new StringWriter();
193-
IOUtils.copy(configInputStream, writer, "UTF-8");
194-
String configData = writer.toString();
192+
String configData = new String(configInputStream.readAllBytes(), StandardCharsets.UTF_8);
195193
LOG.debug("Found configuration data of node: {} with {} chars", node.getPath(), configData.length());
196194
return configData;
197195
}
@@ -243,9 +241,7 @@ public String getContentAsString() throws Exception {
243241
if (input == null) {
244242
throw new IllegalStateException("Could not get input stream from entry " + getPath());
245243
}
246-
StringWriter writer = new StringWriter();
247-
IOUtils.copy(input, writer, "UTF-8");
248-
return writer.toString();
244+
return new String(input.readAllBytes(), StandardCharsets.UTF_8);
249245
}
250246
}
251247
}

accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/history/impl/HistoryUtils.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.io.ByteArrayInputStream;
1919
import java.io.IOException;
20+
import java.io.InputStream;
2021
import java.io.StringReader;
2122
import java.nio.charset.StandardCharsets;
2223
import java.util.ArrayList;
@@ -36,7 +37,6 @@
3637
import javax.jcr.nodetype.ConstraintViolationException;
3738
import javax.jcr.version.VersionException;
3839

39-
import org.apache.commons.io.IOUtils;
4040
import org.apache.commons.lang3.StringUtils;
4141
import org.apache.commons.lang3.text.WordUtils;
4242
import org.apache.jackrabbit.commons.JcrUtils;
@@ -332,7 +332,9 @@ public static String getLog(final Session session, final String path,
332332
logFileNode = historyNode.getNode(LOG_FILE_NAME);
333333
}
334334
sb.append(PersistableInstallationLogger.EOL);
335-
sb.append(IOUtils.toString(JcrUtils.readFile(logFileNode), StandardCharsets.UTF_8));
335+
try (InputStream logFileStream = JcrUtils.readFile(logFileNode)) {
336+
sb.append(new String(logFileStream.readAllBytes(), StandardCharsets.UTF_8));
337+
}
336338
}
337339

338340
sb.append(lineFeedSymbol

accesscontroltool-bundle/src/test/java/biz/netcentric/cq/tools/actool/aceinstaller/AceBeanInstallerIncrementalTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry;
5252
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList;
5353
import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager;
54-
import org.apache.jackrabbit.api.security.authorization.PrivilegeCollection;
5554
import org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl;
5655
import org.apache.sling.jcr.api.SlingRepository;
5756
import org.junit.jupiter.api.BeforeEach;

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
import org.hamcrest.Matchers;
2929
import org.junit.jupiter.api.Test;
3030

31-
import com.google.common.collect.ImmutableList;
32-
3331
import biz.netcentric.cq.tools.actool.slingsettings.ExtendedSlingSettingsServiceImpl;
3432

3533
public class ConfigFilesRetrieverImplTest {
@@ -107,15 +105,15 @@ public void testIsRelevantConfigurationsFiltered() throws Exception {
107105
Arrays.asList("author"));
108106
slingSettings = new ExtendedSlingSettingsServiceImpl(currentRunmodes);
109107
assertTrue((ConfigFilesRetrieverImpl.isRelevantConfiguration(new StubEntry("/conf", "file.yaml"), "config.author",
110-
slingSettings, ImmutableList.<String> of())));
108+
slingSettings, List.of())));
111109
assertTrue((ConfigFilesRetrieverImpl.isRelevantConfiguration(new StubEntry("/conf", "file.yaml"), "config.author",
112-
slingSettings, ImmutableList.<String> of("/noMatch", "/conf/.*"))));
110+
slingSettings, List.of("/noMatch", "/conf/.*"))));
113111
assertFalse((ConfigFilesRetrieverImpl.isRelevantConfiguration(new StubEntry("/conf", "file.yaml"), "config.author",
114-
slingSettings, ImmutableList.<String> of("/conf/test.*.yaml"))));
112+
slingSettings, List.of("/conf/test.*.yaml"))));
115113
assertTrue((ConfigFilesRetrieverImpl.isRelevantConfiguration(new StubEntry("/conf", "file.yaml"), "config.author",
116-
slingSettings, ImmutableList.<String> of("/conf/.*\\.yaml", "/noMatch"))));
114+
slingSettings, List.of("/conf/.*\\.yaml", "/noMatch"))));
117115
assertFalse((ConfigFilesRetrieverImpl.isRelevantConfiguration(new StubEntry("/conf", "file.yaml"), "config.author",
118-
slingSettings, ImmutableList.<String> of("/nonconf.*"))));
116+
slingSettings, List.of("/nonconf.*"))));
119117

120118
}
121119

accesscontroltool-bundle/src/test/java/biz/netcentric/cq/tools/actool/slingsettings/ExtendedSlingSettingsServiceImplTest.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,19 @@
1515

1616
import static org.junit.jupiter.api.Assertions.assertEquals;
1717

18-
import java.util.Collections;
18+
import java.util.Set;
1919

2020
import org.junit.jupiter.api.Test;
2121

22-
import com.google.common.collect.ImmutableSet;
23-
2422
public class ExtendedSlingSettingsServiceImplTest {
2523

2624
@Test
2725
public void testGetBestRunModeMatchCountFromSpec() {
28-
assertEquals(0, ExtendedSlingSettingsServiceImpl.getBestRunModeMatchCountFromSpec("test1.test2,-test3.test4", Collections.singleton("test5")));
29-
assertEquals(0, ExtendedSlingSettingsServiceImpl.getBestRunModeMatchCountFromSpec("test1.test2,-test3.test4", ImmutableSet.of("test1", "test3")));
30-
assertEquals(0, ExtendedSlingSettingsServiceImpl.getBestRunModeMatchCountFromSpec("test1.test2,-test3.test4", ImmutableSet.of("test2", "test3")));
31-
assertEquals(2, ExtendedSlingSettingsServiceImpl.getBestRunModeMatchCountFromSpec("test1.test2,-test3.test4", ImmutableSet.of("test1", "test2")));
32-
assertEquals(2, ExtendedSlingSettingsServiceImpl.getBestRunModeMatchCountFromSpec("test1.test2,-test3.test4", ImmutableSet.of("test2", "test4")));
33-
assertEquals(3, ExtendedSlingSettingsServiceImpl.getBestRunModeMatchCountFromSpec("test1.test2,-test3.test4,test5.test6.test7", ImmutableSet.of("test1", "test2", "test4", "test5", "test6", "test7")));
26+
assertEquals(0, ExtendedSlingSettingsServiceImpl.getBestRunModeMatchCountFromSpec("test1.test2,-test3.test4", Set.of("test5")));
27+
assertEquals(0, ExtendedSlingSettingsServiceImpl.getBestRunModeMatchCountFromSpec("test1.test2,-test3.test4", Set.of("test1", "test3")));
28+
assertEquals(0, ExtendedSlingSettingsServiceImpl.getBestRunModeMatchCountFromSpec("test1.test2,-test3.test4", Set.of("test2", "test3")));
29+
assertEquals(2, ExtendedSlingSettingsServiceImpl.getBestRunModeMatchCountFromSpec("test1.test2,-test3.test4", Set.of("test1", "test2")));
30+
assertEquals(2, ExtendedSlingSettingsServiceImpl.getBestRunModeMatchCountFromSpec("test1.test2,-test3.test4", Set.of("test2", "test4")));
31+
assertEquals(3, ExtendedSlingSettingsServiceImpl.getBestRunModeMatchCountFromSpec("test1.test2,-test3.test4,test5.test6.test7", Set.of("test1", "test2", "test4", "test5", "test6", "test7")));
3432
}
3533
}

accesscontroltool-content-package/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<parent>
1616
<groupId>biz.netcentric.cq.tools.accesscontroltool</groupId>
1717
<artifactId>accesscontroltool</artifactId>
18-
<version>3.6.3-SNAPSHOT</version>
18+
<version>4.0.0-SNAPSHOT</version>
1919
</parent>
2020

2121
<!-- ====================================================================== -->

0 commit comments

Comments
 (0)