MIR INSTALLATION HOWTO
-Last updated: $Date: 2003/11/24 19:57:54 $
+Last updated: $Date: 2003/12/03 18:10:45 $
----------------------------------------------------------------
Here is a short installation-howto of Mir.
- postgres 7.1+
- ant (a java-based make)
- jaxp-1.1 (a SAX 2.0 compliant XML parser, comes with ant >= 1.4)
-- the JAI image framework (Java Advanced Imaging) versin 1.1.1 . get it from
- java.sun.com. ** NOTE: because JAI uses a native acceration library (a .so)
- it must be placed in tomcat's "lib" (i.e $TOMCAT_HOME/common/lib) directory and
- not under the default webapps/Mir/WEB-INF/lib directory **
+- the JAI image framework (Java Advanced Imaging) version 1.1.2 . Get it from
+ java.sun.com. You need both: JAI and JAI Image I/O. Install those two in
+ the JRE running tomcat.
+
- A good reading of Tomcat, Apache and Postgresql documentation if you are not
familiar with any of them. The documentation is available at:
http://jakarta.apache.org/tomcat/tomcat-4.0-doc/index.html,
tomcat or other webapps and can't afford to shutdown all of them.
See the tomcat documentation to learn how to enable and use the manager app.
-7. Copy any dynamic library files ending with ".so" (so far only the JAI native
-acceleration library found in the JAI package tarball or zip from sun) to your
-$JAVA_HOME/jre/lib/i386 directory (where the other ".so" files live). Or, you
-can skip the whole thing and live without "native" acceleration for image
-manupulation.
+7. Follow the installation instructions of JAI / JAI Image I/O.
8a. create a new database
The database name should be the same as in config.properties. Please look at
----------------------------------------------------------------
-$Date: 2003/11/24 19:57:54 $ - the Mir coders
+$Date: 2003/12/03 18:10:45 $ - the Mir coders
* Copyright: Copyright (c) 2001, 2002
* Company: Mir-coders group
* @author idfx, the Mir-coders group
- * @version $Id: AbstractServlet.java,v 1.30.2.5 2003/10/23 14:55:26 rk Exp $
+ * @version $Id: AbstractServlet.java,v 1.30.2.6 2003/12/03 18:10:45 rk Exp $
*/
public abstract class AbstractServlet extends HttpServlet {
- protected static String lang;
+ //protected static String lang;
protected LoggerWrapper logger;
protected MirPropertiesConfiguration configuration;
*/
protected String getAcceptLanguage(HttpServletRequest aRequest) {
Locale loc = aRequest.getLocale();
- lang = loc.getLanguage();
+ String lang = loc.getLanguage();
return lang;
}
if (manager != null) {
pool = manager.createPool(meta);
}
+
+ if (pool==null) {
+ logger.fatal("Can't get pool!");
+ throw new ServletException("Can't get pool!" );
+ }
Connection connection;
try {
connection = pool.requestConnection();
- JDBCPool.closeConnection(connection);
+ JDBCPool.closeConnection(connection);
}
catch (Throwable t) {
logger.fatal("Can't connect to database: " + t.toString());
-/*\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 any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-\r
-package mircoders.localizer.basic;\r
-\r
-import gnu.regexp.RE;\r
-\r
-import java.util.Arrays;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-\r
-import mir.entity.Entity;\r
-import mir.session.Request;\r
-import mir.util.InternetFunctions;\r
-import mircoders.localizer.MirAntiAbuseFilterType;\r
-\r
-\r
-/**\r
- * <p>Title: </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author not attributable\r
- * @version 1.0\r
- */\r
-\r
-public class MirBasicAntiAbuseFilterTypes {\r
- private MirBasicAntiAbuseFilterTypes() {\r
- }\r
-\r
- public static abstract class BasicFilterType implements MirAntiAbuseFilterType {\r
- private String name;\r
-\r
- public BasicFilterType(String aName) {\r
- name = aName;\r
- }\r
-\r
- public String getName() {\r
- return name;\r
- }\r
- }\r
-\r
- /**\r
- * A basic ip filter. Supports x.x.x.x, x.x.x.x/x and x.x.x.x/x.x.x.x expressions.\r
- *\r
- * <p>Title: </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author not attributable\r
- * @version 1.0\r
- */\r
-\r
- public static class IPFilter extends BasicFilterType {\r
- public IPFilter(String aName) {\r
- super(aName);\r
- }\r
-\r
- public boolean validate(String anExpression) {\r
- try {\r
- InternetFunctions.isIpAddressInNetwork("1.1.1.1", anExpression);\r
- return true;\r
- }\r
- catch (Throwable t) {\r
- return false;\r
- }\r
- };\r
-\r
- public boolean test(String anExpression, Entity anEntity, Request aRequest) {\r
- try {\r
- return InternetFunctions.isIpAddressInNetwork(aRequest.getHeader("ip"), anExpression);\r
- }\r
- catch (Throwable t) {\r
- return false;\r
- }\r
- };\r
- }\r
-\r
- /**\r
- * A regular expression filter.\r
- *\r
- * <p>Title: </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author not attributable\r
- * @version 1.0\r
- */\r
-\r
- public static class RegularExpressionFilter extends BasicFilterType {\r
- private boolean exactMatch;\r
- private boolean caseSensitive;\r
- private int fieldKind;\r
- private List selectedFields;\r
-\r
- public static final int ENTITY_FIELDS = 0;\r
- public static final int REQUEST_HEADERS = 2;\r
-\r
- public RegularExpressionFilter(String aName) {\r
- this(aName, false, false, null);\r
- }\r
-\r
- public RegularExpressionFilter(String aName, boolean aCaseSensitive, boolean anExactMatch, String[] aSelectedFields) {\r
- this (aName, aCaseSensitive, anExactMatch, ENTITY_FIELDS, aSelectedFields);\r
- }\r
-\r
- public RegularExpressionFilter(String aName, boolean aCaseSensitive, boolean anExactMatch, int aFieldKind, String[] aSelectedFields) {\r
- super(aName);\r
-\r
- fieldKind = aFieldKind;\r
-\r
- caseSensitive = aCaseSensitive;\r
- exactMatch = anExactMatch;\r
- if (aSelectedFields==null)\r
- selectedFields = null;\r
- else\r
- selectedFields = Arrays.asList(aSelectedFields);\r
- }\r
-\r
- public boolean validate(String anExpression) {\r
- try {\r
- new RE(anExpression);\r
- return true;\r
- }\r
- catch (Throwable t) {\r
- return false;\r
- }\r
- };\r
-\r
- public boolean test(String anExpression, Entity anEntity, Request aRequest) {\r
- try {\r
- Iterator j;\r
- int flags = 0;\r
-\r
- if (caseSensitive)\r
- flags |= RE.REG_ICASE;\r
-\r
- RE regularExpression = new RE(anExpression, RE.REG_ICASE);\r
-\r
- switch (fieldKind) {\r
- case REQUEST_HEADERS:\r
- if (selectedFields != null) {\r
- j = selectedFields.iterator();\r
-\r
- while (j.hasNext()) {\r
- String field = aRequest.getHeader( (String) j.next());\r
-\r
- if (exactMatch) {\r
- if (field != null && regularExpression.isMatch(field)) {\r
- return true;\r
- }\r
- }\r
- else {\r
- if (field != null && regularExpression.getMatch(field) != null) {\r
- return true;\r
- }\r
- }\r
- }\r
- }\r
- break;\r
- case ENTITY_FIELDS:\r
- if (selectedFields != null)\r
- j = selectedFields.iterator();\r
- else\r
- j = anEntity.getFields().iterator();\r
-\r
- while (j.hasNext()) {\r
- String field = anEntity.getValue( (String) j.next());\r
-\r
- if (exactMatch) {\r
- if (field != null && regularExpression.isMatch(field)) {\r
- return true;\r
- }\r
- }\r
- else {\r
- if (field != null && regularExpression.getMatch(field) != null) {\r
- return true;\r
- }\r
- }\r
- }\r
- }\r
- }\r
- catch (Throwable t) {\r
- }\r
- return false;\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 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.localizer.basic;
+
+import gnu.regexp.RE;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import mir.entity.Entity;
+import mir.session.Request;
+import mir.util.InternetFunctions;
+import mircoders.localizer.MirAntiAbuseFilterType;
+
+
+/**
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+
+public class MirBasicAntiAbuseFilterTypes {
+ private MirBasicAntiAbuseFilterTypes() {
+ }
+
+ public static abstract class BasicFilterType implements MirAntiAbuseFilterType {
+ private String name;
+
+ public BasicFilterType(String aName) {
+ name = aName;
+ }
+
+ public String getName() {
+ return name;
+ }
+ }
+
+ /**
+ * A basic ip filter. Supports x.x.x.x, x.x.x.x/x and x.x.x.x/x.x.x.x expressions.
+ *
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+
+ public static class IPFilter extends BasicFilterType {
+ public IPFilter(String aName) {
+ super(aName);
+ }
+
+ public boolean validate(String anExpression) {
+ try {
+ InternetFunctions.isIpAddressInNetwork("1.1.1.1", anExpression);
+ return true;
+ }
+ catch (Throwable t) {
+ return false;
+ }
+ };
+
+ public boolean test(String anExpression, Entity anEntity, Request aRequest) {
+ try {
+ return InternetFunctions.isIpAddressInNetwork(aRequest.getHeader("ip"), anExpression);
+ }
+ catch (Throwable t) {
+ return false;
+ }
+ };
+ }
+
+ /**
+ * A regular expression filter.
+ *
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+
+ public static class RegularExpressionFilter extends BasicFilterType {
+ private boolean exactMatch;
+ private boolean caseSensitive;
+ private int fieldKind;
+ private List selectedFields;
+
+ public static final int ENTITY_FIELDS = 0;
+ public static final int REQUEST_HEADERS = 2;
+
+ public RegularExpressionFilter(String aName) {
+ this(aName, false, false, null);
+ }
+
+ public RegularExpressionFilter(String aName, boolean aCaseSensitive, boolean anExactMatch, String[] aSelectedFields) {
+ this (aName, aCaseSensitive, anExactMatch, ENTITY_FIELDS, aSelectedFields);
+ }
+
+ public RegularExpressionFilter(String aName, boolean aCaseSensitive, boolean anExactMatch, int aFieldKind, String[] aSelectedFields) {
+ super(aName);
+
+ fieldKind = aFieldKind;
+
+ caseSensitive = aCaseSensitive;
+ exactMatch = anExactMatch;
+ if (aSelectedFields==null)
+ selectedFields = null;
+ else
+ selectedFields = Arrays.asList(aSelectedFields);
+ }
+
+ public boolean validate(String anExpression) {
+ try {
+ new RE(anExpression);
+ return true;
+ }
+ catch (Throwable t) {
+ return false;
+ }
+ };
+
+ public boolean test(String anExpression, Entity anEntity, Request aRequest) {
+ try {
+ Iterator j;
+ int flags = 0;
+
+ if (caseSensitive)
+ // TODO jlint says this operator is useless
+ flags |= RE.REG_ICASE;
+
+ RE regularExpression = new RE(anExpression, RE.REG_ICASE);
+
+ switch (fieldKind) {
+ case REQUEST_HEADERS:
+ if (selectedFields != null) {
+ j = selectedFields.iterator();
+
+ while (j.hasNext()) {
+ String field = aRequest.getHeader( (String) j.next());
+
+ if (exactMatch) {
+ if (field != null && regularExpression.isMatch(field)) {
+ return true;
+ }
+ }
+ else {
+ if (field != null && regularExpression.getMatch(field) != null) {
+ return true;
+ }
+ }
+ }
+ }
+ break;
+ case ENTITY_FIELDS:
+ if (selectedFields != null)
+ j = selectedFields.iterator();
+ else
+ j = anEntity.getFields().iterator();
+
+ while (j.hasNext()) {
+ String field = anEntity.getValue( (String) j.next());
+
+ if (exactMatch) {
+ if (field != null && regularExpression.isMatch(field)) {
+ return true;
+ }
+ }
+ else {
+ if (field != null && regularExpression.getMatch(field) != null) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ catch (Throwable t) {
+ }
+ return false;
+ }
+ }
+
}
\ No newline at end of file
-/*\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 any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mircoders.media;\r
-\r
-import java.io.StringReader;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Vector;\r
-\r
-import mir.entity.Entity;\r
-import mir.log.LoggerWrapper;\r
-import mir.media.MediaExc;\r
-import mir.media.MediaFailure;\r
-import mir.media.MirMedia;\r
-import mir.misc.FileUtil;\r
-import mir.misc.StringUtil;\r
-\r
-/**\r
- * Please note: this media handler produces\r
- * 3 media files, the raw .mp3, a .m3u which is\r
- * contains the URL for the mp3 and a .pls which\r
- * contains the URL to the mp3 in shoutcast playlist\r
- * format. What's important is that the web server (of\r
- * the media host) must recognize the .m3u and .pls file\r
- * extensions and send the proper "audio/x-mpegurl"\r
- * and "audio/x-scpls" mime-types respectively.\r
- * If the web server is apache, it's easy, just\r
- * add:\r
- *\r
- * audio/x-mpegurl m3u\r
- * audio/x-scpl pls\r
- *\r
- * to the file pointed to by the "TypesConfig"\r
- * command in your apache config file. Or add\r
- * and equivalent AddType command to your httpd.conf.\r
- * Of course this assumes that the mod_mime is loaded.\r
- *\r
- * If the web server is not apache, then your on your own.\r
- *\r
- * @see mir.media.MirMedia\r
- * @author mh <mh@nadir.org>\r
- * @version $Id: MediaHandlerMp3.java,v 1.15.2.1 2003/09/03 17:49:39 zapata Exp $\r
- */\r
-\r
-public class MediaHandlerMp3 extends MediaHandlerAudio implements MirMedia\r
-{\r
- protected LoggerWrapper logger;\r
-\r
- public MediaHandlerMp3() {\r
- logger = new LoggerWrapper("Media.Audio.Mp3");\r
- }\r
-\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
- String baseName = ent.getId();\r
- String date = ent.getValue("date");\r
- String datePath = StringUtil.webdbDate2path(date);\r
- String mp3Pointer = getPublishHost() + ent.getValue("publish_path");\r
- String mpegURLFile = baseName + ".m3u";\r
- String playlistFile = baseName + ".pls";\r
-\r
- try {\r
- //write the "meta" files\r
- //first the .m3u since it only contains one line\r
- FileUtil.write(getStoragePath() + "/" + datePath + "/" + mpegURLFile,\r
- new StringReader(mp3Pointer), "US-ASCII");\r
- //now the .pls file\r
- FileUtil.write(getStoragePath() + "/" + datePath + "/" + playlistFile,\r
- new StringReader(mp3Pointer), "US-ASCII");\r
- }\r
- catch (Throwable e) {\r
- logger.error("MediaHandlerMp3.produce: " + e.toString());\r
-\r
- throw new MediaFailure(e);\r
- }\r
- }\r
-\r
- public List getURL(Entity ent, Entity mediaTypeEnt) {\r
- List theList = new Vector();\r
-\r
- //String stringSize = ent.getValue("size");\r
- //int size = Integer.parseInt(stringSize, 10)/1024;\r
- theList.add(ent);\r
-\r
- String basePath = StringUtil.regexpReplace(ent.getValue("publish_path"),\r
- ".mp3$", "");\r
-\r
- // @todo the texts ("title") below urgently need to be sanely localizaeble\r
- // somehow\r
- Map m3uHash = new HashMap();\r
- m3uHash.put("publish_path", basePath + ".m3u");\r
- m3uHash.put("publish_server", ent.getValue("publish_server"));\r
- m3uHash.put("title", "stream URL");\r
- theList.add(m3uHash);\r
-\r
- Map plsHash = new HashMap();\r
- plsHash.put("publish_path", basePath + ".pls");\r
- plsHash.put("publish_server", ent.getValue("publish_server"));\r
- plsHash.put("title", "playlist URL");\r
- theList.add(plsHash);\r
-\r
- return theList;\r
-\r
- }\r
-\r
- public String getDescr(Entity mediaType) {\r
- return "mp3";\r
- }\r
-}\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 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.io.StringReader;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import mir.entity.Entity;
+import mir.log.LoggerWrapper;
+import mir.media.MediaExc;
+import mir.media.MediaFailure;
+import mir.media.MirMedia;
+import mir.misc.FileUtil;
+import mir.misc.StringUtil;
+
+/**
+ * Please note: this media handler produces
+ * 3 media files, the raw .mp3, a .m3u which is
+ * contains the URL for the mp3 and a .pls which
+ * contains the URL to the mp3 in shoutcast playlist
+ * format. What's important is that the web server (of
+ * the media host) must recognize the .m3u and .pls file
+ * extensions and send the proper "audio/x-mpegurl"
+ * and "audio/x-scpls" mime-types respectively.
+ * If the web server is apache, it's easy, just
+ * add:
+ *
+ * audio/x-mpegurl m3u
+ * audio/x-scpl pls
+ *
+ * to the file pointed to by the "TypesConfig"
+ * command in your apache config file. Or add
+ * and equivalent AddType command to your httpd.conf.
+ * Of course this assumes that the mod_mime is loaded.
+ *
+ * If the web server is not apache, then your on your own.
+ *
+ * @see mir.media.MirMedia
+ * @author mh <mh@nadir.org>
+ * @version $Id: MediaHandlerMp3.java,v 1.15.2.2 2003/12/03 18:10:45 rk Exp $
+ */
+
+public class MediaHandlerMp3 extends MediaHandlerAudio implements MirMedia
+{
+
+ public MediaHandlerMp3() {
+ logger = new LoggerWrapper("Media.Audio.Mp3");
+ }
+
+ public void produce(Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure {
+
+ // first check if the file exists
+ super.produce(ent, mediaTypeEnt);
+
+ String baseName = ent.getId();
+ String date = ent.getValue("date");
+ String datePath = StringUtil.webdbDate2path(date);
+ String mp3Pointer = getPublishHost() + ent.getValue("publish_path");
+ String mpegURLFile = baseName + ".m3u";
+ String playlistFile = baseName + ".pls";
+
+ try {
+ //write the "meta" files
+ //first the .m3u since it only contains one line
+ FileUtil.write(getStoragePath() + "/" + datePath + "/" + mpegURLFile,
+ new StringReader(mp3Pointer), "US-ASCII");
+ //now the .pls file
+ FileUtil.write(getStoragePath() + "/" + datePath + "/" + playlistFile,
+ new StringReader(mp3Pointer), "US-ASCII");
+ }
+ catch (Throwable e) {
+ logger.error("MediaHandlerMp3.produce: " + e.toString());
+
+ throw new MediaFailure(e);
+ }
+ }
+
+ public List getURL(Entity ent, Entity mediaTypeEnt) {
+ List theList = new Vector();
+
+ //String stringSize = ent.getValue("size");
+ //int size = Integer.parseInt(stringSize, 10)/1024;
+ theList.add(ent);
+
+ String basePath = StringUtil.regexpReplace(ent.getValue("publish_path"),
+ ".mp3$", "");
+
+ // @todo the texts ("title") below urgently need to be sanely localizaeble
+ // somehow
+ Map m3uHash = new HashMap();
+ m3uHash.put("publish_path", basePath + ".m3u");
+ m3uHash.put("publish_server", ent.getValue("publish_server"));
+ m3uHash.put("title", "stream URL");
+ theList.add(m3uHash);
+
+ Map plsHash = new HashMap();
+ plsHash.put("publish_path", basePath + ".pls");
+ plsHash.put("publish_server", ent.getValue("publish_server"));
+ plsHash.put("title", "playlist URL");
+ theList.add(plsHash);
+
+ return theList;
+
+ }
+
+ public String getDescr(Entity mediaType) {
+ return "mp3";
+ }
+}
+
+
+
-/*\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 any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mircoders.media;\r
-\r
-import java.io.File;\r
-import java.io.StringReader;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Vector;\r
-\r
-import mir.entity.Entity;\r
-import mir.log.LoggerWrapper;\r
-import mir.media.MediaExc;\r
-import mir.media.MediaFailure;\r
-import mir.media.MirMedia;\r
-import mir.misc.FileUtil;\r
-import mir.misc.StringUtil;\r
-\r
-\r
-\r
-/**\r
- * Handles realVideo .it manages the ram file.\r
- *\r
- * 03.2002 - reworked Realmedia handling. -mh\r
- *\r
- * @see mir.media.MediaHandlerGeneric\r
- * @see mir.media.MirMedia\r
- * @author john <john@manifestor.org>, mh <mh@nadir.org>\r
- * @version $Id: MediaHandlerRealVideo.java,v 1.19.2.1 2003/09/03 17:49:40 zapata Exp $\r
- */\r
-\r
-\r
-public class MediaHandlerRealVideo extends MediaHandlerVideo implements MirMedia\r
-{\r
- protected LoggerWrapper logger;\r
-\r
- public MediaHandlerRealVideo() {\r
- logger = new LoggerWrapper("Media.Video.Real");\r
- }\r
-\r
- public void produce (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure {\r
- // first see if the file exists\r
- super.produce(ent, mediaTypeEnt);\r
-\r
- String baseName = ent.getId();\r
- String date = ent.getValue("date");\r
- String datePath = StringUtil.webdbDate2path(date);\r
- String rtspDir = configuration.getString("Producer.RealMedia.Path");\r
- String rtspMediaHost = configuration.getString("Producer.RealMedia.Host");\r
-\r
- String RealMediaPointer = rtspMediaHost+ent.getValue("publish_path");\r
- String RealMediaFile = datePath+ent.getId()+".ram";\r
- try {\r
- //write an rm (ram?. -mh) file\r
- FileUtil.write(super.getStoragePath()+File.separator+RealMediaFile,\r
- new StringReader(RealMediaPointer), "US-ASCII");\r
- }\r
- catch (Throwable e) {\r
- logger.error("MediaHandlerRealVideo.produce: " + e.toString());\r
-\r
- throw new MediaFailure(e);\r
- }\r
- }\r
-\r
- public List getURL(Entity ent, Entity mediaTypeEnt) {\r
- List theList = new Vector();\r
-\r
- //String stringSize = ent.getValue("size");\r
- //int size = Integer.parseInt(stringSize, 10)/1024;\r
- theList.add(ent);\r
-\r
- String basePath=StringUtil.regexpReplace(ent.getValue("publish_path"),\r
- ".rm$","");\r
-\r
- // @todo the texts ("title") below urgently need to be sanely localizaeble\r
- // somehow\r
- Map ramHash = new HashMap();\r
- ramHash.put("publish_path", basePath+".ram");\r
- ramHash.put("publish_server", configuration.getString("Producer.Media.Host"));\r
- ramHash.put("title", "stream URL");\r
- theList.add(ramHash);\r
-\r
- return theList;\r
-\r
- }\r
-\r
- public String getStoragePath() {\r
- return configuration.getString("Producer.RealMedia.Path");\r
- }\r
-\r
- public String getDescr(Entity mediaType) {\r
- return "RealMedia";\r
- }\r
-\r
- public String getPublishHost() {\r
- return StringUtil.removeSlash(configuration.getString("Producer.RealMedia.Host"));\r
- }\r
-\r
-}\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 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.io.File;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import mir.entity.Entity;
+import mir.log.LoggerWrapper;
+import mir.media.MediaExc;
+import mir.media.MediaFailure;
+import mir.media.MirMedia;
+import mir.misc.FileUtil;
+import mir.misc.StringUtil;
+
+
+
+/**
+ * Handles realVideo .it manages the ram file.
+ *
+ * 03.2002 - reworked Realmedia handling. -mh
+ *
+ * @see mir.media.MediaHandlerGeneric
+ * @see mir.media.MirMedia
+ * @author john <john@manifestor.org>, mh <mh@nadir.org>
+ * @version $Id: MediaHandlerRealVideo.java,v 1.19.2.2 2003/12/03 18:10:45 rk Exp $
+ */
+
+
+public class MediaHandlerRealVideo extends MediaHandlerVideo implements MirMedia
+{
+
+ public MediaHandlerRealVideo() {
+ logger = new LoggerWrapper("Media.Video.Real");
+ }
+
+ public void produce (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure {
+ // first see if the file exists
+ super.produce(ent, mediaTypeEnt);
+
+ String baseName = ent.getId();
+ String date = ent.getValue("date");
+ String datePath = StringUtil.webdbDate2path(date);
+ String rtspDir = configuration.getString("Producer.RealMedia.Path");
+ String rtspMediaHost = configuration.getString("Producer.RealMedia.Host");
+
+ String RealMediaPointer = rtspMediaHost+ent.getValue("publish_path");
+ String RealMediaFile = datePath+ent.getId()+".ram";
+ try {
+ //write an rm (ram?. -mh) file
+ FileUtil.write(super.getStoragePath()+File.separator+RealMediaFile,
+ new StringReader(RealMediaPointer), "US-ASCII");
+ }
+ catch (Throwable e) {
+ logger.error("MediaHandlerRealVideo.produce: " + e.toString());
+
+ throw new MediaFailure(e);
+ }
+ }
+
+ public List getURL(Entity ent, Entity mediaTypeEnt) {
+ List theList = new Vector();
+
+ //String stringSize = ent.getValue("size");
+ //int size = Integer.parseInt(stringSize, 10)/1024;
+ theList.add(ent);
+
+ String basePath=StringUtil.regexpReplace(ent.getValue("publish_path"),
+ ".rm$","");
+
+ // @todo the texts ("title") below urgently need to be sanely localizaeble
+ // somehow
+ Map ramHash = new HashMap();
+ ramHash.put("publish_path", basePath+".ram");
+ ramHash.put("publish_server", configuration.getString("Producer.Media.Host"));
+ ramHash.put("title", "stream URL");
+ theList.add(ramHash);
+
+ return theList;
+
+ }
+
+ public String getStoragePath() {
+ return configuration.getString("Producer.RealMedia.Path");
+ }
+
+ public String getDescr(Entity mediaType) {
+ return "RealMedia";
+ }
+
+ public String getPublishHost() {
+ return StringUtil.removeSlash(configuration.getString("Producer.RealMedia.Host"));
+ }
+
+}
+
+
+
public class AudioSearchTerm extends SearchTerm{
-
- public static String matchField = "hasAudio";
- public static String paramName = "search_hasAudio";
- public static String templateVariable = "hasAudio";
+ static {
+ matchField = "hasAudio";
+ paramName = "search_hasAudio";
+ templateVariable = "hasAudio";
+ }
public void index(Document doc, Entity entity) throws StorageObjectFailure{
EntityList audio = DatabaseContentToMedia.getInstance().getAudio((EntityContent) entity);
public class ContentSearchTerm extends SearchTerm{
- public String templateVariable;
- public String dataField;
- public String matchField;
- public String paramName;
- public String partOfEntity;
-
public ContentSearchTerm(String anEntityPart,String aParamName,String aMatchField,String aDataField, String aTemplateVariable){
partOfEntity = anEntityPart;
paramName = aParamName;
matchField = aMatchField;
dataField = aDataField;
templateVariable = aTemplateVariable;
-
}
public void index(Document doc, Entity entity){
public class ImagesSearchTerm extends SearchTerm{
-
- public static String matchField = "hasImages";
- public static String paramName = "search_hasImages";
- public static String dataField = "images";
- public static String templateVariable = "images";
-
+ static {
+ matchField = "hasImages";
+ paramName = "search_hasImages";
+ dataField = "images";
+ templateVariable = "images";
+ }
+
public void index(Document doc, Entity entity) throws StorageObjectFailure{
EntityList images = DatabaseContentToMedia.getInstance().getImages((EntityContent) entity);
if (images != null && images.size()>0){
public class KeywordSearchTerm extends SearchTerm{
- public String templateVariable;
- public String dataField;
- public String matchField;
- public String paramName;
- public String partOfEntity;
-
-
public KeywordSearchTerm(String anEntityPart,String aParamName,String aMatchField,String aDataField, String aTemplateVariable){
partOfEntity = anEntityPart;
public class MediaSearchTerm extends SearchTerm{
- public static String matchField = "";
- public static String paramName = "search_hasMedia";
- public static String templateVariable = "";
+
+ static {
+ matchField = "";
+ paramName = "search_hasMedia";
+ templateVariable = "";
+ }
public void index(Document doc, Entity entity) throws StorageObjectFailure{
// only use this term for doing alternate queries on media
public class TextSearchTerm extends SearchTerm{
- public String templateVariable;
- public String dataField;
- public String matchField;
- public String paramName;
- public String partOfEntity;
public TextSearchTerm(String anEntityPart,String aParamName,String aMatchField,String aDataField, String aTemplateVariable){
partOfEntity = anEntityPart;
matchField = aMatchField;
dataField = aDataField;
templateVariable = aTemplateVariable;
-
}
public void index(Document doc, Entity entity){
public class TopicMatrixSearchTerm extends SearchTerm{
-
- public static String matchField = "topic";
- public static String paramName = "search_topicmatrix";
+ static {
+ matchField = "topic";
+ paramName = "search_topicmatrix";
+ }
public void index(Document doc, Entity entity) throws StorageObjectFailure{
EntityList topics = DatabaseContentToTopics.getInstance().getTopics((EntityContent) entity);
public class TopicSearchTerm extends SearchTerm{
-
- public static String matchField = "topic";
- public static String paramName = "search_topic";
+ static {
+ matchField = "topic";
+ paramName = "search_topic";
+ }
public void index(Document doc, Entity entity) throws StorageObjectFailure{
EntityList topics = DatabaseContentToTopics.getInstance().getTopics((EntityContent) entity);
public class UnIndexedSearchTerm extends SearchTerm{
- public String templateVariable;
- public String dataField;
- public String matchField;
- public String paramName;
- public String partOfEntity;
public UnIndexedSearchTerm(String anEntityPart,String aParamName,String aMatchField,String aDataField, String aTemplateVariable){
partOfEntity = anEntityPart;
public class UnStoredSearchTerm extends SearchTerm{
- public String templateVariable;
- public String dataField;
- public String matchField;
- public String paramName;
- public String partOfEntity;
-
public UnStoredSearchTerm(String anEntityPart,String aParamName,String aMatchField,String aDataField, String aTemplateVariable){
partOfEntity = anEntityPart;
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
* If you do not wish to do so, delete this exception statement from your version.
*/
-
package mircoders.search;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-
import mir.entity.Entity;
import mir.entity.EntityList;
import mir.storage.StorageObjectFailure;
import mircoders.entity.EntityContent;
import mircoders.storage.DatabaseContentToMedia;
-
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
-public class VideoSearchTerm extends SearchTerm{
- public static String matchField = "hasVideo";
- public static String paramName = "search_hasVideo";
- public static String templateVariable = "hasVideo";
+public class VideoSearchTerm extends SearchTerm {
+ static {
+ matchField = "hasVideo";
+ paramName = "search_hasVideo";
+ templateVariable = "hasVideo";
+ }
- public void index(Document doc, Entity entity) throws StorageObjectFailure{
+ public void index(Document doc, Entity entity) throws StorageObjectFailure {
EntityList video = DatabaseContentToMedia.getInstance().getVideo((EntityContent) entity);
- if (video != null && video.size()>0){
- doc.add(Field.Keyword(matchField,"y"));
+
+ if ((video != null) && (video.size() > 0)) {
+ doc.add(Field.Keyword(matchField, "y"));
}
}
- public String makeTerm(HttpServletRequest req){
+ public String makeTerm(HttpServletRequest req) {
String wanted = req.getParameter(paramName);
- if (wanted != null && wanted.equals("y")){
+
+ if ((wanted != null) && wanted.equals("y")) {
return matchField + ":" + "\"" + wanted + "\"";
- }
- else {
+ } else {
return null;
}
}
- public void returnMeta(Map result,Document doc){
+ public void returnMeta(Map result, Document doc) {
result.put(templateVariable, doc.get(matchField));
}
-
-
}
-
-
* open-postings to the newswire
*
* @author mir-coders group
- * @version $Id: ServletModuleOpenIndy.java,v 1.89.2.8 2003/10/23 14:55:25 rk Exp $
+ * @version $Id: ServletModuleOpenIndy.java,v 1.89.2.9 2003/12/03 18:10:46 rk Exp $
*
*/
queryString = queryString + " +" + videoFragment;
}
- if (queryString == null || queryString == "") {
+ if (queryString == null) {
queryString = "";
}
else {
public static ServletModule getInstance() { return instance; }
Object comments;
- Map generationData;
- Generator generator;
int totalNrComments;
- List producersData;
void generateResponse(String aGeneratorIdentifier, PrintWriter aWriter, Map aResponseData, Locale aLocale) {
+ Generator generator;
try {
generator = MirGlobal.localizer().generators().makeAdminGeneratorLibrary().makeGenerator(aGeneratorIdentifier);
MirGlobal.localizer().producerAssistant().initializeGenerationValueSet(aResponseData);
-/*\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 any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mircoders.storage;\r
-\r
-import java.util.GregorianCalendar;\r
-\r
-import mir.entity.Entity;\r
-import mir.log.LoggerWrapper;\r
-import mir.misc.StringUtil;\r
-import mir.storage.Database;\r
-import mir.storage.StorageObject;\r
-import mir.storage.StorageObjectFailure;\r
-\r
-public class DatabaseAudio extends Database implements StorageObject{\r
-\r
- private static DatabaseAudio 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 DatabaseAudio getInstance() {\r
- if (instance == null) {\r
- instance = new DatabaseAudio();\r
- }\r
- return instance;\r
- }\r
-\r
- private DatabaseAudio() throws StorageObjectFailure {\r
- super();\r
- logger = new LoggerWrapper("Database.Audio");\r
-\r
- hasTimestamp = true;\r
- theTable = "audio";\r
- theCoreTable = "media";\r
- theEntityClass = mircoders.entity.EntityAudio.class;\r
- }\r
-\r
- public void update(Entity theEntity) throws StorageObjectFailure {\r
- String date = theEntity.getValue("date");\r
- if (date == null) {\r
- date = StringUtil.date2webdbDate(new GregorianCalendar());\r
- theEntity.setValueForProperty("date", date);\r
- }\r
-\r
- super.update(theEntity);\r
- }\r
-\r
- public String insert(Entity theEntity) throws StorageObjectFailure {\r
- String date = theEntity.getValue("date");\r
- if (date == null) {\r
- date = StringUtil.date2webdbDate(new GregorianCalendar());\r
- theEntity.setValueForProperty("date", date);\r
- }\r
- return super.insert(theEntity);\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 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.util.GregorianCalendar;
+
+import mir.entity.Entity;
+import mir.log.LoggerWrapper;
+import mir.misc.StringUtil;
+import mir.storage.Database;
+import mir.storage.StorageObject;
+import mir.storage.StorageObjectFailure;
+
+public class DatabaseAudio extends Database implements StorageObject{
+
+ private static DatabaseAudio 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 DatabaseAudio getInstance() {
+ if (instance == null) {
+ instance = new DatabaseAudio();
+ }
+ return instance;
+ }
+
+ private DatabaseAudio() throws StorageObjectFailure {
+ super();
+ logger = new LoggerWrapper("Database.Audio");
+
+ hasTimestamp = true;
+ theTable = "audio";
+ theCoreTable = "media";
+ theEntityClass = mircoders.entity.EntityAudio.class;
+ }
+
+ public void update(Entity theEntity) throws StorageObjectFailure {
+ String date = theEntity.getValue("date");
+ if (date == null) {
+ date = StringUtil.date2webdbDate(new GregorianCalendar());
+ theEntity.setValueForProperty("date", date);
+ }
+
+ super.update(theEntity);
+ }
+
+ public String insert(Entity theEntity) throws StorageObjectFailure {
+ String date = theEntity.getValue("date");
+ if (date == null) {
+ date = StringUtil.date2webdbDate(new GregorianCalendar());
+ theEntity.setValueForProperty("date", date);
+ }
+ return super.insert(theEntity);
+ }
+
+}