From 1bb7abb8f82c9bc0287fb3e226a0ea5d805db2df Mon Sep 17 00:00:00 2001 From: zapata Date: Sun, 9 Mar 2003 03:53:10 +0000 Subject: [PATCH] exception + misc. cleanup --- source/Mir.java | 9 +- source/OpenMir.java | 6 +- source/default.properties | 8 - .../MediaExc.java} | 24 +- .../{MirMediaException.java => MediaFailure.java} | 19 +- source/mir/media/MediaHelper.java | 24 +- source/mir/media/MirMedia.java | 56 +- source/mir/media/MirMediaUserException.java | 57 -- source/mir/misc/FileHandler.java | 133 +++-- source/mir/misc/FileHandlerUserException.java | 83 --- source/mir/misc/WebdbMultipartRequest.java | 22 +- source/mir/module/AbstractModule.java | 466 +++++++-------- .../{ModuleException.java => ModuleExc.java} | 20 +- ...ModuleUserException.java => ModuleFailure.java} | 23 +- source/mir/producer/ProducerFailure.java | 2 +- source/mircoders/entity/EntityUploadedMedia.java | 6 +- .../basic/MirBasicDataModelLocalizer.java | 1 - source/mircoders/media/MediaHandlerGeneric.java | 38 +- source/mircoders/media/MediaHandlerImages.java | 77 ++- .../mircoders/media/MediaHandlerImagesExtern.java | 15 +- source/mircoders/media/MediaHandlerMp3.java | 10 +- source/mircoders/media/MediaHandlerRealAudio.java | 10 +- source/mircoders/media/MediaHandlerRealVideo.java | 25 +- source/mircoders/media/MediaRequest.java | 586 ++++++++++--------- .../mircoders/media/UnsupportedMediaFormatExc.java | 9 + source/mircoders/module/ModuleComment.java | 39 +- source/mircoders/module/ModuleContent.java | 60 +- source/mircoders/module/ModuleFeature.java | 66 --- source/mircoders/module/ModuleImages.java | 15 +- source/mircoders/module/ModuleMediafolder.java | 18 +- source/mircoders/module/ModuleSchwerpunkt.java | 67 --- source/mircoders/module/ModuleTopics.java | 32 +- source/mircoders/module/ModuleUsers.java | 31 +- source/mircoders/servlet/ServletModuleContent.java | 14 +- .../mircoders/servlet/ServletModuleOpenIndy.java | 96 ++-- .../servlet/ServletModuleSchwerpunkt.java | 67 --- .../servlet/ServletModuleUploadedMedia.java | 38 +- source/mircoders/storage/DatabaseComment.java | 23 +- source/mircoders/storage/DatabaseContent.java | 15 +- .../mircoders/storage/DatabaseContentToMedia.java | 20 +- .../mircoders/storage/DatabaseContentToTopics.java | 638 ++++++++++----------- source/mircoders/storage/DatabaseFeature.java | 76 --- .../mircoders/storage/DatabaseUploadedMedia.java | 185 +++--- templates/admin/feature.template | 65 --- templates/admin/featurelist.template | 70 --- 45 files changed, 1380 insertions(+), 1984 deletions(-) rename source/mir/{misc/FileHandlerException.java => media/MediaExc.java} (81%) rename source/mir/media/{MirMediaException.java => MediaFailure.java} (86%) delete mode 100755 source/mir/media/MirMediaUserException.java delete mode 100755 source/mir/misc/FileHandlerUserException.java rename source/mir/module/{ModuleException.java => ModuleExc.java} (87%) rename source/mir/module/{ModuleUserException.java => ModuleFailure.java} (86%) create mode 100755 source/mircoders/media/UnsupportedMediaFormatExc.java delete mode 100755 source/mircoders/module/ModuleFeature.java delete mode 100755 source/mircoders/module/ModuleSchwerpunkt.java delete mode 100755 source/mircoders/servlet/ServletModuleSchwerpunkt.java delete mode 100755 source/mircoders/storage/DatabaseFeature.java delete mode 100755 templates/admin/feature.template delete mode 100755 templates/admin/featurelist.template diff --git a/source/Mir.java b/source/Mir.java index 48c57975..61ba5161 100755 --- a/source/Mir.java +++ b/source/Mir.java @@ -78,8 +78,8 @@ import freemarker.template.TemplateModel; /** * Mir.java - main servlet, that dispatches to servletmodules * - * @author $Author: idfx $ - * @version $Id: Mir.java,v 1.35 2003/03/08 17:18:19 idfx Exp $ + * @author $Author: zapata $ + * @version $Id: Mir.java,v 1.36 2003/03/09 03:53:10 zapata Exp $ * */ public class Mir extends AbstractServlet { @@ -405,9 +405,10 @@ public class Mir extends AbstractServlet { } return usersModule.getUserForLogin(user, password); - } catch (Exception e) { + } + catch (Exception e) { logger.debug(e.getMessage()); - e.printStackTrace(); + e.printStackTrace(logger.asPrintWriter(logger.DEBUG_MESSAGE)); return null; } diff --git a/source/OpenMir.java b/source/OpenMir.java index 7b54da24..c3c6108e 100755 --- a/source/OpenMir.java +++ b/source/OpenMir.java @@ -54,7 +54,7 @@ import freemarker.template.SimpleScalar; * OpenMir.java - main servlet for open posting and comment feature to articles * * @author RK 1999-2001, the mir-coders group - * @version $Id: OpenMir.java,v 1.24 2003/03/08 17:18:19 idfx Exp $ + * @version $Id: OpenMir.java,v 1.25 2003/03/09 03:53:10 zapata Exp $ * */ @@ -115,7 +115,7 @@ public class OpenMir extends AbstractServlet { SimpleHash modelRoot = new SimpleHash(); modelRoot.put("errorstring", new SimpleScalar(anException.getMessage())); modelRoot.put("date", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar()))); - HTMLTemplateProcessor.process(aResponse,MirPropertiesConfiguration.instance().getString("Mir.OpenIndy.UserErrorTemplate"), + HTMLTemplateProcessor.process(aResponse,MirPropertiesConfiguration.instance().getString("ServletModule.OpenIndy.UserErrorTemplate"), modelRoot, out, aRequest.getLocale() ); out.close(); } @@ -131,7 +131,7 @@ public class OpenMir extends AbstractServlet { modelRoot.put("errorstring", new SimpleScalar(anException.getMessage())); modelRoot.put("date", new SimpleScalar(StringUtil.date2readableDateTime( new GregorianCalendar()))); - HTMLTemplateProcessor.process(aResponse,MirPropertiesConfiguration.instance().getString("Mir.OpenIndy.ErrorTemplate"), + HTMLTemplateProcessor.process(aResponse,MirPropertiesConfiguration.instance().getString("ServletModule.OpenIndy.ErrorTemplate"), modelRoot,out, aRequest.getLocale()); out.close(); } diff --git a/source/default.properties b/source/default.properties index 0b5d417d..3455052e 100755 --- a/source/default.properties +++ b/source/default.properties @@ -278,14 +278,6 @@ Mir.LoginTemplate=templates/admin/login.template Mir.ErrorTemplate=templates/error.template Mir.UserErrorTemplate=templates/usererror.template -ServletModule.Schwerpunkt.ConfirmTemplate=templates/admin/confirm.template -ServletModule.Schwerpunkt.ObjektTemplate=templates/admin/feature.template -ServletModule.Schwerpunkt.ListTemplate=templates/admin/featurelist.template - -ServletModule.Feature.ConfirmTemplate=templates/admin/confirm.template -ServletModule.Feature.ObjektTemplate=templates/admin/schwerpunkt.template -ServletModule.Feature.ListTemplate=templates/admin/schwerpunktlist.template - ServletModule.Themen.ConfirmTemplate=templates/admin/confirm.template ServletModule.Themen.ObjektTemplate=templates/admin/topic.template ServletModule.Themen.ListTemplate=templates/admin/topiclist.template diff --git a/source/mir/misc/FileHandlerException.java b/source/mir/media/MediaExc.java similarity index 81% rename from source/mir/misc/FileHandlerException.java rename to source/mir/media/MediaExc.java index c10bfe09..43c3c93a 100755 --- a/source/mir/misc/FileHandlerException.java +++ b/source/mir/media/MediaExc.java @@ -29,26 +29,12 @@ * not wish to do so, delete this exception statement from your version. */ -package mir.misc; +package mir.media; +import multex.Exc; -/* - * - * @version $Id: FileHandlerException.java,v 1.4 2003/01/25 17:45:17 idfx Exp $ - * @author mh, mir-coders - * - */ - -public final class FileHandlerException extends Exception { - String msg; - - public FileHandlerException(String msg) { - super(msg); - this.msg = msg; - } - - public String getMsg() { - return msg; +public class MediaExc extends Exc { + public MediaExc(String aMessage) { + super(aMessage); } } - diff --git a/source/mir/media/MirMediaException.java b/source/mir/media/MediaFailure.java similarity index 86% rename from source/mir/media/MirMediaException.java rename to source/mir/media/MediaFailure.java index 6893f363..3df8e3a4 100755 --- a/source/mir/media/MirMediaException.java +++ b/source/mir/media/MediaFailure.java @@ -31,18 +31,15 @@ package mir.media; +import multex.Failure; -/* - * MirMediaException - - * - * @version $Id: MirMediaException.java,v 1.8 2003/01/25 17:45:17 idfx Exp $ - * @author mh - * - */ +public class MediaFailure extends Failure { -public final class MirMediaException extends Exception { - public MirMediaException(String msg) { - super(msg); + public MediaFailure(String msg,Throwable cause) { + super(msg,cause); } -} + public MediaFailure(Throwable aCause) { + this (aCause.getMessage(), aCause); + } +} diff --git a/source/mir/media/MediaHelper.java b/source/mir/media/MediaHelper.java index 6822e88a..b2748db5 100755 --- a/source/mir/media/MediaHelper.java +++ b/source/mir/media/MediaHelper.java @@ -45,25 +45,23 @@ import mir.storage.Database; */ public final class MediaHelper { - + static String _classPrefix = "mircoders.media.MediaHandler"; - public static MirMedia getHandler( Entity mediaType ) - throws MirMediaException { + public static MirMedia getHandler( Entity mediaType ) throws MediaExc, MediaFailure { MirMedia mediaHandler; String handlerName = mediaType.getValue("classname"); try { Class handlerClass = Class.forName(_classPrefix+handlerName); return mediaHandler = (MirMedia)handlerClass.newInstance(); - } catch (Exception e) { - throw new MirMediaException ("getHandler -- error in reflection " - +e.toString()); } - } + catch (Throwable e) { + throw new MediaFailure("getHandler -- error in reflection " + e.toString(), e); + } + } - public static Database getStorage(Entity mediaType, String classPrefix) - throws MirMediaException { + public static Database getStorage(Entity mediaType, String classPrefix) throws MediaExc, MediaFailure { Database mediaStorage; String storageName = mediaType.getValue("tablename"); @@ -71,13 +69,13 @@ public final class MediaHelper { Class storageClass = Class.forName(classPrefix+storageName); Method m = storageClass.getMethod("getInstance", null); return mediaStorage = (Database)m.invoke(null, null); - } catch (Exception e) { - throw new MirMediaException ("getStorage -- error in reflection " - +e.toString()); + } + catch (Throwable e) { + throw new MediaFailure("getStorage -- error in reflection " + e.toString(), e); } } } - + diff --git a/source/mir/media/MirMedia.java b/source/mir/media/MirMedia.java index b0aed580..07c3fe7c 100755 --- a/source/mir/media/MirMedia.java +++ b/source/mir/media/MirMedia.java @@ -41,8 +41,8 @@ import freemarker.template.SimpleList; * must implement this interface. Each specific media type, * be it Gif, Jpeg, Mp3 audio, Real Audio or quicktime video * has special needs when it comes to representation on the various - * pages (article, list, summary), must be stored differently and has a - * different URL, etc... This interface allows Mir to support + * pages (article, list, summary), must be stored differently and has a + * different URL, etc... This interface allows Mir to support * an infinite (I hope) number of media types. Once this is done, * no code at any other level in Mir needs to be changed other than * adding the content-type <-> media handler name mapping in the @@ -61,7 +61,7 @@ import freemarker.template.SimpleList; *

* The "name" field is used for various display/filenaming purposes. it should * match a valid file extension name for a media_type (we could have used the - * content-type map for this....). + * content-type map for this....). *

* The "mime_type" field is the most important as it does maps the type to Java * classes (the storage and media_handler name). We call those classes using @@ -79,9 +79,9 @@ import freemarker.template.SimpleList; *

* Most media handlers should just extend MediaHandlerGeneric (i.e inherit from * ) and just override the things that need to be specific. see MediaHandlerAudio - * + * * @author , the Mir-coders group - * @version $Id: MirMedia.java,v 1.15 2003/01/25 17:45:17 idfx Exp $ + * @version $Id: MirMedia.java,v 1.16 2003/03/09 03:53:10 zapata Exp $ */ public interface MirMedia{ @@ -98,11 +98,9 @@ public interface MirMedia{ * @return boolean, success/fail * @see mir.entity.Entity */ - public abstract void set (InputStream in, Entity ent, - Entity mediaTypeEnt ) throws MirMediaException; + public abstract void set (InputStream in, Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure; - public abstract void produce (Entity ent, Entity mediaTypeEnt ) - throws MirMediaException; + public abstract void produce (Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure; /** * Get's the media data from storage and returns it as an InputStream @@ -114,8 +112,7 @@ public interface MirMedia{ * @return java.io.InputStream * @see mir.entity.Entity */ - public abstract InputStream getMedia (Entity ent, Entity mediaTypeEnt) - throws MirMediaException; + public abstract InputStream getMedia (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure; /** * Pretty much like get() above. But get's the specific Icon @@ -124,11 +121,11 @@ public interface MirMedia{ * @return java.io.InputStream * @see mir.entity.Entity */ - public abstract InputStream getIcon (Entity ent) throws MirMediaException; + public abstract InputStream getIcon (Entity ent) throws MediaExc, MediaFailure; - /** + /** * gets the final content representation for the media - * in the form of a URL (String) that allows someone to + * in the form of a URL (String) that allows someone to * download, look at or listen to the media. (HREF, img src * streaming link, etc..) * It should use the helper functions in the StringUtil class to @@ -139,10 +136,9 @@ public interface MirMedia{ * @see mir.entity.Entity * @see mir.misc.StringUtil */ - public abstract SimpleList getURL (Entity ent, Entity mediaTypeEnt) - throws MirMediaException; + public abstract SimpleList getURL (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure; - /** + /** * Returns the absolute filesystem path to where the media * content should be stored. This path is usually defined * in the configuration wich is accessible through the MirConfig @@ -150,9 +146,9 @@ public interface MirMedia{ * @return String, the path. * @see mir.misc.MirConfig */ - public abstract String getStoragePath () throws MirMediaException; + public abstract String getStoragePath () throws MediaExc, MediaFailure; - /** + /** * Returns the *relative* filesystem path to where the media * icon content should be stored. It is relative to the path * returned by getStoragePath() @@ -162,9 +158,9 @@ public interface MirMedia{ * @return String, the path. * @see mir.misc.MirConfig */ - public abstract String getIconStoragePath () throws MirMediaException; + public abstract String getIconStoragePath () throws MediaExc, MediaFailure; - /** + /** * Returns the base URL to that the media is accessible from * to the end user. This could be a URL to another host. * This is used in the Metadata stored in the DB and later on @@ -175,9 +171,9 @@ public interface MirMedia{ * @return String, the base URL to the host. * @see mir.misc.MirConfig */ - public abstract String getPublishHost () throws MirMediaException; + public abstract String getPublishHost () throws MediaExc, MediaFailure; - /** + /** * Returns the file name of the Icon representing the media type. * It is used in the summary view. * It is usually defined @@ -187,9 +183,9 @@ public interface MirMedia{ * @see mir.misc.MirConfig */ public abstract String getBigIconName (); - - /** - * Returns the file name of the small Icon representing + + /** + * Returns the file name of the small Icon representing * the media type. * It is used in the right hand newswire list of the startpage. * It is usually defined @@ -200,26 +196,26 @@ public interface MirMedia{ */ public abstract String getTinyIconName (); - /** + /** * Returns the IMG SRC "ALT" text to be used * for the Icon representations * @return String, the ALT text. */ public abstract String getIconAltName (); - /** + /** * your can all figure it out. * @return boolean. */ public abstract boolean isVideo (); - /** + /** * you can all figure it out. * @return boolean. */ public abstract boolean isAudio (); - /** + /** * you can all figure it out. * @return boolean. */ diff --git a/source/mir/media/MirMediaUserException.java b/source/mir/media/MirMediaUserException.java deleted file mode 100755 index ac8bf0e1..00000000 --- a/source/mir/media/MirMediaUserException.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2001, 2002 The Mir-coders group - * - * This file is part of Mir. - * - * Mir is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Mir is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Mir; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with the com.oreilly.servlet library, any library - * licensed under the Apache Software License, The Sun (tm) Java Advanced - * Imaging library (JAI), The Sun JIMI library (or with modified versions of - * the above that use the same license as the above), and distribute linked - * combinations including the two. You must obey the GNU General Public - * License in all respects for all of the code used other than the above - * mentioned libraries. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If you do - * not wish to do so, delete this exception statement from your version. - */ - -package mir.media; - - -/* - * MirMediaException - - * differentiates itself from a bug in that it - * represents a probable user error - * - * @version $Id: MirMediaUserException.java,v 1.5 2003/01/25 17:45:17 idfx Exp $ - * @author mh - * - */ - -public final class MirMediaUserException extends Exception { - String msg; - - public MirMediaUserException(String msg) { - super(msg); - this.msg = msg; - } - - public String getMsg() { - return msg; - } -} - diff --git a/source/mir/misc/FileHandler.java b/source/mir/misc/FileHandler.java index 790d5c33..7804e245 100755 --- a/source/mir/misc/FileHandler.java +++ b/source/mir/misc/FileHandler.java @@ -1,56 +1,77 @@ -/* - * Copyright (C) 2001, 2002 The Mir-coders group - * - * This file is part of Mir. - * - * Mir is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Mir is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Mir; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with the com.oreilly.servlet library, any library - * licensed under the Apache Software License, The Sun (tm) Java Advanced - * Imaging library (JAI), The Sun JIMI library (or with modified versions of - * the above that use the same license as the above), and distribute linked - * combinations including the two. You must obey the GNU General Public - * License in all respects for all of the code used other than the above - * mentioned libraries. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If you do - * not wish to do so, delete this exception statement from your version. - */ - -package mir.misc; - -import java.util.Map; - -import com.oreilly.servlet.multipart.FilePart; - - -/** - * Interface that classes wishing to be used as a callback on FileParts for the - * WebdbMultipartRequest class should implement this interface. - * - * @author mh - * @version $Id: FileHandler.java,v 1.4 2003/03/04 22:00:52 zapata Exp $ - * @see mir.misc.WebdbMultipartRequest - * - */ - -public interface FileHandler { - - public void setFile (FilePart filePart, int fileNum, Map Params) - throws FileHandlerException, FileHandlerUserException; - -} - - +/* + * Copyright (C) 2001, 2002 The Mir-coders group + * + * This file is part of Mir. + * + * Mir is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Mir is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Mir; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, The Mir-coders gives permission to link + * the code of this program with the com.oreilly.servlet library, any library + * licensed under the Apache Software License, The Sun (tm) Java Advanced + * Imaging library (JAI), The Sun JIMI library (or with modified versions of + * the above that use the same license as the above), and distribute linked + * combinations including the two. You must obey the GNU General Public + * License in all respects for all of the code used other than the above + * mentioned libraries. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If you do + * not wish to do so, delete this exception statement from your version. + */ + +package mir.misc; + +import java.util.Map; +import multex.Exc; +import multex.Failure; + +import com.oreilly.servlet.multipart.FilePart; + + +/** + * Interface that classes wishing to be used as a callback on FileParts for the + * WebdbMultipartRequest class should implement this interface. + * + * @author mh + * @version $Id: FileHandler.java,v 1.5 2003/03/09 03:53:10 zapata Exp $ + * @see mir.misc.WebdbMultipartRequest + * + */ + +public interface FileHandler { + + public void setFile (FilePart filePart, int fileNum, Map Params) throws FileHandlerExc, FileHandlerFailure; + + public static class FileHandlerExc extends Exc { + public FileHandlerExc(String aMessage) { + + super(aMessage); + } + } + + public static class FileHandlerFailure extends Failure { + + public FileHandlerFailure(String msg, Throwable cause) { + super(msg, cause); + } + + public FileHandlerFailure(Throwable aCause) { + this(aCause.getMessage(), aCause); + } + } + +} + + + + diff --git a/source/mir/misc/FileHandlerUserException.java b/source/mir/misc/FileHandlerUserException.java deleted file mode 100755 index 518e9b2d..00000000 --- a/source/mir/misc/FileHandlerUserException.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2001, 2002 The Mir-coders group - * - * This file is part of Mir. - * - * Mir is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Mir is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Mir; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with the com.oreilly.servlet library, any library - * licensed under the Apache Software License, The Sun (tm) Java Advanced - * Imaging library (JAI), The Sun JIMI library (or with modified versions of - * the above that use the same license as the above), and distribute linked - * combinations including the two. You must obey the GNU General Public - * License in all respects for all of the code used other than the above - * mentioned libraries. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If you do - * not wish to do so, delete this exception statement from your version. - */ - -package mir.misc; - - -/* - * differentiates itself from a bug in that it - * represents a probable user error - * - * @version $Id: FileHandlerUserException.java,v 1.5 2003/01/25 17:45:17 idfx Exp $ - * @author mh - * - * $Log: FileHandlerUserException.java,v $ - * Revision 1.5 2003/01/25 17:45:17 idfx - * some small changes delting unneeded imports. two new exceptions in mir.storage. usage of the new config-class. - * - * Revision 1.4 2002/12/01 15:05:51 zapata - * tracked down a nasty error reporting bug - * - * Revision 1.3 2002/11/27 07:46:34 mh - * get rid of annoying $Log: FileHandlerUserException.java,v $ - * get rid of annoying Revision 1.5 2003/01/25 17:45:17 idfx - * get rid of annoying some small changes delting unneeded imports. two new exceptions in mir.storage. usage of the new config-class. - * get rid of annoying - * get rid of annoying Revision 1.4 2002/12/01 15:05:51 zapata - * get rid of annoying tracked down a nasty error reporting bug - * get rid of annoying keywords - * - * Revision 1.2 2002/11/04 04:35:21 mh - * merge media InputStream changes from MIR_1_0 branch - * - * Revision 1.1.2.1 2002/11/01 05:38:20 mh - * Converted media Interface to use streams (Java IO) instead of byte buffers of - * the entire uplaoded files. These saves loads of unecessary memory use. JAI - * still consumes quite a bit though. - * - * A new temporary file (for JAI) parameter is necessary and is in the config.properties file. - * - * A nice side effect of this work is the FileHandler interface which is - * basically a call back mechanism for WebdbMultipartRequest which allows the - * uploaded file to handled by different classes. For example, for a media - * upload, the content-type, etc.. needs to be determined, but if say the - * FileEditor had a feature to upload static files... another handler wood be - * needed. Right now only the MediaRequest handler exists. - * - * - */ - -public final class FileHandlerUserException extends Exception { - public FileHandlerUserException(String msg) { - super(msg); - } -} - diff --git a/source/mir/misc/WebdbMultipartRequest.java b/source/mir/misc/WebdbMultipartRequest.java index 4735fd12..4be6c031 100755 --- a/source/mir/misc/WebdbMultipartRequest.java +++ b/source/mir/misc/WebdbMultipartRequest.java @@ -65,14 +65,14 @@ public class WebdbMultipartRequest FileHandler _fHandler; public WebdbMultipartRequest(HttpServletRequest theReq, FileHandler handler) - throws FileHandlerException, FileHandlerUserException, IOException, PropertiesConfigExc + throws FileHandler.FileHandlerExc, FileHandler.FileHandlerFailure, IOException, PropertiesConfigExc { req=theReq; int maxSize; try { - maxSize = - MirPropertiesConfiguration.instance().getInt("MaxMediaUploadSize"); - } catch (PropertiesConfigExc e) { + maxSize = MirPropertiesConfiguration.instance().getInt("MaxMediaUploadSize"); + } + catch (PropertiesConfigExc e) { maxSize = 1024; throw e; } @@ -103,13 +103,17 @@ public class WebdbMultipartRequest while(Keys.hasMoreElements()) { String KeyNm = (String)Keys.nextElement(); Vector values = (Vector)parameters.get(KeyNm); + if (values == null || values.size() == 0) { value = null; - } else { + } + else { value = (String)values.elementAt(values.size() - 1); - } //endif + } + pHash.put(KeyNm, value); - } // end while + } + return pHash; } @@ -141,8 +145,8 @@ public class WebdbMultipartRequest } } - private void _evaluateRequest() throws FileHandlerException, - FileHandlerUserException, IOException { + private void _evaluateRequest() throws FileHandler.FileHandlerExc, + FileHandler.FileHandlerFailure, IOException { Part part; int i = 1; diff --git a/source/mir/module/AbstractModule.java b/source/mir/module/AbstractModule.java index 718925dc..5f16a227 100755 --- a/source/mir/module/AbstractModule.java +++ b/source/mir/module/AbstractModule.java @@ -1,226 +1,240 @@ -/* - * Copyright (C) 2001, 2002 The Mir-coders group - * - * This file is part of Mir. - * - * Mir is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Mir is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Mir; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with the com.oreilly.servlet library, any library - * licensed under the Apache Software License, The Sun (tm) Java Advanced - * Imaging library (JAI), The Sun JIMI library (or with modified versions of - * the above that use the same license as the above), and distribute linked - * combinations including the two. You must obey the GNU General Public - * License in all respects for all of the code used other than the above - * mentioned libraries. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If you do - * not wish to do so, delete this exception statement from your version. - */ - -package mir.module; - -import java.sql.SQLException; -import java.util.Map; - -import mir.entity.Entity; -import mir.entity.EntityList; -import mir.storage.StorageObject; -import mir.storage.StorageObjectExc; -import mir.storage.StorageObjectFailure; -import freemarker.template.SimpleHash; - - -/** - * This class provides the base functionality for the derived Module-Classes. - * These classes should provide methods to make more or less complex actions - * on Database and Entity classes. The modules are used by ServletModules. - * Future possibility could be access via Applications. - * - * Abstrakte Klasse, von denen die Modules die Basisfunktionalit?t erben. - * Die Moduleschicht dient dazu, Funktionalitaeten zur Verf?gung zu stellen, - * die von mehreren ServletModulen verwendet werden. - * - */ - -public class AbstractModule { - protected StorageObject theStorage; - - public void setStorage(StorageObject storage) { - this.theStorage = storage; - } - - /** - * Liefert das Standard-StorageObject zur?ck, mit dem das Module assoziiert ist. - * @return Standard-StorageObject - */ - public StorageObject getStorageObject () { - return theStorage; - } - - /** - * Holt eine Entity anhand der Id via StorageObject - * @param String der Entity - * @return Entity - */ - public Entity getById (String id) throws ModuleException { - try { - if (theStorage == null) - throw new ModuleException("No StorageObject set!"); - Entity entity = (Entity)theStorage.selectById(id); - if (entity == null) - throw new ModuleException("No object for id = " + id); - else return entity; - } - catch (StorageObjectExc e){ - throw new ModuleException(e.toString()); - } - } - - /** - * Holt eine EntityListe anhand des WhereClause via StorageObject - * @param String whereclause - * @param offset - ab welchem Datensatz die gematchten Entities zurueckgeliefert werden - * @return EntityList Liste der gematchten Datens?tze - */ - public EntityList getByWhereClause (String whereClause, int offset) throws ModuleException { - try { - if (theStorage == null) - throw new ModuleException("Kein StorageObject gesetzt"); - return theStorage.selectByWhereClause(whereClause, offset); - } - catch (StorageObjectFailure e){ - throw new ModuleException(e.toString()); - } - } - - /** - * Holt eine EntityListe anhand des WhereClause aus dem StorageObject - * @param String where WhereClause - * @param String order Sortierreihenfolge - * @param offset - ab welchem Datensatz die gematchten Entities zurueckgeliefert werden - * @return EntityList Liste der gematchten Datens?tze - */ - public EntityList getByWhereClause (String where, String order, int offset) throws ModuleException { - try { - if (theStorage==null) throw new ModuleException("Kein StorageObject gesetzt"); - return theStorage.selectByWhereClause(where, order, offset); - } - catch (StorageObjectFailure e){ - throw new ModuleException(e.toString()); - } - } - /** - * Executes a where clause on the StorageObject with order criteria - * fetching from offset the number of limit objects - * - * @param String where - * @param String order - * @param int offset - * @param int limit - * @return EntityList - */ - - public EntityList getByWhereClause(String where, String order, int offset, int limit) throws ModuleException - { - try { - if (theStorage==null) throw new ModuleException("StorageObject not set!"); - return theStorage.selectByWhereClause(where, order, offset, limit); - } - catch (StorageObjectFailure e){ - throw new ModuleException(e.toString()); - } - } - - /** - * Holt eine EntityListe anhand des Wertes aValue von Feld aField aus dem StorageObject - * @param String aField - Feldname im StorageObject - * @param String aValue - Wert in Feld im StorageObject - * @param offset - ab welchem Datensatz die gematchten Entities zurueckgeliefert werden - * @return EntityList Liste der gematchten Datens?tze - */ - public EntityList getByFieldValue (String aField, String aValue, int offset) throws ModuleException { - String whereClause; - whereClause = aField + " like '%" + aValue + "%'"; - return getByWhereClause(whereClause, offset); - } - - /** - * Standardfunktion, um einen Datensatz via StorageObject einzuf?gen - * @param theValues Hash mit Spalte/Wert-Paaren - * @return Id des eingef?gten Objekts - * @exception ModuleException - */ - public String add (Map theValues) throws ModuleException { - try { - Entity theEntity = (Entity)theStorage.getEntityClass().newInstance(); - theEntity.setStorage(theStorage); - theEntity.setValues(theValues); - return theEntity.insert(); - } - catch (Exception e) { - throw new ModuleException(e.toString()); - } - } - - /** - * Standardfunktion, um einen Datensatz via StorageObject zu aktualisieren - * @param theValues Hash mit Spalte/Wert-Paaren - * @return Id des eingef?gten Objekts - * @exception ModuleException - */ - public String set (Map theValues) throws ModuleException { - try { - Entity theEntity = theStorage.selectById((String)theValues.get("id")); - if (theEntity == null) - throw new ModuleException("No object found with id " + theValues.get("id")); - theEntity.setValues(theValues); - theEntity.update(); - return theEntity.getId(); - } - catch (StorageObjectExc e){ - throw new ModuleException(e.toString()); - } - } - - /** - * Deletes a record using an id - * @param idParam - * @exception ModuleException - */ - public void deleteById (String idParam) throws ModuleException { - try { - theStorage.delete(idParam); - } catch (StorageObjectFailure e){ - throw new ModuleException(e.toString()); - } - } - - /** - * Liefert den Lookuptable aller Objekte des StorageObjects - * @return freemarker.template.SimpleHash - */ - public SimpleHash getHashData() { - return theStorage.getHashData(); - } - - /** - * returns the number of rows - */ - public int getSize(String where) - throws SQLException,StorageObjectFailure { - return theStorage.getSize(where); - } - -} +/* + * Copyright (C) 2001, 2002 The Mir-coders group + * + * This file is part of Mir. + * + * Mir is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Mir is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Mir; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, The Mir-coders gives permission to link + * the code of this program with the com.oreilly.servlet library, any library + * licensed under the Apache Software License, The Sun (tm) Java Advanced + * Imaging library (JAI), The Sun JIMI library (or with modified versions of + * the above that use the same license as the above), and distribute linked + * combinations including the two. You must obey the GNU General Public + * License in all respects for all of the code used other than the above + * mentioned libraries. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If you do + * not wish to do so, delete this exception statement from your version. + */ + +package mir.module; + +import java.sql.SQLException; +import java.util.Map; + +import mir.entity.Entity; +import mir.entity.EntityList; +import mir.storage.StorageObject; +import mir.storage.StorageObjectExc; +import mir.storage.StorageObjectFailure; +import freemarker.template.SimpleHash; + + +/** + * This class provides the base functionality for the derived Module-Classes. + * These classes should provide methods to make more or less complex actions + * on Database and Entity classes. The modules are used by ServletModules. + * Future possibility could be access via Applications. + * + * Abstrakte Klasse, von denen die Modules die Basisfunktionalit?t erben. + * Die Moduleschicht dient dazu, Funktionalitaeten zur Verf?gung zu stellen, + * die von mehreren ServletModulen verwendet werden. + * + */ + +public class AbstractModule { + protected StorageObject theStorage; + + public void setStorage(StorageObject storage) { + this.theStorage = storage; + } + + /** + * Liefert das Standard-StorageObject zur?ck, mit dem das Module assoziiert ist. + * @return Standard-StorageObject + */ + public StorageObject getStorageObject () { + return theStorage; + } + + /** + * Holt eine Entity anhand der Id via StorageObject + * @param String der Entity + * @return Entity + */ + public Entity getById (String id) throws ModuleExc, ModuleFailure { + try { + if (theStorage == null) + throw new ModuleExc("AbstractModule.getById: No StorageObject set!"); + Entity entity = (Entity)theStorage.selectById(id); + + if (entity == null) + throw new ModuleExc("AbstractModule.getById: No object for id = " + id); + else + return entity; + } + catch (Throwable e) { + throw new ModuleFailure(e); + } + } + + /** + * Holt eine EntityListe anhand des WhereClause via StorageObject + * @param String whereclause + * @param offset - ab welchem Datensatz die gematchten Entities zurueckgeliefert werden + * @return EntityList Liste der gematchten Datens?tze + */ + public EntityList getByWhereClause (String whereClause, int offset) throws ModuleExc, ModuleFailure { + try { + if (theStorage == null) + throw new ModuleExc("AbstractModule.getByWhereClause: No StorageObject set!"); + + return theStorage.selectByWhereClause(whereClause, offset); + } + catch (Throwable e) { + throw new ModuleFailure(e); + } + } + + /** + * Holt eine EntityListe anhand des WhereClause aus dem StorageObject + * @param String where WhereClause + * @param String order Sortierreihenfolge + * @param offset - ab welchem Datensatz die gematchten Entities zurueckgeliefert werden + * @return EntityList Liste der gematchten Datens?tze + */ + public EntityList getByWhereClause (String where, String order, int offset) throws ModuleExc, ModuleFailure { + try { + if (theStorage==null) + throw new ModuleExc("AbstractModule.getByWhereClause: No StorageObject set!"); + + return theStorage.selectByWhereClause(where, order, offset); + } + catch (Throwable e) { + throw new ModuleFailure(e); + } + } + /** + * Executes a where clause on the StorageObject with order criteria + * fetching from offset the number of limit objects + * + * @param String where + * @param String order + * @param int offset + * @param int limit + * @return EntityList + */ + + public EntityList getByWhereClause(String where, String order, int offset, int limit) throws ModuleExc, ModuleFailure { + try { + if (theStorage==null) + throw new ModuleExc("AbstractModule.getByWhereClause: StorageObject not set!"); + + return theStorage.selectByWhereClause(where, order, offset, limit); + } + catch (Throwable e) { + throw new ModuleFailure(e); + } + } + + /** + * Holt eine EntityListe anhand des Wertes aValue von Feld aField aus dem StorageObject + * @param String aField - Feldname im StorageObject + * @param String aValue - Wert in Feld im StorageObject + * @param offset - ab welchem Datensatz die gematchten Entities zurueckgeliefert werden + * @return EntityList Liste der gematchten Datens?tze + */ + public EntityList getByFieldValue (String aField, String aValue, int offset) throws ModuleExc, ModuleFailure { + String whereClause; + whereClause = aField + " like '%" + aValue + "%'"; + return getByWhereClause(whereClause, offset); + } + + /** + * * Standardfunktion, um einen Datensatz via StorageObject einzuf?gen + * @param theValues Hash mit Spalte/Wert-Paaren + * @return Id des eingef?gten Objekts + * @exception ModuleExc + * @exception ModuleFailure + */ + public String add (Map theValues) throws ModuleExc, ModuleFailure { + try { + Entity theEntity = (Entity)theStorage.getEntityClass().newInstance(); + theEntity.setStorage(theStorage); + theEntity.setValues(theValues); + return theEntity.insert(); + } + catch (Throwable e) { + throw new ModuleFailure(e); + } + } + + /** + * Standardfunktion, um einen Datensatz via StorageObject zu aktualisieren + * @param theValues Hash mit Spalte/Wert-Paaren + * @return Id des eingef?gten Objekts + * @exception ModuleExc + * @exception ModuleFailure + */ + public String set (Map theValues) throws ModuleExc, ModuleFailure { + try { + Entity theEntity = theStorage.selectById((String)theValues.get("id")); + if (theEntity == null) + throw new ModuleExc("No object found with id " + theValues.get("id")); + theEntity.setValues(theValues); + theEntity.update(); + return theEntity.getId(); + } + catch (Throwable e) { + throw new ModuleFailure(e); + } + } + + /** + * Deletes a record using an id + * @param idParam + * @exception ModuleExc + * @exception ModuleFailure + */ + public void deleteById (String idParam) throws ModuleExc, ModuleFailure { + try { + theStorage.delete(idParam); + } + catch (Throwable e) { + throw new ModuleFailure(e); + } + } + + /** + * Liefert den Lookuptable aller Objekte des StorageObjects + * @return freemarker.template.SimpleHash + */ + public SimpleHash getHashData() { + return theStorage.getHashData(); + } + + /** + * returns the number of rows + */ + public int getSize(String where) throws ModuleExc, ModuleFailure { + try { + return theStorage.getSize(where); + } + catch (Throwable e) { + throw new ModuleFailure(e); + } + } + +} diff --git a/source/mir/module/ModuleException.java b/source/mir/module/ModuleExc.java similarity index 87% rename from source/mir/module/ModuleException.java rename to source/mir/module/ModuleExc.java index 51aeb417..db135d68 100755 --- a/source/mir/module/ModuleException.java +++ b/source/mir/module/ModuleExc.java @@ -31,20 +31,10 @@ package mir.module; +import multex.Exc; -/* - * ServletModuleException - - * wird vom ServletModule geschmissen - * - * - * @version 5.7.199 - * @author RK - */ - -public final class ModuleException extends Exception -{ - public ModuleException(String msg) { - super(msg); - } +public class ModuleExc extends Exc { + public ModuleExc(String aMessage) { + super(aMessage); + } } - diff --git a/source/mir/module/ModuleUserException.java b/source/mir/module/ModuleFailure.java similarity index 86% rename from source/mir/module/ModuleUserException.java rename to source/mir/module/ModuleFailure.java index c33b4a02..48e9ea54 100755 --- a/source/mir/module/ModuleUserException.java +++ b/source/mir/module/ModuleFailure.java @@ -31,20 +31,15 @@ package mir.module; +import multex.Failure; -/* - * ServletModuleException - - * wird vom ServletModule geschmissen - * - * - * @version 5.7.199 - * @author RK - */ +public class ModuleFailure extends Failure { -public final class ModuleUserException extends Exception -{ - public ModuleUserException(String msg) { - super(msg); - } -} + public ModuleFailure(String msg,Throwable cause) { + super(msg,cause); + } + public ModuleFailure(Throwable aCause) { + this (aCause.getMessage(), aCause); + } +} diff --git a/source/mir/producer/ProducerFailure.java b/source/mir/producer/ProducerFailure.java index 5287aa08..5cd26b8a 100755 --- a/source/mir/producer/ProducerFailure.java +++ b/source/mir/producer/ProducerFailure.java @@ -42,4 +42,4 @@ public class ProducerFailure extends Failure { public ProducerFailure(Throwable aCause) { this (aCause.getMessage(), aCause); } -} \ No newline at end of file +} diff --git a/source/mircoders/entity/EntityUploadedMedia.java b/source/mircoders/entity/EntityUploadedMedia.java index 9f90ca35..f6ead2cf 100755 --- a/source/mircoders/entity/EntityUploadedMedia.java +++ b/source/mircoders/entity/EntityUploadedMedia.java @@ -51,7 +51,7 @@ import freemarker.template.TemplateModelException; /** * * @author mh, mir-coders group - * @version $Id: EntityUploadedMedia.java,v 1.22 2003/03/05 19:23:15 idfx Exp $ + * @version $Id: EntityUploadedMedia.java,v 1.23 2003/03/09 03:53:11 zapata Exp $ */ @@ -183,8 +183,8 @@ public class EntityUploadedMedia extends Entity { mediaHandler = MediaHelper.getHandler(mediaType); return mediaHandler.getURL(this, mediaType); } - catch (Exception ex) { - logger.warn("EntityUploadedMedia.getUrl: could not fetch data: " + ex.toString()); + catch (Throwable t) { + logger.warn("EntityUploadedMedia.getUrl: could not fetch data: " + t.toString()); } return null; } diff --git a/source/mircoders/localizer/basic/MirBasicDataModelLocalizer.java b/source/mircoders/localizer/basic/MirBasicDataModelLocalizer.java index e5229ba6..922ed119 100755 --- a/source/mircoders/localizer/basic/MirBasicDataModelLocalizer.java +++ b/source/mircoders/localizer/basic/MirBasicDataModelLocalizer.java @@ -157,7 +157,6 @@ public class MirBasicDataModelLocalizer implements MirDataModelLocalizer { definition.addDBDateField("creationdate", "webdb_create"); result.addMapping( "breakingNews", DatabaseBreaking.getInstance(), definition); - result.addMapping( "feature", DatabaseFeature.getInstance(), new EntityAdapterDefinition()); result.addMapping( "imageType", DatabaseImageType.getInstance(), new EntityAdapterDefinition()); result.addMapping( "language", DatabaseLanguage.getInstance(), new EntityAdapterDefinition()); result.addMapping( "mediaFolder", DatabaseMediafolder.getInstance(), new EntityAdapterDefinition()); diff --git a/source/mircoders/media/MediaHandlerGeneric.java b/source/mircoders/media/MediaHandlerGeneric.java index 66b11cff..e31af291 100755 --- a/source/mircoders/media/MediaHandlerGeneric.java +++ b/source/mircoders/media/MediaHandlerGeneric.java @@ -41,7 +41,8 @@ import mir.config.MirPropertiesConfiguration.PropertiesConfigExc; import mir.entity.Entity; import mir.log.LoggerWrapper; import mir.media.MirMedia; -import mir.media.MirMediaException; +import mir.media.MediaExc; +import mir.media.MediaFailure; import mir.misc.FileUtil; import mir.misc.StringUtil; import freemarker.template.SimpleList; @@ -64,7 +65,7 @@ import freemarker.template.SimpleList; * * @see mir.media.MirMedia * @author mh - * @version $Id: MediaHandlerGeneric.java,v 1.16 2003/03/06 05:40:39 zapata Exp $ + * @version $Id: MediaHandlerGeneric.java,v 1.17 2003/03/09 03:53:11 zapata Exp $ */ public class MediaHandlerGeneric implements MirMedia @@ -89,7 +90,7 @@ public class MediaHandlerGeneric implements MirMedia logger = new LoggerWrapper("Media.Generic"); } - public void set (InputStream in, Entity ent, Entity mediaTypeEnt ) throws MirMediaException { + public void set (InputStream in, Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure { String ext = mediaTypeEnt.getValue("name"); String mediaFname = ent.getId() + "." + ext; String date = ent.getValue("date"); @@ -103,42 +104,41 @@ public class MediaHandlerGeneric implements MirMedia } catch (Throwable e) { logger.error("MediaHandlerGeneric.set: " + e.toString()); - throw new MirMediaException(e.toString()); + throw new MediaFailure(e); } } - public void produce (Entity ent, Entity mediaTypeEnt ) - throws MirMediaException { - + public void produce (Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure { //check first if the media file exist since produced //location is also the storage location + String date = ent.getValue("date"); String datePath = StringUtil.webdbDate2path(date); String relPath = datePath+ent.getId()+"."+mediaTypeEnt.getValue("name"); String fname = getStoragePath()+relPath; if(! new File(fname).exists()) - throw new MirMediaException("error in MirMedia.produce(): "+relPath+ - " does not exist!"); + throw new MediaExc("error in MirMedia.produce(): " + relPath + " does not exist!"); } - public InputStream getMedia (Entity ent, Entity mediaTypeEnt) - throws MirMediaException { + public InputStream getMedia (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure { String publishPath = ent.getValue("publish_path"); String fname = getStoragePath()+publishPath; File f = new File(fname); if(! f.exists()) - throw new MirMediaException("error in MirMedia.getMedia(): "+fname+ - " does not exist!"); - FileInputStream in; + throw new MediaExc("error in MirMedia.getMedia(): " + fname + " does not exist!"); + + FileInputStream inputStream; try { - in = new FileInputStream(f); - } catch (IOException e) { - throw new MirMediaException("getMedia(): "+e.toString()); + inputStream = new FileInputStream(f); } - return in; + catch (Throwable e) { + throw new MediaFailure("MediaHandlerGeneric.getMedia(): " + e.toString(), e); + } + + return inputStream; } - public InputStream getIcon (Entity ent) throws MirMediaException { + public InputStream getIcon (Entity ent) throws MediaExc, MediaFailure { return null; } diff --git a/source/mircoders/media/MediaHandlerImages.java b/source/mircoders/media/MediaHandlerImages.java index 68073e30..ce62a95a 100755 --- a/source/mircoders/media/MediaHandlerImages.java +++ b/source/mircoders/media/MediaHandlerImages.java @@ -40,7 +40,8 @@ import mir.config.MirPropertiesConfiguration.PropertiesConfigExc; import mir.entity.Entity; import mir.log.LoggerWrapper; import mir.media.MirMedia; -import mir.media.MirMediaException; +import mir.media.MediaExc; +import mir.media.MediaFailure; import mir.misc.FileUtil; import mir.misc.StringUtil; import mir.storage.StorageObjectFailure; @@ -61,7 +62,7 @@ import freemarker.template.SimpleList; * * @see mir.media.MirMedia * @author mh - * @version $Id: MediaHandlerImages.java,v 1.19 2003/03/05 19:23:16 idfx Exp $ + * @version $Id: MediaHandlerImages.java,v 1.20 2003/03/09 03:53:11 zapata Exp $ */ @@ -88,36 +89,35 @@ public abstract class MediaHandlerImages implements MirMedia logger = new LoggerWrapper("Media.Images"); } - public InputStream getMedia(Entity ent, Entity mediaTypeEnt) - throws MirMediaException - { - InputStream in; + public InputStream getMedia(Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure { + InputStream inputStream; + try { - in = ((EntityImages)ent).getImage(); + inputStream = ((EntityImages)ent).getImage(); } - catch ( StorageObjectFailure e) { - logger.error("MediaHandlerImages.getImage: "+e.toString()); - throw new MirMediaException(e.toString()); + catch (Throwable e) { + logger.error("MediaHandlerImages.getImage: " + e.toString()); + + throw new MediaFailure(e); } - return in; + return inputStream; } - public void set(InputStream in, Entity ent, Entity mediaTypeEnt) - throws MirMediaException { + public void set(InputStream in, Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure { try { ((EntityImages)ent).setImage(in, getType()); } - catch ( StorageObjectFailure e) { + catch (Throwable e) { logger.error("MediaHandlerImages.set: "+e.getMessage()); e.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE)); - throw new MirMediaException(e.getMessage()); + + throw new MediaFailure(e); } } - public void produce(Entity ent, Entity mediaTypeEnt) throws MirMediaException - { + public void produce(Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure { String date = ent.getValue("date"); String datePath = StringUtil.webdbDate2path(date); String ext = "."+mediaTypeEnt.getValue("name"); @@ -141,84 +141,73 @@ public abstract class MediaHandlerImages implements MirMedia } catch (Throwable e) { logger.error("MediaHandlerImages.produce: " + e.toString()); - throw new MirMediaException("MediaHandlerImages.produce: " + e.toString()); + throw new MediaFailure("MediaHandlerImages.produce: " + e.toString(), e); } } else { logger.error("MediaHandlerImages.produce: missing image or icon OID for: " + ent.getId()); - throw new MirMediaException("MediaHandlerImages.produce: missing image or icon OID for: " + ent.getId()); + + throw new MediaExc("MediaHandlerImages.produce: missing image or icon OID for: " + ent.getId()); } } - public InputStream getIcon(Entity ent) throws MirMediaException - { + public InputStream getIcon(Entity ent) throws MediaExc, MediaFailure { InputStream in; try { in = ((EntityImages)ent).getIcon(); } catch (Throwable e) { logger.error("MediaHandlerImages.getIcon: " + e.toString()); - throw new MirMediaException(e.toString()); + throw new MediaFailure(e); } return in; } - public SimpleList getURL(Entity ent, Entity mediaTypeEnt) - { + public SimpleList getURL(Entity ent, Entity mediaTypeEnt) { SimpleList theList = new SimpleList(); theList.add(ent); return theList; } - public String getStoragePath() - { + public String getStoragePath() { return configuration.getString("Producer.Image.Path"); } - public String getIconStoragePath() - { + public String getIconStoragePath() { return configuration.getString("Producer.Image.IconPath"); } - public String getPublishHost() - { + public String getPublishHost() { return StringUtil.removeSlash(configuration.getString("Producer.Image.Host")); } - public String getTinyIconName() - { + public String getTinyIconName() { return configuration.getString("Producer.Icon.TinyImage"); } - public String getBigIconName() - { + public String getBigIconName() { return configuration.getString("Producer.Icon.BigImage"); } - public String getIconAltName() - { + public String getIconAltName() { return "Image"; } - public boolean isVideo() - { + public boolean isVideo() { return false; } - public boolean isAudio() - { + public boolean isAudio() { return false; } - public boolean isImage () - { + public boolean isImage () { return true; } - public String getDescr(Entity mediaType) - { + public String getDescr(Entity mediaType) { return "image/jpeg"; } diff --git a/source/mircoders/media/MediaHandlerImagesExtern.java b/source/mircoders/media/MediaHandlerImagesExtern.java index 3b8de9e1..a885d2fa 100755 --- a/source/mircoders/media/MediaHandlerImagesExtern.java +++ b/source/mircoders/media/MediaHandlerImagesExtern.java @@ -39,7 +39,8 @@ import java.io.InputStream; import mir.config.MirPropertiesConfiguration; import mir.entity.Entity; import mir.log.LoggerWrapper; -import mir.media.MirMediaException; +import mir.media.MediaExc; +import mir.media.MediaFailure; import mir.misc.StringUtil; import mircoders.storage.DatabaseUploadedMedia; @@ -57,8 +58,7 @@ public class MediaHandlerImagesExtern extends MediaHandlerGeneric logger = new LoggerWrapper("Media.Images.Extern"); } - public void produce(Entity anImageEntity, Entity mediaTypeEnt) throws MirMediaException - { + public void produce(Entity anImageEntity, Entity mediaTypeEnt) throws MediaExc, MediaFailure { try { String date = anImageEntity.getValue("date"); String datePath = StringUtil.webdbDate2path(date); @@ -72,7 +72,7 @@ public class MediaHandlerImagesExtern extends MediaHandlerGeneric File iconFile = new File(iconFilePath); if (!imageFile.exists()) { - throw new MirMediaException("error in MediaHandlerImagesExtern.produce(): " + filePath + " does not exist!"); + throw new MediaExc("error in MediaHandlerImagesExtern.produce(): " + filePath + " does not exist!"); } else { ImageProcessor processor = new ImageProcessor(imageFile, "JPEG"); @@ -101,13 +101,12 @@ public class MediaHandlerImagesExtern extends MediaHandlerGeneric catch(Throwable t) { logger.error("MediaHandlerImagesExtern.produce: " + t.getMessage()); t.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE)); - throw new MirMediaException(t.getMessage()); + throw new MediaFailure(t.getMessage(), t); } } - public InputStream getIcon(Entity anImageEntity) throws MirMediaException - { + public InputStream getIcon(Entity anImageEntity) throws MediaExc, MediaFailure { try { Entity mediaType = DatabaseUploadedMedia.getInstance().getMediaType( anImageEntity); @@ -121,7 +120,7 @@ public class MediaHandlerImagesExtern extends MediaHandlerGeneric return new FileInputStream(new File(filePath)); } catch (Throwable t) { - throw new MirMediaException(t.getMessage()); + throw new MediaFailure(t); } } diff --git a/source/mircoders/media/MediaHandlerMp3.java b/source/mircoders/media/MediaHandlerMp3.java index 582556af..2d4bbaed 100755 --- a/source/mircoders/media/MediaHandlerMp3.java +++ b/source/mircoders/media/MediaHandlerMp3.java @@ -36,7 +36,8 @@ import java.io.StringReader; import mir.entity.Entity; import mir.log.LoggerWrapper; import mir.media.MirMedia; -import mir.media.MirMediaException; +import mir.media.MediaExc; +import mir.media.MediaFailure; import mir.misc.FileUtil; import mir.misc.StringUtil; import freemarker.template.SimpleHash; @@ -66,7 +67,7 @@ import freemarker.template.SimpleList; * * @see mir.media.MirMedia * @author mh - * @version $Id: MediaHandlerMp3.java,v 1.12 2003/03/05 19:23:16 idfx Exp $ + * @version $Id: MediaHandlerMp3.java,v 1.13 2003/03/09 03:53:11 zapata Exp $ */ public class MediaHandlerMp3 extends MediaHandlerAudio implements MirMedia @@ -77,7 +78,7 @@ public class MediaHandlerMp3 extends MediaHandlerAudio implements MirMedia logger = new LoggerWrapper("Media.Audio.Mp3"); } - public void produce(Entity ent, Entity mediaTypeEnt) throws MirMediaException { + public void produce(Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure { // first check if the file exists super.produce(ent, mediaTypeEnt); @@ -100,7 +101,8 @@ public class MediaHandlerMp3 extends MediaHandlerAudio implements MirMedia } catch (Throwable e) { logger.error("MediaHandlerMp3.produce: " + e.toString()); - throw new MirMediaException(e.toString()); + + throw new MediaFailure(e); } } diff --git a/source/mircoders/media/MediaHandlerRealAudio.java b/source/mircoders/media/MediaHandlerRealAudio.java index 9d1cf606..4c3cc6fe 100755 --- a/source/mircoders/media/MediaHandlerRealAudio.java +++ b/source/mircoders/media/MediaHandlerRealAudio.java @@ -36,7 +36,8 @@ import java.io.StringReader; import mir.entity.Entity; import mir.log.LoggerWrapper; import mir.media.MirMedia; -import mir.media.MirMediaException; +import mir.media.MediaExc; +import mir.media.MediaFailure; import mir.misc.FileUtil; import mir.misc.StringUtil; import freemarker.template.SimpleHash; @@ -52,7 +53,7 @@ import freemarker.template.SimpleList; * @see mir.media.MediaHandlerGeneric * @see mir.media.MirMedia * @author john , mh - * @version $Id: MediaHandlerRealAudio.java,v 1.16 2003/03/05 19:23:16 idfx Exp $ + * @version $Id: MediaHandlerRealAudio.java,v 1.17 2003/03/09 03:53:11 zapata Exp $ */ @@ -62,8 +63,7 @@ public class MediaHandlerRealAudio extends MediaHandlerAudio implements MirMedia logger = new LoggerWrapper("Media.Audio.Real"); } - public void produce (Entity ent, Entity mediaTypeEnt ) - throws MirMediaException { + public void produce (Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure { // first see if the file exists super.produce(ent, mediaTypeEnt); @@ -83,7 +83,7 @@ public class MediaHandlerRealAudio extends MediaHandlerAudio implements MirMedia } catch (Throwable e) { logger.error("MediaHandlerRealAudio.produce: " + e.toString()); - throw new MirMediaException(e.toString()); + throw new MediaFailure(e); } } diff --git a/source/mircoders/media/MediaHandlerRealVideo.java b/source/mircoders/media/MediaHandlerRealVideo.java index 65fec96c..ec78572b 100755 --- a/source/mircoders/media/MediaHandlerRealVideo.java +++ b/source/mircoders/media/MediaHandlerRealVideo.java @@ -37,7 +37,8 @@ import java.io.StringReader; import mir.entity.Entity; import mir.log.LoggerWrapper; import mir.media.MirMedia; -import mir.media.MirMediaException; +import mir.media.MediaExc; +import mir.media.MediaFailure; import mir.misc.FileUtil; import mir.misc.StringUtil; import freemarker.template.SimpleHash; @@ -53,7 +54,7 @@ import freemarker.template.SimpleList; * @see mir.media.MediaHandlerGeneric * @see mir.media.MirMedia * @author john , mh - * @version $Id: MediaHandlerRealVideo.java,v 1.16 2003/03/05 19:23:16 idfx Exp $ + * @version $Id: MediaHandlerRealVideo.java,v 1.17 2003/03/09 03:53:11 zapata Exp $ */ @@ -65,9 +66,7 @@ public class MediaHandlerRealVideo extends MediaHandlerVideo implements MirMedia logger = new LoggerWrapper("Media.Video.Real"); } - public void produce (Entity ent, Entity mediaTypeEnt ) - throws MirMediaException { - + public void produce (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure { // first see if the file exists super.produce(ent, mediaTypeEnt); @@ -84,15 +83,14 @@ public class MediaHandlerRealVideo extends MediaHandlerVideo implements MirMedia FileUtil.write(super.getStoragePath()+File.separator+RealMediaFile, new StringReader(RealMediaPointer), "US-ASCII"); } - catch (Exception e) { + catch (Throwable e) { logger.error("MediaHandlerRealVideo.produce: " + e.toString()); - throw new MirMediaException(e.toString()); + throw new MediaFailure(e); } } - public SimpleList getURL(Entity ent, Entity mediaTypeEnt) - { + public SimpleList getURL(Entity ent, Entity mediaTypeEnt) { SimpleList theList = new SimpleList(); //String stringSize = ent.getValue("size"); @@ -114,18 +112,15 @@ public class MediaHandlerRealVideo extends MediaHandlerVideo implements MirMedia } - public String getStoragePath() - { + public String getStoragePath() { return configuration.getString("Producer.RealMedia.Path"); } - public String getDescr(Entity mediaType) - { + public String getDescr(Entity mediaType) { return "RealMedia"; } - public String getPublishHost() - { + public String getPublishHost() { return StringUtil.removeSlash(configuration.getString("Producer.RealMedia.Host")); } diff --git a/source/mircoders/media/MediaRequest.java b/source/mircoders/media/MediaRequest.java index 829e8d9f..6d94e772 100755 --- a/source/mircoders/media/MediaRequest.java +++ b/source/mircoders/media/MediaRequest.java @@ -1,294 +1,292 @@ -/* - * Copyright (C) 2001, 2002 The Mir-coders group - * - * This file is part of Mir. - * - * Mir is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Mir is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Mir; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with the com.oreilly.servlet library, any library - * licensed under the Apache Software License, The Sun (tm) Java Advanced - * Imaging library (JAI), The Sun JIMI library (or with modified versions of - * the above that use the same license as the above), and distribute linked - * combinations including the two. You must obey the GNU General Public - * License in all respects for all of the code used other than the above - * mentioned libraries. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If you do - * not wish to do so, delete this exception statement from your version. - */ - -package mircoders.media; - -import java.util.GregorianCalendar; -import java.util.Iterator; -import java.util.Map; - -import javax.servlet.ServletContext; - -import mir.config.MirPropertiesConfiguration; -import mir.entity.Entity; -import mir.entity.EntityList; -import mir.log.LoggerWrapper; -import mir.media.MediaHelper; -import mir.media.MirMedia; -import mir.media.MirMediaException; -import mir.misc.FileHandler; -import mir.misc.FileHandlerException; -import mir.misc.FileHandlerUserException; -import mir.misc.StringUtil; -import mir.storage.Database; -import mir.storage.StorageObjectExc; -import mir.storage.StorageObjectFailure; -import mircoders.storage.DatabaseMediaType; - -import com.oreilly.servlet.multipart.FilePart; - - -/* - * MediaRequest.java - - * Takes an HTTPServletRequest from a mutltipart form and finds the files - * uploaded via the com.oreilly.servlet.multipart package. Finally the - * appropriate media objects are set. - * - * @author mh - * @version $Id: MediaRequest.java,v 1.16 2003/03/05 19:23:16 idfx Exp $ - * - */ - -public class MediaRequest implements FileHandler -{ - private String _user; - private EntityList _returnList = new EntityList(); - private boolean _publish; - private LoggerWrapper logger; - - public MediaRequest(String user, boolean publish) { - _user = user; - _publish = publish; - logger = new LoggerWrapper("Media.Request"); - } - - public EntityList getEntityList() { - return _returnList; - } - - /* - * parses the files in the uploaded media and creates media Entity's out of - * them. Produces them if the "produce" argument is true. The "publish" - * parameter determines if it should publish per default in the case where no - * is_published parameter (from the upload form) is supplied. (for backwards - * compatibility.) - */ - public void setFile(FilePart filePart, int fileNum, Map mediaValues) - throws FileHandlerException, FileHandlerUserException { - - String mediaId=null; - MirMedia mediaHandler; - Database mediaStorage = null; - - try { - String fileName = filePart.getFileName(); - - //get the content-type from what the client browser - //sends us. (the "Oreilly method") - String contentType = filePart.getContentType(); - - //theLog.printInfo("FROM BROWSER: "+contentType); - - //if the client browser sent us unknown (text/plain is default) - //or if we got application/octet-stream, it's possible that - //the browser is in error, better check against the file extension - if (contentType.equals("text/plain") || - contentType.equals("application/octet-stream")) { - /** - * Fallback to finding the mime-type through the standard ServletApi - * ServletContext getMimeType() method. - * - * This is a way to get the content-type via the .extension, - * we could maybe use a magic method as an additional method of - * figuring out the content-type, by looking at the header (first - * few bytes) of the file. (like the file(1) command). We could - * also call the "file" command through Runtime. This is an - * option that I almost prefer as it is already implemented and - * exists with an up-to-date map on most modern Unix like systems. - * I haven't found a really nice implementation of the magic method - * in pure java yet. - * - * The first method we try thought is the "Oreilly method". It - * relies on the content-type that the client browser sends and - * that sometimes is application-octet stream with - * broken/mis-configured browsers. - * - * The map file we use for the extensions is the standard web-app - * deployment descriptor file (web.xml). See Mir's web.xml or see - * your Servlet containers (most likely Tomcat) documentation. - * So if you support a new media type you have to make sure that - * it is in this file -mh - */ - ServletContext ctx = MirPropertiesConfiguration.getContext(); - contentType = ctx.getMimeType(fileName); - if (contentType==null) - contentType = "text/plain"; // rfc1867 says this is the default - } - //theLog.printInfo("CONTENT TYPE IS: "+contentType); - - if (contentType.equals("text/plain") || - contentType.equals("application/octet-stream")) { - _throwBadContentType(fileName, contentType); - } - - // call the routines that escape html - for (Iterator i=mediaValues.keySet().iterator(); i.hasNext(); ){ - String k=(String)i.next(); - String v=(String)mediaValues.get(k); - - if (k.equals("description")) { - String tmp = StringUtil.deleteForbiddenTags(v); - mediaValues.put(k,StringUtil.deleteHTMLTableTags(tmp)); - } else { - //we don't want people fucking with the author/title, etc.. - mediaValues.put(k,StringUtil.removeHTMLTags(v)); - } - - } - - String mediaTitle = (String)mediaValues.get("media_title"+fileNum); - if ( (mediaTitle == null) || (mediaTitle.length() == 0)) { - // uncomment the next line and comment out the exception throw - // if you'd rather just assign missing media titles automatically - // mediaTitle="media item "+fileNum; - throw new FileHandlerUserException("Missing field: media title "+mediaTitle+fileNum); - } - - // TODO: need to add all the extra fields that can be present in the - // admin upload form. -mh - mediaValues.put("title", mediaTitle); - mediaValues.put("date", StringUtil.date2webdbDate( - new GregorianCalendar())); - mediaValues.put("to_publisher", _user); - //mediaValues.put("to_media_folder", "7"); // op media_folder - mediaValues.put("is_produced", "0"); - - // icky backwards compatibility code -mh - if (_publish == true) { - mediaValues.put("is_published", "1"); - } else { - if (!mediaValues.containsKey("is_published")) - mediaValues.put("is_published", "0"); - } - - // @todo this should probably be moved to DatabaseMediaType -mh - String[] cTypeSplit = StringUtil.split(contentType, "/"); - String wc = " mime_type LIKE '"+cTypeSplit[0]+"%'"; - - DatabaseMediaType mediaTypeStor = DatabaseMediaType.getInstance(); - EntityList mediaTypesList = mediaTypeStor.selectByWhereClause(wc); - - String mediaTypeId = null; - - //if we didn't find an entry matching the - //content-type int the table. - if (mediaTypesList.size() == 0) { - _throwBadContentType(fileName, contentType); - } - - Entity mediaType = null; - Entity mediaType2 = null; - - // find out if we an exact content-type match if so take it. - // otherwise try to match majortype/* - // @todo this should probably be moved to DatabaseMediaType -mh - for(int j=0;jimplements abstract DB connection to the content_x_media SQL table * * @author RK, mir-coders group - * @version $Id: DatabaseContentToMedia.java,v 1.15 2003/03/06 05:40:40 zapata Exp $ + * @version $Id: DatabaseContentToMedia.java,v 1.16 2003/03/09 03:53:12 zapata Exp $ * */ @@ -56,25 +56,25 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ private static DatabaseContentToMedia instance; - // the following *has* to be sychronized cause this static method - // could get preemted and we could end up with 2 instances of DatabaseFoo. - // see the "Singletons with needles and thread" article at JavaWorld -mh - public synchronized static DatabaseContentToMedia getInstance() throws - StorageObjectFailure { + public static DatabaseContentToMedia getInstance() { if (instance == null) { - instance = new DatabaseContentToMedia(); - instance.myselfDatabase = instance; + synchronized (DatabaseContentToMedia.class) { + if (instance == null) { + instance = new DatabaseContentToMedia(); + instance.myselfDatabase = instance; + } + } } return instance; } - private DatabaseContentToMedia() throws StorageObjectFailure { + private DatabaseContentToMedia() { super(); + logger = new LoggerWrapper("Database.ContentToMedia"); hasTimestamp = false; theTable = "content_x_media"; - theEntityClass = mir.entity.GenericEntity.class; } diff --git a/source/mircoders/storage/DatabaseContentToTopics.java b/source/mircoders/storage/DatabaseContentToTopics.java index d01861ca..3dc31160 100755 --- a/source/mircoders/storage/DatabaseContentToTopics.java +++ b/source/mircoders/storage/DatabaseContentToTopics.java @@ -1,320 +1,318 @@ -/* - * Copyright (C) 2001, 2002 The Mir-coders group - * - * This file is part of Mir. - * - * Mir is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Mir is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Mir; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with the com.oreilly.servlet library, any library - * licensed under the Apache Software License, The Sun (tm) Java Advanced - * Imaging library (JAI), The Sun JIMI library (or with modified versions of - * the above that use the same license as the above), and distribute linked - * combinations including the two. You must obey the GNU General Public - * License in all respects for all of the code used other than the above - * mentioned libraries. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If you do - * not wish to do so, delete this exception statement from your version. - */ - -package mircoders.storage; - -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; - -import mir.entity.EntityList; -import mir.log.LoggerWrapper; -import mir.storage.Database; -import mir.storage.StorageObject; -import mir.storage.StorageObjectFailure; -import mircoders.entity.EntityContent; -import mircoders.entity.EntityTopics; - -/** - * This class implements the 1-n-relation between - * content and topic - * - */ - -public class DatabaseContentToTopics extends Database implements StorageObject{ - - private static DatabaseContentToTopics instance; - - // the following *has* to be sychronized cause this static method - // could get preemted and we could end up with 2 instances of DatabaseFoo. - // see the "Singletons with needles and thread" article at JavaWorld -mh - public synchronized static DatabaseContentToTopics getInstance() - throws StorageObjectFailure { - if (instance == null) { - instance = new DatabaseContentToTopics(); - instance.myselfDatabase = instance; - } - return instance; - } - - private DatabaseContentToTopics() throws StorageObjectFailure { - super(); - - logger = new LoggerWrapper("Database.ContentToTopics"); - - hasTimestamp = false; - theTable="content_x_topic"; - try { this.theEntityClass = Class.forName("mir.entity.GenericEntity"); } - catch (Exception e) { throw new StorageObjectFailure(e); } - - } - - /** - * This class return an EntityList of Topics - * @param EntityContent content - * @returns EntityList - */ - public EntityList getTopics(EntityContent content) { - EntityList returnList=null; - if (content != null) { - // get all to_topic from content_x_topic - String id = content.getId(); - String subselect = "id in (select topic_id from " + theTable + " where content_id=" + id+")"; - - try { - returnList = DatabaseTopics.getInstance().selectByWhereClause(subselect,-1); - } - catch (Exception e) { - logger.error("-- get topics failed " + e.toString()); - } - } - return returnList; - } - - /** - * Returns a ArrayList of Integer-Objects from a content-id. - * @returns ArrayList - */ - public ArrayList getTopicsOfContent(String contentId) - throws StorageObjectFailure { - ArrayList returnList = new ArrayList(); - - if (contentId != null) { - String sql = "select topic_id from " + theTable + " where content_id=" + contentId; - Connection con=null;Statement stmt=null; - try { - con = getPooledCon(); - // should be a preparedStatement because is faster - stmt = con.createStatement(); - ResultSet rs = executeSql(stmt,sql); - if(rs!=null){ - while(rs.next()){ - returnList.add(new Integer(rs.getInt("topic_id"))); - } - } - } - catch (Exception e) { - logger.error("DatabaseContentToTopics.getTopicsOfContent: " + e.getMessage()); - } - finally { - freeConnection(con,stmt); - } - } - return returnList; - } - - /** - * Set new topics - */ - public void setTopics(String contentId, String[] topicId) - throws StorageObjectFailure { - if (contentId == null){ - return; - } - if (topicId==null || topicId[0]==null) { - return; - } - //first check which topics this article has - Collection hasTopics = getTopicsOfContent(contentId); - Collection toSet = new ArrayList(); - Collection toDelete = new ArrayList(); - - if(hasTopics!=null && hasTopics.size()>0){ - //now we check if there are new topics and copy them to an array. - for(int i = 0; i< topicId.length;i++){ - boolean set=false; - int whichTopic = 0; - for(Iterator it=hasTopics.iterator();it.hasNext();){ - Integer topic = (Integer)it.next(); - if(topicId[i].equals(topic.toString())){ - set=true; - } else { - whichTopic = i; - } - } - if(set==false){ - toSet.add(topicId[i]); - logger.debug("to set: "+ topicId[i]); - } - } - //now we check if we have to delete topics - for(Iterator it=hasTopics.iterator();it.hasNext();){ - boolean delete=true; - int whichTopic = 0; - Integer topic = (Integer)it.next(); - for(int i = 0; i< topicId.length;i++){ - if(topicId[i].equals(topic.toString())){ - delete=false; - } else { - whichTopic = i; - } - } - if(delete==true){ - toDelete.add(topic.toString()); - logger.debug("to delete: "+ topic.toString()); - } - } - } else { - //all the topics has to be set, so we copy all to the array - for (int i = 0; i < topicId.length; i++){ - toSet.add(topicId[i]); - } - } - - //first delete all row with content_id=contentId - String sql = "delete from "+ theTable +" where content_id=" + contentId - + " and topic_id in ("; - boolean first=false; - for(Iterator it = toDelete.iterator(); it.hasNext();){ - if(first==false){ - first=true; - } else { - sql+=","; - } - sql+= (String)it.next(); - } - sql+=")"; - Connection con=null;Statement stmt=null; - try { - con = getPooledCon(); - // should be a preparedStatement because is faster - stmt = con.createStatement(); - int rs = executeUpdate(stmt,sql); - } catch (Exception e) { - logger.error("-- deleting topics failed"); - } finally { - freeConnection(con,stmt); - } - - //now insert - //first delete all row with content_id=contentId - for (Iterator it = toSet.iterator(); it.hasNext();) { - sql = "insert into "+ theTable +" (content_id,topic_id) values (" - + contentId + "," + (String)it.next() + ")"; - try { - con = getPooledCon(); - // should be a preparedStatement because is faster - stmt = con.createStatement(); - int rs = executeUpdate(stmt,sql); - } - catch (Exception e) { - logger.error("-- set topics failed -- insert laenge topicId" + topicId.length); - } finally { - freeConnection(con,stmt); - } - } - } - - public void deleteByContentId(String contentId) - throws StorageObjectFailure { - if (contentId == null) { - //theLog.printDebugInfo("-- delete topics failed -- no content id"); - return; - } - //delete all row with content_id=contentId - String sql = "delete from "+ theTable +" where content_id=" + contentId; - - Connection con=null;Statement stmt=null; - try { - con = getPooledCon(); - // should be a preparedStatement because is faster - stmt = con.createStatement(); - ResultSet rs = executeSql(stmt,sql); - } catch (Exception e) { - //theLog.printDebugInfo("-- delete topics failed "); - } finally { - freeConnection(con,stmt); - } - } - - public void deleteByTopicId(String topicId) - throws StorageObjectFailure { - if (topicId == null) { - //theLog.printDebugInfo("-- delete topics failed -- no topic id"); - return; - } - //delete all row with content_id=contentId - String sql = "delete from "+ theTable +" where topic_id=" + topicId; - - Connection con=null;Statement stmt=null; - try { - con = getPooledCon(); - // should be a preparedStatement because is faster - stmt = con.createStatement(); - ResultSet rs = executeSql(stmt,sql); - } - catch (Exception e) { - logger.error("-- delete topics failed "); - } - finally { - freeConnection(con,stmt); - } - } - - - public EntityList getContent(EntityTopics topic) - throws StorageObjectFailure { - EntityList returnList=null; - if (topic != null) { - String id = topic.getId(); - String select = "select content_id from " + theTable + " where topic_id=" + id; - - // execute select statement - Connection con=null;Statement stmt=null; - try { - con = getPooledCon(); - // should be a preparedStatement because is faster - stmt = con.createStatement(); - ResultSet rs = executeSql(stmt,select); - if (rs!=null) { - String topicSelect= "id IN ("; - boolean first=true; - while (rs.next()) { - if (first==false) topicSelect+=","; - topicSelect += rs.getString(1); - first=false; - } - topicSelect+=")"; - if (first==false) - returnList = DatabaseContent.getInstance().selectByWhereClause(topicSelect,-1); - } - } - catch (Exception e) { - logger.error("-- get contetn failed"); - } - finally { freeConnection(con,stmt);} - } - return returnList; - } -} +/* + * Copyright (C) 2001, 2002 The Mir-coders group + * + * This file is part of Mir. + * + * Mir is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Mir is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Mir; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, The Mir-coders gives permission to link + * the code of this program with the com.oreilly.servlet library, any library + * licensed under the Apache Software License, The Sun (tm) Java Advanced + * Imaging library (JAI), The Sun JIMI library (or with modified versions of + * the above that use the same license as the above), and distribute linked + * combinations including the two. You must obey the GNU General Public + * License in all respects for all of the code used other than the above + * mentioned libraries. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If you do + * not wish to do so, delete this exception statement from your version. + */ + +package mircoders.storage; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +import mir.entity.EntityList; +import mir.log.LoggerWrapper; +import mir.storage.Database; +import mir.storage.StorageObject; +import mir.storage.StorageObjectFailure; +import mircoders.entity.EntityContent; +import mircoders.entity.EntityTopics; + +/** + * This class implements the 1-n-relation between + * content and topic + * + */ + +public class DatabaseContentToTopics extends Database implements StorageObject{ + + private static DatabaseContentToTopics instance; + + public static DatabaseContentToTopics getInstance() { + if (instance == null) { + synchronized (DatabaseContentToTopics.class) { + if (instance == null) { + instance = new DatabaseContentToTopics(); + instance.myselfDatabase = instance; + } + } + } + return instance; + } + + private DatabaseContentToTopics() { + super(); + + logger = new LoggerWrapper("Database.ContentToTopics"); + + hasTimestamp = false; + theTable="content_x_topic"; + theEntityClass = mir.entity.GenericEntity.class; + } + + /** + * This class return an EntityList of Topics + * @param EntityContent content + * @returns EntityList + */ + public EntityList getTopics(EntityContent content) { + EntityList returnList=null; + if (content != null) { + // get all to_topic from content_x_topic + String id = content.getId(); + String subselect = "id in (select topic_id from " + theTable + " where content_id=" + id+")"; + + try { + returnList = DatabaseTopics.getInstance().selectByWhereClause(subselect,-1); + } + catch (Exception e) { + logger.error("-- get topics failed " + e.toString()); + } + } + return returnList; + } + + /** + * Returns a ArrayList of Integer-Objects from a content-id. + * @returns ArrayList + */ + public ArrayList getTopicsOfContent(String contentId) + throws StorageObjectFailure { + ArrayList returnList = new ArrayList(); + + if (contentId != null) { + String sql = "select topic_id from " + theTable + " where content_id=" + contentId; + Connection con=null;Statement stmt=null; + try { + con = getPooledCon(); + // should be a preparedStatement because is faster + stmt = con.createStatement(); + ResultSet rs = executeSql(stmt,sql); + if(rs!=null){ + while(rs.next()){ + returnList.add(new Integer(rs.getInt("topic_id"))); + } + } + } + catch (Exception e) { + logger.error("DatabaseContentToTopics.getTopicsOfContent: " + e.getMessage()); + } + finally { + freeConnection(con,stmt); + } + } + return returnList; + } + + /** + * Set new topics + */ + public void setTopics(String contentId, String[] topicId) + throws StorageObjectFailure { + if (contentId == null){ + return; + } + if (topicId==null || topicId[0]==null) { + return; + } + //first check which topics this article has + Collection hasTopics = getTopicsOfContent(contentId); + Collection toSet = new ArrayList(); + Collection toDelete = new ArrayList(); + + if(hasTopics!=null && hasTopics.size()>0){ + //now we check if there are new topics and copy them to an array. + for(int i = 0; i< topicId.length;i++){ + boolean set=false; + int whichTopic = 0; + for(Iterator it=hasTopics.iterator();it.hasNext();){ + Integer topic = (Integer)it.next(); + if(topicId[i].equals(topic.toString())){ + set=true; + } else { + whichTopic = i; + } + } + if(set==false){ + toSet.add(topicId[i]); + logger.debug("to set: "+ topicId[i]); + } + } + //now we check if we have to delete topics + for(Iterator it=hasTopics.iterator();it.hasNext();){ + boolean delete=true; + int whichTopic = 0; + Integer topic = (Integer)it.next(); + for(int i = 0; i< topicId.length;i++){ + if(topicId[i].equals(topic.toString())){ + delete=false; + } else { + whichTopic = i; + } + } + if(delete==true){ + toDelete.add(topic.toString()); + logger.debug("to delete: "+ topic.toString()); + } + } + } else { + //all the topics has to be set, so we copy all to the array + for (int i = 0; i < topicId.length; i++){ + toSet.add(topicId[i]); + } + } + + //first delete all row with content_id=contentId + String sql = "delete from "+ theTable +" where content_id=" + contentId + + " and topic_id in ("; + boolean first=false; + for(Iterator it = toDelete.iterator(); it.hasNext();){ + if(first==false){ + first=true; + } else { + sql+=","; + } + sql+= (String)it.next(); + } + sql+=")"; + Connection con=null;Statement stmt=null; + try { + con = getPooledCon(); + // should be a preparedStatement because is faster + stmt = con.createStatement(); + int rs = executeUpdate(stmt,sql); + } catch (Exception e) { + logger.error("-- deleting topics failed"); + } finally { + freeConnection(con,stmt); + } + + //now insert + //first delete all row with content_id=contentId + for (Iterator it = toSet.iterator(); it.hasNext();) { + sql = "insert into "+ theTable +" (content_id,topic_id) values (" + + contentId + "," + (String)it.next() + ")"; + try { + con = getPooledCon(); + // should be a preparedStatement because is faster + stmt = con.createStatement(); + int rs = executeUpdate(stmt,sql); + } + catch (Exception e) { + logger.error("-- set topics failed -- insert laenge topicId" + topicId.length); + } finally { + freeConnection(con,stmt); + } + } + } + + public void deleteByContentId(String contentId) + throws StorageObjectFailure { + if (contentId == null) { + //theLog.printDebugInfo("-- delete topics failed -- no content id"); + return; + } + //delete all row with content_id=contentId + String sql = "delete from "+ theTable +" where content_id=" + contentId; + + Connection con=null;Statement stmt=null; + try { + con = getPooledCon(); + // should be a preparedStatement because is faster + stmt = con.createStatement(); + ResultSet rs = executeSql(stmt,sql); + } catch (Exception e) { + //theLog.printDebugInfo("-- delete topics failed "); + } finally { + freeConnection(con,stmt); + } + } + + public void deleteByTopicId(String topicId) + throws StorageObjectFailure { + if (topicId == null) { + //theLog.printDebugInfo("-- delete topics failed -- no topic id"); + return; + } + //delete all row with content_id=contentId + String sql = "delete from "+ theTable +" where topic_id=" + topicId; + + Connection con=null;Statement stmt=null; + try { + con = getPooledCon(); + // should be a preparedStatement because is faster + stmt = con.createStatement(); + ResultSet rs = executeSql(stmt,sql); + } + catch (Exception e) { + logger.error("-- delete topics failed "); + } + finally { + freeConnection(con,stmt); + } + } + + + public EntityList getContent(EntityTopics topic) + throws StorageObjectFailure { + EntityList returnList=null; + if (topic != null) { + String id = topic.getId(); + String select = "select content_id from " + theTable + " where topic_id=" + id; + + // execute select statement + Connection con=null;Statement stmt=null; + try { + con = getPooledCon(); + // should be a preparedStatement because is faster + stmt = con.createStatement(); + ResultSet rs = executeSql(stmt,select); + if (rs!=null) { + String topicSelect= "id IN ("; + boolean first=true; + while (rs.next()) { + if (first==false) topicSelect+=","; + topicSelect += rs.getString(1); + first=false; + } + topicSelect+=")"; + if (first==false) + returnList = DatabaseContent.getInstance().selectByWhereClause(topicSelect,-1); + } + } + catch (Exception e) { + logger.error("-- get contetn failed"); + } + finally { freeConnection(con,stmt);} + } + return returnList; + } +} diff --git a/source/mircoders/storage/DatabaseFeature.java b/source/mircoders/storage/DatabaseFeature.java deleted file mode 100755 index 4efeb22c..00000000 --- a/source/mircoders/storage/DatabaseFeature.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2001, 2002 The Mir-coders group - * - * This file is part of Mir. - * - * Mir is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Mir is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Mir; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with the com.oreilly.servlet library, any library - * licensed under the Apache Software License, The Sun (tm) Java Advanced - * Imaging library (JAI), The Sun JIMI library (or with modified versions of - * the above that use the same license as the above), and distribute linked - * combinations including the two. You must obey the GNU General Public - * License in all respects for all of the code used other than the above - * mentioned libraries. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If you do - * not wish to do so, delete this exception statement from your version. - */ - -package mircoders.storage; - -import mir.log.LoggerWrapper; -import mir.storage.Database; -import mir.storage.StorageObject; -import mir.storage.StorageObjectFailure; -import freemarker.template.SimpleList; - -/** - * Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle - * - * - */ - -public class DatabaseFeature extends Database implements StorageObject{ - - private static DatabaseFeature instance; - - // the following *has* to be sychronized cause this static method - // could get preemted and we could end up with 2 instances of DatabaseFoo.. - // see the "Singletons with needles and thread" article at JavaWorld -mh - public synchronized static DatabaseFeature getInstance() throws - StorageObjectFailure { - if (instance == null) { - instance = new DatabaseFeature(); - instance.myselfDatabase = instance; - } - return instance; - } - - private DatabaseFeature() throws StorageObjectFailure { - super(); - logger = new LoggerWrapper("Database.Feature"); - - hasTimestamp = false; - theTable = "feature"; - - theEntityClass = mircoders.entity.EntityFeature.class; - } - - public SimpleList getPopupData() throws StorageObjectFailure { - return getPopupData("title", true); - } - -} diff --git a/source/mircoders/storage/DatabaseUploadedMedia.java b/source/mircoders/storage/DatabaseUploadedMedia.java index 81fdd650..edf5d966 100755 --- a/source/mircoders/storage/DatabaseUploadedMedia.java +++ b/source/mircoders/storage/DatabaseUploadedMedia.java @@ -1,98 +1,87 @@ -/* - * Copyright (C) 2001, 2002 The Mir-coders group - * - * This file is part of Mir. - * - * Mir is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Mir is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Mir; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with the com.oreilly.servlet library, any library - * licensed under the Apache Software License, The Sun (tm) Java Advanced - * Imaging library (JAI), The Sun JIMI library (or with modified versions of - * the above that use the same license as the above), and distribute linked - * combinations including the two. You must obey the GNU General Public - * License in all respects for all of the code used other than the above - * mentioned libraries. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If you do - * not wish to do so, delete this exception statement from your version. - */ - -package mircoders.storage; - -import mir.entity.Entity; -import mir.entity.EntityRelation; -import mir.log.LoggerWrapper; -import mir.storage.Database; -import mir.storage.StorageObject; -import mir.storage.StorageObjectFailure; - -/** - * this class implements the access to the content-table - * - * - */ - -public class DatabaseUploadedMedia extends Database implements StorageObject { - - private static DatabaseUploadedMedia instance; - private static EntityRelation relationMediaType; - - // Contructors / Singleton - - public static DatabaseUploadedMedia getInstance() - throws StorageObjectFailure { - - if (instance == null ) { - instance = new DatabaseUploadedMedia(); - instance.myselfDatabase = instance; - } - return instance; - } - - private DatabaseUploadedMedia() - throws StorageObjectFailure { - - super(); - - logger = new LoggerWrapper("Database.UploadedMedia"); - - this.theTable="uploaded_media"; - this.theCoreTable="media"; - relationMediaType = new EntityRelation("to_media_type", "id", DatabaseMediaType.getInstance(), EntityRelation.TO_ONE); - try { this.theEntityClass = Class.forName("mircoders.entity.EntityUploadedMedia"); } - catch (Exception e) { throw new StorageObjectFailure(e); } - } - - // methods - - - /** - * returns the media_type that belongs to the media item (via entityrelation) - * where db-flag is_published is true - */ - public Entity getMediaType(Entity ent) throws StorageObjectFailure { - Entity type=null; - try { - type = relationMediaType.getOne(ent); - } - catch (Throwable t) { - logger.error("DatabaseUploadedMedia :: failed to get media_type: " + t.getMessage()); - - throw new StorageObjectFailure("DatabaseUploadedMedia :: failed to get media_type", t); - } - return type; - } - -} +/* + * Copyright (C) 2001, 2002 The Mir-coders group + * + * This file is part of Mir. + * + * Mir is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Mir is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Mir; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, The Mir-coders gives permission to link + * the code of this program with the com.oreilly.servlet library, any library + * licensed under the Apache Software License, The Sun (tm) Java Advanced + * Imaging library (JAI), The Sun JIMI library (or with modified versions of + * the above that use the same license as the above), and distribute linked + * combinations including the two. You must obey the GNU General Public + * License in all respects for all of the code used other than the above + * mentioned libraries. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If you do + * not wish to do so, delete this exception statement from your version. + */ + +package mircoders.storage; + +import mir.entity.Entity; +import mir.entity.EntityRelation; +import mir.log.LoggerWrapper; +import mir.storage.Database; +import mir.storage.StorageObject; +import mir.storage.StorageObjectFailure; + +public class DatabaseUploadedMedia extends Database implements StorageObject { + private static DatabaseUploadedMedia instance; + private static EntityRelation relationMediaType; + + public static DatabaseUploadedMedia getInstance() { + if (instance == null ) { + synchronized(DatabaseUploadedMedia.class) { + if (instance == null ) { + instance = new DatabaseUploadedMedia(); + instance.myselfDatabase = instance; + } + } + } + + return instance; + } + + private DatabaseUploadedMedia() { + super(); + + logger = new LoggerWrapper("Database.UploadedMedia"); + + theTable="uploaded_media"; + theCoreTable="media"; + relationMediaType = new EntityRelation("to_media_type", "id", DatabaseMediaType.getInstance(), EntityRelation.TO_ONE); + theEntityClass = mircoders.entity.EntityUploadedMedia.class; + } + + + /** + * returns the media_type that belongs to the media item (via entityrelation) + * where db-flag is_published is true + */ + public Entity getMediaType(Entity ent) throws StorageObjectFailure { + Entity type=null; + try { + type = relationMediaType.getOne(ent); + } + catch (Throwable t) { + logger.error("DatabaseUploadedMedia :: failed to get media_type: " + t.getMessage()); + + throw new StorageObjectFailure("DatabaseUploadedMedia :: failed to get media_type", t); + } + return type; + } + +} diff --git a/templates/admin/feature.template b/templates/admin/feature.template deleted file mode 100755 index 92f993e1..00000000 --- a/templates/admin/feature.template +++ /dev/null @@ -1,65 +0,0 @@ - - - ${config["Mir.Name"]} | ${lang("feature.htmltitle")} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
${lang("feature.title")}: - - -
${lang("feature.filename")}: - -
${lang("feature.abstract")}: - -
${lang("feature.link")}: - -
- - - -
- - - diff --git a/templates/admin/featurelist.template b/templates/admin/featurelist.template deleted file mode 100755 index 2ee4c107..00000000 --- a/templates/admin/featurelist.template +++ /dev/null @@ -1,70 +0,0 @@ - - - ${config["Mir.Name"]} | ${lang("featurelist.htmltitle")} - - - - - - - - - - - - - - - - - - - class="list1"class="list2" > - - - - - - - - - - - - - -
${lang("feature.published")}${lang("feature.title")}${lang("feature.filename")}${lang("feature.link")}${lang("feature.abstract")}
X ${entry.title} ${entry.filename} ${entry.main_url} ${entry.description}  ${lang("delete")} - | ${lang("edit")}
-
${data.count} ${lang("records")} / - ${lang("show_from_to", data.from, data.to)}
-
 ${lang("back")}
- -

- -

- - - - - - - - - - - - - - - - -

${lang("no_matches_found")}

- - - - - - - - -- 2.11.0