From 386e5efa787066632dabe1965c7272146ac72b63 Mon Sep 17 00:00:00 2001
From: zapata
Date: Tue, 29 Apr 2003 02:36:50 +0000
Subject: [PATCH] Gif icons for the External image handler dramatically
improved
---
source/mir/media/MirMedia.java | 28 +-
source/mircoders/media/ImageProcessor.java | 93 +++-
source/mircoders/media/MediaHandlerAudio.java | 25 +-
source/mircoders/media/MediaHandlerGeneric.java | 31 +-
.../mircoders/media/MediaHandlerImagesExtern.java | 46 +-
source/mircoders/media/MediaHandlerImagesJpeg.java | 22 +-
source/mircoders/media/MediaHandlerImagesPng.java | 24 +-
.../mircoders/servlet/ServletModuleOpenIndy.java | 556 ++++++++++-----------
.../servlet/ServletModuleUploadedMedia.java | 12 +-
templates/admin/FUNCTIONS.template | 428 ++++++++--------
templates/admin/FUNCTIONS_media.template | 214 ++++----
templates/admin/abuse.filters.template | 40 +-
templates/admin/abuse.log.template | 18 +-
templates/admin/abuse.template | 54 +-
templates/admin/articletype.template | 54 +-
templates/admin/articletypelist.template | 28 +-
templates/admin/audio.template | 148 +++---
templates/admin/audiolist.template | 2 +-
templates/admin/breaking.template | 26 +-
templates/admin/breakinglist.template | 48 +-
templates/admin/comment.template | 112 ++---
templates/admin/commentlist.template | 352 ++++++-------
templates/admin/commentstatus.template | 22 +-
templates/admin/commentstatuslist.template | 38 +-
templates/admin/confirm.template | 10 +-
templates/admin/content.template | 296 +++++------
templates/admin/contentlist.template | 180 +++----
templates/admin/fileedit.template | 30 +-
templates/admin/fileeditlist.template | 72 +--
templates/admin/foot.template | 32 +-
templates/admin/head.template | 26 +-
templates/admin/head_nonavi.template | 26 +-
templates/admin/hiddenlist.template | 144 +++---
templates/admin/image.template | 204 ++++----
templates/admin/imagelist.template | 4 -
templates/admin/infomessage.template | 26 +-
templates/admin/language.template | 18 +-
templates/admin/languagelist.template | 36 +-
templates/admin/linksimcs.template | 54 +-
templates/admin/linksimcslist.template | 126 ++---
templates/admin/login.template | 78 +--
templates/admin/media.template | 184 +++----
templates/admin/mediafolder.template | 16 +-
templates/admin/mediafolderlist.template | 68 +--
templates/admin/medialist.template | 2 +-
templates/admin/message.template | 34 +-
templates/admin/messagelist.template | 34 +-
templates/admin/producerqueue.template | 136 ++---
templates/admin/start_admin.template | 278 +++++------
templates/admin/superusermenu.template | 26 +-
templates/admin/topic.template | 18 +-
templates/admin/topiclist.template | 36 +-
templates/admin/user.template | 80 +--
templates/admin/usererror.template | 50 +-
templates/admin/userlist.template | 42 +-
templates/admin/video.template | 176 +++----
templates/admin/videolist.template | 2 +-
57 files changed, 2512 insertions(+), 2453 deletions(-)
diff --git a/source/mir/media/MirMedia.java b/source/mir/media/MirMedia.java
index 9f0caf14..298809e8 100755
--- a/source/mir/media/MirMedia.java
+++ b/source/mir/media/MirMedia.java
@@ -18,13 +18,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
* If you do not wish to do so, delete this exception statement from your version.
*/
package mir.media;
@@ -79,7 +79,7 @@ import freemarker.template.SimpleList;
* ) and just override the things that need to be specific. see MediaHandlerAudio
*
* @author , the Mir-coders group
- * @version $Id: MirMedia.java,v 1.17 2003/04/21 12:42:46 idfx Exp $
+ * @version $Id: MirMedia.java,v 1.18 2003/04/29 02:36:50 zapata Exp $
*/
public interface MirMedia{
@@ -121,7 +121,17 @@ public interface MirMedia{
*/
public abstract InputStream getIcon (Entity ent) throws MediaExc, MediaFailure;
- /**
+
+ /**
+ *
+ * @param ent
+ * @return
+ * @throws MediaExc
+ * @throws MediaFailure
+ */
+ public abstract String getIconMimeType (Entity aMediaEntity, Entity aMediaType) throws MediaExc, MediaFailure;
+
+ /**
* gets the final content representation for the media
* in the form of a URL (String) that allows someone to
* download, look at or listen to the media. (HREF, img src
diff --git a/source/mircoders/media/ImageProcessor.java b/source/mircoders/media/ImageProcessor.java
index 1d953736..0b152a75 100755
--- a/source/mircoders/media/ImageProcessor.java
+++ b/source/mircoders/media/ImageProcessor.java
@@ -18,13 +18,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
* If you do not wish to do so, delete this exception statement from your version.
*/
@@ -36,11 +36,14 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-import javax.media.jai.InterpolationBilinear;
-import javax.media.jai.JAI;
+import javax.media.jai.InterpolationBicubic;
+import javax.media.jai.*;
import javax.media.jai.ParameterBlockJAI;
import javax.media.jai.PlanarImage;
+import java.awt.image.*;
+import java.awt.*;
+
import mir.log.LoggerWrapper;
import com.sun.media.jai.codec.ByteArraySeekableStream;
@@ -66,22 +69,38 @@ public class ImageProcessor {
private byte[] imageData;
private int iconWidth;
private int iconHeight;
- private String imageType;
-// public ImageScaler(
+ public ImageProcessor(SeekableStream anImageStream) throws IOException {
+ PlanarImage tempImage = JAI.create("stream", anImageStream);
+
+
+ ParameterBlockJAI params = new ParameterBlockJAI("format");
+ params.addSource(tempImage);
+ params.setParameter("dataType", DataBuffer.TYPE_BYTE);
+
+ ImageLayout layout = new ImageLayout();
+ layout.setColorModel(ColorModel.getRGBdefault());
+ layout.setSampleModel(
+ new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE,
+ layout.getSampleModel(tempImage).getWidth(),
+ layout.getSampleModel(tempImage).getHeight(),
+ 3,
+ 3*layout.getSampleModel(tempImage).getWidth(),
+ new int[] {2,1,0}));
+
+ RenderingHints hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout);
+
+ image = JAI.create("format", params, hints);
- public ImageProcessor(SeekableStream anImageStream, String anImageType) throws IOException {
- image = JAI.create("stream", anImageStream);
scaledImage = image;
- imageType = anImageType;
}
- public ImageProcessor(File aFile, String anImageType) throws IOException {
- this(new FileSeekableStream(aFile), anImageType);
+ public ImageProcessor(File aFile) throws IOException {
+ this(new FileSeekableStream(aFile));
}
- public ImageProcessor(byte[] anImageData, String anImageType) throws IOException {
- this(new ByteArraySeekableStream(anImageData), anImageType);
+ public ImageProcessor(byte[] anImageData) throws IOException {
+ this(new ByteArraySeekableStream(anImageData));
}
public void descaleImage(int aMaxSize) throws java.io.IOException {
@@ -163,17 +182,43 @@ public class ImageProcessor {
return scaledImage.getHeight();
}
- public void writeScaledData(OutputStream aStream) {
- JAI.create("encode", scaledImage, aStream, imageType, null);
+ public void writeScaledData(OutputStream aStream, String anImageType) {
+
+// ParameterBlockJAI params = new ParameterBlockJAI("BandSelect");
+// params.addSource(scaledImage);
+// params.setParameter("bandIndices", new int[] {0,1,2});
+// PlanarImage tempImage = JAI.create("BandSelect", params);
+
+ JAI.create("encode", scaledImage, aStream, anImageType, null);
}
- public byte[] getScaledData() {
+ public byte[] getScaledData(String anImageType) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- writeScaledData(outputStream);
+ writeScaledData(outputStream, anImageType);
return outputStream.toByteArray();
}
- public void writeScaledData(File aFile) throws IOException {
- writeScaledData(new FileOutputStream(aFile));
+ public void writeScaledData(File aFile, String anImageType) throws IOException {
+ writeScaledData(new FileOutputStream(aFile), anImageType);
}
}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/source/mircoders/media/MediaHandlerAudio.java b/source/mircoders/media/MediaHandlerAudio.java
index a3201655..05a9c8da 100755
--- a/source/mircoders/media/MediaHandlerAudio.java
+++ b/source/mircoders/media/MediaHandlerAudio.java
@@ -18,19 +18,20 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
* If you do not wish to do so, delete this exception statement from your version.
*/
package mircoders.media;
-import mir.media.MirMedia;
+import mir.media.*;
+import mir.entity.*;
/**
* Handles audio media, like mp3 and maybe it could also handle some other.
@@ -39,7 +40,7 @@ import mir.media.MirMedia;
* @see mir.media.MediaHandlerGeneric
* @see mir.media.MirMedia
* @author mh
- * @version $Id: MediaHandlerAudio.java,v 1.8 2003/04/21 12:42:48 idfx Exp $
+ * @version $Id: MediaHandlerAudio.java,v 1.9 2003/04/29 02:36:50 zapata Exp $
*/
public class MediaHandlerAudio extends MediaHandlerGeneric implements MirMedia
@@ -47,11 +48,11 @@ public class MediaHandlerAudio extends MediaHandlerGeneric implements MirMedia
private static String tinyIcon;
private static String bigIcon;
-
- static {
+
+ static {
tinyIcon = configuration.getString("Producer.Icon.TinyAudio");
bigIcon = configuration.getString("Producer.Icon.BigAudio");
- }
+ }
public String getTinyIcon()
{
diff --git a/source/mircoders/media/MediaHandlerGeneric.java b/source/mircoders/media/MediaHandlerGeneric.java
index bb0ad5d8..c8cb1945 100755
--- a/source/mircoders/media/MediaHandlerGeneric.java
+++ b/source/mircoders/media/MediaHandlerGeneric.java
@@ -18,13 +18,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
* If you do not wish to do so, delete this exception statement from your version.
*/
package mircoders.media;
@@ -32,9 +32,12 @@ package mircoders.media;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
+import javax.servlet.ServletContext;
+
+import freemarker.template.SimpleList;
import mir.config.MirPropertiesConfiguration;
-import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
+import mir.config.MirPropertiesConfiguration$PropertiesConfigExc;
import mir.entity.Entity;
import mir.log.LoggerWrapper;
import mir.media.MediaExc;
@@ -42,7 +45,6 @@ import mir.media.MediaFailure;
import mir.media.MirMedia;
import mir.misc.FileUtil;
import mir.misc.StringUtil;
-import freemarker.template.SimpleList;
/**
@@ -62,7 +64,7 @@ import freemarker.template.SimpleList;
*
* @see mir.media.MirMedia
* @author mh
- * @version $Id: MediaHandlerGeneric.java,v 1.19 2003/04/21 12:42:48 idfx Exp $
+ * @version $Id: MediaHandlerGeneric.java,v 1.20 2003/04/29 02:36:50 zapata Exp $
*/
public class MediaHandlerGeneric implements MirMedia
@@ -136,9 +138,16 @@ public class MediaHandlerGeneric implements MirMedia
}
public InputStream getIcon (Entity ent) throws MediaExc, MediaFailure {
- return null;
+ return null;
}
+ public String getIconMimeType (Entity aMediaEntity, Entity aMediaType) throws MediaExc, MediaFailure {
+ ServletContext servletContext = MirPropertiesConfiguration.getContext();
+ String fileName = aMediaEntity.getId()+"."+aMediaType.getValue("name");
+
+ return servletContext.getMimeType(fileName);
+ };
+
public String getStoragePath()
{
return configuration.getString("Producer.Media.Path");
diff --git a/source/mircoders/media/MediaHandlerImagesExtern.java b/source/mircoders/media/MediaHandlerImagesExtern.java
index e9eb66a6..e8b623ae 100755
--- a/source/mircoders/media/MediaHandlerImagesExtern.java
+++ b/source/mircoders/media/MediaHandlerImagesExtern.java
@@ -18,13 +18,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
* If you do not wish to do so, delete this exception statement from your version.
*/
package mircoders.media;
@@ -78,27 +78,27 @@ public class MediaHandlerImagesExtern extends MediaHandlerGeneric
String date = anImageEntity.getValue("date");
String datePath = StringUtil.webdbDate2path(date);
String ext = "." + mediaTypeEnt.getValue("name");
- String filePath = datePath + anImageEntity.getId() + ext;
- String iconFilePath = MirPropertiesConfiguration.instance().getString("Producer.StorageRoot") + getIconStoragePath() + filePath;
+ String fileBasePath = datePath + anImageEntity.getId();
+ String filePath = fileBasePath + ext;
+ String iconPath = getIconStoragePath() + fileBasePath + ".jpg";
+ String iconStoragePath = configuration.getString("Producer.StorageRoot") + iconPath;
String imageFilePath = getStoragePath() + File.separator + filePath;
File imageFile = new File(imageFilePath);
- File iconFile = new File(iconFilePath);
+ File iconFile = new File(iconStoragePath);
if (!imageFile.exists()) {
throw new MediaExc("error in MediaHandlerImagesExtern.produce(): " + filePath + " does not exist!");
}
else {
- ImageProcessor processor = new ImageProcessor(imageFile, "JPEG");
+ ImageProcessor processor = new ImageProcessor(imageFile);
processor.descaleImage(maxIconSize, minDescaleRatio, minDescaleReduction);
File dir = new File(iconFile.getParent());
if (dir!=null && !dir.exists()){
dir.mkdirs();
}
- processor.writeScaledData(iconFile);
-
- logger.info(processor.getWidth()+"x"+processor.getHeight());
+ processor.writeScaledData(iconFile, "JPEG");
anImageEntity.setValueForProperty("img_height", new Integer(processor.getHeight()).toString());
anImageEntity.setValueForProperty("img_width", new Integer(processor.getWidth()).toString());
@@ -106,7 +106,7 @@ public class MediaHandlerImagesExtern extends MediaHandlerGeneric
anImageEntity.setValueForProperty("icon_height", new Integer(processor.getScaledHeight()).toString());
anImageEntity.setValueForProperty("icon_width", new Integer(processor.getScaledWidth()).toString());
- anImageEntity.setValueForProperty("icon_path", getIconStoragePath()+filePath);
+ anImageEntity.setValueForProperty("icon_path", iconPath);
anImageEntity.setValueForProperty("publish_path", filePath);
anImageEntity.update();
@@ -122,22 +122,22 @@ public class MediaHandlerImagesExtern extends MediaHandlerGeneric
public InputStream getIcon(Entity anImageEntity) throws MediaExc, MediaFailure {
try {
- Entity mediaType = DatabaseUploadedMedia.getInstance().getMediaType(
- anImageEntity);
+ String filePath =
+ configuration.getString("Producer.StorageRoot") + anImageEntity.getValue("icon_path");
- String date = anImageEntity.getValue("date");
- String datePath = StringUtil.webdbDate2path(date);
- String ext = "." + mediaType.getValue("name");
- String filePath = MirPropertiesConfiguration.instance().getString("Producer.StorageRoot") +
- getIconStoragePath() + datePath + anImageEntity.getId() + ext;
+ logger.info(filePath);
return new FileInputStream(new File(filePath));
}
catch (Throwable t) {
- throw new MediaFailure(t);
+ return null;
}
}
+ public String getIconMimeType(Entity anImageEntity, Entity aMediaType) {
+ return "image/jpeg";
+ }
+
public String getStoragePath()
{
return configuration.getString("Producer.Image.Path");
diff --git a/source/mircoders/media/MediaHandlerImagesJpeg.java b/source/mircoders/media/MediaHandlerImagesJpeg.java
index 76c46644..751b6e13 100755
--- a/source/mircoders/media/MediaHandlerImagesJpeg.java
+++ b/source/mircoders/media/MediaHandlerImagesJpeg.java
@@ -18,13 +18,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
* If you do not wish to do so, delete this exception statement from your version.
*/
package mircoders.media;
@@ -42,7 +42,7 @@ import mir.media.MirMedia;
* @see mir.media.MirMedia
* @see mircoders.media.MediaHandlerImages
* @author mh, mir-coders group
- * @version $Id: MediaHandlerImagesJpeg.java,v 1.5 2003/04/21 12:42:48 idfx Exp $
+ * @version $Id: MediaHandlerImagesJpeg.java,v 1.6 2003/04/29 02:36:50 zapata Exp $
*/
@@ -52,9 +52,11 @@ public class MediaHandlerImagesJpeg extends MediaHandlerImages implements MirMed
return JPEG;
}
- public String getDescr(Entity mediaType)
- {
+ public String getDescr(Entity mediaType) {
return "image/jpeg";
}
+ public String getIconMimeType(Entity aMedia, Entity aMediaType) {
+ return "image/jpeg";
+ }
}
diff --git a/source/mircoders/media/MediaHandlerImagesPng.java b/source/mircoders/media/MediaHandlerImagesPng.java
index bf281fd0..cbc9d0a4 100755
--- a/source/mircoders/media/MediaHandlerImagesPng.java
+++ b/source/mircoders/media/MediaHandlerImagesPng.java
@@ -18,13 +18,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
* If you do not wish to do so, delete this exception statement from your version.
*/
package mircoders.media;
@@ -42,7 +42,7 @@ import mir.media.MirMedia;
* @see mir.media.MirMedia
* @see mircoders.media.MediaHandlerImages
* @author mh ,mir-coders
- * @version $Id: MediaHandlerImagesPng.java,v 1.6 2003/04/21 12:42:48 idfx Exp $
+ * @version $Id: MediaHandlerImagesPng.java,v 1.7 2003/04/29 02:36:50 zapata Exp $
*/
@@ -52,9 +52,11 @@ public class MediaHandlerImagesPng extends MediaHandlerImages implements MirMedi
return PNG;
}
- public String getDescr(Entity mediaType)
- {
- return "image/png";
+ public String getDescr(Entity mediaType) {
+ return "image/png";
}
+ public String getIconMimeType(Entity aMedia, Entity aMediaType) {
+ return "image/png";
+ }
}
diff --git a/source/mircoders/servlet/ServletModuleOpenIndy.java b/source/mircoders/servlet/ServletModuleOpenIndy.java
index 2e9a56af..9e7f5be4 100755
--- a/source/mircoders/servlet/ServletModuleOpenIndy.java
+++ b/source/mircoders/servlet/ServletModuleOpenIndy.java
@@ -122,7 +122,7 @@ import mircoders.storage.DatabaseTopics;
* open-postings to the newswire
*
* @author mir-coders group
- * @version $Id: ServletModuleOpenIndy.java,v 1.83 2003/04/26 15:42:17 zapata Exp $
+ * @version $Id: ServletModuleOpenIndy.java,v 1.84 2003/04/29 02:36:50 zapata Exp $
*
*/
@@ -702,350 +702,345 @@ public class ServletModuleOpenIndy extends ServletModule
+ /**
+ * Method for querying a lucene index
+ *
+ * @param req
+ * @param res
+ * @throws ServletModuleExc
+ * @throws ServletModuleUserExc
+ * @throws ServletModuleFailure
+ */
- /**
- * Method for querying a lucene index
- *
- * @param req
- * @param res
- * @throws ServletModuleExc
- * @throws ServletModuleUserExc
- * @throws ServletModuleFailure
- */
-
- public void search(HttpServletRequest req, HttpServletResponse res)
- throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {
- try {
- final String[] search_variables = { "search_content", "search_boolean", "search_creator",
- "search_topic", "search_hasImages", "search_hasAudio", "search_hasVideo", "search_sort",
- "search_submit", "search_back", "search_forward" };
- HTTPRequestParser requestParser = new HTTPRequestParser(req);
-
- int increment=10;
+ public void search(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {
+ try {
+ final String[] search_variables = {
+ "search_content", "search_boolean", "search_creator",
+ "search_topic", "search_hasImages", "search_hasAudio", "search_hasVideo", "search_sort",
+ "search_submit", "search_back", "search_forward"};
+ HTTPRequestParser requestParser = new HTTPRequestParser(req);
- HttpSession session = req.getSession(false);
+ int increment = 10;
- String queryString="";
+ HttpSession session = req.getSession(false);
- Map mergeData = new HashMap();
+ String queryString = "";
- KeywordSearchTerm dateTerm = new KeywordSearchTerm("date_formatted","search_date","webdb_create_formatted","webdb_create_formatted","webdb_create_formatted");
- UnIndexedSearchTerm whereTerm = new UnIndexedSearchTerm("","","","where","where");
- TextSearchTerm creatorTerm = new TextSearchTerm("creator","search_creator","creator","creator","creator");
- TextSearchTerm titleTerm = new TextSearchTerm("title","search_content","title","title","title");
- TextSearchTerm descriptionTerm = new TextSearchTerm("description","search_content","description","description","description");
- ContentSearchTerm contentTerm = new ContentSearchTerm("content_data","search_content","content","","");
- TopicSearchTerm topicTerm = new TopicSearchTerm();
- ImagesSearchTerm imagesTerm = new ImagesSearchTerm();
- AudioSearchTerm audioTerm = new AudioSearchTerm();
- VideoSearchTerm videoTerm = new VideoSearchTerm();
+ Map mergeData = new HashMap();
- //make the query available to subsequent iterations
+ KeywordSearchTerm dateTerm = new KeywordSearchTerm("date_formatted", "search_date", "webdb_create_formatted", "webdb_create_formatted", "webdb_create_formatted");
+ UnIndexedSearchTerm whereTerm = new UnIndexedSearchTerm("", "", "", "where", "where");
+ TextSearchTerm creatorTerm = new TextSearchTerm("creator", "search_creator", "creator", "creator", "creator");
+ TextSearchTerm titleTerm = new TextSearchTerm("title", "search_content", "title", "title", "title");
+ TextSearchTerm descriptionTerm = new TextSearchTerm("description", "search_content", "description", "description", "description");
+ ContentSearchTerm contentTerm = new ContentSearchTerm("content_data", "search_content", "content", "", "");
+ TopicSearchTerm topicTerm = new TopicSearchTerm();
+ ImagesSearchTerm imagesTerm = new ImagesSearchTerm();
+ AudioSearchTerm audioTerm = new AudioSearchTerm();
+ VideoSearchTerm videoTerm = new VideoSearchTerm();
- Iterator j = Arrays.asList(search_variables).iterator();
- while (j.hasNext()) {
- String variable = (String) j.next();
+ //make the query available to subsequent iterations
- mergeData.put(variable, requestParser.getParameter(variable));
- }
+ Iterator j = Arrays.asList(search_variables).iterator();
+ while (j.hasNext()) {
+ String variable = (String) j.next();
- try{
- mergeData.put("topics", topicsModule.getTopicsAsSimpleList());
- }
- catch(Throwable e) {
- logger.debug("Can't get topics: " + e.toString());
- }
+ mergeData.put(variable, requestParser.getParameter(variable));
+ }
- String searchBackValue = req.getParameter("search_back");
- String searchForwardValue = req.getParameter("search_forward");
+ try {
+ mergeData.put("topics", topicsModule.getTopicsAsSimpleList());
+ }
+ catch (Throwable e) {
+ logger.debug("Can't get topics: " + e.toString());
+ }
- if (searchBackValue != null){
- int totalHits = ((Integer) session.getAttribute("numberOfHits")).intValue();
- int newPosition=((Integer)session.getAttribute("positionInResults")).intValue()-increment;
- if (newPosition<0)
- newPosition=0;
+ String searchBackValue = req.getParameter("search_back");
+ String searchForwardValue = req.getParameter("search_forward");
+
+ if (searchBackValue != null) {
+ int totalHits = ( (Integer) session.getAttribute("numberOfHits")).intValue();
+ int newPosition = ( (Integer) session.getAttribute("positionInResults")).intValue() - increment;
+ if (newPosition < 0)
+ newPosition = 0;
+ if (newPosition >= totalHits)
+ newPosition = totalHits - 1;
+ session.setAttribute("positionInResults", new Integer(newPosition));
+ }
+ else {
+ if (searchForwardValue != null) {
+ int totalHits = ( (Integer) session.getAttribute("numberOfHits")).intValue();
+ int newPosition = ( (Integer) session.getAttribute("positionInResults")).intValue() + increment;
+ if (newPosition < 0)
+ newPosition = 0;
if (newPosition >= totalHits)
- newPosition=totalHits-1;
- session.setAttribute("positionInResults",new Integer(newPosition));
+ newPosition = totalHits - 1;
+
+ session.setAttribute("positionInResults", new Integer(newPosition));
}
else {
- if (searchForwardValue != null){
- int totalHits = ((Integer) session.getAttribute("numberOfHits")).intValue();
- int newPosition=((Integer)session.getAttribute("positionInResults")).intValue()+increment;
- if (newPosition<0)
- newPosition=0;
- if (newPosition >= totalHits)
- newPosition=totalHits-1;
-
- session.setAttribute("positionInResults",new Integer(newPosition));
- }
- else {
- String indexPath=configuration.getString("IndexPath");
+ String indexPath = configuration.getString("IndexPath");
+ String creatorFragment = creatorTerm.makeTerm(req);
+ if (creatorFragment != null) {
+ queryString = queryString + " +" + creatorFragment;
+ }
- String creatorFragment = creatorTerm.makeTerm(req);
- if (creatorFragment != null){
- queryString = queryString + " +" + creatorFragment;
- }
-
- // search title, description, and content for something
- // the contentTerm uses param "search_boolean" to combine its terms
- String contentFragment = contentTerm.makeTerm(req);
- if (contentFragment != null){
- logger.debug("contentFragment: " + contentFragment);
- queryString = queryString + " +" + contentFragment;
- }
+ // search title, description, and content for something
+ // the contentTerm uses param "search_boolean" to combine its terms
+ String contentFragment = contentTerm.makeTerm(req);
+ if (contentFragment != null) {
+ logger.debug("contentFragment: " + contentFragment);
+ queryString = queryString + " +" + contentFragment;
+ }
- String topicFragment = topicTerm.makeTerm(req);
- if (topicFragment != null){
- queryString = queryString + " +" + topicFragment;
- }
+ String topicFragment = topicTerm.makeTerm(req);
+ if (topicFragment != null) {
+ queryString = queryString + " +" + topicFragment;
+ }
- String imagesFragment = imagesTerm.makeTerm(req);
- if (imagesFragment != null){
- queryString = queryString + " +" + imagesFragment;
- }
+ String imagesFragment = imagesTerm.makeTerm(req);
+ if (imagesFragment != null) {
+ queryString = queryString + " +" + imagesFragment;
+ }
- String audioFragment = audioTerm.makeTerm(req);
- if (audioFragment != null){
- queryString = queryString + " +" + audioFragment;
- }
+ String audioFragment = audioTerm.makeTerm(req);
+ if (audioFragment != null) {
+ queryString = queryString + " +" + audioFragment;
+ }
- String videoFragment = videoTerm.makeTerm(req);
- if (videoFragment != null){
- queryString = queryString + " +" + videoFragment;
- }
+ String videoFragment = videoTerm.makeTerm(req);
+ if (videoFragment != null) {
+ queryString = queryString + " +" + videoFragment;
+ }
- if (queryString == null || queryString == ""){
- queryString = "";
- }
- else{
- try{
- Searcher searcher = null;
- try {
- searcher = new IndexSearcher(indexPath);
- }
- catch(IOException e) {
- logger.debug("Can't open indexPath: " + indexPath);
- throw new ServletModuleExc("Problem with Search Index! : "+ e.toString());
- }
+ if (queryString == null || queryString == "") {
+ queryString = "";
+ }
+ else {
+ try {
+ Searcher searcher = null;
+ try {
+ searcher = new IndexSearcher(indexPath);
+ }
+ catch (IOException e) {
+ logger.debug("Can't open indexPath: " + indexPath);
+ throw new ServletModuleExc("Problem with Search Index! : " + e.toString());
+ }
- Query query = null;
- try {
- query = QueryParser.parse(queryString, "content", new StandardAnalyzer());
- }
- catch(Exception e) {
- searcher.close();
- logger.debug("Query don't parse: " + queryString);
- throw new ServletModuleExc("Problem with Query String! (was '"+queryString+"')");
- }
+ Query query = null;
+ try {
+ query = QueryParser.parse(queryString, "content", new StandardAnalyzer());
+ }
+ catch (Exception e) {
+ searcher.close();
+ logger.debug("Query don't parse: " + queryString);
+ throw new ServletModuleExc("Problem with Query String! (was '" + queryString + "')");
+ }
- Hits hits = null;
- try {
- hits = searcher.search(query);
- }
- catch(IOException e) {
- searcher.close();
- logger.debug("Can't get hits: " + e.toString());
- throw new ServletModuleExc("Problem getting hits!");
- }
+ Hits hits = null;
+ try {
+ hits = searcher.search(query);
+ }
+ catch (IOException e) {
+ searcher.close();
+ logger.debug("Can't get hits: " + e.toString());
+ throw new ServletModuleExc("Problem getting hits!");
+ }
- int start = 0;
- int end = hits.length();
+ int start = 0;
+ int end = hits.length();
- String sortBy=req.getParameter("search_sort");
- if (sortBy == null || sortBy.equals("")){
- throw new ServletModuleExc("Please let me sort by something!(missing search_sort)");
- }
+ String sortBy = req.getParameter("search_sort");
+ if (sortBy == null || sortBy.equals("")) {
+ throw new ServletModuleExc("Please let me sort by something!(missing search_sort)");
+ }
- // here is where the documents will go for storage across sessions
- ArrayList theDocumentsSorted = new ArrayList();
+ // here is where the documents will go for storage across sessions
+ ArrayList theDocumentsSorted = new ArrayList();
- if (sortBy.equals("score")){
- for(int i = start; i < end; i++) {
- theDocumentsSorted.add(hits.doc(i));
- }
+ if (sortBy.equals("score")) {
+ for (int i = start; i < end; i++) {
+ theDocumentsSorted.add(hits.doc(i));
}
- else{
- // then we'll sort by date!
- Map dateToPosition = new HashMap(end,1.0F); //we know how big it will be
- for(int i = start; i < end; i++) {
- String creationDate=(hits.doc(i)).get("creationDate");
- // do a little dance in case two contents created at the same second!
- if (dateToPosition.containsKey(creationDate)){
- ((ArrayList) (dateToPosition.get(creationDate))).add(new Integer(i));
- }
- else{
- ArrayList thePositions = new ArrayList();
- thePositions.add(new Integer(i));
- dateToPosition.put(creationDate,thePositions);
- }
- }
- Set keys = dateToPosition.keySet();
- ArrayList keyList= new ArrayList(keys);
- Collections.sort(keyList);
- if (sortBy.equals("date_desc")){
- Collections.reverse(keyList);
- }
- else{
- if (!sortBy.equals("date_asc")){
- throw new ServletModuleExc("don't know how to sort by: "+ sortBy);
- }
+ }
+ else {
+ // then we'll sort by date!
+ Map dateToPosition = new HashMap(end, 1.0F); //we know how big it will be
+ for (int i = start; i < end; i++) {
+ String creationDate = (hits.doc(i)).get("creationDate");
+ // do a little dance in case two contents created at the same second!
+ if (dateToPosition.containsKey(creationDate)) {
+ ( (ArrayList) (dateToPosition.get(creationDate))).add(new Integer(i));
}
- ListIterator keyTraverser = keyList.listIterator();
- while (keyTraverser.hasNext()){
- ArrayList positions = (ArrayList)dateToPosition.get((keyTraverser.next()));
- ListIterator positionsTraverser=positions.listIterator();
- while (positionsTraverser.hasNext()){
- theDocumentsSorted.add(hits.doc(((Integer)(positionsTraverser.next())).intValue()));
- }
+ else {
+ ArrayList thePositions = new ArrayList();
+ thePositions.add(new Integer(i));
+ dateToPosition.put(creationDate, thePositions);
}
}
-
- try{
- searcher.close();
+ Set keys = dateToPosition.keySet();
+ ArrayList keyList = new ArrayList(keys);
+ Collections.sort(keyList);
+ if (sortBy.equals("date_desc")) {
+ Collections.reverse(keyList);
}
- catch (IOException e){
- logger.debug("Can't close searcher: " + e.toString());
- throw new ServletModuleFailure("Problem closing searcher(normal):" + e.getMessage(), e);
+ else {
+ if (!sortBy.equals("date_asc")) {
+ throw new ServletModuleExc("don't know how to sort by: " + sortBy);
+ }
}
+ ListIterator keyTraverser = keyList.listIterator();
+ while (keyTraverser.hasNext()) {
+ ArrayList positions = (ArrayList) dateToPosition.get( (keyTraverser.next()));
+ ListIterator positionsTraverser = positions.listIterator();
+ while (positionsTraverser.hasNext()) {
+ theDocumentsSorted.add(hits.doc( ( (Integer) (positionsTraverser.next())).intValue()));
+ }
+ }
+ }
-
- session.removeAttribute("numberOfHits");
- session.removeAttribute("theDocumentsSorted");
- session.removeAttribute("positionInResults");
-
- session.setAttribute("numberOfHits",new Integer(end));
- session.setAttribute("theDocumentsSorted",theDocumentsSorted);
- session.setAttribute("positionInResults",new Integer(0));
-
+ try {
+ searcher.close();
}
- catch (IOException e){
+ catch (IOException e) {
logger.debug("Can't close searcher: " + e.toString());
- throw new ServletModuleFailure("Problem closing searcher: " + e.getMessage(), e);
+ throw new ServletModuleFailure("Problem closing searcher(normal):" + e.getMessage(), e);
}
- }
- }
- }
-
- try {
- ArrayList theDocs = (ArrayList)session.getAttribute("theDocumentsSorted");
- if (theDocs != null){
- mergeData.put("numberOfHits", ((Integer)session.getAttribute("numberOfHits")).toString());
- List theHits = new Vector();
- int pIR=((Integer)session.getAttribute("positionInResults")).intValue();
- int terminus;
- int numHits=((Integer)session.getAttribute("numberOfHits")).intValue();
+ session.removeAttribute("numberOfHits");
+ session.removeAttribute("theDocumentsSorted");
+ session.removeAttribute("positionInResults");
- if (!(pIR+increment>=numHits)){
- mergeData.put("hasNext","y");
- }
- else {
- mergeData.put("hasNext", null);
- }
- if (pIR>0){
- mergeData.put("hasPrevious","y");
- }
- else {
- mergeData.put("hasPrevious", null);
- }
+ session.setAttribute("numberOfHits", new Integer(end));
+ session.setAttribute("theDocumentsSorted", theDocumentsSorted);
+ session.setAttribute("positionInResults", new Integer(0));
- if ((pIR+increment)>numHits){
- terminus=numHits;
- }
- else {
- terminus=pIR+increment;
}
- for(int i = pIR; i < terminus; i++) {
- Map h = new HashMap();
- Document theHit = (Document)theDocs.get(i);
- whereTerm.returnMeta(h,theHit);
- creatorTerm.returnMeta(h,theHit);
- titleTerm.returnMeta(h,theHit);
- descriptionTerm.returnMeta(h,theHit);
- dateTerm.returnMeta(h,theHit);
- imagesTerm.returnMeta(h,theHit);
- audioTerm.returnMeta(h,theHit);
- videoTerm.returnMeta(h,theHit);
- theHits.add(h);
+ catch (IOException e) {
+ logger.debug("Can't close searcher: " + e.toString());
+ throw new ServletModuleFailure("Problem closing searcher: " + e.getMessage(), e);
}
- mergeData.put("hits",theHits);
}
}
- catch (Throwable e) {
- logger.error("Can't iterate over hits: " + e.toString());
+ }
- throw new ServletModuleFailure("Problem getting hits: " + e.getMessage(), e);
- }
+ try {
+ ArrayList theDocs = (ArrayList) session.getAttribute("theDocumentsSorted");
+ if (theDocs != null) {
- mergeData.put("queryString",queryString);
+ mergeData.put("numberOfHits", ( (Integer) session.getAttribute("numberOfHits")).toString());
+ List theHits = new Vector();
+ int pIR = ( (Integer) session.getAttribute("positionInResults")).intValue();
+ int terminus;
+ int numHits = ( (Integer) session.getAttribute("numberOfHits")).intValue();
- deliver(req, res, mergeData, null, searchResultsTemplate);
+ if (! (pIR + increment >= numHits)) {
+ mergeData.put("hasNext", "y");
+ }
+ else {
+ mergeData.put("hasNext", null);
+ }
+ if (pIR > 0) {
+ mergeData.put("hasPrevious", "y");
+ }
+ else {
+ mergeData.put("hasPrevious", null);
+ }
+
+ if ( (pIR + increment) > numHits) {
+ terminus = numHits;
+ }
+ else {
+ terminus = pIR + increment;
+ }
+ for (int i = pIR; i < terminus; i++) {
+ Map h = new HashMap();
+ Document theHit = (Document) theDocs.get(i);
+ whereTerm.returnMeta(h, theHit);
+ creatorTerm.returnMeta(h, theHit);
+ titleTerm.returnMeta(h, theHit);
+ descriptionTerm.returnMeta(h, theHit);
+ dateTerm.returnMeta(h, theHit);
+ imagesTerm.returnMeta(h, theHit);
+ audioTerm.returnMeta(h, theHit);
+ videoTerm.returnMeta(h, theHit);
+ theHits.add(h);
+ }
+ mergeData.put("hits", theHits);
+ }
}
- catch (NullPointerException n){
- throw new ServletModuleFailure("Null Pointer: "+n.toString(), n);
+ catch (Throwable e) {
+ logger.error("Can't iterate over hits: " + e.toString());
+
+ throw new ServletModuleFailure("Problem getting hits: " + e.getMessage(), e);
}
- }
- /*
- * Method for dynamically generating a pdf using iText
- */
+ mergeData.put("queryString", queryString);
+ deliver(req, res, mergeData, null, searchResultsTemplate);
+ }
+ catch (NullPointerException n) {
+ throw new ServletModuleFailure("Null Pointer: " + n.toString(), n);
+ }
+ }
- public void getpdf(HttpServletRequest req, HttpServletResponse res)
- throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {
- String ID_REQUEST_PARAM = "id";
- try {
- String idParam = req.getParameter(ID_REQUEST_PARAM);
- if (idParam != null) {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- PDFGenerator pdfMaker = new PDFGenerator(out);
+ /*
+ * Method for dynamically generating a pdf using iText
+ */
- RE re = new RE("[0-9]+");
+ public void getpdf(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {
+ String ID_REQUEST_PARAM = "id";
+ try {
+ String idParam = req.getParameter(ID_REQUEST_PARAM);
+ if (idParam != null) {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ PDFGenerator pdfMaker = new PDFGenerator(out);
+ RE re = new RE("[0-9]+");
- REMatch[] idMatches=re.getAllMatches(idParam);
+ REMatch[] idMatches = re.getAllMatches(idParam);
- if (idMatches.length > 1){
- pdfMaker.addLine();
- for (int i = 0; i < idMatches.length; i++){
- REMatch aMatch = idMatches[i];
- String id=aMatch.toString();
- EntityContent contentEnt = (EntityContent)contentModule.getById(id);
- pdfMaker.addIndexItem(contentEnt);
+ if (idMatches.length > 1) {
+ pdfMaker.addLine();
+ for (int i = 0; i < idMatches.length; i++) {
+ REMatch aMatch = idMatches[i];
+ String id = aMatch.toString();
+ EntityContent contentEnt = (EntityContent) contentModule.getById(id);
+ pdfMaker.addIndexItem(contentEnt);
- }
- }
+ }
+ }
- for (int i = 0; i < idMatches.length; i++){
- REMatch aMatch = idMatches[i];
+ for (int i = 0; i < idMatches.length; i++) {
+ REMatch aMatch = idMatches[i];
- String id=aMatch.toString();
+ String id = aMatch.toString();
- EntityContent contentEnt = (EntityContent)contentModule.getById(id);
- pdfMaker.add(contentEnt);
+ EntityContent contentEnt = (EntityContent) contentModule.getById(id);
+ pdfMaker.add(contentEnt);
- }
+ }
- pdfMaker.stop();
- res.setContentType("application/pdf");
- byte[] content = out.toByteArray();
- res.setContentLength(content.length);
- res.getOutputStream().write(content);
- res.getOutputStream().flush();
+ pdfMaker.stop();
+ res.setContentType("application/pdf");
+ byte[] content = out.toByteArray();
+ res.setContentLength(content.length);
+ res.getOutputStream().write(content);
+ res.getOutputStream().flush();
- }
- else {
- throw new ServletModuleExc("Missing id.");
- }
}
- catch (Throwable t) {
- logger.error(t.toString());
- throw new ServletModuleFailure(t);
+ else {
+ throw new ServletModuleExc("Missing id.");
}
-
}
+ catch (Throwable t) {
+ logger.error(t.toString());
+ throw new ServletModuleFailure(t);
+ }
+
+ }
+
public String generateOnetimePassword() {
Random r = new Random();
int random = r.nextInt();
@@ -1061,8 +1056,7 @@ public class ServletModuleOpenIndy extends ServletModule
return returnString.substring(5);
}
- public void deliver(HttpServletRequest aRequest, HttpServletResponse aResponse, Map aData, Map anExtra, String aGenerator)
- throws ServletModuleFailure {
+ public void deliver(HttpServletRequest aRequest, HttpServletResponse aResponse, Map aData, Map anExtra, String aGenerator) throws ServletModuleFailure {
try {
deliver(aResponse.getWriter(), aRequest, aResponse, aData, anExtra, aGenerator);
}
diff --git a/source/mircoders/servlet/ServletModuleUploadedMedia.java b/source/mircoders/servlet/ServletModuleUploadedMedia.java
index 6349e424..ba34a639 100755
--- a/source/mircoders/servlet/ServletModuleUploadedMedia.java
+++ b/source/mircoders/servlet/ServletModuleUploadedMedia.java
@@ -76,7 +76,7 @@ import freemarker.template.SimpleList;
* ServletModuleBilder -
* liefert HTML fuer Bilder
*
- * @version $Id: ServletModuleUploadedMedia.java,v 1.27 2003/04/26 00:42:22 zapata Exp $
+ * @version $Id: ServletModuleUploadedMedia.java,v 1.28 2003/04/29 02:36:51 zapata Exp $
* @author RK, the mir-coders group
*/
@@ -391,17 +391,17 @@ public abstract class ServletModuleUploadedMedia
String idParam = req.getParameter("id");
if (idParam!=null && !idParam.equals("")) {
try {
- EntityUploadedMedia ent = (EntityUploadedMedia)mainModule.getById(idParam);
+ EntityUploadedMedia ent = (EntityUploadedMedia) mainModule.getById(idParam);
Entity mediaType = ent.getMediaType();
MirMedia mediaHandler;
- ServletContext ctx = MirPropertiesConfiguration.getContext();
- String fName = ent.getId()+"."+mediaType.getValue("name");
-
mediaHandler = MediaHelper.getHandler(mediaType);
InputStream in = mediaHandler.getIcon(ent);
- res.setContentType(ctx.getMimeType(fName));
+ if (in==null)
+ throw new ServletModuleExc("no icon available");
+
+ res.setContentType(mediaHandler.getIconMimeType(ent, mediaType));
//important that before calling this res.getWriter was not called first
ServletOutputStream out = res.getOutputStream();
diff --git a/templates/admin/FUNCTIONS.template b/templates/admin/FUNCTIONS.template
index a7c207ab..b312836c 100755
--- a/templates/admin/FUNCTIONS.template
+++ b/templates/admin/FUNCTIONS.template
@@ -2,53 +2,53 @@