Skip to content

Commit 064329d

Browse files
committed
Emit all products in map comment
Not only the main AEM version but also add-ons installed on top
1 parent bf37eca commit 064329d

File tree

3 files changed

+47
-14
lines changed

3 files changed

+47
-14
lines changed

aem-classification-maven-plugin/src/main/java/biz/netcentric/filevault/validator/aem/classification/mojo/DownloadContentClassificationMojo.java

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313
* #L%
1414
*/
1515

16+
17+
import java.io.BufferedReader;
1618
import java.io.IOException;
1719
import java.io.InputStream;
20+
import java.io.InputStreamReader;
1821
import java.io.OutputStream;
1922
import java.net.URI;
2023
import java.net.URLEncoder;
@@ -25,8 +28,10 @@
2528
import java.nio.file.Files;
2629
import java.nio.file.Path;
2730
import java.util.Base64;
31+
import java.util.Collection;
2832
import java.util.Date;
2933
import java.util.EnumSet;
34+
import java.util.LinkedList;
3035
import java.util.List;
3136
import java.util.Map;
3237
import java.util.jar.Attributes;
@@ -94,12 +99,12 @@ public void execute() throws MojoExecutionException, MojoFailureException {
9499
Log log = getLog();
95100
HttpClient httpClient = HttpClient.newHttpClient();
96101
try {
97-
String aemVersion = getAemVersion(httpClient);
102+
Collection<String> products = getProducts(httpClient);
98103

99104
log.warn("Make sure that the relevant search index definitions are deployed on AEM at " + baseUrl + ". Otherwise this goal will fail!");
100105
log.info("Start retrieving the classification and deprecation data from " + baseUrl);
101106

102-
MutableContentClassificationMap map = new MutableContentClassificationMapImpl("AEM " + aemVersion);
107+
MutableContentClassificationMap map = new MutableContentClassificationMapImpl(products.stream().collect(Collectors.joining(", ")));
103108
// always make sure that the root node is PUBLIC (even though this might not be part of the classification map extracted from a repo)
104109
map.put("/", ContentClassification.PUBLIC, null);
105110
// 1. retrieve classifications from mixins and store in map
@@ -138,19 +143,30 @@ public void execute() throws MojoExecutionException, MojoFailureException {
138143
}
139144
}
140145

141-
String getAemVersion(HttpClient httpClient) throws IOException, InterruptedException {
142-
try (InputStream input = downloadFromAem(httpClient, "/libs/granite/operations/content/systemoverview/export.json")) {
143-
JSONParser parser = new JSONParser(input);
144-
Map<String, Object> response = parser.getParsed();
145-
getLog().debug("Received JSON response " + response);
146-
147-
Object results = response.get("Instance");
148-
if (!(results instanceof Map<?, ?>)) {
149-
throw new IllegalStateException("JSON response did not have an array of results");
146+
Collection<String> getProducts(HttpClient httpClient) throws IOException, InterruptedException {
147+
// http://localhost:4502/system/console/status-productinfo does not provide proper JSON, therefore parse TXT
148+
try (InputStream input = downloadFromAem(httpClient, "/system/console/status-productinfo.txt")) {
149+
return extractProductsFromProductInfo(input);
150+
}
151+
}
152+
153+
static Collection<String> extractProductsFromProductInfo(InputStream input) throws IOException {
154+
try (BufferedReader reader = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8))) {
155+
String line;
156+
Collection<String> products = new LinkedList<>();
157+
boolean isRelevantLine = false;
158+
while ((line = reader.readLine()) != null) {
159+
if (line.equals("Installed Products")) {
160+
// the rest is relevant
161+
isRelevantLine = true;
162+
} else if(isRelevantLine){
163+
String product = line.trim();
164+
if (!product.isEmpty()) {
165+
products.add(product);
166+
}
167+
}
150168
}
151-
@SuppressWarnings("unchecked")
152-
Map<String, Object> subResult = (Map<String, Object>)results;
153-
return (String) subResult.get("Adobe Experience Manager");
169+
return products;
154170
}
155171
}
156172

aem-classification-maven-plugin/src/test/java/biz/netcentric/filevault/validator/aem/classification/mojo/DownloadContentClassificationMojoTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515

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

18+
import java.io.IOException;
1819
import java.nio.file.Path;
1920
import java.nio.file.Paths;
21+
import java.util.List;
2022

2123
import org.junit.jupiter.api.Test;
2224

@@ -28,4 +30,9 @@ void testGetPathWithUnixSeparators() {
2830
assertEquals("my/test/path", DownloadContentClassificationMojo.getPathWithUnixSeparators(path));
2931
}
3032

33+
@Test
34+
void testProductsFromProductInfo() throws IOException {
35+
assertEquals(List.of("Adobe Experience Manager (2025.11.23482.20251120T200914Z)", "cif (2025.10.15.00)", "forms (2025.10.17.02)"),
36+
DownloadContentClassificationMojo.extractProductsFromProductInfo(DownloadContentClassificationMojo.class.getResourceAsStream("/productinfo.txt")));
37+
}
3138
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*** Product Information:
2+
License
3+
Customer: Customer A
4+
Download ID: xxxxxxxxxxx
5+
Product : Some Product
6+
7+
Installed Products
8+
Adobe Experience Manager (2025.11.23482.20251120T200914Z)
9+
cif (2025.10.15.00)
10+
forms (2025.10.17.02)

0 commit comments

Comments
 (0)