Skip to content

Commit 773ce33

Browse files
committed
removed encoding from ContextProperties.getProperties() - moved
encoding to getString()
1 parent 4096f77 commit 773ce33

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

logicaldoc-util/src/main/java/com/logicaldoc/util/config/ContextProperties.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,16 @@ public List<File> getBackups() throws IOException {
262262
}
263263

264264
public String getString(String property) {
265-
return getProperty(property);
265+
return getString(property, null);
266266
}
267267

268268
public String getString(String property, String defaultValue) {
269-
return getProperty(property, defaultValue);
269+
String value = getProperty(property, defaultValue);
270+
if (StringUtil.isBase64(value)) {
271+
byte[] decodedBytes = Base64.getDecoder().decode(value);
272+
value = new String(decodedBytes);
273+
}
274+
return StrSubstitutor.replaceSystemProperties(value);
270275
}
271276

272277
public int getInt(String property) {
@@ -343,7 +348,7 @@ public synchronized Object setProperty(String key, String value) {
343348
@Override
344349
public String getProperty(String property) {
345350
String value = super.getProperty(property);
346-
return getPropertyWithDecoding(value);
351+
return StrSubstitutor.replaceSystemProperties(value);
347352
}
348353

349354
/**
@@ -357,14 +362,6 @@ public String getProperty(String property) {
357362
@Override
358363
public String getProperty(String property, String defaultValue) {
359364
String value = super.getProperty(property, defaultValue);
360-
return getPropertyWithDecoding(value);
361-
}
362-
363-
private String getPropertyWithDecoding(String value) {
364-
if (StringUtil.isBase64(value)) {
365-
byte[] decodedBytes = Base64.getDecoder().decode(value);
366-
value = new String(decodedBytes);
367-
}
368365
return StrSubstitutor.replaceSystemProperties(value);
369366
}
370367

logicaldoc-util/src/test/java/com/logicaldoc/util/config/ContextPropertiesTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,11 @@ public void testSetAndGetProperty() throws FileNotFoundException, IOException {
5555

5656
contextProperties.write();
5757

58-
assertEquals("pippo", contextProperties.getProperty("propA"));
59-
assertEquals("pippo\npluto\npaperino", contextProperties.getProperty("propB"));
58+
assertEquals("pippo", contextProperties.getString("propA"));
59+
assertEquals("pippo\npluto\npaperino", contextProperties.getString("propB"));
6060
assertEquals(" Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
61-
contextProperties.getProperty("propC"));
62-
63-
assertEquals("", contextProperties.getProperty("emptyKey"));
61+
contextProperties.getString("propC"));
62+
assertEquals("", contextProperties.getString("emptyKey"));
6463

6564
Properties properties = new Properties();
6665
try (FileReader reader = new FileReader(abcFile)) {

0 commit comments

Comments
 (0)