Procházet zdrojové kódy

fix #1088 add thumbnail.generator.interval

Shinsuke Sugaya před 8 roky
rodič
revize
c417f23e6d

+ 26 - 0
src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java

@@ -768,6 +768,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
     /** The key of the configuration. e.g. png */
     String THUMBNAIL_HTML_IMAGE_FORMAT = "thumbnail.html.image.format";
 
+    /** The key of the configuration. e.g. 0 */
+    String THUMBNAIL_GENERATOR_INTERVAL = "thumbnail.generator.interval";
+
     /** The key of the configuration. e.g. all */
     String THUMBNAIL_GENERATOR_TARGETS = "thumbnail.generator.targets";
 
@@ -3771,6 +3774,21 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
      */
     String getThumbnailHtmlImageFormat();
 
+    /**
+     * Get the value for the key 'thumbnail.generator.interval'. <br>
+     * The value is, e.g. 0 <br>
+     * @return The value of found property. (NotNull: if not found, exception but basically no way)
+     */
+    String getThumbnailGeneratorInterval();
+
+    /**
+     * Get the value for the key 'thumbnail.generator.interval' as {@link Integer}. <br>
+     * The value is, e.g. 0 <br>
+     * @return The value of found property. (NotNull: if not found, exception but basically no way)
+     * @throws NumberFormatException When the property is not integer.
+     */
+    Integer getThumbnailGeneratorIntervalAsInteger();
+
     /**
      * Get the value for the key 'thumbnail.generator.targets'. <br>
      * The value is, e.g. all <br>
@@ -6353,6 +6371,14 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
             return get(FessConfig.THUMBNAIL_HTML_IMAGE_FORMAT);
         }
 
+        public String getThumbnailGeneratorInterval() {
+            return get(FessConfig.THUMBNAIL_GENERATOR_INTERVAL);
+        }
+
+        public Integer getThumbnailGeneratorIntervalAsInteger() {
+            return getAsInteger(FessConfig.THUMBNAIL_GENERATOR_INTERVAL);
+        }
+
         public String getThumbnailGeneratorTargets() {
             return get(FessConfig.THUMBNAIL_GENERATOR_TARGETS);
         }

+ 5 - 0
src/main/java/org/codelibs/fess/thumbnail/ThumbnailManager.java

@@ -211,6 +211,11 @@ public class ThumbnailManager {
                     }
                     if (!generator.generate(entity.getThumbnailId(), entity.getUrl(), outputFile)) {
                         new File(outputFile.getAbsolutePath() + NOIMAGE_FILE_SUFFIX).setLastModified(System.currentTimeMillis());
+                    } else {
+                        long interval = fessConfig.getThumbnailGeneratorIntervalAsInteger().longValue();
+                        if (interval > 0) {
+                            Thread.sleep(interval);
+                        }
                     }
                 } else if (logger.isDebugEnabled()) {
                     logger.debug("No image file exists: " + noImageFile.getAbsolutePath());

+ 1 - 0
src/main/resources/fess_config.properties

@@ -392,6 +392,7 @@ thumbnail.html.image.window.height=800
 thumbnail.html.image.thumbnail.width=100
 thumbnail.html.image.thumbnail.height=100
 thumbnail.html.image.format=png
+thumbnail.generator.interval=0
 thumbnail.generator.targets=all
 thumbnail.crawler.enabled=true