Skip to content

Commit aefe7ea

Browse files
committed
cosmetic: eliminate code warnings
1 parent 053871f commit aefe7ea

File tree

16 files changed

+46
-40
lines changed

16 files changed

+46
-40
lines changed

conga-aem-plugin/src/main/java/io/wcm/devops/conga/plugins/aem/crypto/CryptoString.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
package io.wcm.devops.conga.plugins.aem.crypto;
2121

22-
import org.apache.commons.lang3.StringUtils;
22+
import org.apache.commons.lang3.Strings;
2323

2424
/**
2525
* Converts byte array to crypto string and back in the same fashion as it is done by the Adobe Granite Crypto
@@ -39,7 +39,7 @@ private CryptoString() {
3939
public static boolean isCryptoString(final String text) {
4040
// very simplified check - just check for start and end of curly braces.
4141
return text != null && text.length() > 2
42-
&& StringUtils.startsWith(text, "{") && StringUtils.endsWith(text, "}");
42+
&& Strings.CS.startsWith(text, "{") && Strings.CS.endsWith(text, "}");
4343
}
4444

4545
/**

conga-aem-plugin/src/main/java/io/wcm/devops/conga/plugins/aem/postprocessor/ContentPackageOsgiConfigPostProcessor.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
import org.apache.commons.io.FilenameUtils;
3838
import org.apache.commons.lang3.StringUtils;
39+
import org.apache.commons.lang3.Strings;
3940
import org.apache.sling.provisioning.model.Model;
4041
import org.slf4j.Logger;
4142

@@ -71,7 +72,7 @@ public String getName() {
7172
@Override
7273
public boolean accepts(FileContext file, PostProcessorContext context) {
7374
return ProvisioningUtil.isProvisioningFile(file)
74-
|| StringUtils.endsWith(file.getFile().getName(), JsonOsgiConfigPostProcessor.FILE_EXTENSION);
75+
|| Strings.CS.endsWith(file.getFile().getName(), JsonOsgiConfigPostProcessor.FILE_EXTENSION);
7576
}
7677

7778
@Override
@@ -146,7 +147,7 @@ private boolean generateOsgiConfigurations(Model model, ContentPackage contentPa
146147
@Override
147148
@SuppressWarnings("java:S3457") // log placeholders
148149
public Void accept(String path, Dictionary<String, Object> properties) throws IOException {
149-
String contentPath = rootPath + (StringUtils.contains(path, "/") ? "." : "/") + path;
150+
String contentPath = rootPath + (Strings.CS.contains(path, "/") ? "." : "/") + path;
150151
context.getLogger().info(" Include " + contentPath);
151152

152153
// write configuration to temporary file
@@ -171,7 +172,7 @@ public Void accept(String path, Dictionary<String, Object> properties) throws IO
171172
}
172173

173174
private String getBaseFileName(String fileName) {
174-
if (StringUtils.endsWith(fileName, JsonOsgiConfigPostProcessor.FILE_EXTENSION)) {
175+
if (Strings.CS.endsWith(fileName, JsonOsgiConfigPostProcessor.FILE_EXTENSION)) {
175176
return StringUtils.substringBeforeLast(fileName, JsonOsgiConfigPostProcessor.FILE_EXTENSION);
176177
}
177178
else {

conga-aem-plugin/src/main/java/io/wcm/devops/conga/plugins/aem/util/ContentElementHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.regex.Pattern;
2525

2626
import org.apache.commons.lang3.StringUtils;
27+
import org.apache.commons.lang3.Strings;
2728
import org.apache.sling.contentparser.api.ContentHandler;
2829

2930
import io.wcm.tooling.commons.contentpackagebuilder.element.ContentElement;
@@ -41,7 +42,7 @@ final class ContentElementHandler implements ContentHandler {
4142

4243
@Override
4344
public void resource(String path, Map<String, Object> properties) {
44-
if (StringUtils.equals(path, "/")) {
45+
if (Strings.CS.equals(path, "/")) {
4546
root = new ContentElementImpl(null, properties);
4647
}
4748
else {

conga-aem-plugin/src/main/java/io/wcm/devops/conga/plugins/aem/util/ContentPackageUtil.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252

5353
import org.apache.commons.lang3.BooleanUtils;
5454
import org.apache.commons.lang3.StringUtils;
55+
import org.apache.commons.lang3.Strings;
5556

5657
import io.wcm.devops.conga.generator.GeneratorException;
5758
import io.wcm.devops.conga.generator.UrlFileManager;
@@ -156,10 +157,10 @@ private static List<PackageFilter> getFilters(Map<String, Object> options) {
156157
for (Map<String, Object> ruleDefinition : ruleDefinitions) {
157158
String rule = getMandatoryProp(ruleDefinition, "rule");
158159
String pattern = getMandatoryProp(ruleDefinition, "pattern");
159-
if (StringUtils.equals(rule, "include")) {
160+
if (Strings.CS.equals(rule, "include")) {
160161
filter.addIncludeRule(pattern);
161162
}
162-
else if (StringUtils.equals(rule, "exclude")) {
163+
else if (Strings.CS.equals(rule, "exclude")) {
163164
filter.addExcludeRule(pattern);
164165
}
165166
else {
@@ -216,7 +217,7 @@ private static AcHandling getAcHandling(Map<String, Object> options) {
216217
return null;
217218
}
218219
for (AcHandling acHandling : AcHandling.values()) {
219-
if (StringUtils.equals(acHandling.getMode(), acHandlingString)) {
220+
if (Strings.CS.equals(acHandling.getMode(), acHandlingString)) {
220221
return acHandling;
221222
}
222223
}
@@ -355,7 +356,7 @@ private static List<ContentPackageBinaryFile> getMatchingFiles(File targetDir, S
355356
return paths.filter(Files::isRegularFile)
356357
// strip off the target dir paths, keep only the relative path/file name
357358
.map(ContentPackageUtil::normalizedAbsolutePath)
358-
.map(file -> StringUtils.removeStart(file, targetPathPrefix))
359+
.map(file -> Strings.CS.removeStart(file, targetPathPrefix))
359360
// check if file matches with the regex, apply matching input groups to path
360361
.map(file -> {
361362
Matcher matcher = pattern.matcher(file);
@@ -373,7 +374,7 @@ private static List<ContentPackageBinaryFile> getMatchingFiles(File targetDir, S
373374
}
374375

375376
private static String normalizedAbsolutePath(Path path) {
376-
return StringUtils.replace(path.toAbsolutePath().toString(), "\\", "/");
377+
return Strings.CS.replace(path.toAbsolutePath().toString(), "\\", "/");
377378
}
378379

379380
}

conga-aem-plugin/src/test/java/io/wcm/devops/conga/plugins/aem/fileheader/AnyFileHeaderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import java.util.List;
2727

2828
import org.apache.commons.io.FileUtils;
29-
import org.apache.commons.lang3.StringUtils;
29+
import org.apache.commons.lang3.Strings;
3030
import org.junit.jupiter.api.BeforeEach;
3131
import org.junit.jupiter.api.Test;
3232

@@ -56,7 +56,7 @@ void testApply() throws Exception {
5656
assertTrue(underTest.accepts(fileContext, context));
5757
underTest.apply(fileContext, context);
5858

59-
assertTrue(StringUtils.contains(FileUtils.readFileToString(file, StandardCharsets.UTF_8),
59+
assertTrue(Strings.CS.contains(FileUtils.readFileToString(file, StandardCharsets.UTF_8),
6060
"# Der Jodelkaiser\n# aus dem Oetztal\n# ist wieder daheim.\n"));
6161

6262
FileHeaderContext extractContext = underTest.extract(fileContext);

tooling/conga-aem-crypto-cli/src/test/java/io/wcm/devops/conga/plugins/aem/tooling/crypto/cli/AemCryptoTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import java.io.File;
2626

2727
import org.apache.commons.io.FileUtils;
28-
import org.apache.commons.lang3.StringUtils;
28+
import org.apache.commons.lang3.Strings;
2929
import org.junit.jupiter.api.AfterEach;
3030
import org.junit.jupiter.api.BeforeEach;
3131
import org.junit.jupiter.api.Test;
@@ -56,7 +56,7 @@ void testEncryptDecryptString() throws Exception {
5656
String value = "myTestValue-äöü߀";
5757

5858
String encryptedValue = AemCrypto.encryptString(value, cryptoAesKey);
59-
assertFalse(StringUtils.equals(value, encryptedValue));
59+
assertFalse(Strings.CS.equals(value, encryptedValue));
6060

6161
String decryptedValue = AemCrypto.decryptString(encryptedValue, cryptoAesKey);
6262
assertEquals(value, decryptedValue);

tooling/conga-aem-crypto-cli/src/test/java/io/wcm/devops/conga/plugins/aem/tooling/crypto/cli/AnsibleVaultTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import java.nio.charset.StandardCharsets;
2727

2828
import org.apache.commons.io.FileUtils;
29-
import org.apache.commons.lang3.StringUtils;
29+
import org.apache.commons.lang3.Strings;
3030
import org.junit.jupiter.api.AfterEach;
3131
import org.junit.jupiter.api.BeforeEach;
3232
import org.junit.jupiter.api.Test;
@@ -76,7 +76,7 @@ void testEncryptDecryptWithCarriageReturns() throws Exception {
7676
assertNotEquals(TEST_CONTENT, content);
7777

7878
// replace \n with \r\n to simulate new lines on windows file systems
79-
content = StringUtils.replace(content, "\n", "\r\n");
79+
content = Strings.CS.replace(content, "\n", "\r\n");
8080
FileUtils.write(testFile, content, StandardCharsets.UTF_8);
8181

8282
// decrypt file

tooling/conga-aem-maven-plugin/src/main/java/io/wcm/devops/conga/plugins/aem/maven/CloudManagerDispatcherConfigMojo.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import javax.inject.Inject;
3131

3232
import org.apache.commons.lang3.StringUtils;
33+
import org.apache.commons.lang3.Strings;
3334
import org.apache.maven.plugin.MojoExecutionException;
3435
import org.apache.maven.plugin.MojoFailureException;
3536
import org.apache.maven.plugins.annotations.Mojo;
@@ -121,7 +122,7 @@ private void buildDispatcherConfig(File environmentDir, File nodeDir) throws Moj
121122
@SuppressWarnings("java:S3776") // ignore complexity
122123
private void addZipDirectory(String basePath, File directory, Set<String> excludeFiles) throws IOException {
123124
String directoryPath = toZipDirectoryPath(directory);
124-
if (StringUtils.startsWith(directoryPath, basePath)) {
125+
if (Strings.CS.startsWith(directoryPath, basePath)) {
125126
String relativeDirectoryPath = StringUtils.substring(directoryPath, basePath.length());
126127
File[] files = directory.listFiles();
127128
if (files != null) {
@@ -152,7 +153,7 @@ private String toZipDirectoryPath(File directory) {
152153
}
153154

154155
private String sanitizePathSeparators(String path) {
155-
return StringUtils.replace(path, "\\", "/");
156+
return Strings.CS.replace(path, "\\", "/");
156157
}
157158

158159
}

tooling/conga-aem-maven-plugin/src/main/java/io/wcm/devops/conga/plugins/aem/maven/allpackage/AllPackageBuilder.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import org.apache.commons.io.FilenameUtils;
5757
import org.apache.commons.io.IOUtils;
5858
import org.apache.commons.lang3.StringUtils;
59+
import org.apache.commons.lang3.Strings;
5960
import org.apache.jackrabbit.vault.packaging.Dependency;
6061
import org.apache.jackrabbit.vault.packaging.DependencyUtil;
6162
import org.apache.jackrabbit.vault.packaging.PackageType;
@@ -454,7 +455,7 @@ private static boolean isValidPackageType(ContentPackageFile pkg) {
454455
}
455456

456457
private static boolean isMutable(ContentPackageFile pkg) {
457-
return StringUtils.equals("content", pkg.getPackageType());
458+
return Strings.CS.equals("content", pkg.getPackageType());
458459
}
459460

460461
private static boolean mutableMatches(ContentPackageFile pkg1, ContentPackageFile pkg2) {
@@ -487,7 +488,7 @@ private static String buildRunModeSuffix(InstallableFile file, String environmen
487488
else if (isOnlyPublish(file)) {
488489
runModeSuffix.append(".").append(RUNMODE_PUBLISH);
489490
}
490-
if (!StringUtils.equals(environmentRunMode, RUNMODE_DEFAULT)) {
491+
if (!Strings.CS.equals(environmentRunMode, RUNMODE_DEFAULT)) {
491492
runModeSuffix.append(".").append(environmentRunMode);
492493
}
493494
return runModeSuffix.toString();
@@ -504,11 +505,11 @@ private String buildVersionSuffix(ContentPackageFile pkg, boolean ignoreSnapshot
504505

505506
if (this.packageVersionMode == PackageVersionMode.RELEASE_SUFFIX_VERSION
506507
&& (!ArtifactUtils.isSnapshot(pkg.getVersion()) || !ignoreSnapshot)
507-
&& !StringUtils.equals(pkg.getVersion(), this.version)
508+
&& !Strings.CS.equals(pkg.getVersion(), this.version)
508509
&& this.version != null) {
509510
versionSuffix.append(VERSION_SUFFIX_SEPARATOR)
510511
// replace dots with underlines in version suffix to avoid confusion with main version number
511-
.append(StringUtils.replace(this.version, ".", "_"));
512+
.append(Strings.CS.replace(this.version, ".", "_"));
512513
}
513514

514515
return versionSuffix.toString();
@@ -535,7 +536,7 @@ private String buildPackagePath(ContentPackageFile pkg, String rootPath, String
535536
String packageVersion = pkg.getVersion();
536537
String packageVersionWithoutSuffix = packageVersion;
537538
if (this.packageVersionMode == PackageVersionMode.RELEASE_SUFFIX_VERSION && this.version != null) {
538-
packageVersionWithoutSuffix = StringUtils.removeEnd(packageVersion, buildVersionSuffix(pkg, false));
539+
packageVersionWithoutSuffix = Strings.CS.removeEnd(packageVersion, buildVersionSuffix(pkg, false));
539540
}
540541
if (packageVersion != null && pkg.getFile().getName().contains(packageVersionWithoutSuffix)) {
541542
versionSuffix = "-" + packageVersion;
@@ -596,7 +597,7 @@ private List<TemporaryContentPackageFile> processContentPackage(ContentPackageFi
596597
boolean processedEntry = false;
597598

598599
// if entry is properties.xml, update dependency information
599-
if (StringUtils.equals(zipInEntry.getName(), "META-INF/vault/properties.xml")) {
600+
if (Strings.CS.equals(zipInEntry.getName(), "META-INF/vault/properties.xml")) {
600601
FileVaultProperties fileVaultProps = new FileVaultProperties(is);
601602
Properties props = fileVaultProps.getProperties();
602603
addSuffixToPackageName(props, pkg, environmentRunMode);
@@ -623,7 +624,7 @@ private List<TemporaryContentPackageFile> processContentPackage(ContentPackageFi
623624
}
624625

625626
// process sub-packages as well: add runmode suffix and update dependencies
626-
else if (StringUtils.equals(FilenameUtils.getExtension(zipInEntry.getName()), "zip")) {
627+
else if (Strings.CS.equals(FilenameUtils.getExtension(zipInEntry.getName()), "zip")) {
627628
File tempSubPackageFile = File.createTempFile(FilenameUtils.getBaseName(zipInEntry.getName()), ".zip");
628629
try (FileOutputStream subPackageFos = new FileOutputStream(tempSubPackageFile)) {
629630
IOUtils.copy(is, subPackageFos);

tooling/conga-aem-maven-plugin/src/main/java/io/wcm/devops/conga/plugins/aem/maven/allpackage/FileVaultProperties.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import java.nio.charset.StandardCharsets;
2828
import java.util.Properties;
2929

30-
import org.apache.commons.lang3.StringUtils;
30+
import org.apache.commons.lang3.Strings;
3131

3232
/**
3333
* Read and write properties.xml for FileVault package.
@@ -63,7 +63,7 @@ public void storeToXml(OutputStream os) throws IOException {
6363
String xmlOutput = bos.toString(StandardCharsets.UTF_8.name());
6464

6565
// normalize line endings with unix line ending
66-
xmlOutput = StringUtils.replace(xmlOutput, System.lineSeparator(), "\n");
66+
xmlOutput = Strings.CS.replace(xmlOutput, System.lineSeparator(), "\n");
6767

6868
// output normalized XML
6969
OutputStreamWriter writer = new OutputStreamWriter(os, StandardCharsets.UTF_8);

0 commit comments

Comments
 (0)