Skip to content

Commit

Permalink
Remove Commons Lang dependency (#28)
Browse files Browse the repository at this point in the history
Update Commons CSV/IO dependency
  • Loading branch information
kwin authored Oct 10, 2024
1 parent c494ff5 commit ad43dff
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 2 additions & 7 deletions aem-classification-validator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,12 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.5</version>
<version>1.12.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -59,7 +58,7 @@ public class ContentClassificationMapImpl implements ContentClassificationMap {
protected final Map<String, String> 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) {
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -110,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 (StringUtils.isBlank(resourcePath)) {
if (resourcePath == null || resourcePath.isEmpty()) {
return new SimpleEntry<>(ContentClassification.PUBLIC, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
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;

Expand All @@ -36,8 +34,6 @@
*/
public class MutableContentClassificationMapImpl extends ContentClassificationMapImpl implements MutableContentClassificationMap {

private static final CSVFormat CSV_FORMAT = CSVFormat.RFC4180.withCommentMarker('#');

public MutableContentClassificationMapImpl(@NotNull String label) {
super(label);
}
Expand All @@ -56,7 +52,7 @@ public void write(@NotNull OutputStream output) throws IOException {
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);
Expand Down

0 comments on commit ad43dff

Please sign in to comment.