fix #2725 improve log messages

This commit is contained in:
Shinsuke Sugaya 2023-03-16 17:45:09 +09:00
parent 1f52507824
commit 1580556c51
2 changed files with 30 additions and 7 deletions

View file

@ -324,11 +324,13 @@ public class ThumbnailManager {
}
public void add(final ThumbnailGenerator generator) {
if (logger.isDebugEnabled()) {
logger.debug("{} is available.", generator.getName());
}
if (generator.isAvailable()) {
if (logger.isDebugEnabled()) {
logger.debug("{} is available.", generator.getName());
}
generatorList.add(generator);
} else if (logger.isDebugEnabled()) {
logger.debug("{} is not available.", generator.getName());
}
}

View file

@ -76,12 +76,18 @@ public abstract class BaseThumbnailGenerator implements ThumbnailGenerator {
@Override
public boolean isTarget(final Map<String, Object> docMap) {
if (!docMap.containsKey(ComponentUtil.getFessConfig().getIndexFieldThumbnail())) {
final String thumbnailFieldName = ComponentUtil.getFessConfig().getIndexFieldThumbnail();
if (logger.isDebugEnabled()) {
logger.debug("[{}] thumbnail: {}", name, docMap.get(thumbnailFieldName));
}
if (!docMap.containsKey(thumbnailFieldName)) {
return false;
}
for (final Map.Entry<String, String> entry : conditionMap.entrySet()) {
final Object value = docMap.get(entry.getKey());
if (value instanceof String && ((String) value).matches(entry.getValue())) {
if (docMap.get(entry.getKey()) instanceof String value && value.matches(entry.getValue())) {
if (logger.isDebugEnabled()) {
logger.debug("[{}] match {}:{}", entry.getKey(), name, value);
}
return true;
}
}
@ -106,6 +112,9 @@ public abstract class BaseThumbnailGenerator implements ThumbnailGenerator {
if (path != null) {
stream(path.split(File.pathSeparator)).of(stream -> stream.map(String::trim).forEach(s -> pathList.add(s)));
}
if (logger.isDebugEnabled()) {
logger.debug("search paths: {}", pathList);
}
available = generatorList.stream().map(s -> {
if (s.startsWith("${path}")) {
for (final String p : pathList) {
@ -113,12 +122,24 @@ public abstract class BaseThumbnailGenerator implements ThumbnailGenerator {
if (f.exists()) {
final String filePath = f.getAbsolutePath();
filePathMap.put(s, filePath);
if (logger.isDebugEnabled()) {
logger.debug("generator path: {}", filePath);
}
return filePath;
}
}
}
if (logger.isDebugEnabled()) {
logger.debug("generator path: {}", s);
}
return s;
}).allMatch(s -> new File(s).isFile());
}).allMatch(s -> {
final boolean found = new File(s).isFile();
if (found && logger.isDebugEnabled()) {
logger.debug("{} is found.", s);
}
return found;
});
} else {
available = true;
}