From 3b3c0fcd27f32725d2788ca45629fcb0f923ab7f Mon Sep 17 00:00:00 2001 From: Konrad Windszus Date: Thu, 10 Oct 2024 10:29:29 +0200 Subject: [PATCH] Remove Commons IO/Lang dependency completely --- aem-classification-validator/pom.xml | 5 ----- .../aem/classification/AemClassificationValidator.java | 3 +-- .../classification/AemClassificationValidatorFactory.java | 5 ++--- .../aem/classification/MutableContentClassificationMap.java | 2 +- .../aem/classification/map/ContentClassificationMapImpl.java | 2 +- .../map/MutableContentClassificationMapImpl.java | 3 +-- 6 files changed, 6 insertions(+), 14 deletions(-) diff --git a/aem-classification-validator/pom.xml b/aem-classification-validator/pom.xml index 8edca2b..e6947d3 100644 --- a/aem-classification-validator/pom.xml +++ b/aem-classification-validator/pom.xml @@ -40,11 +40,6 @@ commons-csv 1.12.0 - - commons-io - commons-io - 2.17.0 - org.slf4j slf4j-api diff --git a/aem-classification-validator/src/main/java/biz/netcentric/filevault/validator/aem/classification/AemClassificationValidator.java b/aem-classification-validator/src/main/java/biz/netcentric/filevault/validator/aem/classification/AemClassificationValidator.java index 03287c3..2372aa9 100644 --- a/aem-classification-validator/src/main/java/biz/netcentric/filevault/validator/aem/classification/AemClassificationValidator.java +++ b/aem-classification-validator/src/main/java/biz/netcentric/filevault/validator/aem/classification/AemClassificationValidator.java @@ -30,7 +30,6 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; -import org.apache.commons.lang3.StringUtils; import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl; import org.apache.jackrabbit.vault.util.DocViewNode; import org.apache.jackrabbit.vault.validation.spi.DocumentViewXmlValidator; @@ -230,7 +229,7 @@ private static boolean isJspFile(Path file) { } static @NotNull String extendMessageWithRemark(@NotNull String message, String remark) { - if (StringUtils.isNotBlank(remark)) { + if (remark != null && !remark.isEmpty()) { return message + " Remark: " + remark; } return message; diff --git a/aem-classification-validator/src/main/java/biz/netcentric/filevault/validator/aem/classification/AemClassificationValidatorFactory.java b/aem-classification-validator/src/main/java/biz/netcentric/filevault/validator/aem/classification/AemClassificationValidatorFactory.java index a40b207..3000017 100644 --- a/aem-classification-validator/src/main/java/biz/netcentric/filevault/validator/aem/classification/AemClassificationValidatorFactory.java +++ b/aem-classification-validator/src/main/java/biz/netcentric/filevault/validator/aem/classification/AemClassificationValidatorFactory.java @@ -27,7 +27,6 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; -import org.apache.commons.lang3.StringUtils; import org.apache.jackrabbit.vault.validation.spi.ValidationContext; import org.apache.jackrabbit.vault.validation.spi.ValidationMessageSeverity; import org.apache.jackrabbit.vault.validation.spi.Validator; @@ -61,7 +60,7 @@ public class AemClassificationValidatorFactory implements ValidatorFactory { public Validator createValidator(@NotNull ValidationContext context, @NotNull ValidatorSettings settings) { String mapUrls = settings.getOptions().get(OPTION_MAPS); // either load map from classpath, from filesystem or from generic url - if (StringUtils.isBlank(mapUrls)) { + if (mapUrls == null || mapUrls.isEmpty()) { throw new IllegalArgumentException("Mandatory option " + OPTION_MAPS + " missing!"); } String optionWhitelistedResourcePaths = null; @@ -125,7 +124,7 @@ static Map getSeverityPerClass private static Map parseSeverityClassification(List severities) { Map result = severities.stream() .map(severity -> severity.split("=")) - .filter(arr -> arr.length == 2 && !StringUtils.isEmpty(arr[0]) && !StringUtils.isEmpty(arr[1])) + .filter(arr -> arr.length == 2 && !arr[0].isEmpty() && !arr[1].isEmpty()) .collect(Collectors.toMap(s -> ContentClassification.valueOf(s[0].trim()), s -> ValidationMessageSeverity.valueOf(s[1].trim()))); diff --git a/aem-classification-validator/src/main/java/biz/netcentric/filevault/validator/aem/classification/MutableContentClassificationMap.java b/aem-classification-validator/src/main/java/biz/netcentric/filevault/validator/aem/classification/MutableContentClassificationMap.java index ad15efe..7910c34 100644 --- a/aem-classification-validator/src/main/java/biz/netcentric/filevault/validator/aem/classification/MutableContentClassificationMap.java +++ b/aem-classification-validator/src/main/java/biz/netcentric/filevault/validator/aem/classification/MutableContentClassificationMap.java @@ -28,7 +28,7 @@ public interface MutableContentClassificationMap extends ContentClassificationMa /** * Writes the map to a given output stream. - * Leaves the output stream open. + * Closes the stream upon completion. * * @param outputStream the stream to write to * @throws IOException in case of any exception during writing diff --git a/aem-classification-validator/src/main/java/biz/netcentric/filevault/validator/aem/classification/map/ContentClassificationMapImpl.java b/aem-classification-validator/src/main/java/biz/netcentric/filevault/validator/aem/classification/map/ContentClassificationMapImpl.java index 9a65522..a2d7a60 100644 --- a/aem-classification-validator/src/main/java/biz/netcentric/filevault/validator/aem/classification/map/ContentClassificationMapImpl.java +++ b/aem-classification-validator/src/main/java/biz/netcentric/filevault/validator/aem/classification/map/ContentClassificationMapImpl.java @@ -109,7 +109,7 @@ protected void put(@NotNull String resourcePath, @NotNull ContentClassification @NotNull public Entry getContentClassificationAndRemarkForResourcePath(@NotNull String resourcePath, @Nullable Collection whitelistedResourcePaths) { // ignore empty resourceTypes - if (resourcePath == null || resourcePath.isEmpty()) { + if (resourcePath.isEmpty()) { return new SimpleEntry<>(ContentClassification.PUBLIC, null); } diff --git a/aem-classification-validator/src/main/java/biz/netcentric/filevault/validator/aem/classification/map/MutableContentClassificationMapImpl.java b/aem-classification-validator/src/main/java/biz/netcentric/filevault/validator/aem/classification/map/MutableContentClassificationMapImpl.java index 8f735ff..882b5d6 100644 --- a/aem-classification-validator/src/main/java/biz/netcentric/filevault/validator/aem/classification/map/MutableContentClassificationMapImpl.java +++ b/aem-classification-validator/src/main/java/biz/netcentric/filevault/validator/aem/classification/map/MutableContentClassificationMapImpl.java @@ -22,7 +22,6 @@ import java.util.Map.Entry; import org.apache.commons.csv.CSVPrinter; -import org.apache.commons.io.output.CloseShieldOutputStream; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -45,7 +44,7 @@ public void put(@NotNull String resourcePath, @NotNull ContentClassification cla @Override public void write(@NotNull OutputStream output) throws IOException { - try (CSVPrinter csvPrinter = new CSVPrinter(new OutputStreamWriter(new CloseShieldOutputStream(output), StandardCharsets.US_ASCII), CSV_FORMAT)) { + try (CSVPrinter csvPrinter = new CSVPrinter(new OutputStreamWriter(output, StandardCharsets.US_ASCII), CSV_FORMAT)) { csvPrinter.printComment(getLabel()); for (Entry entry : classificationMap.entrySet()) { Collection values = new LinkedList<>();