1.1 restoration
[mir.git] / source / mircoders / media / MediaHandlerImagesExtern.java
index 7d90b7f..c3a2a89 100755 (executable)
@@ -35,7 +35,6 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
 
-import mir.config.MirPropertiesConfiguration;
 import mir.entity.Entity;
 import mir.log.LoggerWrapper;
 import mir.media.MediaExc;
@@ -59,14 +58,6 @@ public class MediaHandlerImagesExtern extends MediaHandlerGeneric
   public MediaHandlerImagesExtern() {
 
     logger = new LoggerWrapper("Media.Images.Extern");
-    try {
-      MirPropertiesConfiguration configuration = MirPropertiesConfiguration.instance();
-    }
-    catch (Throwable t) {
-      logger.fatal("MediaHandlerImagesExtern: can't get configuration");
-
-      throw new RuntimeException(t.toString());
-    }
 
     maxIconSize = configuration.getInt("Producer.Image.MaxIconSize");
     minDescaleRatio = configuration.getFloat("Producer.Image.MinDescalePercentage")/100;
@@ -115,22 +106,25 @@ public class MediaHandlerImagesExtern extends MediaHandlerGeneric
       }
     }
     catch(Throwable t) {
-      logger.error("MediaHandlerImagesExtern.produce: " + t.getMessage());
+      logger.error("MediaHandlerImagesExtern.produce: " + t.toString());
       t.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));
       throw new MediaFailure(t.getMessage(), t);
     }
   }
 
 
-  public InputStream getIcon(Entity anImageEntity) throws MediaExc, MediaFailure {
+  /** {@inheritDoc} */
+  public InputStream getThumbnail(Entity anImageEntity) throws MediaExc, MediaFailure {
     try {
-      String filePath =
-          configuration.getString("Producer.StorageRoot") + anImageEntity.getFieldValue("icon_path");
+      File file = new File(configuration.getString("Producer.StorageRoot") + anImageEntity.getFieldValue("icon_path"));
 
-      logger.info(filePath);
+      if (!file.exists()) {
+        // hackish
+        file = new File(configuration.getHome(), "../img/photo_big.gif");
+      }
 
       return new BufferedInputStream(
-        new FileInputStream(new File(filePath)),8192);
+        new FileInputStream(file),8192);
     }
     catch (Throwable t) {
       return null;