From: mh Date: Thu, 31 Jan 2002 12:06:00 +0000 (+0000) Subject: proper handling of exceptions all around. especially for the media stuff. X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=b917564ca5b903a1832b001afc1c4d443b507299;p=mir.git proper handling of exceptions all around. especially for the media stuff. there's still a little more left to do.. --- diff --git a/doc/TODO.txt b/doc/TODO.txt index 8bd1fac2..c2ebf734 100755 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -1,4 +1,4 @@ -[Updated 26.10.2001. -mh] +[Updated 29.01.2002. -mh] Version 1.0: @@ -11,16 +11,16 @@ templates) and "external"-templates (producer-templates) b) code-cleaning - the variable-names for the freemarker should be better: the same name for the same thing c) We have to make sure that all errors are handled intelligently. e.g. if an -article is corrupt, do we just ignore it, etc.. +article is corrupt, do we just ignore it, etc.. (almost there, mh) d) Admin interface needs to be made aware of media handlers (mj) -e) insposting() in ServletModuleOpenIndy should not insert article text if any associated media upload is wrong. (mh) +e) insposting() in ServletModuleOpenIndy should not insert article text if any associated media upload is wrong. (done, mh) c) documentation - it lacks a documentation for creating the producer-templates -d) new layout Mir/OpenMir (gilad) -e) translating the templates/code-comments to english +d) new layout Mir/OpenMir (gilad, indy de team??) +e) translating the templates/code-comments to english (underway, mir-coders) f) mission-statement and licensing -g) there are no memory-leaks +g) there are no memory-leaks (done, confirmed by indy NL) New Features: diff --git a/source/mir/media/MediaHandlerGeneric.java b/source/mir/media/MediaHandlerGeneric.java index c06141e8..a466a988 100755 --- a/source/mir/media/MediaHandlerGeneric.java +++ b/source/mir/media/MediaHandlerGeneric.java @@ -38,7 +38,9 @@ public class MediaHandlerGeneric implements MirMedia protected String imageHost = MirConfig.getProp("Producer.Image.Host"); protected String imageRoot = MirConfig.getProp("Producer.ImageRoot"); protected Logfile theLog = Logfile.getInstance(MirConfig.getProp("Home")+"log/media.log"); - public boolean set (byte[] uploadedData, Entity ent, Entity mediaTypeEnt ) { + public boolean set (byte[] uploadedData, Entity ent, Entity mediaTypeEnt ) + throws MirMediaException { + String ext = mediaTypeEnt.getValue("name"); String dir = MirConfig.getProp("Producer.Media.Path"); String mediaHost = MirConfig.getProp("Producer.Media.Host"); @@ -46,40 +48,42 @@ public class MediaHandlerGeneric implements MirMedia String date = ent.getValue("date"); String datePath = StringUtil.webdbDate2path(date); Integer size = new Integer(uploadedData.length); - if(FileUtil.write(dir+"/"+datePath+"/"+mediaFname, uploadedData)) { - //if(FileUtil.write(dir+"/"+mediaFname, uploadedData)) { + try { + FileUtil.write(dir+"/"+datePath+"/"+mediaFname, uploadedData); + //if(FileUtil.write(dir+"/"+mediaFname, uploadedData)) { //were done with the data, dereference. uploadedData=null; - try { - ent.setValueForProperty("is_produced", "1"); - ent.setValueForProperty("icon_is_produced", "1"); - ent.setValueForProperty("publish_path",datePath+"/"+mediaFname); - //ent.setValueForProperty("publish_path", mediaFname); - ent.setValueForProperty("publish_server", mediaHost); - ent.setValueForProperty("size", size.toString()); - ent.update(); - } catch (StorageObjectException e) { - theLog.printError("StorageObjectException: "+e.toString()); - return false; - } - } else { - theLog.printError("could not write FILE!"); - return false; + ent.setValueForProperty("is_produced", "1"); + ent.setValueForProperty("icon_is_produced", "1"); + ent.setValueForProperty("publish_path",datePath+"/"+mediaFname); + //ent.setValueForProperty("publish_path", mediaFname); + ent.setValueForProperty("publish_server", mediaHost); + ent.setValueForProperty("size", size.toString()); + ent.update(); + } catch (Exception e) { + theLog.printError(e.toString()); + throw new MirMediaException(e.toString()); } return true; } //a class that will probably never get used.. - private byte[] getFile (String fileName) { + private byte[] getFile (String fileName) + throws MirMediaException { + long size = FileUtil.getSize(fileName); if (size < 0) return null; byte[] container = new byte[(int)size]; - if(!FileUtil.read(fileName, container)) - return null; + try { + FileUtil.read(fileName, container); + } catch (Exception e) { + theLog.printError(e.toString()); + throw new MirMediaException(e.toString()); + } return container; } @@ -89,8 +93,7 @@ public class MediaHandlerGeneric implements MirMedia } public byte[] getIcon (Entity ent) { - String name = "/path/to/some/generic/icon"; - return getFile(name); + return null; } public String getStoragePath() diff --git a/source/mir/media/MediaHandlerImages.java b/source/mir/media/MediaHandlerImages.java index b85904a9..0ee930a7 100755 --- a/source/mir/media/MediaHandlerImages.java +++ b/source/mir/media/MediaHandlerImages.java @@ -36,7 +36,7 @@ public class MediaHandlerImages protected String imageType="0"; private Logfile theLog = Logfile.getInstance(MirConfig.getProp("Home")+"log/media.log"); - public byte[] get(Entity ent, Entity mediaTypeEnt) + public byte[] get(Entity ent, Entity mediaTypeEnt) throws MirMediaException { byte[] image_data = null; @@ -45,10 +45,13 @@ public class MediaHandlerImages image_data = (byte[])method.invoke(ent, null); } catch ( NoSuchMethodException e) { theLog.printDebugInfo("method lookup unsuccesful: "+e.toString()); + throw new MirMediaException(e.toString()); } catch ( IllegalAccessException e) { theLog.printDebugInfo("method illegal: "+e.toString()); + throw new MirMediaException(e.toString()); } catch ( InvocationTargetException e) { theLog.printDebugInfo("get: invocation target illegal: "+e.toString()); + throw new MirMediaException(e.toString()); } @@ -56,7 +59,8 @@ public class MediaHandlerImages } protected boolean set(byte[] uploadData, Entity ent, Entity mediaTypeEnt) - { + throws MirMediaException { + try { Class[] params = {byte[].class, String.class}; theLog.printDebugInfo("NAME: "+ent.getClass().getName()+" "+ @@ -66,13 +70,13 @@ public class MediaHandlerImages method.invoke(ent, new Object[] {uploadData, imageType}); } catch ( NoSuchMethodException e) { theLog.printDebugInfo("method lookup unsuccesful: "+e.toString()); - return false; + throw new MirMediaException(e.toString()); } catch ( IllegalAccessException e) { theLog.printDebugInfo("method illegal: "+e.toString()); - return false; + throw new MirMediaException(e.toString()); } catch ( InvocationTargetException e) { theLog.printDebugInfo("set: invocation target illegal: "+e.toString()); - return false; + throw new MirMediaException(e.toString()); } //deref. -mh uploadData=null; @@ -80,7 +84,7 @@ public class MediaHandlerImages return true; } - public byte[] getIcon(Entity ent) + public byte[] getIcon(Entity ent) throws MirMediaException { byte[] icon_data = null; @@ -89,10 +93,13 @@ public class MediaHandlerImages icon_data = (byte[])method.invoke(ent, null); } catch ( NoSuchMethodException e) { theLog.printDebugInfo("method lookup unsuccesful: "+e.toString()); + throw new MirMediaException(e.toString()); } catch ( IllegalAccessException e) { theLog.printDebugInfo("method illegal: "+e.toString()); + throw new MirMediaException(e.toString()); } catch ( InvocationTargetException e) { theLog.printDebugInfo("getIcon: invocation target illegal: "+e.toString()); + throw new MirMediaException(e.toString()); } return icon_data; diff --git a/source/mir/media/MediaHandlerImagesGif.java b/source/mir/media/MediaHandlerImagesGif.java index 0b22412e..5b940c4b 100755 --- a/source/mir/media/MediaHandlerImagesGif.java +++ b/source/mir/media/MediaHandlerImagesGif.java @@ -23,8 +23,13 @@ public class MediaHandlerImagesGif extends MediaHandlerImages implements MirMedi { public boolean set(byte[] uploadData, Entity ent, Entity mediaTypeEnt) - { + throws MirMediaException { + imageType = WEBDB_GIF; - return super.set(uploadData, ent, mediaTypeEnt); + try { + return super.set(uploadData, ent, mediaTypeEnt); + } catch (Exception e) { + throw new MirMediaException(e.toString()); + } } } diff --git a/source/mir/media/MediaHandlerImagesJpeg.java b/source/mir/media/MediaHandlerImagesJpeg.java index ff01abc6..39faaf0c 100755 --- a/source/mir/media/MediaHandlerImagesJpeg.java +++ b/source/mir/media/MediaHandlerImagesJpeg.java @@ -22,8 +22,13 @@ import mir.entity.*; public class MediaHandlerImagesJpeg extends MediaHandlerImages implements MirMedia { public boolean set(byte[] uploadData, Entity ent, Entity mediaTypeEnt) - { + throws MirMediaException { + imageType = WEBDB_JPG; - return super.set(uploadData, ent, mediaTypeEnt); + try { + return super.set(uploadData, ent, mediaTypeEnt); + } catch (Exception e) { + throw new MirMediaException(e.toString()); + } } } diff --git a/source/mir/media/MediaHandlerMp3.java b/source/mir/media/MediaHandlerMp3.java index 747ef37d..0357a02b 100755 --- a/source/mir/media/MediaHandlerMp3.java +++ b/source/mir/media/MediaHandlerMp3.java @@ -42,7 +42,9 @@ import mir.storage.*; public class MediaHandlerMp3 extends MediaHandlerAudio implements MirMedia { - public boolean set (byte[] uploadedData, Entity ent, Entity mediaTypeEnt ) { + public boolean set (byte[] uploadedData, Entity ent, Entity mediaTypeEnt ) + throws MirMediaException { + String ext = mediaTypeEnt.getValue("name"); String dir = MirConfig.getProp("Producer.Media.Path"); String mediaHost = MirConfig.getProp("Producer.Media.Host"); @@ -54,31 +56,27 @@ public class MediaHandlerMp3 extends MediaHandlerAudio implements MirMedia String mpegURLFile = baseName+".m3u"; String playlistFile = baseName+".pls"; Integer size = new Integer(uploadedData.length); - if(FileUtil.write(dir+"/"+datePath+"/"+mediaFname, uploadedData)) { - //if(FileUtil.write(dir+"/"+mediaFname, uploadedData)) { + try { + FileUtil.write(dir+"/"+datePath+"/"+mediaFname, uploadedData); + //FileUtil.write(dir+"/"+mediaFname, uploadedData); //were done with the data, dereference. uploadedData=null; - try { - //write the "meta" files - //first the .m3u since it only contains one line - FileUtil.write(dir+"/"+datePath+"/"+mpegURLFile,mp3Pointer.getBytes()); - //now the .pls file - FileUtil.write(dir+"/"+datePath+"/"+playlistFile,mp3Pointer.getBytes()); - ent.setValueForProperty("is_produced", "1"); - ent.setValueForProperty("icon_is_produced", "1"); - ent.setValueForProperty("publish_path",datePath+"/"+mediaFname); - //ent.setValueForProperty("publish_path", mediaFname); - ent.setValueForProperty("publish_server", mediaHost); - ent.setValueForProperty("size", size.toString()); - ent.update(); - } catch (StorageObjectException e) { - theLog.printError("StorageObjectException: "+e.toString()); - return false; - } - } else { - theLog.printError("could not write FILE!"); - return false; + //write the "meta" files + //first the .m3u since it only contains one line + FileUtil.write(dir+"/"+datePath+"/"+mpegURLFile,mp3Pointer.getBytes()); + //now the .pls file + FileUtil.write(dir+"/"+datePath+"/"+playlistFile,mp3Pointer.getBytes()); + ent.setValueForProperty("is_produced", "1"); + ent.setValueForProperty("icon_is_produced", "1"); + ent.setValueForProperty("publish_path",datePath+"/"+mediaFname); + //ent.setValueForProperty("publish_path", mediaFname); + ent.setValueForProperty("publish_server", mediaHost); + ent.setValueForProperty("size", size.toString()); + ent.update(); + } catch (Exception e) { + theLog.printError(e.toString()); + throw new MirMediaException(e.toString()); } return true; diff --git a/source/mir/media/MediaHandlerRealAudio.java b/source/mir/media/MediaHandlerRealAudio.java index 5a1c7c1c..e9f99a2d 100755 --- a/source/mir/media/MediaHandlerRealAudio.java +++ b/source/mir/media/MediaHandlerRealAudio.java @@ -26,7 +26,8 @@ import mir.storage.*; public class MediaHandlerRealAudio extends MediaHandlerAudio implements MirMedia { - public boolean set (byte[] uploadedData, Entity ent, Entity mediaTypeEnt ) { + public boolean set (byte[] uploadedData, Entity ent, Entity mediaTypeEnt ) + throws MirMediaException { String ext = mediaTypeEnt.getValue("name"); String dir = MirConfig.getProp("Producer.Media.Path"); String rtspDir = MirConfig.getProp("Producer.RealMedia.Path"); @@ -39,28 +40,24 @@ public class MediaHandlerRealAudio extends MediaHandlerAudio implements MirMedia String realMediaPointer = rtspMediaHost+datePath+mediaFname; String realMediaFile = ent.getId()+".ram"; Integer size = new Integer(uploadedData.length); - if(FileUtil.write(dir+"/"+datePath+"/"+mediaFname, uploadedData)) { - //if(FileUtil.write(rtspDir+"/"+mediaFname, uploadedData)) { + try { + FileUtil.write(dir+"/"+datePath+"/"+mediaFname, uploadedData); + //FileUtil.write(rtspDir+"/"+mediaFname, uploadedData); //were done with the data, dereference. uploadedData=null; - try { - //write a ram file - FileUtil.write(dir+"/"+datePath+"/"+realMediaFile,realMediaPointer.getBytes()); - ent.setValueForProperty("is_produced", "1"); - ent.setValueForProperty("icon_is_produced", "1"); - ent.setValueForProperty("publish_path",datePath+"/"+realMediaFile); - //ent.setValueForProperty("publish_path", realMediaFile); - ent.setValueForProperty("publish_server", mediaHost); - ent.setValueForProperty("size", size.toString()); - ent.update(); - } catch (StorageObjectException e) { - theLog.printError("StorageObjectException: "+e.toString()); - return false; - } - } else { - theLog.printError("could not write FILE!"); - return false; + //write a ram file + FileUtil.write(dir+"/"+datePath+"/"+realMediaFile,realMediaPointer.getBytes()); + ent.setValueForProperty("is_produced", "1"); + ent.setValueForProperty("icon_is_produced", "1"); + ent.setValueForProperty("publish_path",datePath+"/"+realMediaFile); + //ent.setValueForProperty("publish_path", realMediaFile); + ent.setValueForProperty("publish_server", mediaHost); + ent.setValueForProperty("size", size.toString()); + ent.update(); + } catch (Exception e) { + theLog.printError(e.toString()); + throw new MirMediaException(e.toString()); } return true; diff --git a/source/mir/media/MediaHandlerRealVideo.java b/source/mir/media/MediaHandlerRealVideo.java index 264d1bd0..f47e9963 100755 --- a/source/mir/media/MediaHandlerRealVideo.java +++ b/source/mir/media/MediaHandlerRealVideo.java @@ -29,7 +29,10 @@ public class MediaHandlerRealVideo extends MediaHandlerGeneric implements MirMed private String imageHost = MirConfig.getProp("Producer.Image.Host"); private static String imageRoot = MirConfig.getProp("Producer.ImageRoot"); private Logfile theLog = Logfile.getInstance(MirConfig.getProp("Home")+"log/media.log"); - public boolean set (byte[] uploadedData, Entity ent, Entity mediaTypeEnt ) { + + public boolean set (byte[] uploadedData, Entity ent, Entity mediaTypeEnt ) + throws MirMediaException { + String ext = mediaTypeEnt.getValue("name"); String dir = MirConfig.getProp("Producer.Media.Path"); String rtspDir = MirConfig.getProp("Producer.RealMedia.Path"); @@ -37,34 +40,29 @@ public class MediaHandlerRealVideo extends MediaHandlerGeneric implements MirMed String rtspMediaHost = MirConfig.getProp("Producer.RealMedia.Host"); String mediaFname = ent.getId()+"."+ext; - String RealMediaPointer = rtspMediaHost+mediaFname; - String RealMediaFile = ent.getId()+".ram"; + String RealMediaPointer = rtspMediaHost+mediaFname; + String RealMediaFile = ent.getId()+".ram"; String date = ent.getValue("date"); String datePath = StringUtil.webdbDate2path(date); Integer size = new Integer(uploadedData.length); - if(FileUtil.write(dir+"/"+datePath+"/"+mediaFname, uploadedData)) { - //if(FileUtil.write(rtspDir+"/"+mediaFname, uploadedData)) { + try { + FileUtil.write(dir+"/"+datePath+"/"+mediaFname, uploadedData); + //FileUtil.write(rtspDir+"/"+mediaFname, uploadedData); //were done with the data, dereference. uploadedData=null; - - try { -//write an rm file -FileUtil.write(dir+"/"+RealMediaFile,RealMediaPointer.getBytes()); - - ent.setValueForProperty("is_produced", "1"); - ent.setValueForProperty("icon_is_produced", "1"); - ent.setValueForProperty("publish_path",datePath+"/"+mediaFname); - //ent.setValueForProperty("publish_path", RealMediaFile); - ent.setValueForProperty("publish_server", mediaHost); - ent.setValueForProperty("size", size.toString()); - ent.update(); - } catch (StorageObjectException e) { - theLog.printError("StorageObjectException: "+e.toString()); - return false; - } - } else { - theLog.printError("could not write FILE!"); - return false; + + //write an rm file + FileUtil.write(dir+"/"+RealMediaFile,RealMediaPointer.getBytes()); + ent.setValueForProperty("is_produced", "1"); + ent.setValueForProperty("icon_is_produced", "1"); + ent.setValueForProperty("publish_path",datePath+"/"+mediaFname); + //ent.setValueForProperty("publish_path", RealMediaFile); + ent.setValueForProperty("publish_server", mediaHost); + ent.setValueForProperty("size", size.toString()); + ent.update(); + } catch (Exception e) { + theLog.printError(e.toString()); + throw new MirMediaException(e.toString()); } return true; @@ -95,25 +93,25 @@ FileUtil.write(dir+"/"+RealMediaFile,RealMediaPointer.getBytes()); private static String tinyIcon = MirConfig.getProp("Producer.Icon.TinyVideo"); private static String bigIcon = MirConfig.getProp("Producer.Icon.BigVideo"); - public String getTinyIcon() - { - return tinyIcon; - } - - public String getBigIcon() - { - return bigIcon; - } - - public String getIconAlt() - { - return "Video"; - } - - public boolean isVideo() - { - return true; - } + public String getTinyIcon() + { + return tinyIcon; + } + + public String getBigIcon() + { + return bigIcon; + } + + public String getIconAlt() + { + return "Video"; + } + + public boolean isVideo() + { + return true; + } } diff --git a/source/mir/media/MirMedia.java b/source/mir/media/MirMedia.java index 2a3a9b66..3597a1fc 100755 --- a/source/mir/media/MirMedia.java +++ b/source/mir/media/MirMedia.java @@ -72,7 +72,7 @@ public interface MirMedia{ * @return boolean, success/fail * @see mir.entity.Entity */ - public abstract boolean set (byte[] uploadedData, Entity ent, Entity mediaTypeEnt ); + public abstract boolean set (byte[] uploadedData, Entity ent, Entity mediaTypeEnt ) throws MirMediaException; /** * Get's the media data from storage and returns it as a byte array @@ -84,7 +84,8 @@ public interface MirMedia{ * @return byte[] * @see mir.entity.Entity */ - public abstract byte[] get (Entity ent, Entity mediaTypeEnt); + public abstract byte[] get (Entity ent, Entity mediaTypeEnt) + throws MirMediaException; /** * Pretty much like get() above. But get's the specific Icon @@ -93,7 +94,7 @@ public interface MirMedia{ * @return byte[] * @see mir.entity.Entity */ - public abstract byte[] getIcon (Entity ent); + public abstract byte[] getIcon (Entity ent) throws MirMediaException; /** * gets the final content representation for the media @@ -108,7 +109,8 @@ public interface MirMedia{ * @see mir.entity.Entity * @see mir.misc.StringUtil */ - public abstract String getURL (Entity ent, Entity mediaTypeEnt); + public abstract String getURL (Entity ent, Entity mediaTypeEnt) + throws MirMediaException; /** * gets the summary representation for the media @@ -123,7 +125,8 @@ public interface MirMedia{ * @see mir.entity.Entity * @see mir.misc.StringUtil */ - public abstract String getListView (Entity ent, Entity mediaTypeEnt); + public abstract String getListView (Entity ent, Entity mediaTypeEnt) + throws MirMediaException; /** * Returns the absolute filesystem path to where the media @@ -133,7 +136,7 @@ public interface MirMedia{ * @return String, the path. * @see mir.misc.MirConfig */ - public abstract String getStoragePath (); + public abstract String getStoragePath () throws MirMediaException; /** * Returns the *relative* filesystem path to where the media @@ -145,7 +148,7 @@ public interface MirMedia{ * @return String, the path. * @see mir.misc.MirConfig */ - public abstract String getIconStoragePath (); + public abstract String getIconStoragePath () throws MirMediaException; /** * Returns the base URL to that the media is accessible from @@ -153,12 +156,12 @@ public interface MirMedia{ * This is used in the Metadata stored in the DB and later on * ,the templates use it. * It is usually defined - * in the configuration wich is accessible through the MirConfig + * in the configuration witch is accessible through the MirConfig * class. * @return String, the base URL to the host. * @see mir.misc.MirConfig */ - public abstract String getPublishHost (); + public abstract String getPublishHost () throws MirMediaException; /** * Returns the file name of the Icon representing the media type. diff --git a/source/mir/misc/FileUtil.java b/source/mir/misc/FileUtil.java index 5a68e319..f9b3e7e2 100755 --- a/source/mir/misc/FileUtil.java +++ b/source/mir/misc/FileUtil.java @@ -30,7 +30,6 @@ public final class FileUtil { static { System.setProperty("content.types.user.table", MirConfig.getProp("Home")+"content-types.properties"); - System.err.println("DDD: "+MirConfig.getProp("Home")+"content-types.properties"); fileNameMap = sun.net.www.MimeTable.loadTable(); producerStorageRoot = MirConfig.getProp("Producer.StorageRoot"); } @@ -41,7 +40,8 @@ public final class FileUtil { private FileUtil () { } - public static boolean write(String filename, byte[] in) { + public static boolean write(String filename, byte[] in) + throws IOException { boolean retVal = false; @@ -57,12 +57,15 @@ public final class FileUtil { outStream.write(in); outStream.close(); retVal = true; - } catch(IOException exception) {} + } catch(IOException e) { + throw new IOException(e.toString()); + } } return retVal; } - public static boolean read(String filename, byte out[]) { + public static boolean read(String filename, byte out[]) + throws IOException { File f = null; f = new File(filename); @@ -75,8 +78,8 @@ public final class FileUtil { inStream = new FileInputStream(f); inStream.read(out); inStream.close(); - } catch(IOException exception) { - return false; + } catch(IOException e) { + throw new IOException(e.toString()); } } else { return false; @@ -117,9 +120,8 @@ public final class FileUtil { public static String guessContentTypeFromName(String fname) { String contentType = null; - System.err.println("NAME: "+fname); contentType = getFileNameMap().getContentTypeFor(fname); - System.err.println("TYPE: "+contentType); + return contentType; } diff --git a/source/mir/misc/MirConfig.java b/source/mir/misc/MirConfig.java index d6cd4859..4eb5b8fe 100755 --- a/source/mir/misc/MirConfig.java +++ b/source/mir/misc/MirConfig.java @@ -79,7 +79,7 @@ public class MirConfig extends Configuration { (String)configHash.get(propName); } - public static void addBroker(String driver, String URL){ + public static void addBroker(String driver, String URL) throws Exception { String username,passwd,min,max,log,reset; @@ -107,6 +107,7 @@ public class MirConfig extends Configuration { } } catch(Exception e){ System.err.println("Der ConnectionBroker konnte nicht initializiert werden"+ e.toString());e.printStackTrace(); + throw new Exception(e.toString()); } } // end if } diff --git a/source/mir/storage/Database.java b/source/mir/storage/Database.java index 3c753653..9fc15d02 100755 --- a/source/mir/storage/Database.java +++ b/source/mir/storage/Database.java @@ -7,7 +7,8 @@ import java.sql.*; import java.lang.*; import java.io.*; import java.util.*; -import freemarker.template.*; +import freemarker.template.SimpleList; +import freemarker.template.SimpleHash; import com.javaexchange.dbConnectionBroker.*; import mir.storage.StorageObject; import mir.entity.*; @@ -59,25 +60,25 @@ public class Database implements StorageObject { * * @param String confFilename Dateiname der Konfigurationsdatei */ - public Database() { - //theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Database.Logfile")); - theLog = Logfile.getInstance(this.getClass().getName()); - String database_username=DatabaseConfig.getProp("Database.Username"); - String database_password=DatabaseConfig.getProp("Database.Password"); - String database_host=DatabaseConfig.getProp("Database.Host"); - String theAdaptorName=DatabaseConfig.getProp("Database.Adaptor"); + public Database() throws StorageObjectException { + theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Database.Logfile")); + String database_username=MirConfig.getProp("Database.Username"); + String database_password=MirConfig.getProp("Database.Password"); + String database_host=MirConfig.getProp("Database.Host"); + String theAdaptorName=MirConfig.getProp("Database.Adaptor"); try { theEntityClass = Class.forName("mir.entity.GenericEntity"); theAdaptor = (DatabaseAdaptor)Class.forName(theAdaptorName).newInstance(); - defaultLimit = Integer.parseInt(DatabaseConfig.getProp("Database.Limit")); + defaultLimit = Integer.parseInt(MirConfig.getProp("Database.Limit")); database_driver=theAdaptor.getDriver(); database_url=theAdaptor.getURL(database_username,database_password,database_host); theLog.printDebugInfo("adding Broker with: " +database_driver+":"+database_url ); - DatabaseConfig.addBroker(database_driver,database_url); - myBroker=DatabaseConfig.getBroker(); + MirConfig.addBroker(database_driver,database_url); + myBroker=MirConfig.getBroker(); } catch (Exception e){ theLog.printError("Bei Konstruktion von Database() with " + theAdaptorName + " -- " +e.toString()); + throw new StorageObjectException(e.toString()); } } @@ -753,7 +754,7 @@ public class Database implements StorageObject { * eine SimpleList mit Standard-Popupdaten erzeugt werden koennen soll. * @return null */ - public SimpleList getPopupData () { + public SimpleList getPopupData () throws StorageObjectException { return null; } @@ -763,7 +764,8 @@ public class Database implements StorageObject { * @param hasNullValue Wenn true wird eine leerer Eintrag fuer die Popups erzeugt. * @return SimpleList Gibt freemarker.template.SimpleList zurueck. */ - public SimpleList getPopupData (String name, boolean hasNullValue) { + public SimpleList getPopupData (String name, boolean hasNullValue) + throws StorageObjectException { return getPopupData(name, hasNullValue, null); } @@ -774,8 +776,8 @@ public class Database implements StorageObject { * @param where Schraenkt die Selektion der Datensaetze ein. * @return SimpleList Gibt freemarker.template.SimpleList zurueck. */ - public SimpleList getPopupData (String name, boolean hasNullValue, String where) { - return getPopupData(name, hasNullValue, where, null); + public SimpleList getPopupData (String name, boolean hasNullValue, String where) throws StorageObjectException { + return getPopupData(name, hasNullValue, where, null); } /** @@ -786,8 +788,7 @@ public class Database implements StorageObject { * @param order Gibt ein Feld als Sortierkriterium an. * @return SimpleList Gibt freemarker.template.SimpleList zurueck. */ - public SimpleList getPopupData (String name, boolean hasNullValue, String where, - String order) { + public SimpleList getPopupData (String name, boolean hasNullValue, String where, String order) throws StorageObjectException { // caching if (hasPopupCache && popupCache != null) return popupCache; @@ -829,6 +830,7 @@ public class Database implements StorageObject { } } catch (Exception e) { theLog.printDebugInfo(e.toString()); + throw new StorageObjectException(e.toString()); } finally { freeConnection(con, stmt); } @@ -968,7 +970,10 @@ public class Database implements StorageObject { pstmt = con.prepareStatement(sql); result = pstmt.executeUpdate(); } - catch (Exception e) {theLog.printDebugInfo("settimage :: setImage gescheitert: "+e.toString());} + catch (Exception e) { + theLog.printDebugInfo("settimage :: setImage gescheitert: "+e.toString()); + throw new StorageObjectException("executeUpdate failed: "+e.toString()); + } finally { freeConnection(con,pstmt); } theLog.printInfo((new java.util.Date().getTime() - startTime) + "ms. for: " + sql); return result; @@ -1032,11 +1037,11 @@ public class Database implements StorageObject { /** * Datenbankverbindung wird geschlossen */ - public void disconnectPool () { + public void disconnectPool () throws StorageObjectException { try { myBroker.destroy(100); } catch (SQLException sqe) { - ; + throwSQLException(sqe, "disconnectPool"); } } @@ -1060,17 +1065,21 @@ public class Database implements StorageObject { * @param con Connection zur Datenbank * @param stmt Statement-Objekt */ - public void freeConnection (Connection con, Statement stmt) { + public void freeConnection (Connection con, Statement stmt) + throws StorageObjectException { try { if (stmt != null) stmt.close(); } catch (SQLException e1) { theLog.printDebugInfo(e1.toString()); + throw new StorageObjectException("DB, in freeConnection: "+e1.toString()); } if (con != null) myBroker.freeConnection(con); - else + else { theLog.printDebugInfo("Con was null!"); + throw new StorageObjectException("Con was null!"); + } } /** diff --git a/source/mir/storage/StorageObject.java b/source/mir/storage/StorageObject.java index 1677903f..d489d2dc 100755 --- a/source/mir/storage/StorageObject.java +++ b/source/mir/storage/StorageObject.java @@ -204,7 +204,8 @@ public interface StorageObject { * @param con * @param stmt */ - abstract public void freeConnection(Connection con, Statement stmt); + abstract public void freeConnection(Connection con, Statement stmt) + throws StorageObjectException; @@ -212,7 +213,7 @@ public interface StorageObject { * Dokumentation siehe Database.java * @return */ - abstract public SimpleList getPopupData (); + abstract public SimpleList getPopupData () throws StorageObjectException; abstract public int executeUpdate(Statement a, String sql) throws StorageObjectException, SQLException ; abstract public int executeUpdate(String sql) throws StorageObjectException, SQLException ; diff --git a/source/mircoders/entity/EntityContent.java b/source/mircoders/entity/EntityContent.java index 693afd86..485f609d 100755 --- a/source/mircoders/entity/EntityContent.java +++ b/source/mircoders/entity/EntityContent.java @@ -55,7 +55,7 @@ public class EntityContent extends AbstractEntity implements Entity * set is_produced flag for the article */ - public void setProduced(boolean yesno) + public void setProduced(boolean yesno) throws StorageObjectException { Connection con=null;Statement stmt=null; String value = (yesno) ? "1":"0"; @@ -96,7 +96,7 @@ public class EntityContent extends AbstractEntity implements Entity * dettach from media */ - public void dettach(String cid,String mid) + public void dettach(String cid,String mid) throws StorageObjectException { if (mid!=null){ try{ @@ -113,7 +113,7 @@ public class EntityContent extends AbstractEntity implements Entity * attach to media */ - public void attach(String mid) + public void attach(String mid) throws StorageObjectException { if (mid!=null) { //write media-id mid and content-id in table content_x_media diff --git a/source/mircoders/entity/EntityImages.java b/source/mircoders/entity/EntityImages.java index f098b682..c9c1a319 100755 --- a/source/mircoders/entity/EntityImages.java +++ b/source/mircoders/entity/EntityImages.java @@ -37,7 +37,7 @@ public class EntityImages extends AbstractEntity implements Entity - public byte[] getImage() + public byte[] getImage() throws StorageObjectException { theLog.printDebugInfo("--getimage started"); Connection con=null;Statement stmt=null; @@ -64,7 +64,7 @@ public class EntityImages extends AbstractEntity implements Entity } public void setImage(byte[] uploadData, String imageType) - { + throws StorageObjectException { int type = 0; //hack -mh @@ -129,7 +129,7 @@ public class EntityImages extends AbstractEntity implements Entity super.setValues(theStringValues); } - public byte[] getIcon() + public byte[] getIcon() throws StorageObjectException { Connection con=null;Statement stmt=null; byte[] img_data=null; diff --git a/source/mircoders/entity/EntityMedia.java b/source/mircoders/entity/EntityMedia.java index d43fdeca..a1c4f637 100755 --- a/source/mircoders/entity/EntityMedia.java +++ b/source/mircoders/entity/EntityMedia.java @@ -38,8 +38,13 @@ public class EntityMedia extends AbstractEntity implements Entity * * @return mir.entity.Entity */ - public Entity getMediaType() { - return ((DatabaseMedia)theStorageObject).getMediaType(this); + public Entity getMediaType() throws StorageObjectException { + try { + return ((DatabaseMedia)theStorageObject).getMediaType(this); + } catch (StorageObjectException e) { + throw new StorageObjectException("getMediaType(): "+e.toString()); + } + } public void finalize() { diff --git a/source/mircoders/entity/EntityVideo.java b/source/mircoders/entity/EntityVideo.java index 2adf427b..ae08955b 100755 --- a/source/mircoders/entity/EntityVideo.java +++ b/source/mircoders/entity/EntityVideo.java @@ -35,7 +35,7 @@ public class EntityVideo extends AbstractEntity implements Entity // // methods - public byte[] getVideoData() + public byte[] getVideoData() throws StorageObjectException { Connection con=null;Statement stmt=null; @@ -61,7 +61,7 @@ public class EntityVideo extends AbstractEntity implements Entity return video_data; } - public void setVideoData(byte[] uploadData) + public void setVideoData(byte[] uploadData) throws StorageObjectException { if (uploadData!=null) { Connection con=null;PreparedStatement pstmt=null; diff --git a/source/mircoders/module/ModuleComment.java b/source/mircoders/module/ModuleComment.java index 19037213..169e4189 100755 --- a/source/mircoders/module/ModuleComment.java +++ b/source/mircoders/module/ModuleComment.java @@ -31,14 +31,18 @@ public class ModuleComment extends AbstractModule // Contructor public ModuleComment(StorageObject theStorage) { - //if (theLog == null) theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Module.Comment.Logfile")); - //if (theStorage == null) theLog.printWarning("StorageObject was null!"); + if (theLog == null) theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Module.Comment.Logfile")); + if (theStorage == null) theLog.printWarning("StorageObject was null!"); this.theStorage = theStorage; } // Methoden - public SimpleList getCommentAsSimpleList() { - return ((DatabaseComment)theStorage).getPopupData(); + public SimpleList getCommentAsSimpleList() throws ModuleException { + try { + return ((DatabaseComment)theStorage).getPopupData(); + } catch (StorageObjectException e) { + throw new ModuleException(e.toString()); + } } /** diff --git a/source/mircoders/module/ModuleFeature.java b/source/mircoders/module/ModuleFeature.java index 9639ed14..5f42664d 100755 --- a/source/mircoders/module/ModuleFeature.java +++ b/source/mircoders/module/ModuleFeature.java @@ -32,12 +32,17 @@ public class ModuleFeature extends AbstractModule this.theStorage = theStorage; if (theLog == null) - theLog = Logfile.getInstance(this.getClass().getName()); + theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Module.Feature.Logfile")); } - public SimpleList getSchwerpunktAsSimpleList() { - return ((DatabaseFeature)theStorage).getPopupData(); + public SimpleList getSchwerpunktAsSimpleList() + throws ModuleException { + try { + return ((DatabaseFeature)theStorage).getPopupData(); + } catch (StorageObjectException e) { + throw new ModuleException(e.toString()); + } } } diff --git a/source/mircoders/module/ModuleImages.java b/source/mircoders/module/ModuleImages.java index e5c37a51..01e8e5f0 100755 --- a/source/mircoders/module/ModuleImages.java +++ b/source/mircoders/module/ModuleImages.java @@ -24,7 +24,7 @@ public class ModuleImages extends AbstractModule { public ModuleImages(StorageObject theStorage) { - if (theLog == null) theLog = Logfile.getInstance(this.getClass().getName()); + if (theLog == null) theLog = Logfile.getInstance(MirConfig.getProp("Home")+MirConfig.getProp("Module.Bilder.Logfile")); if (theStorage == null) theLog.printWarning("StorageObject was null!"); this.theStorage = theStorage; @@ -32,10 +32,15 @@ public class ModuleImages extends AbstractModule { // Methoden - public SimpleList getBilderAsSimpleList() { + public SimpleList getBilderAsSimpleList() + throws ModuleException { // String sql = "select id, name from Bilder order by name"; - return ((DatabaseImages)theStorage).getPopupData(); + try { + return ((DatabaseImages)theStorage).getPopupData(); + } catch (StorageObjectException e) { + throw new ModuleException(e.toString()); + } } } diff --git a/source/mircoders/module/ModuleMediafolder.java b/source/mircoders/module/ModuleMediafolder.java index eb825765..4609e064 100755 --- a/source/mircoders/module/ModuleMediafolder.java +++ b/source/mircoders/module/ModuleMediafolder.java @@ -35,15 +35,19 @@ public class ModuleMediafolder extends AbstractModule public ModuleMediafolder(StorageObject theStorage) { - if (theLog == null) theLog = Logfile.getInstance(this.getClass().getName()); + if (theLog == null) theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Module.Mediafolder.Logfile")); if (theStorage == null) theLog.printWarning("StorageObject was null!"); this.theStorage = theStorage; } // Methoden - public SimpleList getPopupData() { - return ((DatabaseMediafolder)theStorage).getPopupData(); + public SimpleList getPopupData() throws ModuleException { + try { + return ((DatabaseMediafolder)theStorage).getPopupData(); + } catch (Exception e) { + throw new ModuleException(e.toString()); + } } diff --git a/source/mircoders/module/ModuleSchwerpunkt.java b/source/mircoders/module/ModuleSchwerpunkt.java index a0c1cd2b..3cab0fec 100755 --- a/source/mircoders/module/ModuleSchwerpunkt.java +++ b/source/mircoders/module/ModuleSchwerpunkt.java @@ -33,12 +33,17 @@ public class ModuleSchwerpunkt extends AbstractModule this.theStorage = theStorage; if (theLog == null) - theLog = Logfile.getInstance(this.getClass().getName()); + theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Module.Schwerpunkt.Logfile")); } - public SimpleList getSchwerpunktAsSimpleList() { - return ((DatabaseFeature)theStorage).getPopupData(); + public SimpleList getSchwerpunktAsSimpleList() + throws ModuleException { + try { + return ((DatabaseFeature)theStorage).getPopupData(); + } catch (StorageObjectException e) { + throw new ModuleException(e.toString()); + } } } diff --git a/source/mircoders/module/ModuleTopics.java b/source/mircoders/module/ModuleTopics.java index 4a132e32..546473f2 100755 --- a/source/mircoders/module/ModuleTopics.java +++ b/source/mircoders/module/ModuleTopics.java @@ -32,11 +32,15 @@ public class ModuleTopics extends AbstractModule public ModuleTopics(StorageObject theStorage) { this.theStorage = theStorage; if (theLog == null) - theLog = Logfile.getInstance(this.getClass().getName()); + theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Module.Themen.Logfile")); } - public SimpleList getTopicsAsSimpleList() { - return ((DatabaseTopics)theStorage).getPopupData(); + public SimpleList getTopicsAsSimpleList() throws ModuleException { + try { + return ((DatabaseTopics)theStorage).getPopupData(); + } catch(StorageObjectException e) { + throw new ModuleException(e.toString()); + } } } diff --git a/source/mircoders/module/ModuleUploadedMedia.java b/source/mircoders/module/ModuleUploadedMedia.java index 76a1cec7..e3446e8e 100755 --- a/source/mircoders/module/ModuleUploadedMedia.java +++ b/source/mircoders/module/ModuleUploadedMedia.java @@ -32,11 +32,16 @@ public class ModuleUploadedMedia extends AbstractModule public ModuleUploadedMedia(StorageObject theStorage) { this.theStorage = theStorage; if (theLog == null) - theLog = Logfile.getInstance(this.getClass().getName()); + theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Module.Themen.Logfile")); } - public SimpleList getUploadedMediaAsSimpleList() { - return ((DatabaseUploadedMedia)theStorage).getPopupData(); + public SimpleList getUploadedMediaAsSimpleList() + throws ModuleException { + try { + return ((DatabaseUploadedMedia)theStorage).getPopupData(); + } catch (StorageObjectException e) { + throw new ModuleException(e.toString()); + } } } diff --git a/source/mircoders/module/ModuleUsers.java b/source/mircoders/module/ModuleUsers.java index 779dc2c6..13c07c56 100755 --- a/source/mircoders/module/ModuleUsers.java +++ b/source/mircoders/module/ModuleUsers.java @@ -35,7 +35,7 @@ public class ModuleUsers extends AbstractModule public ModuleUsers(StorageObject theStorage) { - if (theLog == null) theLog = Logfile.getInstance(this.getClass().getName()); + if (theLog == null) theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Module.Users.Logfile")); if (theStorage == null) theLog.printWarning("StorageObject was null!"); this.theStorage = theStorage; @@ -67,9 +67,13 @@ public class ModuleUsers extends AbstractModule } } - public SimpleList getUsersAsSimpleList() { + public SimpleList getUsersAsSimpleList() throws ModuleException { // String sql = "select id, name from Users order by name"; - return ((DatabaseUsers)theStorage).getPopupData(); + try { + return ((DatabaseUsers)theStorage).getPopupData(); + } catch(StorageObjectException e) { + throw new ModuleException(e.toString()); + } } } diff --git a/source/mircoders/producer/Producer.java b/source/mircoders/producer/Producer.java index d3e05535..f62dcba2 100755 --- a/source/mircoders/producer/Producer.java +++ b/source/mircoders/producer/Producer.java @@ -18,7 +18,7 @@ abstract public class Producer { protected static String producerStorageRoot = MirConfig.getProp("Producer.StorageRoot"); protected static String producerProductionHost = MirConfig.getProp("Producer.ProductionHost"); protected static String producerOpenAction = MirConfig.getProp("Producer.OpenAction");; - protected static Logfile theLog = Logfile.getInstance("Producer"); + protected static Logfile theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Producer.Logfile")); protected static ModuleTopics topicsModule; protected static ModuleLinksImcs linksImcsModule; protected static ModuleSchwerpunkt schwerpunktModule; @@ -32,7 +32,7 @@ abstract public class Producer { try { contentModule = new ModuleContent(DatabaseContent.getInstance()); topicsModule = new ModuleTopics(DatabaseTopics.getInstance()); - linksImcsModule = new ModuleLinksImcs(DatabaseLinksImcs.getInstance()); + linksImcsModule = new ModuleLinksImcs(DatabaseLinksImcs.getInstance()); schwerpunktModule = new ModuleSchwerpunkt(DatabaseFeature.getInstance()); featureModule = new ModuleFeature(DatabaseFeature.getInstance()); imageModule = new ModuleImages(DatabaseImages.getInstance()); diff --git a/source/mircoders/producer/ProducerContent.java b/source/mircoders/producer/ProducerContent.java index c198f82c..c7cf7bc4 100755 --- a/source/mircoders/producer/ProducerContent.java +++ b/source/mircoders/producer/ProducerContent.java @@ -102,105 +102,106 @@ public class ProducerContent extends Producer { while (batchEntityList != null) { for(int i=0;i0){ - temp = StringUtil.createHTML(temp,imageRoot,mailLinkName,extLinkName,intLinkName); - temp = StringUtil.decodeHTMLinTags(temp); - currentContentValues.put("content_data",temp); - } - temp = (String)currentContentValues.get("description"); - if(temp!=null && temp.length()>0){ - temp = StringUtil.createHTML(temp,imageRoot,mailLinkName,extLinkName,intLinkName); - temp = StringUtil.decodeHTMLinTags(temp); - currentContentValues.put("description",temp); - } - } else { - String temp = (String)currentContentValues.get("content_data"); - if(temp!=null && temp.length()>0){ - temp = StringUtil.decodeHTMLinTags(temp); - currentContentValues.put("content_data",temp); - } - temp = (String)currentContentValues.get("description"); - if(temp!=null && temp.length()>0){ - temp = StringUtil.decodeHTMLinTags(temp); - currentContentValues.put("description",temp); - } - } - - //create the freemarker-model - SimpleHash mergeData = HTMLTemplateProcessor.makeSimpleHash(currentContentValues); - - // get the uploaded media - EntityList currentMediaList = DatabaseContentToMedia.getInstance().getUploadedMedia(currentContent); - if (currentMediaList!=null && currentMediaList.getCount()>=1) { - SimpleList mediaList = new SimpleList(); - for (int n=0; n < currentMediaList.size();n++) { - upMedia = currentMediaList.elementAt(n); - upMediaSimpleHash = HTMLTemplateProcessor.makeSimpleHash(upMedia); - mediaType = ((EntityMedia)upMedia).getMediaType(); - //in case it's a non-existant to_media_type entry.. - if (mediaType != null) { - try { - mediaHandlerName = mediaType.getValue("classname"); - mediaStorageName = mediaType.getValue("tablename"); - mediaStorageClass = Class.forName("mircoders.storage.Database"+mediaStorageName); - mediaHandlerClass = Class.forName("mir.media.MediaHandler"+mediaHandlerName); - mediaHandler = (MirMedia)mediaHandlerClass.newInstance(); - Method m = mediaStorageClass.getMethod("getInstance", null); - mediaStorage = (Database)m.invoke(null, null); - //we most likely need further info - upMedia = mediaStorage.selectById(upMedia.getId()); - } catch (Exception e) { - theLog.printError("ProducerStartpage:problem in reflection: "+mediaHandlerName); - } //end catch - upMediaSimpleHash.put("url", mediaHandler.getURL(upMedia, mediaType)); - upMediaSimpleHash.put("type",mediaType.getValue("classname")); - mediaList.add(upMediaSimpleHash); - } //end if media_type != null - } //end for - mergeData.put("to_media", mediaList); - } //end if currentMediaList != null - - // get the comments for the article - // and html-ize them - SimpleList commentList = currentContent.getComments(); - try{ - if(commentList.isEmpty()==false){ - while(commentList.hasNext()){ - SimpleHash comment = (SimpleHash)commentList.next(); - SimpleScalar commentText = (SimpleScalar)comment.get("description"); - comment.put("description",new SimpleScalar(StringUtil.createHTML(commentText.getAsString(),imageRoot,mailLinkName,extLinkName,intLinkName))); + try { + currentContentValues = currentContent.getValues(); + + //because of postgres 7.1.* not needed anymore + //currentContentValues.put("content_data",currentContent.getContentData()); + String date = (String)currentContentValues.get("date"); + String year = date.substring(0,4); + String month = date.substring(4,6); + + htmlFileName = producerDocRoot + + "/" + year + "/" + month + "/" + currentContentValues.get("id") + ".shtml"; + + currentContentValues.put("content_data",StringUtil.deleteForbiddenTags((String)currentContentValues.get("content_data"))); + currentContentValues.put("description",StringUtil.deleteForbiddenTags((String)currentContentValues.get("description"))); + + + //create http-links and email-links + if (currentContentValues.get("is_html").equals("0")) { + String temp = (String)currentContentValues.get("content_data"); + if(temp!=null && temp.length()>0){ + temp = StringUtil.createHTML(temp,imageRoot,mailLinkName,extLinkName,intLinkName); + temp = StringUtil.decodeHTMLinTags(temp); + currentContentValues.put("content_data",temp); + } + temp = (String)currentContentValues.get("description"); + if(temp!=null && temp.length()>0){ + temp = StringUtil.createHTML(temp,imageRoot,mailLinkName,extLinkName,intLinkName); + temp = StringUtil.decodeHTMLinTags(temp); + currentContentValues.put("description",temp); + } + } else { + String temp = (String)currentContentValues.get("content_data"); + if(temp!=null && temp.length()>0){ + temp = StringUtil.decodeHTMLinTags(temp); + currentContentValues.put("content_data",temp); + } + temp = (String)currentContentValues.get("description"); + if(temp!=null && temp.length()>0){ + temp = StringUtil.decodeHTMLinTags(temp); + currentContentValues.put("description",temp); + } } - } - } catch(Exception e){} - mergeData.put("comments", commentList); - - // get the topics of this article - mergeData.put("topics",HTMLTemplateProcessor.makeSimpleList(DatabaseContentToTopics.getInstance().getTopics(currentContent))); - //produce html - boolean retVal = produce(contentTemplate, htmlFileName, mergeData, htmlout); - sessionConnectTime = new java.util.Date().getTime() - startTime; - if (retVal == true && !"1".equals(currentContent.getValue("is_produced"))) - currentContent.setProduced(true); - }//while + //create the freemarker-model + SimpleHash mergeData = HTMLTemplateProcessor.makeSimpleHash(currentContentValues); + + // get the uploaded media + EntityList currentMediaList = DatabaseContentToMedia.getInstance().getUploadedMedia(currentContent); + if (currentMediaList!=null && currentMediaList.getCount()>=1) { + SimpleList mediaList = new SimpleList(); + for (int n=0; n < currentMediaList.size();n++) { + upMedia = currentMediaList.elementAt(n); + upMediaSimpleHash = HTMLTemplateProcessor.makeSimpleHash(upMedia); + mediaType = ((EntityMedia)upMedia).getMediaType(); + //must be a non-existant to_media_type entry.. + if (mediaType != null) { + mediaHandlerName = mediaType.getValue("classname"); + mediaStorageName = mediaType.getValue("tablename"); + mediaStorageClass = Class.forName("mircoders.storage.Database"+mediaStorageName); + mediaHandlerClass = Class.forName("mir.media.MediaHandler"+mediaHandlerName); + mediaHandler = (MirMedia)mediaHandlerClass.newInstance(); + Method m = mediaStorageClass.getMethod("getInstance", null); + mediaStorage = (Database)m.invoke(null, null); + //we most likely need further info + upMedia = mediaStorage.selectById(upMedia.getId()); + upMediaSimpleHash.put("url", mediaHandler.getURL(upMedia, mediaType)); + upMediaSimpleHash.put("type",mediaType.getValue("classname")); + mediaList.add(upMediaSimpleHash); + } //end if media_type != null + } //end for + mergeData.put("to_media", mediaList); + } //end if currentMediaList != null + + // get the comments for the article + // and html-ize them + SimpleList commentList = currentContent.getComments(); + if(commentList.isEmpty()==false){ + while(commentList.hasNext()){ + SimpleHash comment = (SimpleHash)commentList.next(); + SimpleScalar commentText = (SimpleScalar)comment.get("description"); + comment.put("description",new SimpleScalar(StringUtil.createHTML(commentText.getAsString(),imageRoot,mailLinkName,extLinkName,intLinkName))); + } + } + mergeData.put("comments", commentList); + + // get the topics of this article + mergeData.put("topics",HTMLTemplateProcessor.makeSimpleList(DatabaseContentToTopics.getInstance().getTopics(currentContent))); + + //produce html + boolean retVal = produce(contentTemplate, htmlFileName, mergeData, htmlout); + sessionConnectTime = new java.util.Date().getTime() - startTime; + if (retVal == true && !"1".equals(currentContent.getValue("is_produced"))) + currentContent.setProduced(true); + } catch(Exception e) { + logHTML(htmlout, "Producer.Content ERROR while producing content ID: " + currentContent.getId()+",skipping it :: "+e.toString()); + theLog.printError("Producer.Content ERROR while producing content ID: " + currentContent.getId() +",skipping it :: "+e.toString()); + } + + + }//for if (batchEntityList.hasNextBatch()){ batchEntityList = contentModule.getContent(whereClause, orderBy, batchEntityList.getNextBatch(),contentBatchsize, userEntity); @@ -209,7 +210,7 @@ public class ProducerContent extends Producer { } } - // timing an message to browser + // timing and message to browser sessionConnectTime = new java.util.Date().getTime() - startTime; logHTML(htmlout, "Producer.Content finished: " + sessionConnectTime + " ms."); } diff --git a/source/mircoders/producer/ProducerList.java b/source/mircoders/producer/ProducerList.java index 7989c2b0..55adfcd2 100755 --- a/source/mircoders/producer/ProducerList.java +++ b/source/mircoders/producer/ProducerList.java @@ -96,79 +96,78 @@ abstract public class ProducerList extends Producer { //now produce the pages if (list!=null || force==true) { SimpleHash mergeData = HTMLTemplateProcessor.makeSimpleHashWithEntitylistInfos(list); - //first we try to get the images + //first we try to get the media if(list!=null){ for (int k=0; k < list.size();k++) { currentContent = (EntityContent)list.elementAt(k); - //images to content - EntityList currentMediaList = DatabaseContentToMedia.getInstance().getUploadedMedia(currentContent); - if (currentMediaList!=null && currentMediaList.getCount()>=1) { - SimpleList mediaListAudio = new SimpleList(); - SimpleList mediaListImages = new SimpleList(); - SimpleList mediaListVideo = new SimpleList(); - SimpleList mediaListOther = new SimpleList(); - //SimpleHash allMediaSimpleHash = new SimpleHash(); - for (int n=0; n < currentMediaList.size();n++) { - upMedia = currentMediaList.elementAt(n); - upMediaSimpleHash = HTMLTemplateProcessor.makeSimpleHash(upMedia); - mediaType = ((EntityMedia)upMedia).getMediaType(); - //must be a non-existant to_media_type entry.. - if (mediaType != null) { - try { - mediaHandlerName = mediaType.getValue("classname"); - mediaStorageName = mediaType.getValue("tablename"); - mediaStorageClass = Class.forName("mircoders.storage.Database"+mediaStorageName); - mediaHandlerClass = Class.forName("mir.media.MediaHandler"+mediaHandlerName); - mediaHandler = (MirMedia)mediaHandlerClass.newInstance(); - Method m = mediaStorageClass.getMethod("getInstance", null); - mediaStorage = (Database)m.invoke(null, null); - //we most likely need further info - upMedia = mediaStorage.selectById(upMedia.getId()); - } catch (Exception e) { - theLog.printError("ProducerList: problem in reflection: "+mediaHandlerName); - } //end catch - upMediaSimpleHash.put("url", mediaHandler.getListView(upMedia, mediaType)); - if (upMedia.getValue("is_published") == "1") { - if (mediaHandler.isImage()) { - mediaListImages.add(upMediaSimpleHash); - } else if (mediaHandler.isAudio()) { - mediaListAudio.add(upMediaSimpleHash); - } else if (mediaHandler.isVideo()) { - mediaListVideo.add(upMediaSimpleHash); - } else { - mediaListOther.add(upMediaSimpleHash); - } - } //end if is_published - } //end if media_type != null - } //end for - try{ - SimpleList contentList = (SimpleList)mergeData.get("contentlist"); - SimpleHash contentHash = (SimpleHash)contentList.get(k); - contentHash.put("to_media_audio", mediaListAudio); - contentHash.put("to_media_images", mediaListImages); - contentHash.put("to_media_video", mediaListVideo); - contentHash.put("to_media_other", mediaListOther); - } catch (Exception e){} - } //end if currentMediaList != null - - //content to html - if(currentContent.getValue("is_html").equals("0")){ - String temp = (String)currentContent.getValue("description"); - if(temp!=null && temp.length()>0){ - temp = StringUtil.createHTML(temp); - temp = StringUtil.decodeHTMLinTags(temp); - currentContent.setValueForProperty("description",temp); - } - } else { - String temp = (String)currentContent.getValue("description"); - if(temp!=null && temp.length()>0){ - temp = StringUtil.decodeHTMLinTags(temp); - currentContent.setValueForProperty("description",temp); - } + try { + //media to content + EntityList currentMediaList = DatabaseContentToMedia.getInstance().getUploadedMedia(currentContent); + if (currentMediaList!=null && currentMediaList.getCount()>=1) { + SimpleList mediaListAudio = new SimpleList(); + SimpleList mediaListImages = new SimpleList(); + SimpleList mediaListVideo = new SimpleList(); + SimpleList mediaListOther = new SimpleList(); + //SimpleHash allMediaSimpleHash = new SimpleHash(); + for (int n=0; n < currentMediaList.size();n++) { + upMedia = currentMediaList.elementAt(n); + upMediaSimpleHash = HTMLTemplateProcessor.makeSimpleHash(upMedia); + mediaType = ((EntityMedia)upMedia).getMediaType(); + //must be a non-existant to_media_type entry.. + if (mediaType != null) { + mediaHandlerName = mediaType.getValue("classname"); + mediaStorageName = mediaType.getValue("tablename"); + mediaStorageClass = Class.forName("mircoders.storage.Database"+mediaStorageName); + mediaHandlerClass = Class.forName("mir.media.MediaHandler"+mediaHandlerName); + mediaHandler = (MirMedia)mediaHandlerClass.newInstance(); + Method m = mediaStorageClass.getMethod("getInstance", null); + mediaStorage = (Database)m.invoke(null, null); + //we most likely need further info + upMedia = mediaStorage.selectById(upMedia.getId()); + upMediaSimpleHash.put("url", mediaHandler.getListView(upMedia, mediaType)); + if (upMedia.getValue("is_published") == "1") { + if (mediaHandler.isImage()) { + mediaListImages.add(upMediaSimpleHash); + } else if (mediaHandler.isAudio()) { + mediaListAudio.add(upMediaSimpleHash); + } else if (mediaHandler.isVideo()) { + mediaListVideo.add(upMediaSimpleHash); + } else { + mediaListOther.add(upMediaSimpleHash); + } + } //end if is_published + } //end if media_type != null + } //end for + SimpleList contentList = (SimpleList)mergeData.get("contentlist"); + SimpleHash contentHash = (SimpleHash)contentList.get(k); + contentHash.put("to_media_audio", mediaListAudio); + contentHash.put("to_media_images", mediaListImages); + contentHash.put("to_media_video", mediaListVideo); + contentHash.put("to_media_other", mediaListOther); + } //end if currentMediaList != null + + //content to html + if(currentContent.getValue("is_html").equals("0")){ + String temp = (String)currentContent.getValue("description"); + if(temp!=null && temp.length()>0){ + temp = StringUtil.createHTML(temp); + temp = StringUtil.decodeHTMLinTags(temp); + currentContent.setValueForProperty("description",temp); + } + } else { + String temp = (String)currentContent.getValue("description"); + if(temp!=null && temp.length()>0){ + temp = StringUtil.decodeHTMLinTags(temp); + currentContent.setValueForProperty("description",temp); + } + } + } catch (Exception e) { + logHTML(htmlout, "Producer.List id " +currentContent.getId()+ " seems corrupt, skipping it :: "+e.toString()); + theLog.printError("Producer.List id " +currentContent.getId()+ " seems corrupt, skipping it :: "+e.toString()); } - } - } + } //end for over each article + } //end if list != null SimpleList itemList = HTMLTemplateProcessor.makeSimpleList(list); //process hashmap additional and add to mergedata if (additional != null) { diff --git a/source/mircoders/producer/ProducerStartPage.java b/source/mircoders/producer/ProducerStartPage.java index 22939fba..6092df15 100755 --- a/source/mircoders/producer/ProducerStartPage.java +++ b/source/mircoders/producer/ProducerStartPage.java @@ -77,7 +77,7 @@ public class ProducerStartPage extends Producer { Database mediaStorage=null; String tinyIcon; String iconAlt; - Logfile theLog = Logfile.getInstance(this.getClass().getName()); + Logfile theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Producer.Logfile")); SimpleList mediaList; SimpleHash contentHash; @@ -99,70 +99,60 @@ public class ProducerStartPage extends Producer { SimpleList newsWireList = HTMLTemplateProcessor.makeSimpleList(entityList); for (int i=0; i < entityList.size();i++) { currentContent = (EntityContent)entityList.elementAt(i); - //fetching/setting the images - upMediaEntityList = DatabaseContentToMedia.getInstance().getUploadedMedia(currentContent); - if (upMediaEntityList!=null && upMediaEntityList.getCount()>=1) { - tinyIcon = null; - iconAlt = null; - mediaHandler = null; - mediaHandlerName = null; - for (int n=0; n < upMediaEntityList.size();n++) { - uploadedMedia = (EntityMedia)upMediaEntityList.elementAt(n); - mediaType = uploadedMedia.getMediaType(); + try { + //fetching/setting the images + upMediaEntityList = DatabaseContentToMedia.getInstance().getUploadedMedia(currentContent); + if (upMediaEntityList!=null && upMediaEntityList.getCount()>=1) { + tinyIcon = null; + iconAlt = null; + mediaHandler = null; + mediaHandlerName = null; + for (int n=0; n < upMediaEntityList.size();n++) { + uploadedMedia = (EntityMedia)upMediaEntityList.elementAt(n); + mediaType = uploadedMedia.getMediaType(); - //must of had a non-existant to_media_type entry.. - //let's save our ass. - if (mediaType != null) { - /* - * grrr. why doesn't getId return an int! if It - * did I could just compare the value of getId and - * pick the biggest one. or is there - * another way around this that I am missing? - * can we make getIdasInt() or can we just have - * another getId() that returns an Int and the VM - * will handle it transparantly? -mh - */ - try { - mediaHandlerName = mediaType.getValue("classname"); - mediaHandlerClass = Class.forName("mir.media.MediaHandler"+mediaHandlerName); - mediaHandler = (MirMedia)mediaHandlerClass.newInstance(); - } catch (Exception e) { - theLog.printError("ProducerStartpage:problem in reflection: "+mediaHandlerName); - } + //must of had a non-existant to_media_type entry.. + //let's save our ass. + if (mediaType != null) { + mediaHandlerName = mediaType.getValue("classname"); + mediaHandlerClass = Class.forName("mir.media.MediaHandler"+mediaHandlerName); + mediaHandler = (MirMedia)mediaHandlerClass.newInstance(); - //the "best" media type to show - if (mediaHandler.isVideo()) { - tinyIcon = MirConfig.getProp("Producer.Icon.TinyVideo"); - iconAlt = "Video"; - break; - } else if (mediaHandler.isAudio()) { - tinyIcon = MirConfig.getProp("Producer.Icon.TinyAudio"); - iconAlt = "Audio"; - } else if (tinyIcon == null && !mediaHandler.isImage()) { - tinyIcon = mediaHandler.getTinyIcon(); - iconAlt = mediaHandler.getIconAlt(); + //the "best" media type to show + if (mediaHandler.isVideo()) { + tinyIcon = MirConfig.getProp("Producer.Icon.TinyVideo"); + iconAlt = "Video"; + break; + } else if (mediaHandler.isAudio()) { + tinyIcon = MirConfig.getProp("Producer.Icon.TinyAudio"); + iconAlt = "Audio"; + } else if (tinyIcon == null && !mediaHandler.isImage()) { + tinyIcon = mediaHandler.getTinyIcon(); + iconAlt = mediaHandler.getIconAlt(); + } } + } + //it only has image(s) + if (tinyIcon == null) { + tinyIcon = MirConfig.getProp("Producer.Icon.TinyImage"); + iconAlt = "Image"; + } + + // uploadedMedia Entity list is empty. + // we only have text + } else { + tinyIcon = MirConfig.getProp("Producer.Icon.TinyText"); + iconAlt = "Text"; } - } - //it only has image(s) - if (tinyIcon == null) { - tinyIcon = MirConfig.getProp("Producer.Icon.TinyImage"); - iconAlt = "Image"; - } - // uploadedMedia Entity list is empty. - // we only have text - } else { - tinyIcon = MirConfig.getProp("Producer.Icon.TinyText"); - iconAlt = "Text"; + //mediaList = HTMLTemplateProcessor.makeSimpleList(upMediaEntityList); + contentHash = (SimpleHash)newsWireList.get(i); + contentHash.put("tiny_icon", imageRoot+"/"+tinyIcon); + contentHash.put("icon_alt", iconAlt); + } catch (Exception e) { + logHTML(htmlout, "Producer.StartPage error id: " + currentContent.getId() + ", skipping"); + theLog.printError("Producer.StartPage error id: " + currentContent.getId() + ", skipping"+e.toString()); } - - try{ - //mediaList = HTMLTemplateProcessor.makeSimpleList(upMediaEntityList); - contentHash = (SimpleHash)newsWireList.get(i); - contentHash.put("tiny_icon", imageRoot+"/"+tinyIcon); - contentHash.put("icon_alt", iconAlt); - } catch (Exception e){} } // get the startarticle and the related images @@ -176,54 +166,53 @@ public class ProducerStartPage extends Producer { SimpleList startItemList = HTMLTemplateProcessor.makeSimpleList(entityList); for (int k=0; k < entityList.size();k++) { currentContent = (EntityContent)entityList.elementAt(k); - //media to content - currentMediaList = DatabaseContentToMedia.getInstance().getUploadedMedia(currentContent); - if (currentMediaList!=null && currentMediaList.getCount()>=1) { - SimpleList mediaListAudio = new SimpleList(); - SimpleList mediaListImages = new SimpleList(); - SimpleList mediaListVideo = new SimpleList(); - SimpleList mediaListOther = new SimpleList(); - for (int n=0; n < currentMediaList.size();n++) { - upMedia = currentMediaList.elementAt(n); - upMediaSimpleHash = HTMLTemplateProcessor.makeSimpleHash(upMedia); - mediaType = ((EntityMedia)upMedia).getMediaType(); - //must be a non-existant to_media_type entry.. - if (mediaType != null) { - try { - mediaHandlerName = mediaType.getValue("classname"); - mediaStorageName = mediaType.getValue("tablename"); - mediaStorageClass = Class.forName("mircoders.storage.Database"+mediaStorageName); - mediaHandlerClass = Class.forName("mir.media.MediaHandler"+mediaHandlerName); - mediaHandler = (MirMedia)mediaHandlerClass.newInstance(); - Method m = mediaStorageClass.getMethod("getInstance", null); - mediaStorage = (Database)m.invoke(null, null); - //we most likely need further info - upMedia = mediaStorage.selectById(upMedia.getId()); - } catch (Exception e) { - theLog.printError("ProducerList: problem in reflection: "+mediaHandlerName); - } //end catch - upMediaSimpleHash.put("url", mediaHandler.getListView(upMedia, mediaType)); - if (upMedia.getValue("is_published") == "1") { - if (mediaHandler.isImage()) { - mediaListImages.add(upMediaSimpleHash); - } else if (mediaHandler.isAudio()) { - mediaListAudio.add(upMediaSimpleHash); - } else if (mediaHandler.isVideo()) { - mediaListVideo.add(upMediaSimpleHash); - } else { - mediaListOther.add(upMediaSimpleHash); - } - } //end if is_published - } //end if media_type != null - } //end for - try{ - contentHash = (SimpleHash)startItemList.get(k); - contentHash.put("to_media_audio", mediaListAudio); - contentHash.put("to_media_images", mediaListImages); - contentHash.put("to_media_video", mediaListVideo); - contentHash.put("to_media_other", mediaListOther); - } catch (Exception e){} - } //end if currentMediaList != null + try { + //media to content + currentMediaList = DatabaseContentToMedia.getInstance().getUploadedMedia(currentContent); + if (currentMediaList!=null && currentMediaList.getCount()>=1) { + SimpleList mediaListAudio = new SimpleList(); + SimpleList mediaListImages = new SimpleList(); + SimpleList mediaListVideo = new SimpleList(); + SimpleList mediaListOther = new SimpleList(); + for (int n=0; n < currentMediaList.size();n++) { + upMedia = currentMediaList.elementAt(n); + upMediaSimpleHash = HTMLTemplateProcessor.makeSimpleHash(upMedia); + mediaType = ((EntityMedia)upMedia).getMediaType(); + //must be a non-existant to_media_type entry.. + if (mediaType != null) { + mediaHandlerName = mediaType.getValue("classname"); + mediaStorageName = mediaType.getValue("tablename"); + mediaStorageClass = Class.forName("mircoders.storage.Database"+mediaStorageName); + mediaHandlerClass = Class.forName("mir.media.MediaHandler"+mediaHandlerName); + mediaHandler = (MirMedia)mediaHandlerClass.newInstance(); + Method m = mediaStorageClass.getMethod("getInstance", null); + mediaStorage = (Database)m.invoke(null, null); + //we most likely need further info + upMedia = mediaStorage.selectById(upMedia.getId()); + upMediaSimpleHash.put("url", mediaHandler.getListView(upMedia, mediaType)); + if (upMedia.getValue("is_published") == "1") { + if (mediaHandler.isImage()) { + mediaListImages.add(upMediaSimpleHash); + } else if (mediaHandler.isAudio()) { + mediaListAudio.add(upMediaSimpleHash); + } else if (mediaHandler.isVideo()) { + mediaListVideo.add(upMediaSimpleHash); + } else { + mediaListOther.add(upMediaSimpleHash); + } + } //end if is_published + } //end if media_type != null + } //end for + contentHash = (SimpleHash)startItemList.get(k); + contentHash.put("to_media_audio", mediaListAudio); + contentHash.put("to_media_images", mediaListImages); + contentHash.put("to_media_video", mediaListVideo); + contentHash.put("to_media_other", mediaListOther); + } //end if currentMediaList != null + } catch (Exception e) { + logHTML(htmlout, "Producer.StartPage error id: " + currentContent.getId() + ", skipping"); + theLog.printError("Producer.StartPage error id: " + currentContent.getId() + ", skipping"+e.toString()); + } } //enf for featurueList.size.. // get the breaking news @@ -240,54 +229,53 @@ public class ProducerStartPage extends Producer { SimpleList featureList = HTMLTemplateProcessor.makeSimpleList(entityList); for (int k=0; k < entityList.size();k++) { currentContent = (EntityContent)entityList.elementAt(k); - //media to content - currentMediaList = DatabaseContentToMedia.getInstance().getUploadedMedia(currentContent); - if (currentMediaList!=null && currentMediaList.getCount()>=1) { - SimpleList mediaListAudio = new SimpleList(); - SimpleList mediaListImages = new SimpleList(); - SimpleList mediaListVideo = new SimpleList(); - SimpleList mediaListOther = new SimpleList(); - for (int n=0; n < currentMediaList.size();n++) { - upMedia = currentMediaList.elementAt(n); - upMediaSimpleHash = HTMLTemplateProcessor.makeSimpleHash(upMedia); - mediaType = ((EntityMedia)upMedia).getMediaType(); - //must be a non-existant to_media_type entry.. - if (mediaType != null) { - try { - mediaHandlerName = mediaType.getValue("classname"); - mediaStorageName = mediaType.getValue("tablename"); - mediaStorageClass = Class.forName("mircoders.storage.Database"+mediaStorageName); - mediaHandlerClass = Class.forName("mir.media.MediaHandler"+mediaHandlerName); - mediaHandler = (MirMedia)mediaHandlerClass.newInstance(); - Method m = mediaStorageClass.getMethod("getInstance", null); - mediaStorage = (Database)m.invoke(null, null); - //we most likely need further info - upMedia = mediaStorage.selectById(upMedia.getId()); - } catch (Exception e) { - theLog.printError("ProducerList: problem in reflection: "+mediaHandlerName); - } //end catch - upMediaSimpleHash.put("url", mediaHandler.getListView(upMedia, mediaType)); - if (upMedia.getValue("is_published") == "1") { - if (mediaHandler.isImage()) { - mediaListImages.add(upMediaSimpleHash); - } else if (mediaHandler.isAudio()) { - mediaListAudio.add(upMediaSimpleHash); - } else if (mediaHandler.isVideo()) { - mediaListVideo.add(upMediaSimpleHash); - } else { - mediaListOther.add(upMediaSimpleHash); - } - } //end if is_published - } //end if media_type != null - } //end for - try{ - contentHash = (SimpleHash)featureList.get(k); - contentHash.put("to_media_audio", mediaListAudio); - contentHash.put("to_media_images", mediaListImages); - contentHash.put("to_media_video", mediaListVideo); - contentHash.put("to_media_other", mediaListOther); - } catch (Exception e){} - } //end if currentMediaList != null + try { + //media to content + currentMediaList = DatabaseContentToMedia.getInstance().getUploadedMedia(currentContent); + if (currentMediaList!=null && currentMediaList.getCount()>=1) { + SimpleList mediaListAudio = new SimpleList(); + SimpleList mediaListImages = new SimpleList(); + SimpleList mediaListVideo = new SimpleList(); + SimpleList mediaListOther = new SimpleList(); + for (int n=0; n < currentMediaList.size();n++) { + upMedia = currentMediaList.elementAt(n); + upMediaSimpleHash = HTMLTemplateProcessor.makeSimpleHash(upMedia); + mediaType = ((EntityMedia)upMedia).getMediaType(); + //must be a non-existant to_media_type entry.. + if (mediaType != null) { + mediaHandlerName = mediaType.getValue("classname"); + mediaStorageName = mediaType.getValue("tablename"); + mediaStorageClass = Class.forName("mircoders.storage.Database"+mediaStorageName); + mediaHandlerClass = Class.forName("mir.media.MediaHandler"+mediaHandlerName); + mediaHandler = (MirMedia)mediaHandlerClass.newInstance(); + Method m = mediaStorageClass.getMethod("getInstance", null); + mediaStorage = (Database)m.invoke(null, null); + //we most likely need further info + upMedia = mediaStorage.selectById(upMedia.getId()); + upMediaSimpleHash.put("url", mediaHandler.getListView(upMedia, mediaType)); + if (upMedia.getValue("is_published") == "1") { + if (mediaHandler.isImage()) { + mediaListImages.add(upMediaSimpleHash); + } else if (mediaHandler.isAudio()) { + mediaListAudio.add(upMediaSimpleHash); + } else if (mediaHandler.isVideo()) { + mediaListVideo.add(upMediaSimpleHash); + } else { + mediaListOther.add(upMediaSimpleHash); + } + } //end if is_published + } //end if media_type != null + } //end for + contentHash = (SimpleHash)featureList.get(k); + contentHash.put("to_media_audio", mediaListAudio); + contentHash.put("to_media_images", mediaListImages); + contentHash.put("to_media_video", mediaListVideo); + contentHash.put("to_media_other", mediaListOther); + } //end if currentMediaList != null + } catch (Exception e) { + logHTML(htmlout, "Producer.StartPage error id: " + currentContent.getId() + ", skipping"); + theLog.printError("Producer.StartPage error id: " + currentContent.getId() + ", skipping"+e.toString()); + } } //enf for featurueList.size.. // Zusaetzlich Informationen diff --git a/source/mircoders/producer/ProducerTopics.java b/source/mircoders/producer/ProducerTopics.java index 6b3d4183..0c5aa379 100755 --- a/source/mircoders/producer/ProducerTopics.java +++ b/source/mircoders/producer/ProducerTopics.java @@ -101,55 +101,53 @@ public class ProducerTopics extends ProducerList { EntityContent currentContent; if(entityList != null && entityList.size()==1){ currentContent = (EntityContent)entityList.elementAt(0); - SimpleHash specialHash = HTMLTemplateProcessor.makeSimpleHash(currentContent); - - currentMediaList = DatabaseContentToMedia.getInstance().getUploadedMedia(currentContent); - if (currentMediaList!=null && currentMediaList.getCount()>=1) { - SimpleList mediaListAudio = new SimpleList(); - SimpleList mediaListImages = new SimpleList(); - SimpleList mediaListVideo = new SimpleList(); - SimpleList mediaListOther = new SimpleList(); - for (int n=0; n < currentMediaList.size();n++) { - upMedia = currentMediaList.elementAt(n); - upMediaSimpleHash = HTMLTemplateProcessor.makeSimpleHash(upMedia); - mediaType = ((EntityMedia)upMedia).getMediaType(); - //must be a non-existant to_media_type entry.. - if (mediaType != null) { - try { - mediaHandlerName = mediaType.getValue("classname"); - mediaStorageName = mediaType.getValue("tablename"); - mediaStorageClass = Class.forName("mircoders.storage.Database"+mediaStorageName); - mediaHandlerClass = Class.forName("mir.media.MediaHandler"+mediaHandlerName); - mediaHandler = (MirMedia)mediaHandlerClass.newInstance(); - Method m = mediaStorageClass.getMethod("getInstance", null); - mediaStorage = (Database)m.invoke(null, null); - //we most likely need further info - upMedia = mediaStorage.selectById(upMedia.getId()); - } catch (Exception e) { - theLog.printError("ProducerList: problem in reflection: "+mediaHandlerName); - } //end catch - upMediaSimpleHash.put("url", mediaHandler.getListView(upMedia, mediaType)); - if (upMedia.getValue("is_published") == "1") { - if (mediaHandler.isImage()) { - mediaListImages.add(upMediaSimpleHash); - } else if (mediaHandler.isAudio()) { - mediaListAudio.add(upMediaSimpleHash); - } else if (mediaHandler.isVideo()) { - mediaListVideo.add(upMediaSimpleHash); - } else { - mediaListOther.add(upMediaSimpleHash); - } - } //end if is_published - } //end if media_type != null - } //end for - try{ - specialHash.put("to_media_audio", mediaListAudio); - specialHash.put("to_media_images", mediaListImages); - specialHash.put("to_media_video", mediaListVideo); - specialHash.put("to_media_other", mediaListOther); - } catch (Exception e){} - } //end if currentMediaList != null - setAdditional("special",specialHash); + try { + SimpleHash specialHash = HTMLTemplateProcessor.makeSimpleHash(currentContent); + + currentMediaList = DatabaseContentToMedia.getInstance().getUploadedMedia(currentContent); + if (currentMediaList!=null && currentMediaList.getCount()>=1) { + SimpleList mediaListAudio = new SimpleList(); + SimpleList mediaListImages = new SimpleList(); + SimpleList mediaListVideo = new SimpleList(); + SimpleList mediaListOther = new SimpleList(); + for (int n=0; n < currentMediaList.size();n++) { + upMedia = currentMediaList.elementAt(n); + upMediaSimpleHash = HTMLTemplateProcessor.makeSimpleHash(upMedia); + mediaType = ((EntityMedia)upMedia).getMediaType(); + //must be a non-existant to_media_type entry.. + if (mediaType != null) { + mediaHandlerName = mediaType.getValue("classname"); + mediaStorageName = mediaType.getValue("tablename"); + mediaStorageClass = Class.forName("mircoders.storage.Database"+mediaStorageName); + mediaHandlerClass = Class.forName("mir.media.MediaHandler"+mediaHandlerName); + mediaHandler = (MirMedia)mediaHandlerClass.newInstance(); + Method m = mediaStorageClass.getMethod("getInstance", null); + mediaStorage = (Database)m.invoke(null, null); + //we most likely need further info + upMedia = mediaStorage.selectById(upMedia.getId()); + upMediaSimpleHash.put("url", mediaHandler.getListView(upMedia, mediaType)); + if (upMedia.getValue("is_published") == "1") { + if (mediaHandler.isImage()) { + mediaListImages.add(upMediaSimpleHash); + } else if (mediaHandler.isAudio()) { + mediaListAudio.add(upMediaSimpleHash); + } else if (mediaHandler.isVideo()) { + mediaListVideo.add(upMediaSimpleHash); + } else { + mediaListOther.add(upMediaSimpleHash); + } + } //end if is_published + } //end if media_type != null + } //end for + specialHash.put("to_media_audio", mediaListAudio); + specialHash.put("to_media_images", mediaListImages); + specialHash.put("to_media_video", mediaListVideo); + specialHash.put("to_media_other", mediaListOther); + } //end if currentMediaList != null + setAdditional("special",specialHash); + } catch (Exception e) { + theLog.printError("ProducerTopics: problem with start special: "+currentContent.getId()+" "+e.toString()); + } } //set the list of topics diff --git a/source/mircoders/servlet/ServletModuleContent.java b/source/mircoders/servlet/ServletModuleContent.java index e26ef652..eef12afa 100755 --- a/source/mircoders/servlet/ServletModuleContent.java +++ b/source/mircoders/servlet/ServletModuleContent.java @@ -45,7 +45,7 @@ public class ServletModuleContent extends ServletModule private ServletModuleContent() { try { - theLog = Logfile.getInstance(this.getClass().getName()); + theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("ServletModule.Content.Logfile")); templateListString = MirConfig.getProp("ServletModule.Content.ListTemplate"); templateOpString = MirConfig.getProp("ServletModule.Content.OpTemplate"); templateObjektString = MirConfig.getProp("ServletModule.Content.ObjektTemplate"); @@ -146,18 +146,27 @@ public class ServletModuleContent extends ServletModule mergeData.put("is_published", "1"); String now = StringUtil.date2webdbDate(new GregorianCalendar()); mergeData.put("date", new SimpleScalar(now)); - mergeData.put("themenPopupData", themenModule.getTopicsAsSimpleList()); + try { + mergeData.put("themenPopupData", themenModule.getTopicsAsSimpleList()); + } catch (ModuleException e) { + theLog.printError("cannot get topics as simple list."); + throw new ServletModuleException(e.toString()); + } try { mergeData.put("articletypePopupData", DatabaseArticleType.getInstance().getPopupData()); } catch (Exception e) { theLog.printError("articletype could not be fetched."); + throw new ServletModuleException("articletype could not be fetched: " + +e.toString()); } try { mergeData.put("languagePopupData", DatabaseLanguage.getInstance().getPopupData()); + mergeData.put("schwerpunktPopupData", schwerpunktModule.getSchwerpunktAsSimpleList()); } catch (Exception e) { - theLog.printError("language-popup could not be fetched."); + theLog.printError("language-popup or scwerpunk list could not be fetched."); + throw new ServletModuleException("language/schwerpunkt list could not be fetched.: " + +e.toString()); } - mergeData.put("schwerpunktPopupData", schwerpunktModule.getSchwerpunktAsSimpleList()); mergeData.put("login_user", HTMLTemplateProcessor.makeSimpleHash(user)); deliver(req, res, mergeData, templateObjektString); } @@ -256,7 +265,7 @@ public class ServletModuleContent extends ServletModule EntityContent entContent = (EntityContent)mainModule.getById(idParam); entContent.attach(mediaIdParam); } - catch(ModuleException e) { + catch(Exception e) { theLog.printError("smod content :: attach :: could not get entityContent"); } _showObject(idParam, req, res); @@ -273,7 +282,7 @@ public class ServletModuleContent extends ServletModule EntityContent entContent = (EntityContent)mainModule.getById(cidParam); entContent.dettach(cidParam,midParam); } - catch(ModuleException e) { + catch(Exception e) { theLog.printError("smod content :: dettach :: could not get entityContent"); } _showObject(cidParam, req, res); diff --git a/source/mircoders/servlet/ServletModuleImages.java b/source/mircoders/servlet/ServletModuleImages.java index dbea216a..970d777a 100755 --- a/source/mircoders/servlet/ServletModuleImages.java +++ b/source/mircoders/servlet/ServletModuleImages.java @@ -368,6 +368,7 @@ public class ServletModuleImages extends mir.servlet.ServletModule } catch (IOException e) { throw new ServletModuleException("upload -- ioexception " + e.toString());} catch (ModuleException e) { throw new ServletModuleException("upload -- moduleexception " + e.toString());} + catch (StorageObjectException e) { throw new ServletModuleException("upload -- storageobjectexception " + e.toString());} } else // keine id throw new ServletModuleException("Keine id angegeben"); diff --git a/source/mircoders/servlet/ServletModuleOpenIndy.java b/source/mircoders/servlet/ServletModuleOpenIndy.java index 9c6d5014..fe76052a 100755 --- a/source/mircoders/servlet/ServletModuleOpenIndy.java +++ b/source/mircoders/servlet/ServletModuleOpenIndy.java @@ -158,14 +158,15 @@ public class ServletModuleOpenIndy extends ServletModule } mergeData.put("medianum",numOfMedia); mergeData.put("mediafields",mediaFields); - mergeData.put("themenPopupData", themenModule.getTopicsAsSimpleList()); /** @todo popups missing */ try{ mergeData.put("languagePopUpData",DatabaseLanguage.getInstance().getPopupData()); + mergeData.put("themenPopupData", themenModule.getTopicsAsSimpleList()); } catch (Exception e) { - theLog.printError("languagePopUpData failed"); + theLog.printError("languagePopUpData or getTopicslist failed"); + throw new ServletModuleException("smod -- openindy -- getting language or topics failed: "+e.toString()); } deliver(req, res, mergeData, postingFormTemplate); } @@ -242,6 +243,8 @@ public class ServletModuleOpenIndy extends ServletModule theLog.printError("setting content_x_topic success"); } catch (Exception e) { theLog.printError("setting content_x_topic failed"); + contentModule.deleteById(cid); + throw new ServletModuleException("smod - openindy :: insposting: setting content_x_topic failed: "+e.toString()); } //end try } //end if @@ -329,42 +332,38 @@ public class ServletModuleOpenIndy extends ServletModule String MediaId; Entity mediaEnt = null; try { - Class mediaStorageClass = Class.forName("mircoders.storage.Database"+mediaStorageName); - Method m = mediaStorageClass.getMethod("getInstance", null); - Database mediaStorage = (Database)m.invoke(null, null); - mediaEnt = (Entity)mediaStorage.getEntityClass().newInstance(); - mediaEnt.setStorage(mediaStorage); - mediaEnt.setValues(mediaValues); - mediaId = mediaEnt.insert(); - - Class mediaHandlerClass = Class.forName("mir.media.MediaHandler"+mediaHandlerName); - MirMedia mediaHandler = (MirMedia)mediaHandlerClass.newInstance(); - //save and store the media data/metadata - mediaHandler.set(mpReq.getMedia(), mediaEnt,mediaTypesList.elementAt(0)); - - //were done with mpReq at this point, dereference it. - //as it contains mucho mem. -mh 01.10.2001 - mpReq=null; - - } catch (Exception e) { - theLog.printError("setting uploaded_media failed: "+e.toString()); - } //end try-catch + Class mediaStorageClass = Class.forName("mircoders.storage.Database"+mediaStorageName); + Method m = mediaStorageClass.getMethod("getInstance", null); + Database mediaStorage = (Database)m.invoke(null, null); + mediaEnt = (Entity)mediaStorage.getEntityClass().newInstance(); + mediaEnt.setStorage(mediaStorage); + mediaEnt.setValues(mediaValues); + mediaId = mediaEnt.insert(); + + Class mediaHandlerClass = Class.forName("mir.media.MediaHandler"+mediaHandlerName); + MirMedia mediaHandler = (MirMedia)mediaHandlerClass.newInstance(); + //save and store the media data/metadata + mediaHandler.set(mpReq.getMedia(), mediaEnt,mediaTypesList.elementAt(0)); + + //were done with mpReq at this point, dereference it. + //as it contains mucho mem. -mh 01.10.2001 + mpReq=null; - //we got this far, associate the media to the article - try{ - theLog.printError("ID"+mediaId); - DatabaseContentToMedia.getInstance().addMedia(cid,mediaId); - mediaEnt.setValueForProperty("is_published","1"); - mediaEnt.update(); - new ProducerMedia().handle(null,null,false,false,mediaId); - theLog.printError("setting content_x_media success"); + //we got this far, associate the media to the article + theLog.printError("ID"+mediaId); + mediaEnt.setValueForProperty("is_published","1"); + mediaEnt.update(); + new ProducerMedia().handle(null,null,false,false,mediaId); + DatabaseContentToMedia.getInstance().addMedia(cid,mediaId); } catch (Exception e) { - theLog.printError("setting content_x_media failed"); + theLog.printError("setting media failed: "+e.toString()); + contentModule.deleteById(cid); + throw new ServletModuleException("setting media failed: "+e.toString()); } } else { contentModule.deleteById(cid); - theLog.printDebugInfo("Wrong file uploaded!: " + fileName); + theLog.printDebugInfo("Wrong file type uploaded!: " + fileName); throw new ServletModuleUserException("One or more files of unrecognized types"); } // end if-else mediaTypesList.size() > 0 diff --git a/source/mircoders/storage/DatabaseArticleType.java b/source/mircoders/storage/DatabaseArticleType.java index 4320b331..ffd0ec28 100755 --- a/source/mircoders/storage/DatabaseArticleType.java +++ b/source/mircoders/storage/DatabaseArticleType.java @@ -42,7 +42,8 @@ public class DatabaseArticleType extends Database implements StorageObject{ this.theTable="article_type"; } - public SimpleList getPopupData() { return getPopupData("name",false); } + public SimpleList getPopupData() + throws StorageObjectException { return getPopupData("name",false); } } diff --git a/source/mircoders/storage/DatabaseComment.java b/source/mircoders/storage/DatabaseComment.java index 25ada19e..869defae 100755 --- a/source/mircoders/storage/DatabaseComment.java +++ b/source/mircoders/storage/DatabaseComment.java @@ -42,7 +42,8 @@ public class DatabaseComment extends Database implements StorageObject{ catch (Exception e) { throw new StorageObjectException(e.toString()); } } - public SimpleList getPopupData() { return getPopupData("title",true); } + public SimpleList getPopupData() + throws StorageObjectException { return getPopupData("title",true); } public boolean deleteByContentId(String id) throws StorageObjectException { diff --git a/source/mircoders/storage/DatabaseContent.java b/source/mircoders/storage/DatabaseContent.java index 72286ff9..5a76432c 100755 --- a/source/mircoders/storage/DatabaseContent.java +++ b/source/mircoders/storage/DatabaseContent.java @@ -55,7 +55,7 @@ public class DatabaseContent extends Database implements StorageObject { * sets the database flag is_produced to unproduced */ - public void setUnproduced(String where) + public void setUnproduced(String where) throws StorageObjectException { Connection con=null;Statement stmt=null; String sql = "update content set is_produced='0' where " + where; diff --git a/source/mircoders/storage/DatabaseContentToMedia.java b/source/mircoders/storage/DatabaseContentToMedia.java index 8466e9e4..1cf37083 100755 --- a/source/mircoders/storage/DatabaseContentToMedia.java +++ b/source/mircoders/storage/DatabaseContentToMedia.java @@ -105,7 +105,8 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ } - public void setMedia(String contentId, String[] mediaId) { + public void setMedia(String contentId, String[] mediaId) + throws StorageObjectException { if (contentId == null){ return; } @@ -145,7 +146,8 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ } } - public void addMedia(String contentId, String mediaId) { + public void addMedia(String contentId, String mediaId) + throws StorageObjectException { if (contentId == null && mediaId == null) { return; } @@ -167,7 +169,8 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ } } - public void setMedia(String contentId, String mediaId) { + public void setMedia(String contentId, String mediaId) + throws StorageObjectException { if (contentId == null && mediaId == null) { return; } @@ -203,7 +206,8 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ } } - public void deleteByContentId(String contentId) { + public void deleteByContentId(String contentId) + throws StorageObjectException { if (contentId == null) { //theLog.printDebugInfo("-- delete topics failed -- no content id"); return; @@ -224,7 +228,8 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ } } - public void deleteByMediaId(String mediaId) { + public void deleteByMediaId(String mediaId) + throws StorageObjectException { if (mediaId == null) { //theLog.printDebugInfo("-- delete topics failed -- no topic id"); return; @@ -246,7 +251,8 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ } } - public void delete(String contentId, String mediaId) { + public void delete(String contentId, String mediaId) + throws StorageObjectException { if (mediaId == null || contentId==null) { theLog.printDebugInfo("-- delete media failed -- missing parameter"); return; @@ -269,7 +275,8 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ } - public EntityList getContent(EntityMedia media) { + public EntityList getContent(EntityMedia media) + throws StorageObjectException { EntityList returnList=null; if (media != null) { String id = media.getId(); @@ -305,7 +312,8 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ * Returns a EntityList with all content-objects having a relation to a media */ -public EntityList getContent() { +public EntityList getContent() + throws StorageObjectException { EntityList returnList=null; String select = "select distinct content_id from " + theTable; diff --git a/source/mircoders/storage/DatabaseContentToTopics.java b/source/mircoders/storage/DatabaseContentToTopics.java index d00fa861..944eff4e 100755 --- a/source/mircoders/storage/DatabaseContentToTopics.java +++ b/source/mircoders/storage/DatabaseContentToTopics.java @@ -65,7 +65,8 @@ public class DatabaseContentToTopics extends Database implements StorageObject{ * Returns a ArrayList of Integer-Objects from a content-id. * @returns ArrayList */ - public ArrayList getTopicsOfContent(String contentId) { + public ArrayList getTopicsOfContent(String contentId) + throws StorageObjectException { ArrayList returnList = new ArrayList(); if (contentId != null) { String sql = "select topic_id from " + theTable + " where content_id=" + contentId; @@ -93,7 +94,8 @@ public class DatabaseContentToTopics extends Database implements StorageObject{ /** * Set new topics */ - public void setTopics(String contentId, String[] topicId) { + public void setTopics(String contentId, String[] topicId) + throws StorageObjectException { if (contentId == null){ return; } @@ -188,7 +190,8 @@ public class DatabaseContentToTopics extends Database implements StorageObject{ } } - public void deleteByContentId(String contentId) { + public void deleteByContentId(String contentId) + throws StorageObjectException { if (contentId == null) { //theLog.printDebugInfo("-- delete topics failed -- no content id"); return; @@ -209,7 +212,8 @@ public class DatabaseContentToTopics extends Database implements StorageObject{ } } - public void deleteByTopicId(String topicId) { + public void deleteByTopicId(String topicId) + throws StorageObjectException { if (topicId == null) { //theLog.printDebugInfo("-- delete topics failed -- no topic id"); return; @@ -231,7 +235,8 @@ public class DatabaseContentToTopics extends Database implements StorageObject{ } - public EntityList getContent(EntityTopics topic) { + public EntityList getContent(EntityTopics topic) + throws StorageObjectException { EntityList returnList=null; if (topic != null) { String id = topic.getId(); diff --git a/source/mircoders/storage/DatabaseFeature.java b/source/mircoders/storage/DatabaseFeature.java index 43293ebf..2ae9d15a 100755 --- a/source/mircoders/storage/DatabaseFeature.java +++ b/source/mircoders/storage/DatabaseFeature.java @@ -44,7 +44,7 @@ public class DatabaseFeature extends Database implements StorageObject{ } } - public SimpleList getPopupData() { + public SimpleList getPopupData() throws StorageObjectException { return getPopupData("title",true); } diff --git a/source/mircoders/storage/DatabaseImageColor.java b/source/mircoders/storage/DatabaseImageColor.java index 1cfb63d6..ab798f1c 100755 --- a/source/mircoders/storage/DatabaseImageColor.java +++ b/source/mircoders/storage/DatabaseImageColor.java @@ -38,7 +38,8 @@ public class DatabaseImageColor extends Database implements StorageObject{ this.theTable="img_color"; } - public SimpleList getPopupData() { return getPopupData("name",true); } + public SimpleList getPopupData() + throws StorageObjectException { return getPopupData("name",true); } } diff --git a/source/mircoders/storage/DatabaseImageFormat.java b/source/mircoders/storage/DatabaseImageFormat.java index 606d1c7c..80eda36a 100755 --- a/source/mircoders/storage/DatabaseImageFormat.java +++ b/source/mircoders/storage/DatabaseImageFormat.java @@ -38,7 +38,8 @@ public class DatabaseImageFormat extends Database implements StorageObject{ this.theTable="img_format"; } - public SimpleList getPopupData() { return getPopupData("name",true); } + public SimpleList getPopupData() + throws StorageObjectException { return getPopupData("name",true); } } diff --git a/source/mircoders/storage/DatabaseImageLayout.java b/source/mircoders/storage/DatabaseImageLayout.java index a4b5fb4d..d67596cf 100755 --- a/source/mircoders/storage/DatabaseImageLayout.java +++ b/source/mircoders/storage/DatabaseImageLayout.java @@ -38,7 +38,8 @@ public class DatabaseImageLayout extends Database implements StorageObject{ this.theTable="img_layout"; } - public SimpleList getPopupData() { return getPopupData("name",true); } + public SimpleList getPopupData() + throws StorageObjectException { return getPopupData("name",true); } } diff --git a/source/mircoders/storage/DatabaseImageType.java b/source/mircoders/storage/DatabaseImageType.java index 4cd78d4a..2de500d7 100755 --- a/source/mircoders/storage/DatabaseImageType.java +++ b/source/mircoders/storage/DatabaseImageType.java @@ -38,7 +38,8 @@ public class DatabaseImageType extends Database implements StorageObject{ this.theTable="img_type"; } - public SimpleList getPopupData() { return getPopupData("name",true); } + public SimpleList getPopupData() + throws StorageObjectException { return getPopupData("name",true); } } diff --git a/source/mircoders/storage/DatabaseImages.java b/source/mircoders/storage/DatabaseImages.java index f181f3de..ede4e156 100755 --- a/source/mircoders/storage/DatabaseImages.java +++ b/source/mircoders/storage/DatabaseImages.java @@ -43,7 +43,7 @@ public class DatabaseImages extends Database implements StorageObject{ catch (Exception e) { throw new StorageObjectException(e.toString()); } } - public SimpleList getPopupData() { + public SimpleList getPopupData() throws StorageObjectException { return getPopupData("title",true); } diff --git a/source/mircoders/storage/DatabaseLanguage.java b/source/mircoders/storage/DatabaseLanguage.java index 0f96648c..6db1af06 100755 --- a/source/mircoders/storage/DatabaseLanguage.java +++ b/source/mircoders/storage/DatabaseLanguage.java @@ -42,7 +42,7 @@ public class DatabaseLanguage extends Database implements StorageObject{ this.theTable="language"; } - public SimpleList getPopupData() { return getPopupData("name",false); } + public SimpleList getPopupData() throws StorageObjectException { return getPopupData("name",false); } } diff --git a/source/mircoders/storage/DatabaseLinksImcs.java b/source/mircoders/storage/DatabaseLinksImcs.java index 63f6c687..06c75e6a 100755 --- a/source/mircoders/storage/DatabaseLinksImcs.java +++ b/source/mircoders/storage/DatabaseLinksImcs.java @@ -206,7 +206,7 @@ public class DatabaseLinksImcs extends Database return getHashData(); } - public SimpleList getPopupData () { + public SimpleList getPopupData () throws StorageObjectException { return getPopupData(); } } diff --git a/source/mircoders/storage/DatabaseMedia.java b/source/mircoders/storage/DatabaseMedia.java index 3094f764..c16f9471 100755 --- a/source/mircoders/storage/DatabaseMedia.java +++ b/source/mircoders/storage/DatabaseMedia.java @@ -52,13 +52,14 @@ public class DatabaseMedia extends Database implements StorageObject{ * returns the comments that belong to the article (via entityrelation) * where db-flag is_published is true */ - public Entity getMediaType(Entity ent) { + public Entity getMediaType(Entity ent) throws StorageObjectException { Entity type=null; try { type = relationMediaType.getOne(ent); } catch (StorageObjectException e) { theLog.printError("DatabaseUploadedMedia :: failed to get media_type"); + throw new StorageObjectException("DatabaseUploadedMedia :"+e.toString()); } return type; } diff --git a/source/mircoders/storage/DatabaseMediafolder.java b/source/mircoders/storage/DatabaseMediafolder.java index e2f81c62..2cf9bff9 100755 --- a/source/mircoders/storage/DatabaseMediafolder.java +++ b/source/mircoders/storage/DatabaseMediafolder.java @@ -42,7 +42,7 @@ public class DatabaseMediafolder extends Database implements StorageObject{ this.theTable="media_folder"; } - public SimpleList getPopupData() { + public SimpleList getPopupData() throws StorageObjectException { return getPopupData("name",true); } diff --git a/source/mircoders/storage/DatabaseRights.java b/source/mircoders/storage/DatabaseRights.java index fbdf0107..71255ccc 100755 --- a/source/mircoders/storage/DatabaseRights.java +++ b/source/mircoders/storage/DatabaseRights.java @@ -38,7 +38,8 @@ public class DatabaseRights extends Database implements StorageObject{ this.theTable="rights"; } - public SimpleList getPopupData() { return getPopupData("name",true); } + public SimpleList getPopupData() throws StorageObjectException + { return getPopupData("name",true); } } diff --git a/source/mircoders/storage/DatabaseTopics.java b/source/mircoders/storage/DatabaseTopics.java index 5804b88c..481b8442 100755 --- a/source/mircoders/storage/DatabaseTopics.java +++ b/source/mircoders/storage/DatabaseTopics.java @@ -44,7 +44,7 @@ public class DatabaseTopics extends Database implements StorageObject{ } - public SimpleList getPopupData() { + public SimpleList getPopupData() throws StorageObjectException { return getPopupData("title",true); } diff --git a/source/mircoders/storage/DatabaseUsers.java b/source/mircoders/storage/DatabaseUsers.java index dd03a1b1..8f8c211e 100755 --- a/source/mircoders/storage/DatabaseUsers.java +++ b/source/mircoders/storage/DatabaseUsers.java @@ -42,7 +42,7 @@ public class DatabaseUsers extends Database implements StorageObject{ } } - public SimpleList getPopupData() { + public SimpleList getPopupData() throws StorageObjectException { return getPopupData("login",true); } } diff --git a/source/mircoders/storage/DatabaseVideos.java b/source/mircoders/storage/DatabaseVideos.java index 5c71b3ed..a53c2c2f 100755 --- a/source/mircoders/storage/DatabaseVideos.java +++ b/source/mircoders/storage/DatabaseVideos.java @@ -43,7 +43,7 @@ public class DatabaseVideos extends Database implements StorageObject{ catch (Exception e) { throw new StorageObjectException(e.toString()); } } - public SimpleList getPopupData() { + public SimpleList getPopupData() throws StorageObjectException { return getPopupData("title",true); }