Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Commons Lang/IO dependency #29

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions aem-classification-validator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@
<artifactId>commons-csv</artifactId>
<version>1.12.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -125,7 +124,7 @@ static Map<ContentClassification, ValidationMessageSeverity> getSeverityPerClass
private static Map<ContentClassification, ValidationMessageSeverity> parseSeverityClassification(List<String> severities) {
Map<ContentClassification, ValidationMessageSeverity> 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())));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected void put(@NotNull String resourcePath, @NotNull ContentClassification
@NotNull
public Entry<ContentClassification, String> getContentClassificationAndRemarkForResourcePath(@NotNull String resourcePath, @Nullable Collection<Pattern> whitelistedResourcePaths) {
// ignore empty resourceTypes
if (resourcePath == null || resourcePath.isEmpty()) {
if (resourcePath.isEmpty()) {
return new SimpleEntry<>(ContentClassification.PUBLIC, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<String, ContentClassification> entry : classificationMap.entrySet()) {
Collection<String> values = new LinkedList<>();
Expand Down