From f686dd55489e6241bff68b4169058cf6e498ec2c Mon Sep 17 00:00:00 2001 From: rk Date: Wed, 3 Dec 2003 18:10:45 +0000 Subject: [PATCH] minor changes according to JLint --- doc/INSTALL.mir | 18 +- source/mir/servlet/AbstractServlet.java | 13 +- .../basic/MirBasicAntiAbuseFilterTypes.java | 431 +++++++++++---------- source/mircoders/media/MediaHandlerMp3.java | 285 +++++++------- source/mircoders/media/MediaHandlerRealVideo.java | 259 ++++++------- source/mircoders/search/AudioSearchTerm.java | 9 +- source/mircoders/search/ContentSearchTerm.java | 7 - source/mircoders/search/ImagesSearchTerm.java | 13 +- source/mircoders/search/KeywordSearchTerm.java | 7 - source/mircoders/search/MediaSearchTerm.java | 9 +- source/mircoders/search/TextSearchTerm.java | 6 - source/mircoders/search/TopicMatrixSearchTerm.java | 7 +- source/mircoders/search/TopicSearchTerm.java | 7 +- source/mircoders/search/UnIndexedSearchTerm.java | 5 - source/mircoders/search/UnStoredSearchTerm.java | 6 - source/mircoders/search/VideoSearchTerm.java | 53 ++- .../mircoders/servlet/ServletModuleOpenIndy.java | 4 +- .../mircoders/servlet/ServletModuleProducer.java | 4 +- source/mircoders/storage/DatabaseAudio.java | 168 ++++---- 19 files changed, 640 insertions(+), 671 deletions(-) diff --git a/doc/INSTALL.mir b/doc/INSTALL.mir index d011c7b0..a4411bb5 100755 --- a/doc/INSTALL.mir +++ b/doc/INSTALL.mir @@ -1,6 +1,6 @@ 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. @@ -15,10 +15,10 @@ prerequisites: - 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, @@ -85,11 +85,7 @@ This is practical if you are running several installations of mir on one 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 @@ -260,4 +256,4 @@ You can give these a try if anything goes wrong: ---------------------------------------------------------------- -$Date: 2003/11/24 19:57:54 $ - the Mir coders +$Date: 2003/12/03 18:10:45 $ - the Mir coders diff --git a/source/mir/servlet/AbstractServlet.java b/source/mir/servlet/AbstractServlet.java index ff059d5d..90aff294 100755 --- a/source/mir/servlet/AbstractServlet.java +++ b/source/mir/servlet/AbstractServlet.java @@ -56,11 +56,11 @@ import com.codestudio.util.SQLManager; * 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; @@ -132,7 +132,7 @@ public abstract class AbstractServlet extends HttpServlet { */ protected String getAcceptLanguage(HttpServletRequest aRequest) { Locale loc = aRequest.getLocale(); - lang = loc.getLanguage(); + String lang = loc.getLanguage(); return lang; } @@ -191,11 +191,16 @@ public abstract class AbstractServlet extends HttpServlet { 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()); diff --git a/source/mircoders/localizer/basic/MirBasicAntiAbuseFilterTypes.java b/source/mircoders/localizer/basic/MirBasicAntiAbuseFilterTypes.java index 020605dc..ef148e2a 100755 --- a/source/mircoders/localizer/basic/MirBasicAntiAbuseFilterTypes.java +++ b/source/mircoders/localizer/basic/MirBasicAntiAbuseFilterTypes.java @@ -1,216 +1,217 @@ -/* - * 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; - - -/** - *

Title:

- *

Description:

- *

Copyright: Copyright (c) 2003

- *

Company:

- * @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. - * - *

Title:

- *

Description:

- *

Copyright: Copyright (c) 2003

- *

Company:

- * @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. - * - *

Title:

- *

Description:

- *

Copyright: Copyright (c) 2003

- *

Company:

- * @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) - 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; - } - } - +/* + * 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; + + +/** + *

Title:

+ *

Description:

+ *

Copyright: Copyright (c) 2003

+ *

Company:

+ * @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. + * + *

Title:

+ *

Description:

+ *

Copyright: Copyright (c) 2003

+ *

Company:

+ * @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. + * + *

Title:

+ *

Description:

+ *

Copyright: Copyright (c) 2003

+ *

Company:

+ * @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 diff --git a/source/mircoders/media/MediaHandlerMp3.java b/source/mircoders/media/MediaHandlerMp3.java index 81bf55a5..e17cfb1d 100755 --- a/source/mircoders/media/MediaHandlerMp3.java +++ b/source/mircoders/media/MediaHandlerMp3.java @@ -1,143 +1,142 @@ -/* - * 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 - * @version $Id: MediaHandlerMp3.java,v 1.15.2.1 2003/09/03 17:49:39 zapata Exp $ - */ - -public class MediaHandlerMp3 extends MediaHandlerAudio implements MirMedia -{ - protected LoggerWrapper logger; - - 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"; - } -} - - - +/* + * 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 + * @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"; + } +} + + + diff --git a/source/mircoders/media/MediaHandlerRealVideo.java b/source/mircoders/media/MediaHandlerRealVideo.java index 12af17f6..613f1cc0 100755 --- a/source/mircoders/media/MediaHandlerRealVideo.java +++ b/source/mircoders/media/MediaHandlerRealVideo.java @@ -1,130 +1,129 @@ -/* - * 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 , mh - * @version $Id: MediaHandlerRealVideo.java,v 1.19.2.1 2003/09/03 17:49:40 zapata Exp $ - */ - - -public class MediaHandlerRealVideo extends MediaHandlerVideo implements MirMedia -{ - protected LoggerWrapper logger; - - 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")); - } - -} - - - +/* + * 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 , mh + * @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")); + } + +} + + + diff --git a/source/mircoders/search/AudioSearchTerm.java b/source/mircoders/search/AudioSearchTerm.java index 7887a96c..f43e12a4 100755 --- a/source/mircoders/search/AudioSearchTerm.java +++ b/source/mircoders/search/AudioSearchTerm.java @@ -45,10 +45,11 @@ import org.apache.lucene.document.Field; 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); diff --git a/source/mircoders/search/ContentSearchTerm.java b/source/mircoders/search/ContentSearchTerm.java index 20aadbb2..d349c245 100755 --- a/source/mircoders/search/ContentSearchTerm.java +++ b/source/mircoders/search/ContentSearchTerm.java @@ -43,19 +43,12 @@ import org.apache.lucene.document.Field; 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){ diff --git a/source/mircoders/search/ImagesSearchTerm.java b/source/mircoders/search/ImagesSearchTerm.java index e0bdb672..0a411d7c 100755 --- a/source/mircoders/search/ImagesSearchTerm.java +++ b/source/mircoders/search/ImagesSearchTerm.java @@ -49,12 +49,13 @@ import org.apache.lucene.document.Field; 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){ diff --git a/source/mircoders/search/KeywordSearchTerm.java b/source/mircoders/search/KeywordSearchTerm.java index 63bdb6de..0cd904d6 100755 --- a/source/mircoders/search/KeywordSearchTerm.java +++ b/source/mircoders/search/KeywordSearchTerm.java @@ -43,13 +43,6 @@ import org.apache.lucene.document.Field; 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; diff --git a/source/mircoders/search/MediaSearchTerm.java b/source/mircoders/search/MediaSearchTerm.java index 38ee4a0e..087c725c 100755 --- a/source/mircoders/search/MediaSearchTerm.java +++ b/source/mircoders/search/MediaSearchTerm.java @@ -41,9 +41,12 @@ import org.apache.lucene.document.Document; 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 diff --git a/source/mircoders/search/TextSearchTerm.java b/source/mircoders/search/TextSearchTerm.java index 04c9f13c..bb8b116d 100755 --- a/source/mircoders/search/TextSearchTerm.java +++ b/source/mircoders/search/TextSearchTerm.java @@ -42,11 +42,6 @@ import org.apache.lucene.document.Field; 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; @@ -54,7 +49,6 @@ public class TextSearchTerm extends SearchTerm{ matchField = aMatchField; dataField = aDataField; templateVariable = aTemplateVariable; - } public void index(Document doc, Entity entity){ diff --git a/source/mircoders/search/TopicMatrixSearchTerm.java b/source/mircoders/search/TopicMatrixSearchTerm.java index e9fcf341..acc99fb7 100755 --- a/source/mircoders/search/TopicMatrixSearchTerm.java +++ b/source/mircoders/search/TopicMatrixSearchTerm.java @@ -45,9 +45,10 @@ import org.apache.lucene.document.Field; 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); diff --git a/source/mircoders/search/TopicSearchTerm.java b/source/mircoders/search/TopicSearchTerm.java index 30a4ad38..39fa7d08 100755 --- a/source/mircoders/search/TopicSearchTerm.java +++ b/source/mircoders/search/TopicSearchTerm.java @@ -45,9 +45,10 @@ import org.apache.lucene.document.Field; 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); diff --git a/source/mircoders/search/UnIndexedSearchTerm.java b/source/mircoders/search/UnIndexedSearchTerm.java index 930cfe4f..b814f186 100755 --- a/source/mircoders/search/UnIndexedSearchTerm.java +++ b/source/mircoders/search/UnIndexedSearchTerm.java @@ -42,11 +42,6 @@ import org.apache.lucene.document.Field; 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; diff --git a/source/mircoders/search/UnStoredSearchTerm.java b/source/mircoders/search/UnStoredSearchTerm.java index 8ed8c108..9c5fd731 100755 --- a/source/mircoders/search/UnStoredSearchTerm.java +++ b/source/mircoders/search/UnStoredSearchTerm.java @@ -41,12 +41,6 @@ import org.apache.lucene.document.Field; 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; diff --git a/source/mircoders/search/VideoSearchTerm.java b/source/mircoders/search/VideoSearchTerm.java index 6ea040dd..8dcac1b5 100755 --- a/source/mircoders/search/VideoSearchTerm.java +++ b/source/mircoders/search/VideoSearchTerm.java @@ -18,59 +18,54 @@ * 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)); } - - } - - diff --git a/source/mircoders/servlet/ServletModuleOpenIndy.java b/source/mircoders/servlet/ServletModuleOpenIndy.java index 6172d1c0..3f890736 100755 --- a/source/mircoders/servlet/ServletModuleOpenIndy.java +++ b/source/mircoders/servlet/ServletModuleOpenIndy.java @@ -121,7 +121,7 @@ import org.apache.struts.util.MessageResources; * 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 $ * */ @@ -844,7 +844,7 @@ public class ServletModuleOpenIndy extends ServletModule queryString = queryString + " +" + videoFragment; } - if (queryString == null || queryString == "") { + if (queryString == null) { queryString = ""; } else { diff --git a/source/mircoders/servlet/ServletModuleProducer.java b/source/mircoders/servlet/ServletModuleProducer.java index 51427b5f..c6ba0ec1 100755 --- a/source/mircoders/servlet/ServletModuleProducer.java +++ b/source/mircoders/servlet/ServletModuleProducer.java @@ -57,12 +57,10 @@ public class ServletModuleProducer extends ServletModule 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); diff --git a/source/mircoders/storage/DatabaseAudio.java b/source/mircoders/storage/DatabaseAudio.java index 24d6b069..46117669 100755 --- a/source/mircoders/storage/DatabaseAudio.java +++ b/source/mircoders/storage/DatabaseAudio.java @@ -1,84 +1,84 @@ -/* - * 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); - } - -} +/* + * 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); + } + +} -- 2.11.0