/**
* 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 {
}
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;
}
* 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 $
*
*/
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();
}
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();
}
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
--- /dev/null
+/*
+ * 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;
+
+import multex.Exc;
+
+public class MediaExc extends Exc {
+ public MediaExc(String aMessage) {
+ super(aMessage);
+ }
+}
--- /dev/null
+/*
+ * 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;
+
+import multex.Failure;
+
+public class MediaFailure extends Failure {
+
+ public MediaFailure(String msg,Throwable cause) {
+ super(msg,cause);
+ }
+
+ public MediaFailure(Throwable aCause) {
+ this (aCause.getMessage(), aCause);
+ }
+}
*/
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");
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);
}
}
}
-
+
* 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
* <p>
* 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....).
* <p>
* 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
* <p>
* Most media handlers should just extend MediaHandlerGeneric (i.e inherit from
* ) and just override the things that need to be specific. see MediaHandlerAudio
- *
+ *
* @author <mh@nadir.org>, 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{
* @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
* @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
* @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
* @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
* @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()
* @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
* @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
* @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
*/
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.
*/
+++ /dev/null
-/*
- * 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 -
- *
- * @version $Id: MirMediaException.java,v 1.8 2003/01/25 17:45:17 idfx Exp $
- * @author mh
- *
- */
-
-public final class MirMediaException extends Exception {
- public MirMediaException(String msg) {
- super(msg);
- }
-}
-
+++ /dev/null
-/*
- * 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;
- }
-}
-
-/*
- * 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 <mh@nadir.org>
- * @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;
-
-}
-
-
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two. You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries. If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so. If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mir.misc;\r
+\r
+import java.util.Map;\r
+import multex.Exc;\r
+import multex.Failure;\r
+\r
+import com.oreilly.servlet.multipart.FilePart;\r
+\r
+\r
+/**\r
+ * Interface that classes wishing to be used as a callback on FileParts for the\r
+ * WebdbMultipartRequest class should implement this interface.\r
+ *\r
+ * @author mh <mh@nadir.org>\r
+ * @version $Id: FileHandler.java,v 1.5 2003/03/09 03:53:10 zapata Exp $\r
+ * @see mir.misc.WebdbMultipartRequest\r
+ *\r
+ */\r
+\r
+public interface FileHandler {\r
+\r
+ public void setFile (FilePart filePart, int fileNum, Map Params) throws FileHandlerExc, FileHandlerFailure;\r
+\r
+ public static class FileHandlerExc extends Exc {\r
+ public FileHandlerExc(String aMessage) {\r
+\r
+ super(aMessage);\r
+ }\r
+ }\r
+\r
+ public static class FileHandlerFailure extends Failure {\r
+\r
+ public FileHandlerFailure(String msg, Throwable cause) {\r
+ super(msg, cause);\r
+ }\r
+\r
+ public FileHandlerFailure(Throwable aCause) {\r
+ this(aCause.getMessage(), aCause);\r
+ }\r
+ }\r
+\r
+}\r
+\r
+\r
+\r
+\r
+++ /dev/null
-/*
- * 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;
-
-
-/*
- *
- * @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;
- }
-}
-
+++ /dev/null
-/*
- * 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);
- }
-}
-
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;
}
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;
}
}
}
- private void _evaluateRequest() throws FileHandlerException,
- FileHandlerUserException, IOException {
+ private void _evaluateRequest() throws FileHandler.FileHandlerExc,
+ FileHandler.FileHandlerFailure, IOException {
Part part;
int i = 1;
-/*
- * 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);
- }
-
-}
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two. You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries. If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so. If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mir.module;\r
+\r
+import java.sql.SQLException;\r
+import java.util.Map;\r
+\r
+import mir.entity.Entity;\r
+import mir.entity.EntityList;\r
+import mir.storage.StorageObject;\r
+import mir.storage.StorageObjectExc;\r
+import mir.storage.StorageObjectFailure;\r
+import freemarker.template.SimpleHash;\r
+\r
+\r
+/**\r
+ * This class provides the base functionality for the derived Module-Classes.\r
+ * These classes should provide methods to make more or less complex actions\r
+ * on Database and Entity classes. The modules are used by ServletModules.\r
+ * Future possibility could be access via Applications.\r
+ *\r
+ * Abstrakte Klasse, von denen die Modules die Basisfunktionalit?t erben.\r
+ * Die Moduleschicht dient dazu, Funktionalitaeten zur Verf?gung zu stellen,\r
+ * die von mehreren ServletModulen verwendet werden.\r
+ *\r
+ */\r
+\r
+public class AbstractModule {\r
+ protected StorageObject theStorage;\r
+\r
+ public void setStorage(StorageObject storage) {\r
+ this.theStorage = storage;\r
+ }\r
+\r
+ /**\r
+ * Liefert das Standard-StorageObject zur?ck, mit dem das Module assoziiert ist.\r
+ * @return Standard-StorageObject\r
+ */\r
+ public StorageObject getStorageObject () {\r
+ return theStorage;\r
+ }\r
+\r
+ /**\r
+ * Holt eine Entity anhand der Id via StorageObject\r
+ * @param String der Entity\r
+ * @return Entity\r
+ */\r
+ public Entity getById (String id) throws ModuleExc, ModuleFailure {\r
+ try {\r
+ if (theStorage == null)\r
+ throw new ModuleExc("AbstractModule.getById: No StorageObject set!");\r
+ Entity entity = (Entity)theStorage.selectById(id);\r
+\r
+ if (entity == null)\r
+ throw new ModuleExc("AbstractModule.getById: No object for id = " + id);\r
+ else\r
+ return entity;\r
+ }\r
+ catch (Throwable e) {\r
+ throw new ModuleFailure(e);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Holt eine EntityListe anhand des WhereClause via StorageObject\r
+ * @param String whereclause\r
+ * @param offset - ab welchem Datensatz die gematchten Entities zurueckgeliefert werden\r
+ * @return EntityList Liste der gematchten Datens?tze\r
+ */\r
+ public EntityList getByWhereClause (String whereClause, int offset) throws ModuleExc, ModuleFailure {\r
+ try {\r
+ if (theStorage == null)\r
+ throw new ModuleExc("AbstractModule.getByWhereClause: No StorageObject set!");\r
+\r
+ return theStorage.selectByWhereClause(whereClause, offset);\r
+ }\r
+ catch (Throwable e) {\r
+ throw new ModuleFailure(e);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Holt eine EntityListe anhand des WhereClause aus dem StorageObject\r
+ * @param String where WhereClause\r
+ * @param String order Sortierreihenfolge\r
+ * @param offset - ab welchem Datensatz die gematchten Entities zurueckgeliefert werden\r
+ * @return EntityList Liste der gematchten Datens?tze\r
+ */\r
+ public EntityList getByWhereClause (String where, String order, int offset) throws ModuleExc, ModuleFailure {\r
+ try {\r
+ if (theStorage==null)\r
+ throw new ModuleExc("AbstractModule.getByWhereClause: No StorageObject set!");\r
+\r
+ return theStorage.selectByWhereClause(where, order, offset);\r
+ }\r
+ catch (Throwable e) {\r
+ throw new ModuleFailure(e);\r
+ }\r
+ }\r
+ /**\r
+ * Executes a where clause on the StorageObject with order criteria\r
+ * fetching from offset the number of limit objects\r
+ *\r
+ * @param String where\r
+ * @param String order\r
+ * @param int offset\r
+ * @param int limit\r
+ * @return EntityList\r
+ */\r
+\r
+ public EntityList getByWhereClause(String where, String order, int offset, int limit) throws ModuleExc, ModuleFailure {\r
+ try {\r
+ if (theStorage==null)\r
+ throw new ModuleExc("AbstractModule.getByWhereClause: StorageObject not set!");\r
+\r
+ return theStorage.selectByWhereClause(where, order, offset, limit);\r
+ }\r
+ catch (Throwable e) {\r
+ throw new ModuleFailure(e);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Holt eine EntityListe anhand des Wertes aValue von Feld aField aus dem StorageObject\r
+ * @param String aField - Feldname im StorageObject\r
+ * @param String aValue - Wert in Feld im StorageObject\r
+ * @param offset - ab welchem Datensatz die gematchten Entities zurueckgeliefert werden\r
+ * @return EntityList Liste der gematchten Datens?tze\r
+ */\r
+ public EntityList getByFieldValue (String aField, String aValue, int offset) throws ModuleExc, ModuleFailure {\r
+ String whereClause;\r
+ whereClause = aField + " like '%" + aValue + "%'";\r
+ return getByWhereClause(whereClause, offset);\r
+ }\r
+\r
+ /**\r
+ * * Standardfunktion, um einen Datensatz via StorageObject einzuf?gen\r
+ * @param theValues Hash mit Spalte/Wert-Paaren\r
+ * @return Id des eingef?gten Objekts\r
+ * @exception ModuleExc\r
+ * @exception ModuleFailure\r
+ */\r
+ public String add (Map theValues) throws ModuleExc, ModuleFailure {\r
+ try {\r
+ Entity theEntity = (Entity)theStorage.getEntityClass().newInstance();\r
+ theEntity.setStorage(theStorage);\r
+ theEntity.setValues(theValues);\r
+ return theEntity.insert();\r
+ }\r
+ catch (Throwable e) {\r
+ throw new ModuleFailure(e);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Standardfunktion, um einen Datensatz via StorageObject zu aktualisieren\r
+ * @param theValues Hash mit Spalte/Wert-Paaren\r
+ * @return Id des eingef?gten Objekts\r
+ * @exception ModuleExc\r
+ * @exception ModuleFailure\r
+ */\r
+ public String set (Map theValues) throws ModuleExc, ModuleFailure {\r
+ try {\r
+ Entity theEntity = theStorage.selectById((String)theValues.get("id"));\r
+ if (theEntity == null)\r
+ throw new ModuleExc("No object found with id " + theValues.get("id"));\r
+ theEntity.setValues(theValues);\r
+ theEntity.update();\r
+ return theEntity.getId();\r
+ }\r
+ catch (Throwable e) {\r
+ throw new ModuleFailure(e);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Deletes a record using an id\r
+ * @param idParam\r
+ * @exception ModuleExc\r
+ * @exception ModuleFailure\r
+ */\r
+ public void deleteById (String idParam) throws ModuleExc, ModuleFailure {\r
+ try {\r
+ theStorage.delete(idParam);\r
+ }\r
+ catch (Throwable e) {\r
+ throw new ModuleFailure(e);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Liefert den Lookuptable aller Objekte des StorageObjects\r
+ * @return freemarker.template.SimpleHash\r
+ */\r
+ public SimpleHash getHashData() {\r
+ return theStorage.getHashData();\r
+ }\r
+\r
+ /**\r
+ * returns the number of rows\r
+ */\r
+ public int getSize(String where) throws ModuleExc, ModuleFailure {\r
+ try {\r
+ return theStorage.getSize(where);\r
+ }\r
+ catch (Throwable e) {\r
+ throw new ModuleFailure(e);\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*
+ * 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 multex.Exc;
+
+public class ModuleExc extends Exc {
+ public ModuleExc(String aMessage) {
+ super(aMessage);
+ }
+}
+++ /dev/null
-/*
- * 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;
-
-
-/*
- * ServletModuleException -
- * wird vom ServletModule geschmissen</b>
- *
- *
- * @version 5.7.199
- * @author RK
- */
-
-public final class ModuleException extends Exception
-{
- public ModuleException(String msg) {
- super(msg);
- }
-}
-
--- /dev/null
+/*
+ * 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 multex.Failure;
+
+public class ModuleFailure extends Failure {
+
+ public ModuleFailure(String msg,Throwable cause) {
+ super(msg,cause);
+ }
+
+ public ModuleFailure(Throwable aCause) {
+ this (aCause.getMessage(), aCause);
+ }
+}
+++ /dev/null
-/*
- * 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;
-
-
-/*
- * ServletModuleException -
- * wird vom ServletModule geschmissen</b>
- *
- *
- * @version 5.7.199
- * @author RK
- */
-
-public final class ModuleUserException extends Exception
-{
- public ModuleUserException(String msg) {
- super(msg);
- }
-}
-
public ProducerFailure(Throwable aCause) {
this (aCause.getMessage(), aCause);
}
-}
\ No newline at end of file
+}
/**
*
* @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 $
*/
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;
}
definition.addDBDateField("creationdate", "webdb_create");\r
result.addMapping( "breakingNews", DatabaseBreaking.getInstance(), definition);\r
\r
- result.addMapping( "feature", DatabaseFeature.getInstance(), new EntityAdapterDefinition());\r
result.addMapping( "imageType", DatabaseImageType.getInstance(), new EntityAdapterDefinition());\r
result.addMapping( "language", DatabaseLanguage.getInstance(), new EntityAdapterDefinition());\r
result.addMapping( "mediaFolder", DatabaseMediafolder.getInstance(), new EntityAdapterDefinition());\r
import mir.entity.Entity;\r
import mir.log.LoggerWrapper;\r
import mir.media.MirMedia;\r
-import mir.media.MirMediaException;\r
+import mir.media.MediaExc;\r
+import mir.media.MediaFailure;\r
import mir.misc.FileUtil;\r
import mir.misc.StringUtil;\r
import freemarker.template.SimpleList;\r
*\r
* @see mir.media.MirMedia\r
* @author mh <mh@nadir.org>\r
- * @version $Id: MediaHandlerGeneric.java,v 1.16 2003/03/06 05:40:39 zapata Exp $\r
+ * @version $Id: MediaHandlerGeneric.java,v 1.17 2003/03/09 03:53:11 zapata Exp $\r
*/\r
\r
public class MediaHandlerGeneric implements MirMedia\r
logger = new LoggerWrapper("Media.Generic");\r
}\r
\r
- public void set (InputStream in, Entity ent, Entity mediaTypeEnt ) throws MirMediaException {\r
+ public void set (InputStream in, Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure {\r
String ext = mediaTypeEnt.getValue("name");\r
String mediaFname = ent.getId() + "." + ext;\r
String date = ent.getValue("date");\r
}\r
catch (Throwable e) {\r
logger.error("MediaHandlerGeneric.set: " + e.toString());\r
- throw new MirMediaException(e.toString());\r
+ throw new MediaFailure(e);\r
}\r
}\r
\r
- public void produce (Entity ent, Entity mediaTypeEnt )\r
- throws MirMediaException {\r
-\r
+ public void produce (Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure {\r
//check first if the media file exist since produced\r
//location is also the storage location\r
+\r
String date = ent.getValue("date");\r
String datePath = StringUtil.webdbDate2path(date);\r
String relPath = datePath+ent.getId()+"."+mediaTypeEnt.getValue("name");\r
String fname = getStoragePath()+relPath;\r
if(! new File(fname).exists())\r
- throw new MirMediaException("error in MirMedia.produce(): "+relPath+\r
- " does not exist!");\r
+ throw new MediaExc("error in MirMedia.produce(): " + relPath + " does not exist!");\r
}\r
\r
- public InputStream getMedia (Entity ent, Entity mediaTypeEnt)\r
- throws MirMediaException {\r
+ public InputStream getMedia (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure {\r
String publishPath = ent.getValue("publish_path");\r
String fname = getStoragePath()+publishPath;\r
File f = new File(fname);\r
if(! f.exists())\r
- throw new MirMediaException("error in MirMedia.getMedia(): "+fname+\r
- " does not exist!");\r
- FileInputStream in;\r
+ throw new MediaExc("error in MirMedia.getMedia(): " + fname + " does not exist!");\r
+\r
+ FileInputStream inputStream;\r
try {\r
- in = new FileInputStream(f);\r
- } catch (IOException e) {\r
- throw new MirMediaException("getMedia(): "+e.toString());\r
+ inputStream = new FileInputStream(f);\r
}\r
- return in;\r
+ catch (Throwable e) {\r
+ throw new MediaFailure("MediaHandlerGeneric.getMedia(): " + e.toString(), e);\r
+ }\r
+\r
+ return inputStream;\r
}\r
\r
- public InputStream getIcon (Entity ent) throws MirMediaException {\r
+ public InputStream getIcon (Entity ent) throws MediaExc, MediaFailure {\r
return null;\r
}\r
\r
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;
*
* @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 $
*/
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");
}
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";
}
import mir.config.MirPropertiesConfiguration;\r
import mir.entity.Entity;\r
import mir.log.LoggerWrapper;\r
-import mir.media.MirMediaException;\r
+import mir.media.MediaExc;\r
+import mir.media.MediaFailure;\r
import mir.misc.StringUtil;\r
import mircoders.storage.DatabaseUploadedMedia;\r
\r
logger = new LoggerWrapper("Media.Images.Extern");\r
}\r
\r
- public void produce(Entity anImageEntity, Entity mediaTypeEnt) throws MirMediaException\r
- {\r
+ public void produce(Entity anImageEntity, Entity mediaTypeEnt) throws MediaExc, MediaFailure {\r
try {\r
String date = anImageEntity.getValue("date");\r
String datePath = StringUtil.webdbDate2path(date);\r
File iconFile = new File(iconFilePath);\r
\r
if (!imageFile.exists()) {\r
- throw new MirMediaException("error in MediaHandlerImagesExtern.produce(): " + filePath + " does not exist!");\r
+ throw new MediaExc("error in MediaHandlerImagesExtern.produce(): " + filePath + " does not exist!");\r
}\r
else {\r
ImageProcessor processor = new ImageProcessor(imageFile, "JPEG");\r
catch(Throwable t) {\r
logger.error("MediaHandlerImagesExtern.produce: " + t.getMessage());\r
t.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));\r
- throw new MirMediaException(t.getMessage());\r
+ throw new MediaFailure(t.getMessage(), t);\r
}\r
}\r
\r
\r
- public InputStream getIcon(Entity anImageEntity) throws MirMediaException\r
- {\r
+ public InputStream getIcon(Entity anImageEntity) throws MediaExc, MediaFailure {\r
try {\r
Entity mediaType = DatabaseUploadedMedia.getInstance().getMediaType(\r
anImageEntity);\r
return new FileInputStream(new File(filePath));\r
}\r
catch (Throwable t) {\r
- throw new MirMediaException(t.getMessage());\r
+ throw new MediaFailure(t);\r
}\r
}\r
\r
import mir.entity.Entity;\r
import mir.log.LoggerWrapper;\r
import mir.media.MirMedia;\r
-import mir.media.MirMediaException;\r
+import mir.media.MediaExc;\r
+import mir.media.MediaFailure;\r
import mir.misc.FileUtil;\r
import mir.misc.StringUtil;\r
import freemarker.template.SimpleHash;\r
*\r
* @see mir.media.MirMedia\r
* @author mh <mh@nadir.org>\r
- * @version $Id: MediaHandlerMp3.java,v 1.12 2003/03/05 19:23:16 idfx Exp $\r
+ * @version $Id: MediaHandlerMp3.java,v 1.13 2003/03/09 03:53:11 zapata Exp $\r
*/\r
\r
public class MediaHandlerMp3 extends MediaHandlerAudio implements MirMedia\r
logger = new LoggerWrapper("Media.Audio.Mp3");\r
}\r
\r
- public void produce(Entity ent, Entity mediaTypeEnt) throws MirMediaException {\r
+ public void produce(Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure {\r
\r
// first check if the file exists\r
super.produce(ent, mediaTypeEnt);\r
}\r
catch (Throwable e) {\r
logger.error("MediaHandlerMp3.produce: " + e.toString());\r
- throw new MirMediaException(e.toString());\r
+\r
+ throw new MediaFailure(e);\r
}\r
}\r
\r
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;
* @see mir.media.MediaHandlerGeneric
* @see mir.media.MirMedia
* @author john <john@manifestor.org>, mh <heckmann@hbe.ca>
- * @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 $
*/
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);
}
catch (Throwable e) {
logger.error("MediaHandlerRealAudio.produce: " + e.toString());
- throw new MirMediaException(e.toString());
+ throw new MediaFailure(e);
}
}
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;
* @see mir.media.MediaHandlerGeneric
* @see mir.media.MirMedia
* @author john <john@manifestor.org>, mh <mh@nadir.org>
- * @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 $
*/
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);
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");
}
- 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"));
}
-/*
- * 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;j<mediaTypesList.size();j++) {
- if(contentType.equals(
- mediaTypesList.elementAt(j).getValue("mime_type")))
- mediaType = mediaTypesList.elementAt(j);
- else if ((mediaTypesList.elementAt(j).getValue("mime_type")).equals(
- cTypeSplit[0]+"/*") )
- mediaType2= mediaTypesList.elementAt(j);
- }
-
- if ( (mediaType == null) && (mediaType2 == null) ) {
- _throwBadContentType(fileName, contentType);
- } else if( (mediaType == null) && (mediaType2 != null) ) {
- mediaType = mediaType2;
- }
-
- //get the class names from the media_type table.
- mediaTypeId = mediaType.getId();
- // ############### @todo: merge these and the getURL call into one
- // getURL helper call that just takes the Entity as a parameter
- // along with media_type
- try {
- mediaHandler = MediaHelper.getHandler(mediaType);
- mediaStorage = MediaHelper.getStorage(mediaType,
- "mircoders.storage.Database");
- }
- catch (MirMediaException e) {
- throw new FileHandlerException (e.getMessage());
- }
- mediaValues.put("to_media_type",mediaTypeId);
-
- //load the classes via reflection
- String MediaId;
- Entity mediaEnt = null;
- try {
- mediaEnt = (Entity)mediaStorage.getEntityClass().newInstance();
- }
- catch (Exception e) {
- throw new FileHandlerException("Error in MediaRequest: "+e.toString());
- }
-
- mediaEnt.setStorage(mediaStorage);
- mediaEnt.setValues(mediaValues);
- mediaId = mediaEnt.insert();
-
- //save and store the media data/metadata
- try {
- mediaHandler.set(filePart.getInputStream(), mediaEnt, mediaType);
- }
- catch (MirMediaException e) {
- throw new FileHandlerException(e.getMessage());
- }
-
- _returnList.add(mediaEnt);
- }
- catch (StorageObjectFailure e) {
- // first try to delete it.. don't catch exception as we've already..
- try {
- mediaStorage.delete(mediaId);
- }
- catch (Exception e2) {
- }
- throw new FileHandlerException("error in MediaRequest: "+e.toString());
- }
- catch (StorageObjectExc e) {
- throw new FileHandlerException("error in MediaRequest: "+e.toString());
- } //end try/catch block
-
- } // method setFile()
-
- private void _throwBadContentType (String fileName, String contentType)
- throws FileHandlerUserException {
-
- //theLog.printDebugInfo("Wrong file type uploaded!: " + fileName+" "
- // +contentType);
- throw new FileHandlerUserException("The file you uploaded is of the "
- +"following mime-type: "+contentType
- +", we do not support this mime-type. "
- +"Error One or more files of unrecognized type. Sorry");
- }
-
-}
-
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two. You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries. If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so. If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.media;\r
+\r
+import java.util.GregorianCalendar;\r
+import java.util.Iterator;\r
+import java.util.Map;\r
+\r
+import javax.servlet.ServletContext;\r
+\r
+import mir.config.MirPropertiesConfiguration;\r
+import mir.entity.Entity;\r
+import mir.entity.EntityList;\r
+import mir.log.LoggerWrapper;\r
+import mir.media.MediaHelper;\r
+import mir.media.MirMedia;\r
+\r
+import mir.misc.FileHandler;\r
+import mir.misc.StringUtil;\r
+import mir.storage.Database;\r
+import mir.storage.StorageObjectExc;\r
+import mir.storage.StorageObjectFailure;\r
+import mircoders.storage.DatabaseMediaType;\r
+\r
+import com.oreilly.servlet.multipart.FilePart;\r
+\r
+\r
+/*\r
+ * MediaRequest.java -\r
+ * Takes an HTTPServletRequest from a mutltipart form and finds the files\r
+ * uploaded via the com.oreilly.servlet.multipart package. Finally the\r
+ * appropriate media objects are set.\r
+ *\r
+ * @author mh\r
+ * @version $Id: MediaRequest.java,v 1.17 2003/03/09 03:53:11 zapata Exp $\r
+ *\r
+ */\r
+\r
+public class MediaRequest implements FileHandler\r
+{\r
+ private String _user;\r
+ private EntityList _returnList = new EntityList();\r
+ private boolean _publish;\r
+ private LoggerWrapper logger;\r
+\r
+ public MediaRequest(String user, boolean publish) {\r
+ _user = user;\r
+ _publish = publish;\r
+ logger = new LoggerWrapper("Media.Request");\r
+ }\r
+\r
+ public EntityList getEntityList() {\r
+ return _returnList;\r
+ }\r
+\r
+ /*\r
+ * parses the files in the uploaded media and creates media Entity's out of\r
+ * them. Produces them if the "produce" argument is true. The "publish"\r
+ * parameter determines if it should publish per default in the case where no\r
+ * is_published parameter (from the upload form) is supplied. (for backwards\r
+ * compatibility.)\r
+ */\r
+ public void setFile(FilePart filePart, int fileNum, Map mediaValues) throws FileHandlerExc, FileHandlerFailure {\r
+\r
+ String mediaId=null;\r
+ MirMedia mediaHandler;\r
+ Database mediaStorage = null;\r
+\r
+ try {\r
+ String fileName = filePart.getFileName();\r
+\r
+ //get the content-type from what the client browser\r
+ //sends us. (the "Oreilly method")\r
+ String contentType = filePart.getContentType();\r
+\r
+ //theLog.printInfo("FROM BROWSER: "+contentType);\r
+\r
+ //if the client browser sent us unknown (text/plain is default)\r
+ //or if we got application/octet-stream, it's possible that\r
+ //the browser is in error, better check against the file extension\r
+ if (contentType.equals("text/plain") ||\r
+ contentType.equals("application/octet-stream")) {\r
+ /**\r
+ * Fallback to finding the mime-type through the standard ServletApi\r
+ * ServletContext getMimeType() method.\r
+ *\r
+ * This is a way to get the content-type via the .extension,\r
+ * we could maybe use a magic method as an additional method of\r
+ * figuring out the content-type, by looking at the header (first\r
+ * few bytes) of the file. (like the file(1) command). We could\r
+ * also call the "file" command through Runtime. This is an\r
+ * option that I almost prefer as it is already implemented and\r
+ * exists with an up-to-date map on most modern Unix like systems.\r
+ * I haven't found a really nice implementation of the magic method\r
+ * in pure java yet.\r
+ *\r
+ * The first method we try thought is the "Oreilly method". It\r
+ * relies on the content-type that the client browser sends and\r
+ * that sometimes is application-octet stream with\r
+ * broken/mis-configured browsers.\r
+ *\r
+ * The map file we use for the extensions is the standard web-app\r
+ * deployment descriptor file (web.xml). See Mir's web.xml or see\r
+ * your Servlet containers (most likely Tomcat) documentation.\r
+ * So if you support a new media type you have to make sure that\r
+ * it is in this file -mh\r
+ */\r
+ ServletContext ctx = MirPropertiesConfiguration.getContext();\r
+ contentType = ctx.getMimeType(fileName);\r
+ if (contentType==null)\r
+ contentType = "text/plain"; // rfc1867 says this is the default\r
+ }\r
+ //theLog.printInfo("CONTENT TYPE IS: "+contentType);\r
+\r
+ if (contentType.equals("text/plain") ||\r
+ contentType.equals("application/octet-stream")) {\r
+ _throwBadContentType(fileName, contentType);\r
+ }\r
+\r
+ // call the routines that escape html\r
+ for (Iterator i=mediaValues.keySet().iterator(); i.hasNext(); ){\r
+ String k=(String)i.next();\r
+ String v=(String)mediaValues.get(k);\r
+\r
+ if (k.equals("description")) {\r
+ String tmp = StringUtil.deleteForbiddenTags(v);\r
+ mediaValues.put(k,StringUtil.deleteHTMLTableTags(tmp));\r
+ } else {\r
+ //we don't want people fucking with the author/title, etc..\r
+ mediaValues.put(k,StringUtil.removeHTMLTags(v));\r
+ }\r
+\r
+ }\r
+\r
+ String mediaTitle = (String)mediaValues.get("media_title"+fileNum);\r
+ if ( (mediaTitle == null) || (mediaTitle.length() == 0)) {\r
+ // uncomment the next line and comment out the exception throw\r
+ // if you'd rather just assign missing media titles automatically\r
+ // mediaTitle="media item "+fileNum;\r
+// throw new FileHandlerUserException("Missing field: media title "+mediaTitle+fileNum);\r
+ }\r
+\r
+ // TODO: need to add all the extra fields that can be present in the\r
+ // admin upload form. -mh\r
+ mediaValues.put("title", mediaTitle);\r
+ mediaValues.put("date", StringUtil.date2webdbDate(\r
+ new GregorianCalendar()));\r
+ mediaValues.put("to_publisher", _user);\r
+ //mediaValues.put("to_media_folder", "7"); // op media_folder\r
+ mediaValues.put("is_produced", "0");\r
+\r
+ // icky backwards compatibility code -mh\r
+ if (_publish == true) {\r
+ mediaValues.put("is_published", "1");\r
+ } else {\r
+ if (!mediaValues.containsKey("is_published"))\r
+ mediaValues.put("is_published", "0");\r
+ }\r
+\r
+ // @todo this should probably be moved to DatabaseMediaType -mh\r
+ String[] cTypeSplit = StringUtil.split(contentType, "/");\r
+ String wc = " mime_type LIKE '"+cTypeSplit[0]+"%'";\r
+\r
+ DatabaseMediaType mediaTypeStor = DatabaseMediaType.getInstance();\r
+ EntityList mediaTypesList = mediaTypeStor.selectByWhereClause(wc);\r
+\r
+ String mediaTypeId = null;\r
+\r
+ //if we didn't find an entry matching the\r
+ //content-type int the table.\r
+ if (mediaTypesList.size() == 0) {\r
+ _throwBadContentType(fileName, contentType);\r
+ }\r
+\r
+ Entity mediaType = null;\r
+ Entity mediaType2 = null;\r
+\r
+ // find out if we an exact content-type match if so take it.\r
+ // otherwise try to match majortype/*\r
+ // @todo this should probably be moved to DatabaseMediaType -mh\r
+ for(int j=0;j<mediaTypesList.size();j++) {\r
+ if(contentType.equals(\r
+ mediaTypesList.elementAt(j).getValue("mime_type")))\r
+ mediaType = mediaTypesList.elementAt(j);\r
+ else if ((mediaTypesList.elementAt(j).getValue("mime_type")).equals(\r
+ cTypeSplit[0]+"/*") )\r
+ mediaType2= mediaTypesList.elementAt(j);\r
+ }\r
+\r
+ if ( (mediaType == null) && (mediaType2 == null) ) {\r
+ _throwBadContentType(fileName, contentType);\r
+ } else if( (mediaType == null) && (mediaType2 != null) ) {\r
+ mediaType = mediaType2;\r
+ }\r
+\r
+ //get the class names from the media_type table.\r
+ mediaTypeId = mediaType.getId();\r
+ // ############### @todo: merge these and the getURL call into one\r
+ // getURL helper call that just takes the Entity as a parameter\r
+ // along with media_type\r
+ try {\r
+ mediaHandler = MediaHelper.getHandler(mediaType);\r
+ mediaStorage = MediaHelper.getStorage(mediaType, "mircoders.storage.Database");\r
+ }\r
+ catch (Throwable e) {\r
+ throw new FileHandlerFailure(e);\r
+ }\r
+ mediaValues.put("to_media_type",mediaTypeId);\r
+\r
+ //load the classes via reflection\r
+ String MediaId;\r
+ Entity mediaEnt = null;\r
+\r
+ try {\r
+ mediaEnt = (Entity)mediaStorage.getEntityClass().newInstance();\r
+ }\r
+ catch (Throwable e) {\r
+ throw new FileHandlerFailure("MediaRequest.setFile: "+e.toString(), e);\r
+ }\r
+\r
+ mediaEnt.setStorage(mediaStorage);\r
+ mediaEnt.setValues(mediaValues);\r
+ mediaId = mediaEnt.insert();\r
+\r
+ //save and store the media data/metadata\r
+ try {\r
+ mediaHandler.set(filePart.getInputStream(), mediaEnt, mediaType);\r
+ }\r
+ catch (Throwable e) {\r
+ throw new FileHandlerFailure("MediaRequest.setFile: "+e.toString(), e);\r
+ }\r
+\r
+ _returnList.add(mediaEnt);\r
+ }\r
+ catch (StorageObjectFailure e) {\r
+ // first try to delete it.. don't catch exception as we've already..\r
+ try {\r
+ mediaStorage.delete(mediaId);\r
+ }\r
+ catch (Exception e2) {\r
+ }\r
+ throw new FileHandlerFailure("MediaRequest.setFile: "+e.toString(), e);\r
+ }\r
+ catch (Throwable e) {\r
+ throw new FileHandlerFailure("MediaRequest.setFile: "+e.toString(), e);\r
+ } //end try/catch block\r
+\r
+ } // method setFile()\r
+\r
+ private void _throwBadContentType (String fileName, String contentType) throws FileHandlerExc, FileHandlerFailure {\r
+ try {\r
+ throw new UnsupportedMediaFormatExc(\r
+ "The file you uploaded is of the following mime-type: " + contentType +\r
+ ", we do not support this mime-type. "\r
+ + "Error One or more files of unrecognized type. Sorry");\r
+ }\r
+ catch (Throwable t) {\r
+ throw new FileHandlerFailure(t);\r
+ }\r
+ }\r
+\r
+}\r
+\r
--- /dev/null
+package mircoders.media;
+
+import mir.media.MediaExc;
+
+public class UnsupportedMediaFormatExc extends MediaExc {
+ public UnsupportedMediaFormatExc(String aMessage) {
+ super(aMessage);
+ }
+}
\ No newline at end of file
import mir.entity.Entity;
import mir.log.LoggerWrapper;
import mir.module.AbstractModule;
-import mir.module.ModuleException;
+import mir.module.ModuleExc;
+import mir.module.ModuleFailure;
import mir.storage.StorageObject;
import mir.storage.StorageObjectExc;
import mir.storage.StorageObjectFailure;
{
static LoggerWrapper logger = new LoggerWrapper("Module.Comment");
- // Contructor
public ModuleComment(StorageObject theStorage)
{
if (theStorage == null) logger.warn("StorageObject was null!");
this.theStorage = theStorage;
}
- // Methoden
- public SimpleList getCommentAsSimpleList() throws ModuleException {
+ public SimpleList getCommentAsSimpleList() throws ModuleExc, ModuleFailure {
try {
return ((DatabaseComment)theStorage).getPopupData();
}
- catch (StorageObjectFailure e) {
- throw new ModuleException(e.toString());
+ catch (Throwable e) {
+ throw new ModuleFailure(e);
}
}
- public void deleteById (String anId) throws ModuleException {
+ public void deleteById (String anId) throws ModuleExc, ModuleFailure {
try {
Entity theEntity = theStorage.selectById((String)anId);
if (theEntity != null)
super.deleteById(anId);
}
- catch (StorageObjectFailure e){
- throw new ModuleException(e.toString());
- } catch (StorageObjectExc e) {
- throw new ModuleException(e.toString());
+ catch (Throwable e) {
+ throw new ModuleFailure(e);
}
}
/**
- * setValues in the Entity and updates them on the StorageObject
+ *
+ * @param theValues
+ * @return
+ * @throws ModuleExc
+ * @throws ModuleFailure
*/
- public String set(Map theValues) throws ModuleException {
+
+ public String set(Map theValues) throws ModuleExc, ModuleFailure {
try {
Entity theEntity = theStorage.selectById((String)theValues.get("id"));
if (theEntity == null)
- throw new ModuleException("No Object in the database with id " + theValues.get("id"));
+ throw new ModuleExc("No Object in the database with id " + theValues.get("id"));
DatabaseContent.getInstance().setUnproduced("id=" + theEntity.getValue("to_media"));
theEntity.setValues(theValues);
theEntity.update();
return theEntity.getId();
}
- catch (StorageObjectFailure e){
- logger.error("ModuleComment.set: " + e.getMessage());
- e.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));
-
- throw new ModuleException(e.toString());
- } catch (StorageObjectExc e) {
- throw new ModuleException(e.toString());
+ catch (Throwable e) {
+ throw new ModuleFailure(e);
}
}
}
import mir.entity.EntityList;
import mir.log.LoggerWrapper;
import mir.module.AbstractModule;
-import mir.module.ModuleException;
+import mir.module.ModuleExc;
+import mir.module.ModuleFailure;
import mir.storage.StorageObject;
import mir.storage.StorageObjectFailure;
import mir.util.JDBCStringRoutines;
/*
* ContentObjekt -
*
- * @version $Id: ModuleContent.java,v 1.16 2003/03/05 19:23:16 idfx Exp $
+ * @version $Id: ModuleContent.java,v 1.17 2003/03/09 03:53:11 zapata Exp $
*
* @author RK, mir-coders
*
//
// various methods to retrieve content entities
- public EntityList getFeatures(int offset, int limit) throws ModuleException
- {
- return getContent("is_published=true AND to_article_type=2", "webdb_create desc",
- offset, limit);
- }
+// public EntityList getFeatures(int offset, int limit) throws ModuleExc, ModuleFailure {
+// return getContent("is_published=true AND to_article_type=2", "webdb_create desc",
+// offset, limit);
+// }
- public EntityList getNewsWire(int offset, int limit) throws ModuleException
- {
- return getContent("is_published=true AND to_article_type = 1",
- "webdb_create desc",offset,limit);
- }
+// public EntityList getNewsWire(int offset, int limit) throws ModuleExc, ModuleFailure {
+// return getContent("is_published=true AND to_article_type = 1",
+// "webdb_create desc",offset,limit);
+// }
- public EntityList getStartArticle() throws ModuleException
- {
- EntityList returnList = getContent("is_published=true AND to_article_type=4",
- "webdb_create desc",0,1);
+// public EntityList getStartArticle() throws ModuleExc, ModuleFailure {
+// EntityList returnList = getContent("is_published=true AND to_article_type=4",
+// "webdb_create desc",0,1);
//if no startspecial exists
- if (returnList==null || returnList.size()==0)
- returnList = getContent("is_published=true AND to_article_type=3",
- "webdb_create desc",0,1);
+// if (returnList==null || returnList.size()==0)
+// returnList = getContent("is_published=true AND to_article_type=3",
+// "webdb_create desc",0,1);
- return returnList;
- }
+// return returnList;
+// }
- public EntityList getContent(Map searchValues, boolean concat, int offset, EntityUsers user)
- throws ModuleException {
+/*
+ public EntityList getContent(Map searchValues, boolean concat, int offset, EntityUsers user) throws ModuleException {
try {
}
}
-
+*/
+/*
public EntityList getContentByField(String aField, String aValue, String orderBy, int offset,
EntityUsers user) throws ModuleException
{
return getContent(whereClause, orderBy, offset, user);
}
+
public EntityList getContent(String whereClause, String orderBy, int offset,
int limit, EntityUsers user) throws ModuleException {
}
catch (StorageObjectFailure e){ throw new ModuleException(e.toString()); }
}
+*/
- public EntityList getContent(String whereClause, String orderBy,int offset, int limit)
- throws ModuleException {
+ public EntityList getContent(String whereClause, String orderBy,int offset, int limit) throws ModuleExc, ModuleFailure {
try {
return theStorage.selectByWhereClause(whereClause, orderBy, offset, limit);
- } catch (StorageObjectFailure e){
- throw new ModuleException(e.toString());
+ }
+ catch (Throwable e){
+ throw new ModuleFailure(e);
}
}
-
+/*
public EntityList getContent(String whereClause, String orderBy, int offset, EntityUsers user)
throws ModuleException
{
throw new ModuleException(e.toString());
}
}
+*/
}
+++ /dev/null
-/*
- * 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.module;
-
-import mir.log.LoggerWrapper;
-import mir.module.AbstractModule;
-import mir.module.ModuleException;
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectFailure;
-import mircoders.storage.DatabaseFeature;
-import freemarker.template.SimpleList;
-/*
- * SchwerpunktObjekt -
- *
- *
- * @author RK
- */
-
-public class ModuleFeature extends AbstractModule
-{
- static LoggerWrapper logger = new LoggerWrapper("Module.Feature");
-
- public ModuleFeature(StorageObject theStorage) {
-
- this.theStorage = theStorage;
- }
-
- public SimpleList getSchwerpunktAsSimpleList() throws ModuleException {
- try {
- return ((DatabaseFeature)theStorage).getPopupData();
- }
- catch (StorageObjectFailure e) {
- throw new ModuleException(e.toString());
- }
- }
-}
-
import mir.log.LoggerWrapper;
import mir.module.AbstractModule;
-import mir.module.ModuleException;
+import mir.module.ModuleExc;
+import mir.module.ModuleFailure;
import mir.storage.StorageObject;
import mir.storage.StorageObjectFailure;
import mircoders.storage.DatabaseImages;
}
// Methoden
-
- public SimpleList getBilderAsSimpleList()
- throws ModuleException {
-
-// String sql = "select id, name from Bilder order by name";
+/*
+ public SimpleList getBilderAsSimpleList() throws ModuleExc, ModuleFailure {
try {
return ((DatabaseImages)theStorage).getPopupData();
- } catch (StorageObjectFailure e) {
+ }
+ catch (StorageObjectFailure e) {
throw new ModuleException(e.toString());
}
}
-
+*/
}
import mir.log.LoggerWrapper;
import mir.module.AbstractModule;
-import mir.module.ModuleException;
+import mir.module.ModuleExc;
+import mir.module.ModuleFailure;
import mir.storage.StorageObject;
import mircoders.storage.DatabaseMediafolder;
import freemarker.template.SimpleList;
// Kontruktor
- public ModuleMediafolder(StorageObject theStorage)
+ public ModuleMediafolder(StorageObject aStorage)
{
- if (theStorage == null) logger.warn("ModuleMediafolder: StorageObject was null!");
- this.theStorage = theStorage;
+ if (aStorage == null)
+ logger.warn("ModuleMediafolder: StorageObject was null!");
+
+ theStorage = aStorage;
}
// Methoden
- public SimpleList getPopupData() throws ModuleException {
+ public SimpleList getPopupData() throws ModuleExc, ModuleFailure {
try {
return ((DatabaseMediafolder)theStorage).getPopupData();
- } catch (Exception e) {
- throw new ModuleException(e.toString());
+ }
+ catch (Throwable e) {
+ throw new ModuleFailure(e);
}
}
+++ /dev/null
-/*
- * 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.module;
-
-import mir.log.LoggerWrapper;
-import mir.module.AbstractModule;
-import mir.module.ModuleException;
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectFailure;
-import mircoders.storage.DatabaseFeature;
-import freemarker.template.SimpleList;
-
-/*
- * Feature -
- *
- *
- * @author RK
- */
-
-public class ModuleSchwerpunkt extends AbstractModule
-{
- static LoggerWrapper logger = new LoggerWrapper("Module.Feature");
-
- public ModuleSchwerpunkt(StorageObject theStorage) {
-
- this.theStorage = theStorage;
- }
-
- public SimpleList getSchwerpunktAsSimpleList() throws ModuleException {
- try {
- return ((DatabaseFeature)theStorage).getPopupData();
- }
- catch (StorageObjectFailure e) {
- throw new ModuleException(e.toString());
- }
- }
-}
-
import mir.entity.EntityList;
import mir.log.LoggerWrapper;
import mir.module.AbstractModule;
-import mir.module.ModuleException;
+import mir.module.ModuleExc;
+import mir.module.ModuleFailure;
import mir.storage.StorageObject;
import mir.storage.StorageObjectExc;
import mir.storage.StorageObjectFailure;
this.theStorage = theStorage;
}
- public SimpleList getTopicsAsSimpleList() throws ModuleException {
+ public SimpleList getTopicsAsSimpleList() throws ModuleExc, ModuleFailure {
try {
return ((DatabaseTopics) theStorage).getPopupData();
}
- catch (StorageObjectFailure e) {
- throw new ModuleException(e.toString());
+ catch (Throwable e) {
+ throw new ModuleFailure(e);
}
}
* @return SimpleList of all Topics sorted by title
*
*/
- public EntityList getTopicsList() {
- EntityList returnList = null;
+ public EntityList getTopicsList() throws ModuleExc, ModuleFailure {
try {
- returnList = getByWhereClause("", "title", -1);
+ return getByWhereClause("", "title", -1);
}
- catch (Exception e) {
- logger.warn("ModuleTopics.getTopicsList: topics could not be fetched: " + e.getMessage());
+ catch (Throwable e) {
+ logger.error("ModuleTopics.getTopicsList: topics could not be fetched: " + e.getMessage());
+
+ throw new ModuleFailure("ModuleTopics.getTopicsList: topics could not be fetched: " + e.getMessage(), e);
}
- return returnList;
}
/**
* @return Id des eingef?gten Objekts
* @exception ModuleException
*/
- public String set(Map theValues) throws ModuleException {
+ public String set(Map theValues) throws ModuleExc, ModuleFailure {
try {
Entity theEntity = theStorage.selectById((String) theValues.get("id"));
if (theEntity == null) {
- throw new ModuleException("No topic with id " + theValues.get("id") + " found");
+ throw new ModuleExc("No topic with id " + theValues.get("id") + " found");
}
theEntity.setValues(theValues);
theEntity.update();
return theEntity.getId();
}
- catch (StorageObjectFailure e) {
- throw new ModuleException(e.toString());
- }
- catch (StorageObjectExc e) {
- throw new ModuleException(e.toString());
+ catch (Throwable e) {
+ throw new ModuleFailure(e);
}
}
import mir.entity.EntityList;\r
import mir.log.LoggerWrapper;\r
import mir.module.AbstractModule;\r
-import mir.module.ModuleException;\r
+import mir.module.ModuleExc;\r
+import mir.module.ModuleFailure;\r
import mir.storage.StorageObject;\r
import mir.util.JDBCStringRoutines;\r
import mircoders.entity.EntityUsers;\r
* @throws ModuleException\r
*/\r
\r
- public EntityUsers getUserForLogin(String user, String password) throws ModuleException\r
- {\r
+ public EntityUsers getUserForLogin(String user, String password) throws ModuleExc, ModuleFailure {\r
try {\r
String whereString =\r
"login='" + JDBCStringRoutines.escapeStringLiteral(user) + "' " +\r
return null;\r
}\r
catch (Throwable t) {\r
- throw new ModuleException(t.getMessage());\r
+ throw new ModuleFailure(t);\r
}\r
}\r
\r
- private Map digestPassword(Map aValues) throws ModuleException {\r
+ private Map digestPassword(Map aValues) throws ModuleExc, ModuleFailure {\r
Map result = aValues;\r
\r
try {\r
}\r
}\r
catch (Throwable t) {\r
- throw new ModuleException("ModuleUsers.add: " + t.getMessage());\r
+ throw new ModuleFailure("ModuleUsers.add: " + t.getMessage(), t);\r
}\r
\r
return result;\r
}\r
\r
- public String add (Map theValues) throws ModuleException {\r
- return super.add(digestPassword(theValues));\r
+ public String add (Map theValues) throws ModuleExc, ModuleFailure {\r
+ try {\r
+ return super.add(digestPassword(theValues));\r
+ }\r
+ catch (Throwable t) {\r
+ throw new ModuleFailure(t);\r
+ }\r
}\r
\r
/**\r
* @return Id des eingef?gten Objekts\r
* @exception ModuleException\r
*/\r
- public String set (Map theValues) throws ModuleException {\r
- return super.set(digestPassword(theValues));\r
+ public String set (Map theValues) throws ModuleExc, ModuleFailure {\r
+ try {\r
+ return super.set(digestPassword(theValues));\r
+ }\r
+ catch (Throwable t) {\r
+ throw new ModuleFailure(t);\r
+ }\r
}\r
-\r
}
\ No newline at end of file
import mir.entity.adapter.EntityIteratorAdapter;
import mir.log.LoggerWrapper;
import mir.misc.StringUtil;
-import mir.module.ModuleException;
+import mir.module.ModuleExc;
import mir.servlet.ServletModule;
import mir.servlet.ServletModuleExc;
import mir.servlet.ServletModuleFailure;
* ServletModuleContent -
* deliver html for the article admin form.
*
- * @version $Id: ServletModuleContent.java,v 1.41 2003/03/08 17:18:19 idfx Exp $
+ * @version $Id: ServletModuleContent.java,v 1.42 2003/03/09 03:53:11 zapata Exp $
* @author rk, mir-coders
*
*/
EntityContent entContent = (EntityContent)mainModule.getById(idParam);
entContent.attach(mediaIdParam);
}
- catch(ModuleException e) {
- logger.error("smod content :: attach :: could not get entityContent");
- }
- catch(StorageObjectFailure e) {
+ catch(Throwable e) {
logger.error("smod content :: attach :: could not get entityContent");
}
EntityContent entContent = (EntityContent)mainModule.getById(cidParam);
entContent.dettach(cidParam,midParam);
}
- catch(ModuleException e) {
- logger.error("smod content :: dettach :: could not get entityContent");
- }
- catch(StorageObjectFailure e) {
+ catch(Throwable e) {
logger.error("smod content :: dettach :: could not get entityContent");
}
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import org.apache.commons.net.smtp.SMTPClient;
+import org.apache.commons.net.smtp.SMTPReply;
+import org.apache.fop.apps.Driver;
+import org.apache.fop.apps.XSLTInputHandler;
+import org.apache.log.Hierarchy;
+import org.apache.log.Priority;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Hits;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.Searcher;
+
+import freemarker.template.SimpleHash;
+import freemarker.template.SimpleList;
+import freemarker.template.SimpleScalar;
+import freemarker.template.TemplateModelRoot;
+
import mir.entity.Entity;
import mir.entity.EntityList;
import mir.log.LoggerWrapper;
import mir.misc.FileHandler;
-import mir.misc.FileHandlerUserException;
import mir.misc.HTMLTemplateProcessor;
import mir.misc.StringUtil;
import mir.misc.WebdbMultipartRequest;
-import mir.module.ModuleException;
import mir.servlet.ServletModule;
import mir.servlet.ServletModuleExc;
import mir.servlet.ServletModuleFailure;
import mir.servlet.ServletModuleUserExc;
import mir.storage.StorageObjectFailure;
import mir.util.StringRoutines;
+import mir.util.ExceptionFunctions;
import mircoders.entity.EntityComment;
import mircoders.entity.EntityContent;
import mircoders.global.MirGlobal;
import mircoders.media.MediaRequest;
+import mircoders.media.UnsupportedMediaFormatExc;
import mircoders.module.ModuleComment;
import mircoders.module.ModuleContent;
import mircoders.module.ModuleImages;
import mircoders.storage.DatabaseLanguage;
import mircoders.storage.DatabaseTopics;
-import org.apache.commons.net.smtp.SMTPClient;
-import org.apache.commons.net.smtp.SMTPReply;
-import org.apache.fop.apps.Driver;
-import org.apache.fop.apps.XSLTInputHandler;
-import org.apache.log.Hierarchy;
-import org.apache.log.Priority;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Hits;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.Searcher;
-
-import freemarker.template.SimpleHash;
-import freemarker.template.SimpleList;
-import freemarker.template.SimpleScalar;
-import freemarker.template.TemplateModelRoot;
-
/*
* ServletModuleOpenIndy -
* is the open-access-servlet, which is responsible for
* open-postings to the newswire
*
* @author mir-coders group
- * @version $Id: ServletModuleOpenIndy.java,v 1.64 2003/03/08 17:18:19 idfx Exp $
+ * @version $Id: ServletModuleOpenIndy.java,v 1.65 2003/03/09 03:53:12 zapata Exp $
*
*/
public class ServletModuleOpenIndy extends ServletModule
{
- private String commentFormTemplate, commentFormDoneTemplate,
- commentFormDupeTemplate;
- private String postingFormTemplate, postingFormDoneTemplate,
- postingFormDupeTemplate;
+ private String commentFormTemplate, commentFormDoneTemplate, commentFormDupeTemplate;
+ private String postingFormTemplate, postingFormDoneTemplate, postingFormDupeTemplate;
private String searchResultsTemplate;
private String prepareMailTemplate,sentMailTemplate;
private ModuleContent contentModule;
private ModuleComment commentModule;
private ModuleImages imageModule;
- private ModuleTopics themenModule;
+ private ModuleTopics topicsModule;
private String directOp ="yes";
private String passwdProtection ="yes";
// Singelton / Kontruktor
passwdProtection = configuration.getString("PasswdProtection").toLowerCase();
mainModule = new ModuleComment(DatabaseComment.getInstance());
contentModule = new ModuleContent(DatabaseContent.getInstance());
- themenModule = new ModuleTopics(DatabaseTopics.getInstance());
+ topicsModule = new ModuleTopics(DatabaseTopics.getInstance());
imageModule = new ModuleImages(DatabaseImages.getInstance());
defaultAction="addposting";
-
}
catch (StorageObjectFailure e) {
logger.error("servletmoduleopenindy could not be initialized: " + e.getMessage());
* Method for making a comment
*/
- public void addcomment(HttpServletRequest req, HttpServletResponse res)
- throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure
+ public void addcomment(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure
{
String aid = req.getParameter("aid"); // the article id the comment will belong to
String language = req.getParameter("language");
SimpleHash extraInfo = new SimpleHash();
try{
extraInfo.put("languagePopUpData", DatabaseLanguage.getInstance().getPopupData() );
- extraInfo.put("themenPopupData", themenModule.getTopicsAsSimpleList());
+ extraInfo.put("themenPopupData", topicsModule.getTopicsAsSimpleList());
- extraInfo.put("topics", themenModule.getTopicsList());
+ extraInfo.put("topics", topicsModule.getTopicsList());
}
catch (Exception e) {
throw new ServletModuleFailure("OpenIndy -- failed getting language or topics: "+e.toString(), e);
}
-
-
deliver(req, res, mergeData, extraInfo, postingFormTemplate);
}
mp = new WebdbMultipartRequest(req, (FileHandler)mediaReq);
mediaList = mediaReq.getEntityList();
}
- catch (FileHandlerUserException e) {
+ catch (Throwable e) {
throw new ServletModuleFailure(e);
}
//this doesn't quite work yet, so for now, all html goes
//withValues.put(k,StringUtil.approveHTMLTags(v));
withValues.put(k,StringUtil.deleteForbiddenTags(v));
- } else if (k.equals("description")) {
+ }
+ else if (k.equals("description")) {
String tmp = StringUtil.deleteForbiddenTags(v);
withValues.put(k,StringUtil.deleteHTMLTableTags(tmp));
- } else {
+ }
+ else {
withValues.put(k,StringUtil.removeHTMLTags(v));
}
DatabaseContentToTopics.getInstance().setTopics(cid,to_topicsArr);
setTopic = true;
}
- catch (Exception e) {
+ catch (Throwable e) {
logger.error("setting content_x_topic failed");
contentModule.deleteById(cid);
- throw new ServletModuleExc("smod - openindy :: insposting: setting content_x_topic failed: "+e.toString());
+ throw new ServletModuleFailure("smod - openindy :: insposting: setting content_x_topic failed: "+e.toString(), e);
} //end try
} //end if
}
}
catch (Throwable e) {
+ Throwable cause = ExceptionFunctions.traceCauseException(e);
+
+ if (cause instanceof UnsupportedMediaFormatExc) {
+ throw new ServletModuleUserExc("Unsupported media format");
+ }
throw new ServletModuleFailure(e);
}
}
try{
- mergeData.put("topics", themenModule.getTopicsAsSimpleList());
+ mergeData.put("topics", topicsModule.getTopicsAsSimpleList());
}
- catch(ModuleException e) {
+ catch(Throwable e) {
logger.debug("Can't get topics: " + e.toString());
}
}
}
- private void _throwBadContentType (String fileName, String contentType)
- throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {
-
- logger.error("Wrong file type uploaded!: " + fileName+" "
- +contentType);
- throw new ServletModuleUserExc("The file you uploaded is of the "
- +"following mime-type: "+contentType
- +", we do not support this mime-type. "
- +"Error One or more files of unrecognized type. Sorry");
- }
-
protected String createOneTimePasswd(){
Random r = new Random();
int random = r.nextInt();
+++ /dev/null
-/*
- * 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.servlet;
-
-import mir.log.LoggerWrapper;
-import mir.servlet.ServletModule;
-import mir.storage.StorageObjectFailure;
-import mircoders.module.ModuleSchwerpunkt;
-import mircoders.storage.DatabaseFeature;
-
-/*
- * ServletModuleSchwerpunkt - code for the handling of "features"
- *
- *
- *
- * @author RK
- */
-
-public class ServletModuleSchwerpunkt extends ServletModule
-{
-// Singelton / Kontruktor
- private static ServletModuleSchwerpunkt instance = new ServletModuleSchwerpunkt();
- public static ServletModule getInstance() { return instance; }
-
- private ServletModuleSchwerpunkt() {
- super();
- logger = new LoggerWrapper("ServletModule.Feature");
- templateListString = configuration.getString("ServletModule.Schwerpunkt.ListTemplate");
- templateObjektString = configuration.getString("ServletModule.Schwerpunkt.ObjektTemplate");
- templateConfirmString = configuration.getString("ServletModule.Schwerpunkt.ConfirmTemplate");
- try {
- mainModule = new ModuleSchwerpunkt(DatabaseFeature.getInstance());
- }
- catch (StorageObjectFailure e) {
- logger.error("Intialization of ServletModuleSchwerpunkt (Features) failed!: " + e.getMessage());
- }
- }
-}
\ No newline at end of file
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import freemarker.template.SimpleHash;
+import freemarker.template.SimpleList;
+
import mir.config.MirPropertiesConfiguration;
import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
import mir.entity.Entity;
import mir.media.MediaHelper;
import mir.media.MirMedia;
import mir.misc.FileHandler;
-import mir.misc.FileHandlerException;
-import mir.misc.FileHandlerUserException;
import mir.misc.WebdbMultipartRequest;
import mir.servlet.ServletModule;
import mir.servlet.ServletModuleExc;
import mir.servlet.ServletModuleFailure;
import mir.servlet.ServletModuleUserExc;
import mir.storage.StorageObjectFailure;
+import mir.util.ExceptionFunctions;
import mircoders.entity.EntityContent;
import mircoders.entity.EntityUploadedMedia;
import mircoders.entity.EntityUsers;
import mircoders.media.MediaRequest;
+import mircoders.media.UnsupportedMediaFormatExc;
import mircoders.storage.DatabaseContent;
import mircoders.storage.DatabaseMediafolder;
-import freemarker.template.SimpleHash;
-import freemarker.template.SimpleList;
/*
* ServletModuleBilder -
* liefert HTML fuer Bilder
*
- * @version $Id: ServletModuleUploadedMedia.java,v 1.20 2003/03/08 17:18:19 idfx Exp $
+ * @version $Id: ServletModuleUploadedMedia.java,v 1.21 2003/03/09 03:53:12 zapata Exp $
* @author RK, the mir-coders group
*/
// raus damit
deliver(req, res, mergeData, popups, templateListString);
}
- catch (FileHandlerUserException e) {
- logger.error("ServletModuleUploadedMedia.insert: " + e.getMessage());
- throw new ServletModuleUserExc(e.getMessage());
- }
- catch (FileHandlerException e) {
- throw new ServletModuleFailure("upload -- media handling exception " + e.toString(), e);
- }
- catch (StorageObjectFailure e) {
- throw new ServletModuleFailure("upload -- storageobjectexception " + e.toString(), e);
- }
- catch (IOException e) {
- throw new ServletModuleFailure("upload -- ioexception " + e.toString(), e);
- }
- catch (PropertiesConfigExc e) {
- throw new ServletModuleFailure("upload -- configexception " + e.toString(), e);
- }
catch (Throwable t) {
- throw new ServletModuleFailure("upload -- exception " + t.toString(), t);
+ Throwable cause = ExceptionFunctions.traceCauseException(t);
+
+ if (cause instanceof UnsupportedMediaFormatExc) {
+ throw new ServletModuleUserExc("Unsupported media format");
+ }
+ throw new ServletModuleFailure("ServletModuleUploadedMedia.insert: " + t.toString(), t);
}
}
return (EntityUsers) session.getAttribute("login.uid");
}
- public void getMedia(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
- {
+ public void getMedia(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {
String idParam = req.getParameter("id");
if (idParam!=null && !idParam.equals("")) {
try {
in.close();
out.close();
}
-
catch (Throwable e) {
throw new ServletModuleFailure(e);
}
\r
private static DatabaseComment instance;\r
\r
- // the following *has* to be sychronized cause this static method\r
- // could get preemted and we could end up with 2 instances of DatabaseFoo..\r
- // see the "Singletons with needles and thread" article at JavaWorld -mh\r
- public synchronized static DatabaseComment getInstance() throws\r
- StorageObjectFailure {\r
+ public static DatabaseComment getInstance() {\r
if (instance == null) {\r
- instance = new DatabaseComment();\r
- instance.myselfDatabase = instance;\r
+ synchronized (DatabaseComment.class) {\r
+ if (instance == null) {\r
+ instance = new DatabaseComment();\r
+ instance.myselfDatabase = instance;\r
+ }\r
+ }\r
}\r
return instance;\r
}\r
\r
- private DatabaseComment() throws StorageObjectFailure {\r
+ private DatabaseComment() {\r
super();\r
hasTimestamp = false;\r
theTable = "comment";\r
logger = new LoggerWrapper("Database.Comment");\r
\r
- try {\r
- this.theEntityClass = Class.forName("mircoders.entity.EntityComment");\r
- }\r
- catch (Exception e) {\r
- throw new StorageObjectFailure(e);\r
- }\r
+ this.theEntityClass = mircoders.entity.EntityComment.class;\r
}\r
\r
public SimpleList getPopupData() throws StorageObjectFailure {\r
private static DatabaseContent instance;
private static EntityRelation relationComments;
- private static EntityRelation relationFeature;
// Contructors / Singleton
relationComments =
new EntityRelation("id", "to_media", DatabaseComment.getInstance(), EntityRelation.TO_MANY);
- relationFeature =
- new EntityRelation("id", "to_feature", DatabaseFeature.getInstance(), EntityRelation.TO_ONE);
theEntityClass = mircoders.entity.EntityContent.class;
}
executeUpdate(stmt,sql);
logger.debug("set unproduced: "+where);
}
- catch (Exception e) {_throwStorageObjectException(e, "-- set unproduced failed");}
+ catch (Exception e) {
+ _throwStorageObjectException(e, "-- set unproduced failed");
+ }
finally { freeConnection(con,stmt);}
}
}
/**
- * returns the features that belong to the article (via entityrelation)
+ *
+ * @param id
+ * @return
+ * @throws StorageObjectFailure
*/
- public EntityList getFeature(EntityContent entC) throws StorageObjectFailure {
- return relationFeature.getMany(entC);
- }
public boolean delete(String id) throws StorageObjectFailure
{
* <b>implements abstract DB connection to the content_x_media SQL table\r
*\r
* @author RK, mir-coders group\r
- * @version $Id: DatabaseContentToMedia.java,v 1.15 2003/03/06 05:40:40 zapata Exp $\r
+ * @version $Id: DatabaseContentToMedia.java,v 1.16 2003/03/09 03:53:12 zapata Exp $\r
*\r
*/\r
\r
\r
private static DatabaseContentToMedia instance;\r
\r
- // the following *has* to be sychronized cause this static method\r
- // could get preemted and we could end up with 2 instances of DatabaseFoo.\r
- // see the "Singletons with needles and thread" article at JavaWorld -mh\r
- public synchronized static DatabaseContentToMedia getInstance() throws\r
- StorageObjectFailure {\r
+ public static DatabaseContentToMedia getInstance() {\r
if (instance == null) {\r
- instance = new DatabaseContentToMedia();\r
- instance.myselfDatabase = instance;\r
+ synchronized (DatabaseContentToMedia.class) {\r
+ if (instance == null) {\r
+ instance = new DatabaseContentToMedia();\r
+ instance.myselfDatabase = instance;\r
+ }\r
+ }\r
}\r
return instance;\r
}\r
\r
- private DatabaseContentToMedia() throws StorageObjectFailure {\r
+ private DatabaseContentToMedia() {\r
super();\r
+\r
logger = new LoggerWrapper("Database.ContentToMedia");\r
\r
hasTimestamp = false;\r
theTable = "content_x_media";\r
-\r
theEntityClass = mir.entity.GenericEntity.class;\r
}\r
\r
-/*
- * 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;
-
-/**
- * <b>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;
- }
-}
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two. You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries. If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so. If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.storage;\r
+\r
+import java.sql.Connection;\r
+import java.sql.ResultSet;\r
+import java.sql.Statement;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Iterator;\r
+\r
+import mir.entity.EntityList;\r
+import mir.log.LoggerWrapper;\r
+import mir.storage.Database;\r
+import mir.storage.StorageObject;\r
+import mir.storage.StorageObjectFailure;\r
+import mircoders.entity.EntityContent;\r
+import mircoders.entity.EntityTopics;\r
+\r
+/**\r
+ * <b>This class implements the 1-n-relation between\r
+ * content and topic\r
+ *\r
+ */\r
+\r
+public class DatabaseContentToTopics extends Database implements StorageObject{\r
+\r
+ private static DatabaseContentToTopics instance;\r
+\r
+ public static DatabaseContentToTopics getInstance() {\r
+ if (instance == null) {\r
+ synchronized (DatabaseContentToTopics.class) {\r
+ if (instance == null) {\r
+ instance = new DatabaseContentToTopics();\r
+ instance.myselfDatabase = instance;\r
+ }\r
+ }\r
+ }\r
+ return instance;\r
+ }\r
+\r
+ private DatabaseContentToTopics() {\r
+ super();\r
+\r
+ logger = new LoggerWrapper("Database.ContentToTopics");\r
+\r
+ hasTimestamp = false;\r
+ theTable="content_x_topic";\r
+ theEntityClass = mir.entity.GenericEntity.class;\r
+ }\r
+\r
+ /**\r
+ * This class return an EntityList of Topics\r
+ * @param EntityContent content\r
+ * @returns EntityList\r
+ */\r
+ public EntityList getTopics(EntityContent content) {\r
+ EntityList returnList=null;\r
+ if (content != null) {\r
+ // get all to_topic from content_x_topic\r
+ String id = content.getId();\r
+ String subselect = "id in (select topic_id from " + theTable + " where content_id=" + id+")";\r
+\r
+ try {\r
+ returnList = DatabaseTopics.getInstance().selectByWhereClause(subselect,-1);\r
+ }\r
+ catch (Exception e) {\r
+ logger.error("-- get topics failed " + e.toString());\r
+ }\r
+ }\r
+ return returnList;\r
+ }\r
+\r
+ /**\r
+ * Returns a ArrayList of Integer-Objects from a content-id.\r
+ * @returns ArrayList\r
+ */\r
+ public ArrayList getTopicsOfContent(String contentId)\r
+ throws StorageObjectFailure {\r
+ ArrayList returnList = new ArrayList();\r
+\r
+ if (contentId != null) {\r
+ String sql = "select topic_id from " + theTable + " where content_id=" + contentId;\r
+ Connection con=null;Statement stmt=null;\r
+ try {\r
+ con = getPooledCon();\r
+ // should be a preparedStatement because is faster\r
+ stmt = con.createStatement();\r
+ ResultSet rs = executeSql(stmt,sql);\r
+ if(rs!=null){\r
+ while(rs.next()){\r
+ returnList.add(new Integer(rs.getInt("topic_id")));\r
+ }\r
+ }\r
+ }\r
+ catch (Exception e) {\r
+ logger.error("DatabaseContentToTopics.getTopicsOfContent: " + e.getMessage());\r
+ }\r
+ finally {\r
+ freeConnection(con,stmt);\r
+ }\r
+ }\r
+ return returnList;\r
+ }\r
+\r
+ /**\r
+ * Set new topics\r
+ */\r
+ public void setTopics(String contentId, String[] topicId)\r
+ throws StorageObjectFailure {\r
+ if (contentId == null){\r
+ return;\r
+ }\r
+ if (topicId==null || topicId[0]==null) {\r
+ return;\r
+ }\r
+ //first check which topics this article has\r
+ Collection hasTopics = getTopicsOfContent(contentId);\r
+ Collection toSet = new ArrayList();\r
+ Collection toDelete = new ArrayList();\r
+\r
+ if(hasTopics!=null && hasTopics.size()>0){\r
+ //now we check if there are new topics and copy them to an array.\r
+ for(int i = 0; i< topicId.length;i++){\r
+ boolean set=false;\r
+ int whichTopic = 0;\r
+ for(Iterator it=hasTopics.iterator();it.hasNext();){\r
+ Integer topic = (Integer)it.next();\r
+ if(topicId[i].equals(topic.toString())){\r
+ set=true;\r
+ } else {\r
+ whichTopic = i;\r
+ }\r
+ }\r
+ if(set==false){\r
+ toSet.add(topicId[i]);\r
+ logger.debug("to set: "+ topicId[i]);\r
+ }\r
+ }\r
+ //now we check if we have to delete topics\r
+ for(Iterator it=hasTopics.iterator();it.hasNext();){\r
+ boolean delete=true;\r
+ int whichTopic = 0;\r
+ Integer topic = (Integer)it.next();\r
+ for(int i = 0; i< topicId.length;i++){\r
+ if(topicId[i].equals(topic.toString())){\r
+ delete=false;\r
+ } else {\r
+ whichTopic = i;\r
+ }\r
+ }\r
+ if(delete==true){\r
+ toDelete.add(topic.toString());\r
+ logger.debug("to delete: "+ topic.toString());\r
+ }\r
+ }\r
+ } else {\r
+ //all the topics has to be set, so we copy all to the array\r
+ for (int i = 0; i < topicId.length; i++){\r
+ toSet.add(topicId[i]);\r
+ }\r
+ }\r
+\r
+ //first delete all row with content_id=contentId\r
+ String sql = "delete from "+ theTable +" where content_id=" + contentId\r
+ + " and topic_id in (";\r
+ boolean first=false;\r
+ for(Iterator it = toDelete.iterator(); it.hasNext();){\r
+ if(first==false){\r
+ first=true;\r
+ } else {\r
+ sql+=",";\r
+ }\r
+ sql+= (String)it.next();\r
+ }\r
+ sql+=")";\r
+ Connection con=null;Statement stmt=null;\r
+ try {\r
+ con = getPooledCon();\r
+ // should be a preparedStatement because is faster\r
+ stmt = con.createStatement();\r
+ int rs = executeUpdate(stmt,sql);\r
+ } catch (Exception e) {\r
+ logger.error("-- deleting topics failed");\r
+ } finally {\r
+ freeConnection(con,stmt);\r
+ }\r
+\r
+ //now insert\r
+ //first delete all row with content_id=contentId\r
+ for (Iterator it = toSet.iterator(); it.hasNext();) {\r
+ sql = "insert into "+ theTable +" (content_id,topic_id) values ("\r
+ + contentId + "," + (String)it.next() + ")";\r
+ try {\r
+ con = getPooledCon();\r
+ // should be a preparedStatement because is faster\r
+ stmt = con.createStatement();\r
+ int rs = executeUpdate(stmt,sql);\r
+ }\r
+ catch (Exception e) {\r
+ logger.error("-- set topics failed -- insert laenge topicId" + topicId.length);\r
+ } finally {\r
+ freeConnection(con,stmt);\r
+ }\r
+ }\r
+ }\r
+\r
+ public void deleteByContentId(String contentId)\r
+ throws StorageObjectFailure {\r
+ if (contentId == null) {\r
+ //theLog.printDebugInfo("-- delete topics failed -- no content id");\r
+ return;\r
+ }\r
+ //delete all row with content_id=contentId\r
+ String sql = "delete from "+ theTable +" where content_id=" + contentId;\r
+\r
+ Connection con=null;Statement stmt=null;\r
+ try {\r
+ con = getPooledCon();\r
+ // should be a preparedStatement because is faster\r
+ stmt = con.createStatement();\r
+ ResultSet rs = executeSql(stmt,sql);\r
+ } catch (Exception e) {\r
+ //theLog.printDebugInfo("-- delete topics failed ");\r
+ } finally {\r
+ freeConnection(con,stmt);\r
+ }\r
+ }\r
+\r
+ public void deleteByTopicId(String topicId)\r
+ throws StorageObjectFailure {\r
+ if (topicId == null) {\r
+ //theLog.printDebugInfo("-- delete topics failed -- no topic id");\r
+ return;\r
+ }\r
+ //delete all row with content_id=contentId\r
+ String sql = "delete from "+ theTable +" where topic_id=" + topicId;\r
+\r
+ Connection con=null;Statement stmt=null;\r
+ try {\r
+ con = getPooledCon();\r
+ // should be a preparedStatement because is faster\r
+ stmt = con.createStatement();\r
+ ResultSet rs = executeSql(stmt,sql);\r
+ }\r
+ catch (Exception e) {\r
+ logger.error("-- delete topics failed ");\r
+ }\r
+ finally {\r
+ freeConnection(con,stmt);\r
+ }\r
+ }\r
+\r
+\r
+ public EntityList getContent(EntityTopics topic)\r
+ throws StorageObjectFailure {\r
+ EntityList returnList=null;\r
+ if (topic != null) {\r
+ String id = topic.getId();\r
+ String select = "select content_id from " + theTable + " where topic_id=" + id;\r
+\r
+ // execute select statement\r
+ Connection con=null;Statement stmt=null;\r
+ try {\r
+ con = getPooledCon();\r
+ // should be a preparedStatement because is faster\r
+ stmt = con.createStatement();\r
+ ResultSet rs = executeSql(stmt,select);\r
+ if (rs!=null) {\r
+ String topicSelect= "id IN (";\r
+ boolean first=true;\r
+ while (rs.next()) {\r
+ if (first==false) topicSelect+=",";\r
+ topicSelect += rs.getString(1);\r
+ first=false;\r
+ }\r
+ topicSelect+=")";\r
+ if (first==false)\r
+ returnList = DatabaseContent.getInstance().selectByWhereClause(topicSelect,-1);\r
+ }\r
+ }\r
+ catch (Exception e) {\r
+ logger.error("-- get contetn failed");\r
+ }\r
+ finally { freeConnection(con,stmt);}\r
+ }\r
+ return returnList;\r
+ }\r
+}\r
+++ /dev/null
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with the com.oreilly.servlet library, any library\r
- * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
- * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
- * the above that use the same license as the above), and distribute linked\r
- * combinations including the two. You must obey the GNU General Public\r
- * License in all respects for all of the code used other than the above\r
- * mentioned libraries. If you modify this file, you may extend this exception\r
- * to your version of the file, but you are not obligated to do so. If you do\r
- * not wish to do so, delete this exception statement from your version.\r
- */\r
-\r
-package mircoders.storage;\r
-\r
-import mir.log.LoggerWrapper;\r
-import mir.storage.Database;\r
-import mir.storage.StorageObject;\r
-import mir.storage.StorageObjectFailure;\r
-import freemarker.template.SimpleList;\r
-\r
-/**\r
- * <b>Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle\r
- *\r
- *\r
- */\r
-\r
-public class DatabaseFeature extends Database implements StorageObject{\r
-\r
- private static DatabaseFeature instance;\r
-\r
- // the following *has* to be sychronized cause this static method\r
- // could get preemted and we could end up with 2 instances of DatabaseFoo..\r
- // see the "Singletons with needles and thread" article at JavaWorld -mh\r
- public synchronized static DatabaseFeature getInstance() throws\r
- StorageObjectFailure {\r
- if (instance == null) {\r
- instance = new DatabaseFeature();\r
- instance.myselfDatabase = instance;\r
- }\r
- return instance;\r
- }\r
-\r
- private DatabaseFeature() throws StorageObjectFailure {\r
- super();\r
- logger = new LoggerWrapper("Database.Feature");\r
-\r
- hasTimestamp = false;\r
- theTable = "feature";\r
-\r
- theEntityClass = mircoders.entity.EntityFeature.class;\r
- }\r
-\r
- public SimpleList getPopupData() throws StorageObjectFailure {\r
- return getPopupData("title", true);\r
- }\r
-\r
-}\r
-/*
- * 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;
-
-/**
- * <b>this class implements the access to the content-table</b>
- *
- *
- */
-
-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;
- }
-
-}
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two. You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries. If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so. If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.storage;\r
+\r
+import mir.entity.Entity;\r
+import mir.entity.EntityRelation;\r
+import mir.log.LoggerWrapper;\r
+import mir.storage.Database;\r
+import mir.storage.StorageObject;\r
+import mir.storage.StorageObjectFailure;\r
+\r
+public class DatabaseUploadedMedia extends Database implements StorageObject {\r
+ private static DatabaseUploadedMedia instance;\r
+ private static EntityRelation relationMediaType;\r
+\r
+ public static DatabaseUploadedMedia getInstance() {\r
+ if (instance == null ) {\r
+ synchronized(DatabaseUploadedMedia.class) {\r
+ if (instance == null ) {\r
+ instance = new DatabaseUploadedMedia();\r
+ instance.myselfDatabase = instance;\r
+ }\r
+ }\r
+ }\r
+\r
+ return instance;\r
+ }\r
+\r
+ private DatabaseUploadedMedia() {\r
+ super();\r
+\r
+ logger = new LoggerWrapper("Database.UploadedMedia");\r
+\r
+ theTable="uploaded_media";\r
+ theCoreTable="media";\r
+ relationMediaType = new EntityRelation("to_media_type", "id", DatabaseMediaType.getInstance(), EntityRelation.TO_ONE);\r
+ theEntityClass = mircoders.entity.EntityUploadedMedia.class;\r
+ }\r
+\r
+\r
+ /**\r
+ * returns the media_type that belongs to the media item (via entityrelation)\r
+ * where db-flag is_published is true\r
+ */\r
+ public Entity getMediaType(Entity ent) throws StorageObjectFailure {\r
+ Entity type=null;\r
+ try {\r
+ type = relationMediaType.getOne(ent);\r
+ }\r
+ catch (Throwable t) {\r
+ logger.error("DatabaseUploadedMedia :: failed to get media_type: " + t.getMessage());\r
+\r
+ throw new StorageObjectFailure("DatabaseUploadedMedia :: failed to get media_type", t);\r
+ }\r
+ return type;\r
+ }\r
+\r
+}\r
+++ /dev/null
-<html>
-<head>
- <title>${config["Mir.Name"]} | ${lang("feature.htmltitle")}</title>
- <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
-<head>
-
-<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-
-<include "templates/admin/head.template">
-
-<table border="0">
- <form method="post" action="${config.actionRoot}">
- <input type="hidden" name="module" value="Schwerpunkt">
- <input type="hidden" name="where" value="${data.where}">
- <input type="hidden" name="offset" value="${data.offset}">
- <input type="hidden" name="order" value="${data.order}">
- <if data.new>
- <input type="hidden" name="do" value="insert">
- <else>
- <input type="hidden" name="do" value="update">
- </if>
- <input type="hidden" name="id" value="${data.id}">
- <tr>
- <td align="right" valign="top" class="darkgrey"><span class="witetext"><B>${lang("feature.title")}:</B></span></td>
- <td>
- <input type="text" size="40" name="title" value="${data.title}">
- <select name="is_published">
- <option value="1"<if data.is_published!="0">selected</if>>${lang("feature.is_published")}</option>
- <option value="0" <if data.is_published=="0">selected</if>>${lang("feature.is_not_published")}</option>
- </select>
- </td>
- </tr>
-
- <tr>
- <td align="right" valign="top" class="darkgrey"><span class="witetext"><B>${lang("feature.filename")}:</B></span></td>
- <td>
- <input type="text" size="20" name="filename" value="${data.filename}">
- </td>
- </tr>
-
- <tr>
- <td align="right" valign="top" class="darkgrey"><span class="witetext"><B>${lang("feature.abstract")}:</B></span></td>
- <td>
- <textarea cols="40" rows="3" name="description">${data.description}</textarea>
- </td>
- </tr>
-
- <tr>
- <td align="right" valign="top" class="darkgrey"><span class="witetext"><B>${lang("feature.link")}:</B></span></td>
- <td>
- <input type="text" size="40" name="main_url" value="${data.main_url}">
- </td>
- </tr>
- <tr>
- <td colspan="2" align="right" valign="top" bgcolor="#ffffff"> <span class="witetext"><if new>
- <input type="submit" name="save" value="${lang("insert")}">
- <else>
- <input type="submit" name="save" value="${lang("save")}">
- </if></span></td>
- </tr>
- </form>
-</table>
-<include "templates/admin/foot.template">
-</body>
-</html>
+++ /dev/null
-<html>
-<head>
- <title>${config["Mir.Name"]} | ${lang("featurelist.htmltitle")}</title>
- <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
-</head>
-
-<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
-
-<include "templates/admin/head.template">
-
-
-<if data.contentlist>
-<table border="0">
- <tr class="darkgrey">
- <td><span class="witesmall">${lang("feature.published")}</span></td>
- <td><span class="witesmall">${lang("feature.title")}</span></td>
- <td><span class="witesmall">${lang("feature.filename")}</span></td>
- <td><span class="witesmall">${lang("feature.link")}</span></td>
- <td><span class="witesmall">${lang("feature.abstract")}</span></td>
- </tr>
- <list data.contentlist as entry>
- <tr
- <if grey=="1"><assign grey="0">class="list1"<else>class="list2"<assign grey="1"> </if>>
- <td align="center"><if entry.is_published!="0">X<else> </if></td>
- <td>${entry.title} </td>
- <td>${entry.filename} </td>
- <td>${entry.main_url} </td>
- <td>${entry.description} </td>
- <td><span class="text"> <a href="${config.actionRoot}?module=Schwerpunkt&do=delete&id=${entry.id}">${lang("delete")}</a>
- | <a href="${config.actionRoot}?module=Schwerpunkt&do=edit&id=${entry.id}">${lang("edit")}</a></span></td>
- </tr>
- </list>
-
- <tr>
- <td align="center" colspan="5" class="darkgrey">
- <div align="left"><span class="witesmall">${data.count} ${lang("records")} /
- ${lang("show_from_to", data.from, data.to)}</span></div>
- </td>
- <td><a href="${config.docRoot}"><span class="text"> ${lang("back")}</span></a></td>
- </tr>
-</table>
-
- <P>
-<if (data.prev || data.next)>
- <form method="post" action="${config.actionRoot}">
- <input type="hidden" name="module" value="Schwerpunkt">
- <input type="hidden" name="where" value="${data.where}">
-<if data.prev>
- <input type="hidden" name="prevoffset" value="${data.prev}">
- <input type="submit" name="prev" value="${lang("list.previous")}">
-</if>
-<if data.next>
- <input type="hidden" name="nextoffset" value="${data.next}">
- <input type="submit" name="next" value="${lang("list.next")}">
-</if>
- </form>
-</if>
-
-
-<else>
-
- <P align="center">${lang("no_matches_found")}</p>
-
-</if>
-
-<include "templates/admin/foot.template">
-</body>
-</html>
-
-