Skip to content

Commit e12a5a4

Browse files
committed
Fixed format converter lookup
1 parent bc7753c commit e12a5a4

File tree

5 files changed

+45
-17
lines changed

5 files changed

+45
-17
lines changed

logicaldoc-core/src/main/java/com/logicaldoc/core/conversion/FormatConverterManager.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -448,17 +448,18 @@ public FormatConverter getConverter(String inFileName, String outFileName) {
448448
if (formatConverters == null || formatConverters.isEmpty())
449449
log.warn("No format converter for file {}", inFileName);
450450

451-
// Get the first available converter
452-
FormatConverter converter = formatConverters != null ? formatConverters.get(0) : null;
451+
// Get the first available and enabled converter
452+
FormatConverter converter = formatConverters != null
453+
? formatConverters.stream().filter(c -> c.isEnabled()).findFirst().orElse(null)
454+
: null;
453455

454-
// Check if a special binding is configured
456+
// Check if a special binding is configured and points to an enabled
457+
// converter
455458
String currentConverter = config.getProperty("converter." + inOutkey);
456459
if (StringUtils.isNotEmpty(currentConverter) && formatConverters != null)
457-
for (FormatConverter formatConverter : formatConverters) {
458-
if (formatConverter.getClass().getName().equals(currentConverter)) {
459-
converter = formatConverter;
460-
}
461-
}
460+
formatConverters.stream()
461+
.filter(conv -> conv.getClass().getName().equals(currentConverter) && conv.isEnabled()).findFirst()
462+
.orElse(null);
462463

463464
if (converter != null)
464465
converter.loadParameters();

logicaldoc-util/src/main/java/com/logicaldoc/util/Context.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,14 @@ public Object getBean(String id) {
102102
* @return true if the bean is available
103103
*/
104104
public boolean containsBean(String id) {
105-
// If not found with give ID try to lowercase the first char
106-
return applicationContext.containsBean(id)
107-
|| applicationContext.containsBean(Character.toLowerCase(id.charAt(0)) + id.substring(1));
105+
try {
106+
// If not found with give ID try to lowercase the first char
107+
return applicationContext.containsBean(id)
108+
|| applicationContext.containsBean(Character.toLowerCase(id.charAt(0)) + id.substring(1));
109+
} catch (IllegalStateException ise) {
110+
// the application context was not already initialized
111+
return false;
112+
}
108113
}
109114

110115
/**

logicaldoc-util/src/main/java/com/logicaldoc/util/time/TimeDiff.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ private TimeDiff() {
2020
*
2121
* @param d1 Date one
2222
* @param d2 Date two
23-
* @param field The field we're interested in: day, hour, minute,
24-
* second, millisecond
23+
* @param field The field we're interested in: day, hour, minute, second,
24+
* millisecond
2525
*
2626
* @return The value of the required field
2727
*/
@@ -101,7 +101,17 @@ public static String printDuration(Date start, Date stop) {
101101
*/
102102
public static String printDuration(long diffMillis) {
103103
Duration duration = Duration.of(diffMillis, ChronoUnit.MILLIS);
104+
return printDuration(duration);
105+
}
104106

107+
/**
108+
* Prints the duration in the format HH:MM:ss.SSS
109+
*
110+
* @param duration the Duration to printed in human readable format
111+
*
112+
* @return The formatted output
113+
*/
114+
public static String printDuration(Duration duration) {
105115
long millis = duration.toMillis() % 1000;
106116
long minutes = duration.toMinutes() % 60;
107117
long seconds = (duration.toMillis() / 1000) % 60;

logicaldoc-util/src/test/resources/log4j2.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,14 @@
3030
<Logger name="org.hibernate" level="error" additivity="false">
3131
<AppenderRef ref="file" />
3232
</Logger>
33+
<Logger name="org.hibernate" level="error" additivity="false">
34+
<AppenderRef ref="file" />
35+
</Logger>
36+
<Logger name="console" level="error" additivity="false">
37+
<Appender-Ref ref="console" />
38+
</Logger>
3339
<Root level="info">
34-
<!-- AppenderRef ref="file" / -->
35-
<AppenderRef ref="console" />
40+
<AppenderRef ref="file" />
3641
</Root>
3742
</Loggers>
3843
</Configuration>

logicaldoc-webapp/src/main/resources/context.properties

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,11 @@ converter.RarConverter.enabled=true
390390
converter.TarConverter.enabled=true
391391
converter.SevenZipConverter.enabled=true
392392

393-
converter.HTMLConverter.localUrl=http\://localhost\:8080
394393
converter.HTMLConverter.enabled=true
394+
converter.HTMLConverter.fonts=
395+
converter.HTMLConverter.localUrl=http://localhost:9080
396+
converter.HTMLConverter.out=-
397+
converter.HTMLConverter.useLibreOffice=false
395398

396399
converter.P7MConverter.enabled=true
397400

@@ -830,6 +833,11 @@ converter.png-pdf=com.logicaldoc.core.conversion.ImageConverter
830833
converter.bmp-pdf=com.logicaldoc.core.conversion.ImageConverter
831834
converter.heic-pdf=com.logicaldoc.core.conversion.ImageConverter
832835

836+
converter.html-pdf=com.logicaldoc.conversion.HTMLConverter
837+
converter.html-png=com.logicaldoc.conversion.HTMLConverter
838+
converter.htmlx-pdf=com.logicaldoc.conversion.HTMLConverter
839+
converter.htmlx-png=com.logicaldoc.conversion.HTMLConverter
840+
833841
threadpool.EventCollector.max = 40
834842
threadpool.EventCollector.type = default
835843
threadpool.Email.type = default
@@ -839,7 +847,6 @@ threadpool.WebserviceCallCounter.max=20
839847
threadpool.WebserviceCallCounter.type=default
840848
threadpool.Note.type = default
841849

842-
843850
default.via.enabled=true
844851
default.via.maxattach=5
845852
default.via.maxattachsize=1048576

0 commit comments

Comments
 (0)