diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index d967dbe..8c20835 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -31,7 +31,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Build Site for Maven Plugin if: github.ref != 'refs/heads/master' - run: mvn -B clean site --file aem-classification-maven-plugin/pom.xml + run: ./mvnw -B clean site --file aem-classification-maven-plugin/pom.xml - name: Build, Analyse and Deploy Reactor with Maven if: github.ref == 'refs/heads/master' run: ./mvnw -B clean deploy org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=Netcentric_aem-classification -Dsonar.organization=netcentric -Dsonar.host.url=https://sonarcloud.io -Pcoverage-report @@ -51,6 +51,7 @@ jobs: with: path: aem-classification-maven-plugin/target/site/ deploy: + if: github.ref == 'refs/heads/master' # Add a dependency to the build job needs: build # Grant GITHUB_TOKEN the permissions required to make a Pages deployment diff --git a/aem-classification-validator/pom.xml b/aem-classification-validator/pom.xml index d855741..e6947d3 100644 --- a/aem-classification-validator/pom.xml +++ b/aem-classification-validator/pom.xml @@ -38,17 +38,7 @@ org.apache.commons commons-csv - 1.6 - - - commons-lang - commons-lang - 2.5 - - - commons-io - commons-io - 2.7 + 1.12.0 org.slf4j 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 192ea25..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 @@ -28,7 +28,6 @@ import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVRecord; -import org.apache.commons.lang.StringUtils; import org.apache.jackrabbit.util.Text; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -59,7 +58,7 @@ public class ContentClassificationMapImpl implements ContentClassificationMap { protected final Map remarkMap; // key = absolute repository path private String label; - private static final CSVFormat CSV_FORMAT = CSVFormat.RFC4180.withCommentMarker('#'); + static final CSVFormat CSV_FORMAT = CSVFormat.Builder.create(CSVFormat.RFC4180).setCommentMarker('#').build(); private static final Logger LOGGER = LoggerFactory.getLogger(ContentClassificationMapImpl.class); public ContentClassificationMapImpl(String label) { @@ -101,7 +100,7 @@ protected void put(@NotNull String resourcePath, @NotNull ContentClassification throw new IllegalArgumentException("Only absolute resource paths are supported, but resource path given is '" + resourcePath + "'."); } classificationMap.put(resourcePath, classification); - if (StringUtils.isNotEmpty(remark)) { + if (remark != null && !remark.isEmpty()) { remarkMap.put(resourcePath, remark); } } @@ -110,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 (StringUtils.isBlank(resourcePath)) { + 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 7fe0974..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 @@ -21,10 +21,7 @@ import java.util.LinkedList; import java.util.Map.Entry; -import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVPrinter; -import org.apache.commons.io.output.CloseShieldOutputStream; -import org.apache.commons.lang.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -36,8 +33,6 @@ */ public class MutableContentClassificationMapImpl extends ContentClassificationMapImpl implements MutableContentClassificationMap { - private static final CSVFormat CSV_FORMAT = CSVFormat.RFC4180.withCommentMarker('#'); - public MutableContentClassificationMapImpl(@NotNull String label) { super(label); } @@ -49,14 +44,14 @@ 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<>(); values.add(entry.getKey()); // resource type values.add(entry.getValue().toString()); String remark = remarkMap.get(entry.getKey()); - if (StringUtils.isNotEmpty(remark)) { + if (remark != null && !remark.isEmpty()) { values.add(remark); } csvPrinter.printRecord(values);