########## admin ##########
# language: english
-# $Id: admin_en.properties,v 1.48.2.18 2003/12/07 23:30:34 init Exp $
+# $Id: admin_en.properties,v 1.48.2.19 2003/12/14 16:37:06 zapata Exp $
languagename=English
# media - used by image, audio, video and other media
+media.urls = Urls
media.created=created
media.changed=last modification
media.published=published
--- /dev/null
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with 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 mir.media;\r
+\r
+import java.io.InputStream;\r
+import java.util.List;\r
+\r
+import mir.entity.Entity;\r
+\r
+/**\r
+ * Interface for Media handling in Mir. All media handlers\r
+ * must implement this interface. Each specific media type,\r
+ * be it Gif, Jpeg, Mp3 audio, Real Audio or quicktime video\r
+ * has special needs when it comes to representation on the various\r
+ * pages (article, list, summary), must be stored differently and has a\r
+ * different URL, etc... This interface allows Mir to support\r
+ * an infinite (I hope) number of media types. Once this is done,\r
+ * no code at any other level in Mir needs to be changed other than\r
+ * adding the content-type <-> media handler name mapping in the\r
+ * media_type table. The following is an example of the media_type\r
+ * table:\r
+ * <p>\r
+ * id | name | mime_type | classname | tablename | dcname<br>\r
+ *---+---------+--------------------------+-----------+---------------+-------<br>\r
+ * 2 | unknown | application/octet-stream | -- | UploadedMedia | <br>\r
+ * 3 | jpg | image/gif | ImagesGif | Images | <br>\r
+ * 4 | mp3 | audio/mp3 | Audio | UploadedMedia | <br>\r
+ * <p>\r
+ * The "id" field is used as a mapping in the table that contains the media type\r
+ * to the media_type table. For example, the images table has a to_media_type\r
+ * field that contains the id in the media_type table.\r
+ * <p>\r
+ * The "name" field is used for various display/filenaming purposes. it should\r
+ * match a valid file extension name for a media_type (we could have used the\r
+ * content-type map for this....).\r
+ * <p>\r
+ * The "mime_type" field is the most important as it does maps the type to Java\r
+ * classes (the storage and media_handler name). We call those classes using\r
+ * reflection. This way, once a Handler for a specific media type is implemented\r
+ * and entered into the media_type table, no other Mir code needs to be modified.\r
+ * <p>\r
+ * The "classname" field is the name of the media handler (e.g MediaHandlerAudio)\r
+ * we use it to call the MediaHandler methods via reflection.\r
+ * <p>\r
+ * The "tablename" is the name of the database storage classes (e.g DatabaseImages\r
+ * and EntityImages). We use this to fetch/storage the media (meta)data in the db.\r
+ * <p?\r
+ * The "dcname" field is as of yet unused. Do search for "Dublin Core" on google\r
+ * to learn more.\r
+ * <p>\r
+ * Most media handlers should just extend MediaHandlerGeneric (i.e inherit from\r
+ * ) and just override the things that need to be specific. see MediaHandlerAudio\r
+ *\r
+ * @author <mh@nadir.org>, the Mir-coders group\r
+ * @version $Id: MediaHandler.java,v 1.1.2.1 2003/12/14 16:37:06 zapata Exp $\r
+ */\r
+\r
+public interface MediaHandler {\r
+ /**\r
+ * Takes the uploaded media data itself, along with the media Entity\r
+ * which contains the Media metadata plus the MediaType entity containing\r
+ * all the info for the specific media type itself. It's job is store the\r
+ * Media data (content) itself, this could be on the local filesystem, in the\r
+ * DB or even on a remote host. It then inserts the MetaData in the DB.\r
+ * @param InputStream, a stream of the uploaded data.\r
+ * @param ent, an Entity holding the media MetaData\r
+ * @param mediaType, an Entity holding the media_table entry\r
+ * @return boolean, success/fail\r
+ * @see mir.entity.Entity\r
+ */\r
+ public void store(InputStream in, Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure;\r
+\r
+ public void produce(Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure;\r
+ /**\r
+ * Get's the media data from storage and returns it as an InputStream\r
+ * Not very useful for most media types as they are stored in a file,\r
+ * but very usefull for ones stored in the DB as it is necessary to get\r
+ * it first before making a file out of it (in Producer*).\r
+ * @param ent, an Entity holding the media MetaData\r
+ * @param mediaType, an Entity holding the media_table entry\r
+ * @return java.io.InputStream\r
+ * @see mir.entity.Entity\r
+ */\r
+ public InputStream getMedia (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure;\r
+\r
+ /**\r
+ * Pretty much like get() above. But get's the specific Icon\r
+ * representation. useful for media stored in the DB.\r
+ * @param ent, an Entity holding the media MetaData\r
+ * @return java.io.InputStream\r
+ * @see mir.entity.Entity\r
+ */\r
+ public InputStream getThumbnail(Entity ent) throws MediaExc, MediaFailure;\r
+\r
+\r
+ /**\r
+ *\r
+ * @param ent\r
+ * @return\r
+ * @throws MediaExc\r
+ * @throws MediaFailure\r
+ */\r
+ public String getThumbnailMimeType(Entity aMediaEntity, Entity aMediaType) throws MediaExc, MediaFailure;\r
+\r
+ /**\r
+ * gets the final content representation for the media\r
+ * in the form of a URL (String) that allows someone to\r
+ * download, look at or listen to the media. (HREF, img src\r
+ * streaming link, etc..)\r
+ * It should use the helper functions in the StringUtil class to\r
+ * build URL's safely, eliminating any *illegal* user input.\r
+ * @param ent, an Entity holding the media MetaData\r
+ * @param mediaTypeEnt, an Entity holding the media_table entry\r
+ * @return String, the url.\r
+ * @see mir.entity.Entity\r
+ * @see mir.misc.StringUtil\r
+ */\r
+ public List getURL (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure;\r
+\r
+ /**\r
+ * Returns the absolute filesystem path to where the media\r
+ * content should be stored. This path is usually defined\r
+ * in the configuration wich is accessible through the MirConfig\r
+ * class.\r
+ * @return String, the path.\r
+ * @see mir.misc.MirConfig\r
+ */\r
+ public String getStoragePath () throws MediaExc, MediaFailure;\r
+\r
+ /**\r
+ * Returns the *relative* filesystem path to where the media\r
+ * icon content should be stored. It is relative to the path\r
+ * returned by getStoragePath()\r
+ * This path is usually defined\r
+ * in the configuration wich is accessible through the MirConfig\r
+ * class.\r
+ * @return String, the path.\r
+ * @see mir.misc.MirConfig\r
+ */\r
+ public String getIconStoragePath () throws MediaExc, MediaFailure;\r
+\r
+ /**\r
+ * Returns the base URL to that the media is accessible from\r
+ * to the end user. This could be a URL to another host.\r
+ * This is used in the Metadata stored in the DB and later on\r
+ * ,the templates use it.\r
+ * It is usually defined\r
+ * in the configuration witch is accessible through the MirConfig\r
+ * class.\r
+ * @return String, the base URL to the host.\r
+ * @see mir.misc.MirConfig\r
+ */\r
+ public String getPublishHost () throws MediaExc, MediaFailure;\r
+\r
+ /**\r
+ * Returns the file name of the Icon representing the media type.\r
+ * It is used in the summary view.\r
+ * It is usually defined\r
+ * in the configuration wich is accessible through the MirConfig\r
+ * class.\r
+ * @return String, the icon filename.\r
+ * @see mir.misc.MirConfig\r
+ */\r
+ public String getBigIconName ();\r
+\r
+ /**\r
+ * Returns the file name of the small Icon representing\r
+ * the media type.\r
+ * It is used in the right hand newswire list of the startpage.\r
+ * It is usually defined\r
+ * in the configuration wich is accessible through the MirConfig\r
+ * class.\r
+ * @return String, the icon filename.\r
+ * @see mir.misc.MirConfig\r
+ */\r
+ public String getTinyIconName ();\r
+\r
+ /**\r
+ * Returns the IMG SRC "ALT" text to be used\r
+ * for the Icon representations\r
+ * @return String, the ALT text.\r
+ */\r
+ public String getIconAltName ();\r
+\r
+ /**\r
+ * returns a brief text dscription of what this\r
+ * media type is.\r
+ * @return String\r
+ */\r
+ public String getDescr (Entity mediaTypeEnt);\r
+\r
+}\r
+\r
+\r
+++ /dev/null
-/*
- * Copyright (C) 2001, 2002 The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Mir is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your version.
- */
-package mir.media;
-
-import java.lang.reflect.Method;
-
-import mir.entity.Entity;
-import mir.storage.Database;
-
-
-/**
- * helper class to resolve media handlers using reflection
- *
- * @author mh
- * @version 2002
- */
-
-public final class MediaHelper {
-
- static String _classPrefix = "mircoders.media.MediaHandler";
-
- public static MirMedia getHandler( Entity mediaType ) throws MediaExc, MediaFailure {
-
- MirMedia mediaHandler;
- String handlerName = mediaType.getValue("classname");
- try {
- Class handlerClass = Class.forName(_classPrefix+handlerName);
- return mediaHandler = (MirMedia)handlerClass.newInstance();
- }
- catch (Throwable e) {
- throw new MediaFailure("getHandler -- error in reflection " + e.toString(), e);
- }
- }
-
- public static Database getStorage(Entity mediaType, String classPrefix) throws MediaExc, MediaFailure {
-
- Database mediaStorage;
- String storageName = mediaType.getValue("tablename");
- try {
- Class storageClass = Class.forName(classPrefix+storageName);
- Method m = storageClass.getMethod("getInstance", null);
- return mediaStorage = (Database)m.invoke(null, null);
- }
- catch (Throwable e) {
- throw new MediaFailure("getStorage -- error in reflection " + e.toString(), e);
- }
- }
-
-}
-
-
-
+++ /dev/null
-/*
- * Copyright (C) 2001, 2002 The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Mir is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your version.
- */
-package mir.media;
-
-import java.io.InputStream;\r
-import java.util.List;\r
-\r
-import mir.entity.Entity;
-
-/**
- * Interface for Media handling in Mir. All media handlers
- * must implement this interface. Each specific media type,
- * be it Gif, Jpeg, Mp3 audio, Real Audio or quicktime video
- * has special needs when it comes to representation on the various
- * pages (article, list, summary), must be stored differently and has a
- * different URL, etc... This interface allows Mir to support
- * an infinite (I hope) number of media types. Once this is done,
- * no code at any other level in Mir needs to be changed other than
- * adding the content-type <-> media handler name mapping in the
- * media_type table. The following is an example of the media_type
- * table:
- * <p>
- * id | name | mime_type | classname | tablename | dcname<br>
- *---+---------+--------------------------+-----------+---------------+-------<br>
- * 2 | unknown | application/octet-stream | -- | UploadedMedia | <br>
- * 3 | jpg | image/gif | ImagesGif | Images | <br>
- * 4 | mp3 | audio/mp3 | Audio | UploadedMedia | <br>
- * <p>
- * The "id" field is used as a mapping in the table that contains the media type
- * to the media_type table. For example, the images table has a to_media_type
- * field that contains the id in the media_type table.
- * <p>
- * The "name" field is used for various display/filenaming purposes. it should
- * match a valid file extension name for a media_type (we could have used the
- * content-type map for this....).
- * <p>
- * The "mime_type" field is the most important as it does maps the type to Java
- * classes (the storage and media_handler name). We call those classes using
- * reflection. This way, once a Handler for a specific media type is implemented
- * and entered into the media_type table, no other Mir code needs to be modified.
- * <p>
- * The "classname" field is the name of the media handler (e.g MediaHandlerAudio)
- * we use it to call the MediaHandler methods via reflection.
- * <p>
- * The "tablename" is the name of the database storage classes (e.g DatabaseImages
- * and EntityImages). We use this to fetch/storage the media (meta)data in the db.
- * <p?
- * The "dcname" field is as of yet unused. Do search for "Dublin Core" on google
- * to learn more.
- * <p>
- * Most media handlers should just extend MediaHandlerGeneric (i.e inherit from
- * ) and just override the things that need to be specific. see MediaHandlerAudio
- *
- * @author <mh@nadir.org>, the Mir-coders group
- * @version $Id: MirMedia.java,v 1.18.2.1 2003/09/03 17:49:38 zapata Exp $
- */
-
-public interface MirMedia{
-
- /**
- * Takes the uploaded media data itself, along with the media Entity
- * which contains the Media metadata plus the MediaType entity containing
- * all the info for the specific media type itself. It's job is store the
- * Media data (content) itself, this could be on the local filesystem, in the
- * DB or even on a remote host. It then inserts the MetaData in the DB.
- * @param InputStream, a stream of the uploaded data.
- * @param ent, an Entity holding the media MetaData
- * @param mediaType, an Entity holding the media_table entry
- * @return boolean, success/fail
- * @see mir.entity.Entity
- */
- public abstract void set (InputStream in, Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure;
-
- public abstract void produce (Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure;
-
- /**
- * Get's the media data from storage and returns it as an InputStream
- * Not very useful for most media types as they are stored in a file,
- * but very usefull for ones stored in the DB as it is necessary to get
- * it first before making a file out of it (in Producer*).
- * @param ent, an Entity holding the media MetaData
- * @param mediaType, an Entity holding the media_table entry
- * @return java.io.InputStream
- * @see mir.entity.Entity
- */
- public abstract InputStream getMedia (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure;
-
- /**
- * Pretty much like get() above. But get's the specific Icon
- * representation. useful for media stored in the DB.
- * @param ent, an Entity holding the media MetaData
- * @return java.io.InputStream
- * @see mir.entity.Entity
- */
- public abstract InputStream getIcon (Entity ent) throws MediaExc, MediaFailure;
-
-
- /**
- *
- * @param ent
- * @return
- * @throws MediaExc
- * @throws MediaFailure
- */
- public abstract String getIconMimeType (Entity aMediaEntity, Entity aMediaType) throws MediaExc, MediaFailure;
-
- /**
- * gets the final content representation for the media
- * in the form of a URL (String) that allows someone to
- * download, look at or listen to the media. (HREF, img src
- * streaming link, etc..)
- * It should use the helper functions in the StringUtil class to
- * build URL's safely, eliminating any *illegal* user input.
- * @param ent, an Entity holding the media MetaData
- * @param mediaTypeEnt, an Entity holding the media_table entry
- * @return String, the url.
- * @see mir.entity.Entity
- * @see mir.misc.StringUtil
- */
- public abstract List getURL (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure;
-
- /**
- * Returns the absolute filesystem path to where the media
- * content should be stored. This path is usually defined
- * in the configuration wich is accessible through the MirConfig
- * class.
- * @return String, the path.
- * @see mir.misc.MirConfig
- */
- public abstract String getStoragePath () throws MediaExc, MediaFailure;
-
- /**
- * Returns the *relative* filesystem path to where the media
- * icon content should be stored. It is relative to the path
- * returned by getStoragePath()
- * This path is usually defined
- * in the configuration wich is accessible through the MirConfig
- * class.
- * @return String, the path.
- * @see mir.misc.MirConfig
- */
- public abstract String getIconStoragePath () throws MediaExc, MediaFailure;
-
- /**
- * Returns the base URL to that the media is accessible from
- * to the end user. This could be a URL to another host.
- * This is used in the Metadata stored in the DB and later on
- * ,the templates use it.
- * It is usually defined
- * in the configuration witch is accessible through the MirConfig
- * class.
- * @return String, the base URL to the host.
- * @see mir.misc.MirConfig
- */
- public abstract String getPublishHost () throws MediaExc, MediaFailure;
-
- /**
- * Returns the file name of the Icon representing the media type.
- * It is used in the summary view.
- * It is usually defined
- * in the configuration wich is accessible through the MirConfig
- * class.
- * @return String, the icon filename.
- * @see mir.misc.MirConfig
- */
- public abstract String getBigIconName ();
-
- /**
- * Returns the file name of the small Icon representing
- * the media type.
- * It is used in the right hand newswire list of the startpage.
- * It is usually defined
- * in the configuration wich is accessible through the MirConfig
- * class.
- * @return String, the icon filename.
- * @see mir.misc.MirConfig
- */
- public abstract String getTinyIconName ();
-
- /**
- * Returns the IMG SRC "ALT" text to be used
- * for the Icon representations
- * @return String, the ALT text.
- */
- public abstract String getIconAltName ();
-
- /**
- * your can all figure it out.
- * @return boolean.
- */
- public abstract boolean isVideo ();
-
- /**
- * you can all figure it out.
- * @return boolean.
- */
- public abstract boolean isAudio ();
-
- /**
- * you can all figure it out.
- * @return boolean.
- */
- public abstract boolean isImage ();
-
- /**
- * returns a brief text dscription of what this
- * media type is.
- * @return String
- */
- public abstract String getDescr (Entity mediaTypeEnt);
-
-}
-
-
import org.postgresql.largeobject.LargeObjectManager;
/**
- * Diese Klasse enth?lt die Daten eines MetaObjekts
*
* @author RK, mh, mir-coders
- * @version $Id: EntityImages.java,v 1.21.2.2 2003/11/28 21:21:33 rk Exp $
+ * @version $Id: EntityImages.java,v 1.21.2.3 2003/12/14 16:37:07 zapata Exp $
*/
try {
_con.setAutoCommit(true);
theStorageObject.freeConnection(_con,_stmt);
- } catch (Exception e) {
+ }
+ catch (Exception e) {
throw new IOException("close(): "+e.toString());
}
}
-/*
- * 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.entity;
-
-import java.sql.SQLException;
-import java.util.List;
-import java.util.Map;
-
-import mir.entity.Entity;
-import mir.log.LoggerWrapper;
-import mir.media.MediaHelper;
-import mir.media.MirMedia;
-import mir.misc.NumberUtils;
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectFailure;
-import mircoders.storage.DatabaseUploadedMedia;
-
-/**
- *
- * @author mh, mir-coders group
- * @version $Id: EntityUploadedMedia.java,v 1.26.2.3 2003/11/26 19:21:04 rk Exp $
- */
-
-
-public class EntityUploadedMedia extends Entity {
-
-
- public EntityUploadedMedia() {
- super();
-
- logger = new LoggerWrapper("Entity.UploadedMedia");
- }
-
- public EntityUploadedMedia(StorageObject theStorage) {
- this();
- setStorage(theStorage);
- }
-
- public void update() throws StorageObjectFailure {
- super.update();
- try {
- theStorageObject.executeUpdate( "update content set is_produced='0' where exists(select * from content_x_media where to_content=content.id and to_media=" + getId()+")");
- }
- catch (SQLException e) {
- throwStorageObjectFailure(e, "EntityUploadedMedia :: update :: failed!! ");
- }
- }
-
- public void setValues(Map theStringValues) {
- if (theStringValues != null) {
- if (!theStringValues.containsKey("is_published"))
- theStringValues.put("is_published", "0");
- }
- super.setValues(theStringValues);
- }
-
-
- /**
- * fetches the MediaType entry assiciated w/ this media
- *
- * @return mir.entity.Entity
- */
- public Entity getMediaType() throws StorageObjectFailure {
- Entity ent = null;
- try {
- ent = DatabaseUploadedMedia.getInstance().getMediaType(this);
- }
- catch (StorageObjectFailure e) {
- throwStorageObjectFailure(e, "get MediaType failed -- ");
- }
- return ent;
- }
-
- public String getValue(String key) {
- String returnValue = null;
-
- if (key != null) {
- if (key.equals("big_icon"))
- returnValue = getBigIconName();
- else if (key.equals("descr") || key.equals("media_descr"))
- returnValue = getDescr();
- else if (key.equals("mediatype"))
- returnValue = getMediaTypeString();
- else if (key.equals("mimetype"))
- returnValue = getMimeType();
- else if (key.equals("human_readable_size")) {
- String size = super.getValue("size");
- if (size != null)
- returnValue = NumberUtils.humanReadableSize(Double.parseDouble(size));
- }
- else
- returnValue = super.getValue(key);
- }
- return returnValue;
- }
-
- // @todo all these methods should be merged into 1
- // and the MediaHandler should be cached somehow.
- private String getMediaTypeString() {
- MirMedia mediaHandler = null;
- Entity mediaType = null;
-
- try {
- mediaType = getMediaType();
- mediaHandler = MediaHelper.getHandler(mediaType);
- String t;
- if (mediaHandler.isAudio())
- return "audio";
- else if (mediaHandler.isImage())
- return "image";
- else if (mediaHandler.isVideo())
- return "video";
- else
- return "other";
- }
- catch (Exception ex) {
- logger.warn("EntityUploadedMedia.getMediaTypeString: could not fetch data: " + ex.toString());
- }
- return null;
- }
-
- private String getBigIconName() {
- MirMedia mediaHandler = null;
- Entity mediaType = null;
-
- try {
- mediaType = getMediaType();
- mediaHandler = MediaHelper.getHandler(mediaType);
- return mediaHandler.getBigIconName();
- }
- catch (Exception ex) {
- logger.warn("EntityUploadedMedia.getBigIconName: could not fetch data: " + ex.toString());
- }
- return null;
- }
-
- private List getUrl() {
- MirMedia mediaHandler = null;
- Entity mediaType = null;
-
- try {
- mediaType = getMediaType();
- mediaHandler = MediaHelper.getHandler(mediaType);
- return mediaHandler.getURL(this, mediaType);
- }
- catch (Throwable t) {
- logger.warn("EntityUploadedMedia.getUrl: could not fetch data: " + t.toString());
- }
- return null;
- }
-
- private String getDescr() {
- MirMedia mediaHandler = null;
- Entity mediaType = null;
-
- try {
- mediaType = getMediaType();
- mediaHandler = MediaHelper.getHandler(mediaType);
- return mediaHandler.getDescr(mediaType);
- }
- catch (Exception ex) {
- logger.warn("EntityUploadedMedia.getDescr: could not fetch data: " + ex.toString());
- }
- return null;
- }
- private String getMimeType() {
- Entity mediaType = null;
-
- try {
- mediaType = getMediaType();
- return mediaType.getValue("mime_type");
- }
- catch (Exception ex) {
- logger.warn("EntityUploadedMedia.getBigIconName: could not fetch data: " + ex.toString());
- }
- return null;
- }
-
-}
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with 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.entity;\r
+\r
+import java.sql.SQLException;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import mir.entity.Entity;\r
+import mir.log.LoggerWrapper;\r
+import mircoders.media.MediaHelper;\r
+import mir.media.MediaHandler;\r
+import mir.misc.NumberUtils;\r
+import mir.storage.StorageObject;\r
+import mir.storage.StorageObjectFailure;\r
+import mircoders.storage.DatabaseUploadedMedia;\r
+\r
+/**\r
+ *\r
+ * @author mh, mir-coders group\r
+ * @version $Id: EntityUploadedMedia.java,v 1.26.2.4 2003/12/14 16:37:07 zapata Exp $\r
+ */\r
+\r
+\r
+public class EntityUploadedMedia extends Entity {\r
+ public EntityUploadedMedia() {\r
+ super();\r
+\r
+ logger = new LoggerWrapper("Entity.UploadedMedia");\r
+ }\r
+\r
+ public EntityUploadedMedia(StorageObject theStorage) {\r
+ this();\r
+\r
+ setStorage(theStorage);\r
+ }\r
+\r
+ public void update() throws StorageObjectFailure {\r
+ super.update();\r
+\r
+ try {\r
+ theStorageObject.executeUpdate( "update content set is_produced='0' where exists(select * from content_x_media where content_id=content.id and media_id=" + getId()+")");\r
+ theStorageObject.executeUpdate( "update content set is_produced='0' where exists(select * from comment_x_media, comment where comment_x_media.comment_id=comment.id and comment.to_media=content.id and comment_x_media.media_id=" + getId()+")");\r
+ }\r
+ catch (SQLException e) {\r
+ throwStorageObjectFailure(e, "EntityUploadedMedia :: update :: failed!! ");\r
+ }\r
+ }\r
+\r
+ public void setValues(Map theStringValues) {\r
+ if (theStringValues != null) {\r
+ if (!theStringValues.containsKey("is_published"))\r
+ theStringValues.put("is_published", "0");\r
+ }\r
+ super.setValues(theStringValues);\r
+ }\r
+\r
+\r
+ /**\r
+ * fetches the MediaType entry assiciated w/ this media\r
+ *\r
+ * @return mir.entity.Entity\r
+ */\r
+ public Entity getMediaType() throws StorageObjectFailure {\r
+ Entity ent = null;\r
+ try {\r
+ ent = DatabaseUploadedMedia.getInstance().getMediaType(this);\r
+ }\r
+ catch (StorageObjectFailure e) {\r
+ throwStorageObjectFailure(e, "get MediaType failed -- ");\r
+ }\r
+ return ent;\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;
-
-import mir.entity.adapter.EntityAdapterModel;
-import mir.generator.Generator;
-import mir.generator.WriterEngine;
-
-public class MirCachingLocalizerDecorator implements MirLocalizer {
- private MirLocalizer localizer;
- private MirProducerLocalizer producerLocalizer;
- private MirGeneratorLocalizer generatorLocalizer;
- private MirOpenPostingLocalizer openPostingsLocalizer;
- private MirProducerAssistantLocalizer producerAssistantLocalizer;
- private MirDataModelLocalizer dataModelLocalizer;
- private MirAdminInterfaceLocalizer adminInterfaceLocalizer;
-
- public MirCachingLocalizerDecorator(MirLocalizer aLocalizer) {
- localizer = aLocalizer;
- }
-
- public MirProducerLocalizer producers() throws MirLocalizerFailure, MirLocalizerExc {
- if (producerLocalizer==null) {
- producerLocalizer = localizer.producers();
- }
-
- return producerLocalizer;
- }
-
- public MirGeneratorLocalizer generators() throws MirLocalizerFailure, MirLocalizerExc {
- if (generatorLocalizer==null) {
- generatorLocalizer = new MirCachingGeneratorLocalizer(localizer.generators());
- }
-
- return generatorLocalizer;
- }
-
- public MirOpenPostingLocalizer openPostings() throws MirLocalizerFailure, MirLocalizerExc {
- if (openPostingsLocalizer==null) {
- openPostingsLocalizer = localizer.openPostings();
- }
-
- return openPostingsLocalizer;
- }
-
- public MirProducerAssistantLocalizer producerAssistant() throws MirLocalizerFailure, MirLocalizerExc {
- if (producerAssistantLocalizer==null) {
- producerAssistantLocalizer = localizer.producerAssistant();
- }
-
- return producerAssistantLocalizer;
- }
-
- public MirDataModelLocalizer dataModel() throws MirLocalizerFailure, MirLocalizerExc {
- if (dataModelLocalizer==null) {
- dataModelLocalizer = new MirCachingDatamodelLocalizer(localizer.dataModel());
- }
-
- return dataModelLocalizer;
- }
-
- public MirAdminInterfaceLocalizer adminInterface() throws MirLocalizerFailure, MirLocalizerExc {
- if (adminInterfaceLocalizer==null) {
- adminInterfaceLocalizer = localizer.adminInterface();
- }
-
- return adminInterfaceLocalizer;
- };
-
- private static class MirCachingDatamodelLocalizer implements MirDataModelLocalizer {
- private MirDataModelLocalizer master;
- private EntityAdapterModel adapterModel;
-
- public MirCachingDatamodelLocalizer(MirDataModelLocalizer aMaster) {
- master = aMaster;
- adapterModel = null;
- }
-
- public EntityAdapterModel adapterModel() throws MirLocalizerExc, MirLocalizerFailure {
- if (adapterModel==null) {
- adapterModel = master.adapterModel();
- }
-
- return adapterModel;
- };
-
- }
-
- private static class MirCachingGeneratorLocalizer implements MirGeneratorLocalizer {
- private MirGeneratorLocalizer master;
- private WriterEngine writerEngine;
- private Generator.GeneratorLibrary producerGeneratorLibrary;
- private Generator.GeneratorLibrary adminGeneratorLibrary;
- private Generator.GeneratorLibrary openPostingGeneratorLibrary;
-
- public MirCachingGeneratorLocalizer(MirGeneratorLocalizer aMaster) {
- master = aMaster;
- }
-
- public WriterEngine makeWriterEngine() throws MirLocalizerExc, MirLocalizerFailure {
- if (writerEngine==null) {
- writerEngine = master.makeWriterEngine();
- }
-
- return writerEngine;
- };
-
- public Generator.GeneratorLibrary makeProducerGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {
- if (producerGeneratorLibrary==null) {
- producerGeneratorLibrary = master.makeProducerGeneratorLibrary();
- }
-
- return producerGeneratorLibrary;
- };
-
- public Generator.GeneratorLibrary makeAdminGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {
- if (adminGeneratorLibrary==null) {
- adminGeneratorLibrary = master.makeAdminGeneratorLibrary();
- }
-
- return adminGeneratorLibrary;
- };
-
- public Generator.GeneratorLibrary makeOpenPostingGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {
- if (openPostingGeneratorLibrary==null) {
- openPostingGeneratorLibrary = master.makeOpenPostingGeneratorLibrary();
- }
-
- return openPostingGeneratorLibrary;
- };
- }
-
+/*\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;\r
+\r
+import mir.entity.adapter.EntityAdapterModel;\r
+import mir.generator.Generator;\r
+import mir.generator.WriterEngine;\r
+\r
+public class MirCachingLocalizerDecorator implements MirLocalizer {\r
+ private MirLocalizer localizer;\r
+ private MirProducerLocalizer producerLocalizer;\r
+ private MirGeneratorLocalizer generatorLocalizer;\r
+ private MirOpenPostingLocalizer openPostingsLocalizer;\r
+ private MirProducerAssistantLocalizer producerAssistantLocalizer;\r
+ private MirDataModelLocalizer dataModelLocalizer;\r
+ private MirAdminInterfaceLocalizer adminInterfaceLocalizer;\r
+ private MirMediaLocalizer mediaLocalizer;\r
+\r
+ public MirCachingLocalizerDecorator(MirLocalizer aLocalizer) {\r
+ localizer = aLocalizer;\r
+ }\r
+\r
+ public MirProducerLocalizer producers() throws MirLocalizerFailure, MirLocalizerExc {\r
+ if (producerLocalizer==null) {\r
+ producerLocalizer = localizer.producers();\r
+ }\r
+\r
+ return producerLocalizer;\r
+ }\r
+\r
+ public MirGeneratorLocalizer generators() throws MirLocalizerFailure, MirLocalizerExc {\r
+ if (generatorLocalizer==null) {\r
+ generatorLocalizer = new MirCachingGeneratorLocalizer(localizer.generators());\r
+ }\r
+\r
+ return generatorLocalizer;\r
+ }\r
+\r
+ public MirOpenPostingLocalizer openPostings() throws MirLocalizerFailure, MirLocalizerExc {\r
+ if (openPostingsLocalizer==null) {\r
+ openPostingsLocalizer = localizer.openPostings();\r
+ }\r
+\r
+ return openPostingsLocalizer;\r
+ }\r
+\r
+ public MirProducerAssistantLocalizer producerAssistant() throws MirLocalizerFailure, MirLocalizerExc {\r
+ if (producerAssistantLocalizer==null) {\r
+ producerAssistantLocalizer = localizer.producerAssistant();\r
+ }\r
+\r
+ return producerAssistantLocalizer;\r
+ }\r
+\r
+ public MirDataModelLocalizer dataModel() throws MirLocalizerFailure, MirLocalizerExc {\r
+ if (dataModelLocalizer==null) {\r
+ dataModelLocalizer = new MirCachingDatamodelLocalizer(localizer.dataModel());\r
+ }\r
+\r
+ return dataModelLocalizer;\r
+ }\r
+\r
+ public MirAdminInterfaceLocalizer adminInterface() throws MirLocalizerFailure, MirLocalizerExc {\r
+ if (adminInterfaceLocalizer==null) {\r
+ adminInterfaceLocalizer = localizer.adminInterface();\r
+ }\r
+\r
+ return adminInterfaceLocalizer;\r
+ };\r
+\r
+ public MirMediaLocalizer media() throws MirLocalizerFailure, MirLocalizerExc {\r
+ if (mediaLocalizer==null) {\r
+ mediaLocalizer = localizer.media();\r
+ }\r
+\r
+ return mediaLocalizer;\r
+ }\r
+\r
+ private static class MirCachingDatamodelLocalizer implements MirDataModelLocalizer {\r
+ private MirDataModelLocalizer master;\r
+ private EntityAdapterModel adapterModel;\r
+\r
+ public MirCachingDatamodelLocalizer(MirDataModelLocalizer aMaster) {\r
+ master = aMaster;\r
+ adapterModel = null;\r
+ }\r
+\r
+ public EntityAdapterModel adapterModel() throws MirLocalizerExc, MirLocalizerFailure {\r
+ if (adapterModel==null) {\r
+ adapterModel = master.adapterModel();\r
+ }\r
+\r
+ return adapterModel;\r
+ };\r
+\r
+ }\r
+\r
+ private static class MirCachingGeneratorLocalizer implements MirGeneratorLocalizer {\r
+ private MirGeneratorLocalizer master;\r
+ private WriterEngine writerEngine;\r
+ private Generator.GeneratorLibrary producerGeneratorLibrary;\r
+ private Generator.GeneratorLibrary adminGeneratorLibrary;\r
+ private Generator.GeneratorLibrary openPostingGeneratorLibrary;\r
+\r
+ public MirCachingGeneratorLocalizer(MirGeneratorLocalizer aMaster) {\r
+ master = aMaster;\r
+ }\r
+\r
+ public WriterEngine makeWriterEngine() throws MirLocalizerExc, MirLocalizerFailure {\r
+ if (writerEngine==null) {\r
+ writerEngine = master.makeWriterEngine();\r
+ }\r
+\r
+ return writerEngine;\r
+ };\r
+\r
+ public Generator.GeneratorLibrary makeProducerGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {\r
+ if (producerGeneratorLibrary==null) {\r
+ producerGeneratorLibrary = master.makeProducerGeneratorLibrary();\r
+ }\r
+\r
+ return producerGeneratorLibrary;\r
+ };\r
+\r
+ public Generator.GeneratorLibrary makeAdminGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {\r
+ if (adminGeneratorLibrary==null) {\r
+ adminGeneratorLibrary = master.makeAdminGeneratorLibrary();\r
+ }\r
+\r
+ return adminGeneratorLibrary;\r
+ };\r
+\r
+ public Generator.GeneratorLibrary makeOpenPostingGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {\r
+ if (openPostingGeneratorLibrary==null) {\r
+ openPostingGeneratorLibrary = master.makeOpenPostingGeneratorLibrary();\r
+ }\r
+\r
+ return openPostingGeneratorLibrary;\r
+ };\r
+ }\r
+\r
}
\ No newline at end of file
* 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.
*/
public MirProducerAssistantLocalizer producerAssistant() throws MirLocalizerFailure, MirLocalizerExc;
public MirGeneratorLocalizer generators() throws MirLocalizerFailure, MirLocalizerExc;
public MirDataModelLocalizer dataModel() throws MirLocalizerFailure, MirLocalizerExc;
+ public MirMediaLocalizer media() throws MirLocalizerFailure, MirLocalizerExc;
}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (C) 2001, 2002 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with 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;
+
+import mir.media.MediaHandler;
+
+/**
+ * Interface to allow for customization of the way Mir handles media publication,
+ * manipulation and storage
+ */
+
+public interface MirMediaLocalizer {
+ /** returns the {@link MediaHandler} belonging to handler identifier <code>aName</code> */
+ public MediaHandler getHandler(String aName);
+}
\ No newline at end of file
-/*
- * 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 java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import mir.config.MirPropertiesConfiguration;
-import mir.entity.Entity;
-import mir.entity.adapter.EntityAdapter;
-import mir.entity.adapter.EntityAdapterDefinition;
-import mir.entity.adapter.EntityAdapterModel;
-import mir.log.LoggerWrapper;
-import mir.media.MediaHelper;
-import mir.media.MirMedia;
-import mir.util.ParameterExpander;
-import mir.util.RewindableIterator;
-import mir.util.StructuredContentParser;
-import mircoders.entity.EntityUploadedMedia;
-import mircoders.global.MirGlobal;
-import mircoders.localizer.MirAdminInterfaceLocalizer;
-import mircoders.localizer.MirDataModelLocalizer;
-import mircoders.localizer.MirLocalizerExc;
-import mircoders.localizer.MirLocalizerFailure;
-import mircoders.storage.DatabaseArticleType;
-import mircoders.storage.DatabaseAudio;
-import mircoders.storage.DatabaseBreaking;
-import mircoders.storage.DatabaseComment;
-import mircoders.storage.DatabaseCommentStatus;
-import mircoders.storage.DatabaseContent;
-import mircoders.storage.DatabaseContentToMedia;
-import mircoders.storage.DatabaseContentToTopics;
-import mircoders.storage.DatabaseImageType;
-import mircoders.storage.DatabaseImages;
-import mircoders.storage.DatabaseLanguage;
-import mircoders.storage.DatabaseMediaType;
-import mircoders.storage.DatabaseMediafolder;
-import mircoders.storage.DatabaseMessages;
-import mircoders.storage.DatabaseOther;
-import mircoders.storage.DatabaseTopics;
-import mircoders.storage.DatabaseUploadedMedia;
-import mircoders.storage.DatabaseUsers;
-import mircoders.storage.DatabaseVideo;
-
-public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {
- protected LoggerWrapper logger;
- protected MirPropertiesConfiguration configuration;
-
- public MirBasicDataModelLocalizer() throws MirLocalizerFailure, MirLocalizerExc {
- logger = new LoggerWrapper("Localizer.DataModel");
-
- try {
- configuration = MirPropertiesConfiguration.instance();
- }
- catch (Throwable e) {
- throw new MirLocalizerFailure("Can't get configuration: " + e.getMessage(), e);
- }
- }
-
- protected void constructContentAdapterDefinition(EntityAdapterDefinition anEntityAdapterDefinition) throws MirLocalizerFailure, MirLocalizerExc {
- try {
- anEntityAdapterDefinition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));
- anEntityAdapterDefinition.addDBDateField("changedate", "webdb_lastchange", configuration.getString("Mir.DefaultTimezone"));
- anEntityAdapterDefinition.addMirDateField("date", "date", configuration.getString("Mir.DefaultTimezone"));
- anEntityAdapterDefinition.addCalculatedField("to_topics", new ContentToTopicsField());
- anEntityAdapterDefinition.addCalculatedField("to_comments", new ContentToCommentsField());
- anEntityAdapterDefinition.addCalculatedField("language", new ContentToLanguageField());
-
- anEntityAdapterDefinition.addCalculatedField("commentcount", new ContentCommentCountField(" and is_published='1'"));
- anEntityAdapterDefinition.addCalculatedField("fullcommentcount", new ContentCommentCountField(""));
-
-
- anEntityAdapterDefinition.addCalculatedField("mediacount", new ContentMediaCountField("uploaded_media", true));
- anEntityAdapterDefinition.addCalculatedField("fullmediacount", new ContentMediaCountField("uploaded_media", false));
-
- anEntityAdapterDefinition.addCalculatedField("to_uploaded_media", new ContentToMediaField( "uploadedMedia" ));
- anEntityAdapterDefinition.addCalculatedField("to_media_images", new ContentToMediaField( "image" ));
- anEntityAdapterDefinition.addCalculatedField("to_media_audio", new ContentToMediaField( "audio" ));
- anEntityAdapterDefinition.addCalculatedField("to_media_video", new ContentToMediaField( "video" ));
- anEntityAdapterDefinition.addCalculatedField("to_media_other", new ContentToMediaField( "otherMedia" ));
- anEntityAdapterDefinition.addCalculatedField("to_all_uploaded_media", new ContentToMediaField( "uploadedMedia", false));
- anEntityAdapterDefinition.addCalculatedField("to_all_media_images", new ContentToMediaField( "image", false));
- anEntityAdapterDefinition.addCalculatedField("to_all_media_audio", new ContentToMediaField( "audio", false));
- anEntityAdapterDefinition.addCalculatedField("to_all_media_video", new ContentToMediaField( "video", false));
- anEntityAdapterDefinition.addCalculatedField("to_all_media_other", new ContentToMediaField( "otherMedia", false));
- anEntityAdapterDefinition.addCalculatedField("to_media_icon", new ContentToIconField());
-
- anEntityAdapterDefinition.addCalculatedField("article_type", new ContentToArticleTypeField());
-
- anEntityAdapterDefinition.addCalculatedField("description_parsed", new FilteredField("description"));
- anEntityAdapterDefinition.addCalculatedField("content_data_parsed", new FilteredField("content_data"));
-
- anEntityAdapterDefinition.addCalculatedField("children", new ContentToChildrenField());
- anEntityAdapterDefinition.addCalculatedField("parent", new ContentToParentField());
-
- anEntityAdapterDefinition.addCalculatedField("publicurl", new ExpandedField(configuration.getString("Article.PublicUrl")));
-
- anEntityAdapterDefinition.addCalculatedField("operations",
- new EntityToSimpleOperationsField(MirGlobal.localizer().adminInterface().simpleArticleOperations()));
- }
- catch (Throwable t) {
- throw new MirLocalizerFailure(t.getMessage(), t);
- }
- }
-
- protected void constructCommentAdapterDefinition(EntityAdapterDefinition anEntityAdapterDefinition) throws MirLocalizerFailure {
- try {
- anEntityAdapterDefinition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));
- anEntityAdapterDefinition.addCalculatedField("to_content", new CommentToContentField());
- anEntityAdapterDefinition.addCalculatedField("status", new CommentToStatusField());
-
- anEntityAdapterDefinition.addCalculatedField("to_uploaded_media", new CommentToMediaField( "uploadedMedia" ));
- anEntityAdapterDefinition.addCalculatedField("to_media_images", new CommentToMediaField( "image" ));
- anEntityAdapterDefinition.addCalculatedField("to_media_audio", new CommentToMediaField( "audio" ));
- anEntityAdapterDefinition.addCalculatedField("to_media_video", new CommentToMediaField( "video" ));
- anEntityAdapterDefinition.addCalculatedField("to_media_other", new CommentToMediaField( "otherMedia" ));
- anEntityAdapterDefinition.addCalculatedField("to_all_uploaded_media", new CommentToMediaField( "uploadedMedia", false));
- anEntityAdapterDefinition.addCalculatedField("to_all_media_images", new CommentToMediaField( "image", false));
- anEntityAdapterDefinition.addCalculatedField("to_all_media_audio", new CommentToMediaField( "audio", false));
- anEntityAdapterDefinition.addCalculatedField("to_all_media_video", new CommentToMediaField( "video", false));
- anEntityAdapterDefinition.addCalculatedField("to_all_media_other", new CommentToMediaField( "otherMedia", false));
-
- anEntityAdapterDefinition.addCalculatedField("publicurl", new ExpandedField(configuration.getString("Comment.PublicUrl")));
-
- anEntityAdapterDefinition.addCalculatedField("description_parsed", new FilteredField("description"));
- anEntityAdapterDefinition.addCalculatedField("operations",
- new EntityToSimpleOperationsField(MirGlobal.localizer().adminInterface().simpleCommentOperations()));
- }
- catch (Throwable t) {
- throw new MirLocalizerFailure(t.getMessage(), t);
- }
- }
-
- public EntityAdapterModel adapterModel() throws MirLocalizerFailure, MirLocalizerExc {
- EntityAdapterModel result = new EntityAdapterModel();
-
- try {
- EntityAdapterDefinition definition;
-
- definition = new EntityAdapterDefinition();
- constructContentAdapterDefinition( definition );
- result.addMapping( "content", DatabaseContent.getInstance(), definition);
-
- definition = new EntityAdapterDefinition();
- constructCommentAdapterDefinition( definition );
- result.addMapping( "comment", DatabaseComment.getInstance(), definition);
- result.addMapping( "commentStatus", DatabaseCommentStatus.getInstance(), new EntityAdapterDefinition());
-
- result.addMapping( "articleType", DatabaseArticleType.getInstance(), new EntityAdapterDefinition());
-
- result.addMapping( "mediaType", DatabaseMediaType.getInstance(), new EntityAdapterDefinition());
-
-
- definition = new EntityAdapterDefinition();
- definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));
- result.addMapping( "breakingNews", DatabaseBreaking.getInstance(), definition);
-
- definition = new EntityAdapterDefinition();
- definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));
- result.addMapping( "internalMessage", DatabaseMessages.getInstance(), definition);
-
- definition = new EntityAdapterDefinition();
- definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());
- result.addMapping( "uploadedMedia", DatabaseUploadedMedia.getInstance(), definition);
- definition = new EntityAdapterDefinition();
- definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());
- result.addMapping( "image", DatabaseImages.getInstance(), definition);
- definition = new EntityAdapterDefinition();
- definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());
- result.addMapping( "audio", DatabaseAudio.getInstance(), definition);
- definition = new EntityAdapterDefinition();
- definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());
- result.addMapping( "video", DatabaseVideo.getInstance(), definition);
- definition = new EntityAdapterDefinition();
- definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());
- result.addMapping( "otherMedia", DatabaseOther.getInstance(), definition);
-
-
- result.addMapping( "mediaFolder", DatabaseMediafolder.getInstance(), new EntityAdapterDefinition());
- result.addMapping( "imageType", DatabaseImageType.getInstance(), new EntityAdapterDefinition());
- result.addMapping( "language", DatabaseLanguage.getInstance(), new EntityAdapterDefinition());
- result.addMapping( "mediaType", DatabaseMediaType.getInstance(), new EntityAdapterDefinition());
- result.addMapping( "topic", DatabaseTopics.getInstance(), new EntityAdapterDefinition());
- result.addMapping( "user", DatabaseUsers.getInstance(), new EntityAdapterDefinition());
- result.addMapping( "otherMedia", DatabaseOther.getInstance(), new EntityAdapterDefinition());
-
- result.addMapping( "content_x_topic", DatabaseContentToTopics.getInstance(), new EntityAdapterDefinition());
-
- }
- catch (Throwable t) {
- throw new MirLocalizerFailure(t.getMessage(), t);
- }
-
- return result;
- }
-
- protected class CommentToContentField implements EntityAdapterDefinition.CalculatedField {
- public Object getValue(EntityAdapter anEntityAdapter) {
- try {
- return anEntityAdapter.getToOneRelation(
- "id="+anEntityAdapter.get("to_media"),
- "id",
- "content" );
- }
- catch (Throwable t) {
- throw new RuntimeException(t.getMessage());
- }
- }
- }
-
- protected class CommentToStatusField implements EntityAdapterDefinition.CalculatedField {
- public Object getValue(EntityAdapter anEntityAdapter) {
- try {
- return anEntityAdapter.getToOneRelation(
- "id="+anEntityAdapter.get("to_comment_status"),
- "id",
- "commentStatus" );
- }
- catch (Throwable t) {
- throw new RuntimeException(t.getMessage());
- }
- }
- }
-
- protected class EntityToSimpleOperationsField implements EntityAdapterDefinition.CalculatedField {
- private List operations;
-
- public EntityToSimpleOperationsField(List anOperations) {
- operations = anOperations;
- }
-
- public Object getValue(EntityAdapter anEntityAdapter) {
- try {
- Iterator i = operations.iterator();
- List availableOperations = new Vector();
-
- while (i.hasNext()) {
- MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation =
- (MirAdminInterfaceLocalizer.MirSimpleEntityOperation) i.next();
-
- if (operation.isAvailable(anEntityAdapter)) {
- availableOperations.add(operation.getName());
- }
- };
-
- return availableOperations;
- }
- catch (Throwable t) {
- throw new RuntimeException(t.getMessage());
- }
- }
- }
-
- protected class FilteredField implements EntityAdapterDefinition.CalculatedField {
- private String fieldName;
-
- public FilteredField(String aFieldName) {
- fieldName = aFieldName;
- }
-
- public Object getValue(EntityAdapter anEntityAdapter) {
- try {
- if (anEntityAdapter.get("is_html")!=null && anEntityAdapter.get("is_html").equals("1")) {
- return MirGlobal.localizer().producerAssistant().filterHTMLText((String) anEntityAdapter.get(fieldName));
- }
- else {
- return MirGlobal.localizer().producerAssistant().filterNonHTMLText((String) anEntityAdapter.get(fieldName));
- }
- }
- catch (Throwable t) {
- throw new RuntimeException(t.getMessage());
- }
- }
- }
-
- protected class StructuredContentField implements EntityAdapterDefinition.CalculatedField {
- private String expression;
-
- public StructuredContentField(String anExpression) {
- expression = anExpression;
- }
-
- public Object getValue(EntityAdapter anEntityAdapter) {
- try {
- return StructuredContentParser.parse(ParameterExpander.evaluateStringExpression(anEntityAdapter, expression));
- }
- catch (Throwable t) {
- throw new RuntimeException(t.getMessage());
- }
- }
- }
-
- protected class ExpandedField implements EntityAdapterDefinition.CalculatedField {
- private String expression;
-
- public ExpandedField(String anExpression) {
- expression = anExpression;
- }
-
- public Object getValue(EntityAdapter anEntityAdapter) {
- try {
- return ParameterExpander.expandExpression(anEntityAdapter, expression);
- }
- catch (Throwable t) {
- throw new RuntimeException(t.getMessage());
- }
- }
- }
-
- protected class EvaluatedField implements EntityAdapterDefinition.CalculatedField {
- private String expression;
-
- public EvaluatedField(String anExpression) {
- expression = anExpression;
- }
-
- public Object getValue(EntityAdapter anEntityAdapter) {
- try {
- return ParameterExpander.evaluateExpression(anEntityAdapter, expression);
- }
- catch (Throwable t) {
- throw new RuntimeException(t.getMessage());
- }
- }
- }
-
- protected class ContentToParentField implements EntityAdapterDefinition.CalculatedField {
- public Object getValue(EntityAdapter anEntityAdapter) {
- try {
- logger.debug("ContentToParentField.getValue");
- return anEntityAdapter.getToOneRelation(
- "id="+anEntityAdapter.get("to_content"),
- "id",
- "content" );
- }
- catch (Throwable t) {
- throw new RuntimeException(t.getMessage());
- }
- }
- }
-
- protected class ContentToChildrenField implements EntityAdapterDefinition.CalculatedField {
- public Object getValue(EntityAdapter anEntityAdapter) {
- try {
- return anEntityAdapter.getRelation(
- "to_content="+anEntityAdapter.get("id"),
- "id",
- "content" );
- }
- catch (Throwable t) {
- throw new RuntimeException(t.getMessage());
- }
- }
- }
-
- protected class ContentToLanguageField implements EntityAdapterDefinition.CalculatedField {
- public Object getValue(EntityAdapter anEntityAdapter) {
- try {
- return anEntityAdapter.getToOneRelation(
- "id="+anEntityAdapter.get("to_language"),
- "id",
- "language" );
- }
- catch (Throwable t) {
- throw new RuntimeException(t.getMessage());
- }
- }
- }
-
- protected class ContentToArticleTypeField implements EntityAdapterDefinition.CalculatedField {
- public Object getValue(EntityAdapter anEntityAdapter) {
- try {
- return anEntityAdapter.getToOneRelation(
- "id="+anEntityAdapter.get("to_article_type"),
- "id",
- "articleType" );
- }
- catch (Throwable t) {
- throw new RuntimeException(t.getMessage());
- }
- }
- }
-
- protected class MediaToMediaFolderField implements EntityAdapterDefinition.CalculatedField {
- public Object getValue(EntityAdapter anEntityAdapter) {
- try {
- return anEntityAdapter.getToOneRelation(
- "id="+anEntityAdapter.get("to_media_folder"),
- "id",
- "mediaFolder" );
- }
- catch (Throwable t) {
- throw new RuntimeException(t.getMessage());
- }
- }
- }
-
- protected class ContentToCommentsField implements EntityAdapterDefinition.CalculatedField {
- private String extracondition;
- private String order;
-
- public ContentToCommentsField() {
- this ( " and is_published='1'", "webdb_create");
- }
-
- public ContentToCommentsField(String anExtraCondition, String anOrder) {
- order = anOrder;
- extracondition = anExtraCondition;
- }
-
- public Object getValue(EntityAdapter anEntityAdapter) {
- try {
- return anEntityAdapter.getRelation(
- "to_media="+anEntityAdapter.get("id")+" " + extracondition,
- order,
- "comment" );
- }
- catch (Throwable t) {
- throw new RuntimeException(t.getMessage());
- }
- }
- }
-
- protected class ContentToTopicsField implements EntityAdapterDefinition.CalculatedField {
- private String topicCondition;
- private String topicOrder;
-
- public ContentToTopicsField() {
- this(null);
- }
-
- public ContentToTopicsField(String aTopicCondition) {
- this(aTopicCondition, "title");
- }
-
- public ContentToTopicsField(String aTopicCondition, String aTopicOrder) {
- topicCondition = aTopicCondition;
- topicOrder = aTopicOrder;
- }
-
- public Object getValue(EntityAdapter anEntityAdapter) {
- try {
-
- Vector extraTable = new Vector();
- extraTable.add("content_x_topic cxt");
- String condition = "cxt.content_id="+anEntityAdapter.get("id")+
- " and cxt.topic_id=t.id";
-
- if (topicCondition!=null && topicCondition.length()>0)
- condition = "(" + topicCondition + ") and " + condition;
-
- return anEntityAdapter.getComplexRelation("t", extraTable,
- condition, topicOrder, "topic" );
- }
- catch (Throwable t) {
- throw new RuntimeException(t.getMessage());
- }
- }
- }
-
- protected class ContentToMediaField implements EntityAdapterDefinition.CalculatedField {
- private String definition;
- private boolean published;
-
- public ContentToMediaField(String aDefinition, boolean anOnlyPublished) {
- definition = aDefinition;
- published = anOnlyPublished;
- }
-
- public ContentToMediaField(String aDefinition) {
- this(aDefinition, true);
- }
-
- public Object getValue(EntityAdapter anEntityAdapter) {
- try {
- String condition = "cxm.content_id="+ anEntityAdapter.get("id") +
- " and cxm.media_id = m.id";
- if (published)
- condition = "is_published='t' and " + condition;
-
- List extraTables = new Vector();
- extraTables.add("content_x_media cxm");
-
- return anEntityAdapter.getComplexRelation("m", extraTables, condition, "id", definition);
- }
- catch (Throwable t) {
- throw new RuntimeException(t.getMessage());
- }
- }
- }
-
- protected class CommentToMediaField implements EntityAdapterDefinition.CalculatedField {
- private String definition;
- private boolean published;
-
- public CommentToMediaField(String aDefinition, boolean anOnlyPublished) {
- definition = aDefinition;
- published = anOnlyPublished;
- }
-
- public CommentToMediaField(String aDefinition) {
- this(aDefinition, true);
- }
-
- public Object getValue(EntityAdapter anEntityAdapter) {
- try {
-
- String condition = "cxm.comment_id="+ anEntityAdapter.get("id") +
- " and cxm.media_id = m.id";
- if (published)
- condition = "is_published='t' and " + condition;
-
- List extraTables = new Vector();
- extraTables.add("comment_x_media cxm");
- return anEntityAdapter.getComplexRelation("m", extraTables, condition, "id", definition);
-
- }
- catch (Throwable t) {
- throw new RuntimeException(t.getMessage());
- }
- }
- }
-
- protected class ContentToIconField implements EntityAdapterDefinition.CalculatedField {
- public Object getValue(EntityAdapter anEntityAdapter) {
- EntityAdapter media;
- Entity mediaType;
- RewindableIterator iterator;
- Map result;
- MirMedia mediaHandler;
- String tinyIcon;
- String iconAlt;
-
- try {
- iterator = (RewindableIterator) (anEntityAdapter.get("to_uploaded_media"));
- iterator.rewind();
-
- tinyIcon = MirGlobal.config().getString("Producer.Icon.TinyText");
- iconAlt = "Text";
-
- if (iterator.hasNext()) {
- media = (EntityAdapter) iterator.next();
-
- mediaType = ((EntityUploadedMedia) (media.getEntity())).getMediaType();
- mediaHandler = MediaHelper.getHandler( mediaType );
-
- if (mediaHandler.isVideo()) {
- tinyIcon = MirGlobal.config().getString("Producer.Icon.TinyVideo");
- iconAlt = "Video";
- }
- else if (mediaHandler.isAudio()) {
- tinyIcon = MirGlobal.config().getString("Producer.Icon.TinyAudio");
- iconAlt = "Audio";
- }
- else if (mediaHandler.isImage()) {
- tinyIcon = MirGlobal.config().getString("Producer.Icon.TinyImage");
- iconAlt = "Image";
- }
- else {
- tinyIcon = mediaHandler.getTinyIconName();
- iconAlt = mediaHandler.getIconAltName();
- }
-
- }
- }
- catch (Throwable t) {
- logger.error("ContentToIconField: " +t.getMessage());
- throw new RuntimeException(t.getMessage());
- }
-
- result = new HashMap();
- result.put("tiny_icon", MirGlobal.config().getString("Producer.ImageRoot") + "/" + tinyIcon);
- result.put("icon_alt", iconAlt);
-
- return result;
- }
- }
-
- protected class ContentCommentCountField implements EntityAdapterDefinition.CalculatedField {
- private String extraCondition;
-
- public ContentCommentCountField(String anExtraCondition) {
- super();
-
- extraCondition = anExtraCondition;
- }
-
- public Object getValue(EntityAdapter anEntityAdapter) {
- try {
- return Integer.toString(
- DatabaseComment.getInstance().getSize(
- "to_media="+anEntityAdapter.get("id")+" " + extraCondition));
- }
- catch (Throwable t) {
- throw new RuntimeException(t.getMessage());
- }
- }
- }
-
- protected class ContentMediaCountField implements EntityAdapterDefinition.CalculatedField {
- private String table;
- private boolean published;
-
- public ContentMediaCountField(String aTable, boolean anOnlyPublished) {
- table = aTable;
- published = anOnlyPublished;
- }
-
- public ContentMediaCountField(String aTable) {
- this(aTable, true);
- }
-
- public Object getValue(EntityAdapter anEntityAdapter) {
- try {
- Vector extraTable = new Vector();
- extraTable.add(table+" m");
- String selectSql = "cxm.media_id=m.id and cxm.content_id="+
- anEntityAdapter.get("id");
- if (published)
- selectSql+= " and m.is_published='t'";
-
- return Integer.toString(
- DatabaseContentToMedia.getInstance().getSize(
- "cxm", extraTable, selectSql));
- }
- catch (Throwable t) {
- throw new RuntimeException(t.getMessage());
- }
- }
- }
-}
+/*\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.localizer.basic;\r
+\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Vector;\r
+\r
+import mir.config.MirPropertiesConfiguration;\r
+import mir.entity.Entity;\r
+import mir.entity.adapter.EntityAdapter;\r
+import mir.entity.adapter.EntityAdapterDefinition;\r
+import mir.entity.adapter.EntityAdapterModel;\r
+import mir.log.LoggerWrapper;\r
+import mircoders.media.MediaHelper;\r
+import mir.misc.NumberUtils;\r
+import mir.media.MediaHandler;\r
+import mir.util.ParameterExpander;\r
+import mir.util.RewindableIterator;\r
+import mir.util.StructuredContentParser;\r
+import mircoders.entity.EntityUploadedMedia;\r
+import mircoders.global.MirGlobal;\r
+import mircoders.localizer.MirAdminInterfaceLocalizer;\r
+import mircoders.localizer.MirDataModelLocalizer;\r
+import mircoders.localizer.MirLocalizerExc;\r
+import mircoders.localizer.MirLocalizerFailure;\r
+import mircoders.storage.DatabaseArticleType;\r
+import mircoders.storage.DatabaseAudio;\r
+import mircoders.storage.DatabaseBreaking;\r
+import mircoders.storage.DatabaseComment;\r
+import mircoders.storage.DatabaseCommentStatus;\r
+import mircoders.storage.DatabaseContent;\r
+import mircoders.storage.DatabaseContentToMedia;\r
+import mircoders.storage.DatabaseContentToTopics;\r
+import mircoders.storage.DatabaseImageType;\r
+import mircoders.storage.DatabaseImages;\r
+import mircoders.storage.DatabaseLanguage;\r
+import mircoders.storage.DatabaseMediaType;\r
+import mircoders.storage.DatabaseMediafolder;\r
+import mircoders.storage.DatabaseMessages;\r
+import mircoders.storage.DatabaseOther;\r
+import mircoders.storage.DatabaseTopics;\r
+import mircoders.storage.DatabaseUploadedMedia;\r
+import mircoders.storage.DatabaseUsers;\r
+import mircoders.storage.DatabaseVideo;\r
+\r
+public class MirBasicDataModelLocalizer implements MirDataModelLocalizer {\r
+ protected LoggerWrapper logger;\r
+ protected MirPropertiesConfiguration configuration;\r
+\r
+ public MirBasicDataModelLocalizer() throws MirLocalizerFailure, MirLocalizerExc {\r
+ logger = new LoggerWrapper("Localizer.DataModel");\r
+\r
+ try {\r
+ configuration = MirPropertiesConfiguration.instance();\r
+ }\r
+ catch (Throwable e) {\r
+ throw new MirLocalizerFailure("Can't get configuration: " + e.getMessage(), e);\r
+ }\r
+ }\r
+\r
+ protected void constructContentAdapterDefinition(EntityAdapterDefinition anEntityAdapterDefinition) throws MirLocalizerFailure, MirLocalizerExc {\r
+ try {\r
+ anEntityAdapterDefinition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));\r
+ anEntityAdapterDefinition.addDBDateField("changedate", "webdb_lastchange", configuration.getString("Mir.DefaultTimezone"));\r
+ anEntityAdapterDefinition.addMirDateField("date", "date", configuration.getString("Mir.DefaultTimezone"));\r
+ anEntityAdapterDefinition.addCalculatedField("to_topics", new ContentToTopicsField());\r
+ anEntityAdapterDefinition.addCalculatedField("to_comments", new ContentToCommentsField());\r
+ anEntityAdapterDefinition.addCalculatedField("language", new ContentToLanguageField());\r
+\r
+ anEntityAdapterDefinition.addCalculatedField("commentcount", new ContentCommentCountField(" and is_published='1'"));\r
+ anEntityAdapterDefinition.addCalculatedField("fullcommentcount", new ContentCommentCountField(""));\r
+\r
+\r
+ anEntityAdapterDefinition.addCalculatedField("mediacount", new ContentMediaCountField("uploaded_media", true));\r
+ anEntityAdapterDefinition.addCalculatedField("fullmediacount", new ContentMediaCountField("uploaded_media", false));\r
+\r
+ anEntityAdapterDefinition.addCalculatedField("to_uploaded_media", new ContentToMediaField( "uploadedMedia" ));\r
+ anEntityAdapterDefinition.addCalculatedField("to_media_images", new ContentToMediaField( "image" ));\r
+ anEntityAdapterDefinition.addCalculatedField("to_media_audio", new ContentToMediaField( "audio" ));\r
+ anEntityAdapterDefinition.addCalculatedField("to_media_video", new ContentToMediaField( "video" ));\r
+ anEntityAdapterDefinition.addCalculatedField("to_media_other", new ContentToMediaField( "otherMedia" ));\r
+ anEntityAdapterDefinition.addCalculatedField("to_all_uploaded_media", new ContentToMediaField( "uploadedMedia", false));\r
+ anEntityAdapterDefinition.addCalculatedField("to_all_media_images", new ContentToMediaField( "image", false));\r
+ anEntityAdapterDefinition.addCalculatedField("to_all_media_audio", new ContentToMediaField( "audio", false));\r
+ anEntityAdapterDefinition.addCalculatedField("to_all_media_video", new ContentToMediaField( "video", false));\r
+ anEntityAdapterDefinition.addCalculatedField("to_all_media_other", new ContentToMediaField( "otherMedia", false));\r
+ anEntityAdapterDefinition.addCalculatedField("to_media_icon", new ContentToIconField());\r
+\r
+ anEntityAdapterDefinition.addCalculatedField("article_type", new ContentToArticleTypeField());\r
+\r
+ anEntityAdapterDefinition.addCalculatedField("description_parsed", new FilteredField("description"));\r
+ anEntityAdapterDefinition.addCalculatedField("content_data_parsed", new FilteredField("content_data"));\r
+\r
+ anEntityAdapterDefinition.addCalculatedField("children", new ContentToChildrenField());\r
+ anEntityAdapterDefinition.addCalculatedField("parent", new ContentToParentField());\r
+\r
+ anEntityAdapterDefinition.addCalculatedField("publicurl", new ExpandedField(configuration.getString("Article.PublicUrl")));\r
+\r
+ anEntityAdapterDefinition.addCalculatedField("operations",\r
+ new EntityToSimpleOperationsField(MirGlobal.localizer().adminInterface().simpleArticleOperations()));\r
+ }\r
+ catch (Throwable t) {\r
+ throw new MirLocalizerFailure(t.getMessage(), t);\r
+ }\r
+ }\r
+\r
+ protected void constructCommentAdapterDefinition(EntityAdapterDefinition anEntityAdapterDefinition) throws MirLocalizerFailure {\r
+ try {\r
+ anEntityAdapterDefinition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));\r
+ anEntityAdapterDefinition.addCalculatedField("to_content", new CommentToContentField());\r
+ anEntityAdapterDefinition.addCalculatedField("status", new CommentToStatusField());\r
+\r
+ anEntityAdapterDefinition.addCalculatedField("to_uploaded_media", new CommentToMediaField( "uploadedMedia" ));\r
+ anEntityAdapterDefinition.addCalculatedField("to_media_images", new CommentToMediaField( "image" ));\r
+ anEntityAdapterDefinition.addCalculatedField("to_media_audio", new CommentToMediaField( "audio" ));\r
+ anEntityAdapterDefinition.addCalculatedField("to_media_video", new CommentToMediaField( "video" ));\r
+ anEntityAdapterDefinition.addCalculatedField("to_media_other", new CommentToMediaField( "otherMedia" ));\r
+ anEntityAdapterDefinition.addCalculatedField("to_all_uploaded_media", new CommentToMediaField( "uploadedMedia", false));\r
+ anEntityAdapterDefinition.addCalculatedField("to_all_media_images", new CommentToMediaField( "image", false));\r
+ anEntityAdapterDefinition.addCalculatedField("to_all_media_audio", new CommentToMediaField( "audio", false));\r
+ anEntityAdapterDefinition.addCalculatedField("to_all_media_video", new CommentToMediaField( "video", false));\r
+ anEntityAdapterDefinition.addCalculatedField("to_all_media_other", new CommentToMediaField( "otherMedia", false));\r
+\r
+ anEntityAdapterDefinition.addCalculatedField("publicurl", new ExpandedField(configuration.getString("Comment.PublicUrl")));\r
+\r
+ anEntityAdapterDefinition.addCalculatedField("description_parsed", new FilteredField("description"));\r
+ anEntityAdapterDefinition.addCalculatedField("operations",\r
+ new EntityToSimpleOperationsField(MirGlobal.localizer().adminInterface().simpleCommentOperations()));\r
+ }\r
+ catch (Throwable t) {\r
+ throw new MirLocalizerFailure(t.getMessage(), t);\r
+ }\r
+ }\r
+\r
+ public EntityAdapterModel adapterModel() throws MirLocalizerFailure, MirLocalizerExc {\r
+ EntityAdapterModel result = new EntityAdapterModel();\r
+\r
+ try {\r
+ EntityAdapterDefinition definition;\r
+\r
+ definition = new EntityAdapterDefinition();\r
+ constructContentAdapterDefinition( definition );\r
+ result.addMapping( "content", DatabaseContent.getInstance(), definition);\r
+\r
+ definition = new EntityAdapterDefinition();\r
+ constructCommentAdapterDefinition( definition );\r
+ result.addMapping( "comment", DatabaseComment.getInstance(), definition);\r
+ result.addMapping( "commentStatus", DatabaseCommentStatus.getInstance(), new EntityAdapterDefinition());\r
+\r
+ result.addMapping( "articleType", DatabaseArticleType.getInstance(), new EntityAdapterDefinition());\r
+\r
+ result.addMapping( "mediaType", DatabaseMediaType.getInstance(), new EntityAdapterDefinition());\r
+\r
+\r
+ definition = new EntityAdapterDefinition();\r
+ definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));\r
+ result.addMapping( "breakingNews", DatabaseBreaking.getInstance(), definition);\r
+\r
+ definition = new EntityAdapterDefinition();\r
+ definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));\r
+ result.addMapping( "internalMessage", DatabaseMessages.getInstance(), definition);\r
+\r
+ definition = new EntityAdapterDefinition();\r
+ definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());\r
+ definition.addCalculatedField("human_readable_size", new HumanReadableSizeField("value"));\r
+ definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));\r
+ definition.addCalculatedField("info", new MediaToMediaInfoField());\r
+ result.addMapping( "uploadedMedia", DatabaseUploadedMedia.getInstance(), definition);\r
+ definition = new EntityAdapterDefinition();\r
+ definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());\r
+ definition.addCalculatedField("human_readable_size", new HumanReadableSizeField("value"));\r
+ definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));\r
+ definition.addCalculatedField("info", new MediaToMediaInfoField());\r
+ definition.addCalculatedField("big_icon", new MediaToBigIconField());\r
+ result.addMapping( "image", DatabaseImages.getInstance(), definition);\r
+ definition = new EntityAdapterDefinition();\r
+ definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());\r
+ definition.addCalculatedField("human_readable_size", new HumanReadableSizeField("value"));\r
+ definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));\r
+ definition.addCalculatedField("info", new MediaToMediaInfoField());\r
+ definition.addCalculatedField("big_icon", new MediaToBigIconField());\r
+ result.addMapping( "audio", DatabaseAudio.getInstance(), definition);\r
+ definition = new EntityAdapterDefinition();\r
+ definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());\r
+ definition.addCalculatedField("human_readable_size", new HumanReadableSizeField("value"));\r
+ definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));\r
+ definition.addCalculatedField("info", new MediaToMediaInfoField());\r
+ definition.addCalculatedField("big_icon", new MediaToBigIconField());\r
+ result.addMapping( "video", DatabaseVideo.getInstance(), definition);\r
+ definition = new EntityAdapterDefinition();\r
+ definition.addCalculatedField("mediafolder", new MediaToMediaFolderField());\r
+ definition.addCalculatedField("human_readable_size", new HumanReadableSizeField("value"));\r
+ definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));\r
+ definition.addCalculatedField("info", new MediaToMediaInfoField());\r
+ definition.addCalculatedField("big_icon", new MediaToBigIconField());\r
+ result.addMapping( "otherMedia", DatabaseOther.getInstance(), definition);\r
+\r
+\r
+ result.addMapping( "mediaFolder", DatabaseMediafolder.getInstance(), new EntityAdapterDefinition());\r
+ result.addMapping( "imageType", DatabaseImageType.getInstance(), new EntityAdapterDefinition());\r
+ result.addMapping( "language", DatabaseLanguage.getInstance(), new EntityAdapterDefinition());\r
+ result.addMapping( "mediaType", DatabaseMediaType.getInstance(), new EntityAdapterDefinition());\r
+ result.addMapping( "topic", DatabaseTopics.getInstance(), new EntityAdapterDefinition());\r
+ result.addMapping( "user", DatabaseUsers.getInstance(), new EntityAdapterDefinition());\r
+ result.addMapping( "otherMedia", DatabaseOther.getInstance(), new EntityAdapterDefinition());\r
+\r
+ result.addMapping( "content_x_topic", DatabaseContentToTopics.getInstance(), new EntityAdapterDefinition());\r
+\r
+ }\r
+ catch (Throwable t) {\r
+ throw new MirLocalizerFailure(t.getMessage(), t);\r
+ }\r
+\r
+ return result;\r
+ }\r
+\r
+ protected class CommentToContentField implements EntityAdapterDefinition.CalculatedField {\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+ return anEntityAdapter.getToOneRelation(\r
+ "id="+anEntityAdapter.get("to_media"),\r
+ "id",\r
+ "content" );\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+ }\r
+\r
+ protected class CommentToStatusField implements EntityAdapterDefinition.CalculatedField {\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+ return anEntityAdapter.getToOneRelation(\r
+ "id="+anEntityAdapter.get("to_comment_status"),\r
+ "id",\r
+ "commentStatus" );\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+ }\r
+\r
+ protected class EntityToSimpleOperationsField implements EntityAdapterDefinition.CalculatedField {\r
+ private List operations;\r
+\r
+ public EntityToSimpleOperationsField(List anOperations) {\r
+ operations = anOperations;\r
+ }\r
+\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+ Iterator i = operations.iterator();\r
+ List availableOperations = new Vector();\r
+\r
+ while (i.hasNext()) {\r
+ MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation =\r
+ (MirAdminInterfaceLocalizer.MirSimpleEntityOperation) i.next();\r
+\r
+ if (operation.isAvailable(anEntityAdapter)) {\r
+ availableOperations.add(operation.getName());\r
+ }\r
+ };\r
+\r
+ return availableOperations;\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+ }\r
+\r
+ protected class FilteredField implements EntityAdapterDefinition.CalculatedField {\r
+ private String fieldName;\r
+\r
+ public FilteredField(String aFieldName) {\r
+ fieldName = aFieldName;\r
+ }\r
+\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+ if (anEntityAdapter.get("is_html")!=null && anEntityAdapter.get("is_html").equals("1")) {\r
+ return MirGlobal.localizer().producerAssistant().filterHTMLText((String) anEntityAdapter.get(fieldName));\r
+ }\r
+ else {\r
+ return MirGlobal.localizer().producerAssistant().filterNonHTMLText((String) anEntityAdapter.get(fieldName));\r
+ }\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+ }\r
+\r
+ protected class StructuredContentField implements EntityAdapterDefinition.CalculatedField {\r
+ private String expression;\r
+\r
+ public StructuredContentField(String anExpression) {\r
+ expression = anExpression;\r
+ }\r
+\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+ return StructuredContentParser.parse(ParameterExpander.evaluateStringExpression(anEntityAdapter, expression));\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+ }\r
+\r
+ protected class ExpandedField implements EntityAdapterDefinition.CalculatedField {\r
+ private String expression;\r
+\r
+ public ExpandedField(String anExpression) {\r
+ expression = anExpression;\r
+ }\r
+\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+ return ParameterExpander.expandExpression(anEntityAdapter, expression);\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+ }\r
+\r
+ protected class EvaluatedField implements EntityAdapterDefinition.CalculatedField {\r
+ private String expression;\r
+\r
+ public EvaluatedField(String anExpression) {\r
+ expression = anExpression;\r
+ }\r
+\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+ return ParameterExpander.evaluateExpression(anEntityAdapter, expression);\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+ }\r
+\r
+ protected class ContentToParentField implements EntityAdapterDefinition.CalculatedField {\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+ logger.debug("ContentToParentField.getValue");\r
+ return anEntityAdapter.getToOneRelation(\r
+ "id="+anEntityAdapter.get("to_content"),\r
+ "id",\r
+ "content" );\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+ }\r
+\r
+ protected class ContentToChildrenField implements EntityAdapterDefinition.CalculatedField {\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+ return anEntityAdapter.getRelation(\r
+ "to_content="+anEntityAdapter.get("id"),\r
+ "id",\r
+ "content" );\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+ }\r
+\r
+ protected class ContentToLanguageField implements EntityAdapterDefinition.CalculatedField {\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+ return anEntityAdapter.getToOneRelation(\r
+ "id="+anEntityAdapter.get("to_language"),\r
+ "id",\r
+ "language" );\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+ }\r
+\r
+ protected class ContentToArticleTypeField implements EntityAdapterDefinition.CalculatedField {\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+ return anEntityAdapter.getToOneRelation(\r
+ "id="+anEntityAdapter.get("to_article_type"),\r
+ "id",\r
+ "articleType" );\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+ }\r
+\r
+ protected class MediaToMediaFolderField implements EntityAdapterDefinition.CalculatedField {\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+ return anEntityAdapter.getToOneRelation(\r
+ "id="+anEntityAdapter.get("to_media_folder"),\r
+ "id",\r
+ "mediaFolder" );\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+ }\r
+\r
+ public static class MediaInfo {\r
+ private MediaHandler mediaHandler;\r
+\r
+ public MediaInfo(MediaHandler aHandler) {\r
+ mediaHandler = aHandler;\r
+ }\r
+ public String getBigIcon() {\r
+ if (mediaHandler == null)\r
+ return "bla";\r
+ else\r
+ return mediaHandler.getBigIconName();\r
+ }\r
+\r
+ public String getSmallIcon() {\r
+ if (mediaHandler == null)\r
+ return "bla";\r
+ else\r
+ return mediaHandler.getTinyIconName();\r
+ }\r
+\r
+ public String getMediaType() {\r
+ return "";\r
+ }\r
+ }\r
+\r
+ protected class MediaToMediaInfoField implements EntityAdapterDefinition.CalculatedField {\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+ MediaHandler mediaHandler = MediaHelper.getHandler(((EntityUploadedMedia) anEntityAdapter.getEntity()).getMediaType());\r
+\r
+ return new MediaInfo(mediaHandler);\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+ }\r
+\r
+ protected class MediaToBigIconField implements EntityAdapterDefinition.CalculatedField {\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+ return MediaHelper.getHandler(((EntityUploadedMedia) anEntityAdapter.getEntity()).getMediaType()).getBigIconName();\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+ }\r
+\r
+ protected class ContentToCommentsField implements EntityAdapterDefinition.CalculatedField {\r
+ private String extracondition;\r
+ private String order;\r
+\r
+ public ContentToCommentsField() {\r
+ this ( " and is_published='1'", "webdb_create");\r
+ }\r
+\r
+ public ContentToCommentsField(String anExtraCondition, String anOrder) {\r
+ order = anOrder;\r
+ extracondition = anExtraCondition;\r
+ }\r
+\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+ return anEntityAdapter.getRelation(\r
+ "to_media="+anEntityAdapter.get("id")+" " + extracondition,\r
+ order,\r
+ "comment" );\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+ }\r
+\r
+ protected class ContentToTopicsField implements EntityAdapterDefinition.CalculatedField {\r
+ private String topicCondition;\r
+ private String topicOrder;\r
+\r
+ public ContentToTopicsField() {\r
+ this(null);\r
+ }\r
+\r
+ public ContentToTopicsField(String aTopicCondition) {\r
+ this(aTopicCondition, "title");\r
+ }\r
+\r
+ public ContentToTopicsField(String aTopicCondition, String aTopicOrder) {\r
+ topicCondition = aTopicCondition;\r
+ topicOrder = aTopicOrder;\r
+ }\r
+\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+\r
+ Vector extraTable = new Vector();\r
+ extraTable.add("content_x_topic cxt");\r
+ String condition = "cxt.content_id="+anEntityAdapter.get("id")+\r
+ " and cxt.topic_id=t.id";\r
+\r
+ if (topicCondition!=null && topicCondition.length()>0)\r
+ condition = "(" + topicCondition + ") and " + condition;\r
+\r
+ return anEntityAdapter.getComplexRelation("t", extraTable,\r
+ condition, topicOrder, "topic" );\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+ }\r
+\r
+ protected class ContentToMediaField implements EntityAdapterDefinition.CalculatedField {\r
+ private String definition;\r
+ private boolean published;\r
+\r
+ public ContentToMediaField(String aDefinition, boolean anOnlyPublished) {\r
+ definition = aDefinition;\r
+ published = anOnlyPublished;\r
+ }\r
+\r
+ public ContentToMediaField(String aDefinition) {\r
+ this(aDefinition, true);\r
+ }\r
+\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+ String condition = "cxm.content_id="+ anEntityAdapter.get("id") +\r
+ " and cxm.media_id = m.id";\r
+ if (published)\r
+ condition = "is_published='t' and " + condition;\r
+\r
+ List extraTables = new Vector();\r
+ extraTables.add("content_x_media cxm");\r
+\r
+ return anEntityAdapter.getComplexRelation("m", extraTables, condition, "id", definition);\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+ }\r
+\r
+ protected class CommentToMediaField implements EntityAdapterDefinition.CalculatedField {\r
+ private String definition;\r
+ private boolean published;\r
+\r
+ public CommentToMediaField(String aDefinition, boolean anOnlyPublished) {\r
+ definition = aDefinition;\r
+ published = anOnlyPublished;\r
+ }\r
+\r
+ public CommentToMediaField(String aDefinition) {\r
+ this(aDefinition, true);\r
+ }\r
+\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+\r
+ String condition = "cxm.comment_id="+ anEntityAdapter.get("id") +\r
+ " and cxm.media_id = m.id";\r
+ if (published)\r
+ condition = "is_published='t' and " + condition;\r
+\r
+ List extraTables = new Vector();\r
+ extraTables.add("comment_x_media cxm");\r
+ return anEntityAdapter.getComplexRelation("m", extraTables, condition, "id", definition);\r
+\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+ }\r
+\r
+ protected class ContentToIconField implements EntityAdapterDefinition.CalculatedField {\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ EntityAdapter media;\r
+ Entity mediaType;\r
+ RewindableIterator iterator;\r
+ Map result;\r
+ MediaHandler mediaHandler;\r
+ String tinyIcon;\r
+ String iconAlt;\r
+\r
+ try {\r
+ iterator = (RewindableIterator) (anEntityAdapter.get("to_uploaded_media"));\r
+ iterator.rewind();\r
+\r
+ tinyIcon = MirGlobal.config().getString("Producer.Icon.TinyText");\r
+ iconAlt = "Text";\r
+\r
+ if (iterator.hasNext()) {\r
+ media = (EntityAdapter) iterator.next();\r
+\r
+ mediaType = ((EntityUploadedMedia) (media.getEntity())).getMediaType();\r
+ mediaHandler = MediaHelper.getHandler( mediaType );\r
+\r
+ tinyIcon = mediaHandler.getTinyIconName();\r
+ iconAlt = mediaHandler.getIconAltName();\r
+ }\r
+ }\r
+ catch (Throwable t) {\r
+ logger.error("ContentToIconField: " +t.getMessage());\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+\r
+ result = new HashMap();\r
+ result.put("tiny_icon", MirGlobal.config().getString("Producer.ImageRoot") + "/" + tinyIcon);\r
+ result.put("icon_alt", iconAlt);\r
+\r
+ return result;\r
+ }\r
+ }\r
+\r
+ protected class ContentCommentCountField implements EntityAdapterDefinition.CalculatedField {\r
+ private String extraCondition;\r
+\r
+ public ContentCommentCountField(String anExtraCondition) {\r
+ super();\r
+\r
+ extraCondition = anExtraCondition;\r
+ }\r
+\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+ return Integer.toString(\r
+ DatabaseComment.getInstance().getSize(\r
+ "to_media="+anEntityAdapter.get("id")+" " + extraCondition));\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+ }\r
+\r
+ protected class HumanReadableSizeField implements EntityAdapterDefinition.CalculatedField {\r
+ private String fieldName;\r
+\r
+ public HumanReadableSizeField(String aFieldName) {\r
+ fieldName= aFieldName;\r
+ }\r
+\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+ String size = (String) anEntityAdapter.get(fieldName);\r
+ if (size!=null)\r
+ return NumberUtils.humanReadableSize(Double.parseDouble(size));\r
+ else\r
+ return "";\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+ protected class ContentMediaCountField implements EntityAdapterDefinition.CalculatedField {\r
+ private String table;\r
+ private boolean published;\r
+\r
+ public ContentMediaCountField(String aTable, boolean anOnlyPublished) {\r
+ table = aTable;\r
+ published = anOnlyPublished;\r
+ }\r
+\r
+ public ContentMediaCountField(String aTable) {\r
+ this(aTable, true);\r
+ }\r
+\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+ Vector extraTable = new Vector();\r
+ extraTable.add(table+" m");\r
+ String selectSql = "cxm.media_id=m.id and cxm.content_id="+\r
+ anEntityAdapter.get("id");\r
+ if (published)\r
+ selectSql+= " and m.is_published='t'";\r
+\r
+ return Integer.toString(\r
+ DatabaseContentToMedia.getInstance().getSize(\r
+ "cxm", extraTable, selectSql));\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+\r
+/*\r
+ public String getValue(String key) {\r
+ String returnValue = null;\r
+\r
+ if (key != null) {\r
+ if (key.equals("big_icon"))\r
+ returnValue = getBigIconName();\r
+ else if (key.equals("descr") || key.equals("media_descr"))\r
+ returnValue = getDescr();\r
+ else if (key.equals("mediatype"))\r
+ returnValue = getMediaTypeString();\r
+ else if (key.equals("mimetype"))\r
+ returnValue = getMimeType();\r
+ else\r
+ returnValue = super.getValue(key);\r
+ }\r
+ return returnValue;\r
+ }\r
+\r
+ // @todo all these methods should be merged into 1\r
+ // and the MediaHandler should be cached somehow.\r
+ private String getMediaTypeString() {\r
+ if (this instanceof EntityImages)\r
+ return "image";\r
+ if (this instanceof EntityAudio)\r
+ return "audio";\r
+ if (this instanceof EntityVideo)\r
+ return "video";\r
+ else\r
+ return "other";\r
+ }\r
+\r
+private String getBigIconName() {\r
+ MediaHandler mediaHandler = null;\r
+ Entity mediaType = null;\r
+\r
+ try {\r
+ mediaType = getMediaType();\r
+ mediaHandler = MediaHelper.getHandler(mediaType);\r
+ return mediaHandler.getBigIconName();\r
+ }\r
+ catch (Exception ex) {\r
+ logger.warn("EntityUploadedMedia.getBigIconName: could not fetch data: " + ex.toString());\r
+ }\r
+ return null;\r
+}\r
+\r
+private List getUrl() {\r
+ MediaHandler mediaHandler = null;\r
+ Entity mediaType = null;\r
+\r
+ try {\r
+ mediaType = getMediaType();\r
+ mediaHandler = MediaHelper.getHandler(mediaType);\r
+ return mediaHandler.getURL(this, mediaType);\r
+ }\r
+ catch (Throwable t) {\r
+ logger.warn("EntityUploadedMedia.getUrl: could not fetch data: " + t.toString());\r
+ }\r
+ return null;\r
+}\r
+\r
+private String getDescr() {\r
+ MediaHandler mediaHandler = null;\r
+ Entity mediaType = null;\r
+\r
+ try {\r
+ mediaType = getMediaType();\r
+ mediaHandler = MediaHelper.getHandler(mediaType);\r
+ return mediaHandler.getDescr(mediaType);\r
+ }\r
+ catch (Exception ex) {\r
+ logger.warn("EntityUploadedMedia.getDescr: could not fetch data: " + ex.toString());\r
+ }\r
+ return null;\r
+}\r
+private String getMimeType() {\r
+ Entity mediaType = null;\r
+\r
+ try {\r
+ mediaType = getMediaType();\r
+ return mediaType.getValue("mime_type");\r
+ }\r
+ catch (Exception ex) {\r
+ logger.warn("EntityUploadedMedia.getBigIconName: could not fetch data: " + ex.toString());\r
+ }\r
+ return null;\r
+}\r
+*/
\ No newline at end of file
-/*
- * 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 mircoders.localizer.MirAdminInterfaceLocalizer;
-import mircoders.localizer.MirDataModelLocalizer;
-import mircoders.localizer.MirGeneratorLocalizer;
-import mircoders.localizer.MirLocalizer;
-import mircoders.localizer.MirLocalizerExc;
-import mircoders.localizer.MirLocalizerFailure;
-import mircoders.localizer.MirOpenPostingLocalizer;
-import mircoders.localizer.MirProducerAssistantLocalizer;
-import mircoders.localizer.MirProducerLocalizer;
-
-public class MirBasicLocalizer implements MirLocalizer {
-
- public MirProducerLocalizer producers() throws MirLocalizerFailure, MirLocalizerExc {
- return new MirBasicProducerLocalizer();
- }
-
- public MirGeneratorLocalizer generators() throws MirLocalizerFailure, MirLocalizerExc {
- return new MirBasicGeneratorLocalizer();
- }
-
- public MirOpenPostingLocalizer openPostings() throws MirLocalizerFailure, MirLocalizerExc {
- return new MirBasicOpenPostingLocalizer();
- }
-
- public MirProducerAssistantLocalizer producerAssistant() throws MirLocalizerFailure, MirLocalizerExc {
- return new MirBasicProducerAssistantLocalizer();
- }
-
- public MirDataModelLocalizer dataModel() throws MirLocalizerFailure, MirLocalizerExc {
- return new MirBasicDataModelLocalizer();
- };
-
- public MirAdminInterfaceLocalizer adminInterface() throws MirLocalizerFailure, MirLocalizerExc {
- return new MirBasicAdminInterfaceLocalizer();
- };
-
+/*\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.localizer.basic;\r
+\r
+import mircoders.localizer.MirAdminInterfaceLocalizer;\r
+import mircoders.localizer.MirDataModelLocalizer;\r
+import mircoders.localizer.MirGeneratorLocalizer;\r
+import mircoders.localizer.MirLocalizer;\r
+import mircoders.localizer.MirLocalizerExc;\r
+import mircoders.localizer.MirLocalizerFailure;\r
+import mircoders.localizer.MirOpenPostingLocalizer;\r
+import mircoders.localizer.MirProducerAssistantLocalizer;\r
+import mircoders.localizer.MirProducerLocalizer;\r
+import mircoders.localizer.MirMediaLocalizer;\r
+\r
+public class MirBasicLocalizer implements MirLocalizer {\r
+\r
+ public MirProducerLocalizer producers() throws MirLocalizerFailure, MirLocalizerExc {\r
+ return new MirBasicProducerLocalizer();\r
+ }\r
+\r
+ public MirGeneratorLocalizer generators() throws MirLocalizerFailure, MirLocalizerExc {\r
+ return new MirBasicGeneratorLocalizer();\r
+ }\r
+\r
+ public MirOpenPostingLocalizer openPostings() throws MirLocalizerFailure, MirLocalizerExc {\r
+ return new MirBasicOpenPostingLocalizer();\r
+ }\r
+\r
+ public MirProducerAssistantLocalizer producerAssistant() throws MirLocalizerFailure, MirLocalizerExc {\r
+ return new MirBasicProducerAssistantLocalizer();\r
+ }\r
+\r
+ public MirDataModelLocalizer dataModel() throws MirLocalizerFailure, MirLocalizerExc {\r
+ return new MirBasicDataModelLocalizer();\r
+ };\r
+\r
+ public MirAdminInterfaceLocalizer adminInterface() throws MirLocalizerFailure, MirLocalizerExc {\r
+ return new MirBasicAdminInterfaceLocalizer();\r
+ }\r
+\r
+ public MirMediaLocalizer media() throws MirLocalizerFailure, MirLocalizerExc {\r
+ return new MirBasicMediaLocalizer();\r
+ }\r
}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with 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.localizer.basic;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import mir.media.MediaHandler;\r
+import mir.config.*;\r
+import mircoders.localizer.MirLocalizerExc;\r
+import mircoders.localizer.MirLocalizerFailure;\r
+import mircoders.localizer.MirMediaLocalizer;\r
+import mircoders.media.*;\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 MirBasicMediaLocalizer implements MirMediaLocalizer {\r
+ private Map mediaHandlers;\r
+\r
+ /**\r
+ *\r
+ * @throws MirLocalizerExc\r
+ * @throws MirLocalizerFailure\r
+ */\r
+ public MirBasicMediaLocalizer() throws MirLocalizerExc, MirLocalizerFailure {\r
+ MirPropertiesConfiguration configuration;\r
+\r
+ try {\r
+ configuration = MirPropertiesConfiguration.instance();\r
+ }\r
+ catch (Throwable t) {\r
+ throw new MirLocalizerFailure("Can't get configuration", t);\r
+ }\r
+\r
+ mediaHandlers = new HashMap();\r
+\r
+\r
+ registerMediaHandler("Audio", new MediaHandlerAudio());\r
+ registerMediaHandler("Generic", new MediaHandlerGeneric());\r
+ registerMediaHandler("ImagesExtern", new MediaHandlerImagesExtern());\r
+ registerMediaHandler("ImagesJpeg", new MediaHandlerImagesJpeg());\r
+ registerMediaHandler("ImagesPng", new MediaHandlerImagesPng());\r
+ registerMediaHandler("Mp3", new MediaHandlerMp3());\r
+ registerMediaHandler("Ogg", new MediaHandlerOgg());\r
+ registerMediaHandler("RealAudio", new MediaHandlerRealAudio());\r
+ registerMediaHandler("RealVideo", new MediaHandlerRealVideo());\r
+ registerMediaHandler("Video", new MediaHandlerVideo());\r
+\r
+ registerMediaHandler("VideoUrl", new URLMediaHandler(\r
+ configuration.getString("Producer.Icon.BigVideo"),\r
+ configuration.getString("Producer.Icon.TinyVideo"),\r
+ "Video Url"));\r
+\r
+ registerMediaHandler("AudioUrl", new URLMediaHandler(\r
+ configuration.getString("Producer.Icon.BigAudio"),\r
+ configuration.getString("Producer.Icon.TinyAudio"),\r
+ "Audio Url"));\r
+\r
+ registerMediaHandler("ImageUrl", new URLMediaHandler(\r
+ configuration.getString("Producer.Icon.BigImage"),\r
+ configuration.getString("Producer.Icon.TinyImage"),\r
+ "Image Url"));\r
+\r
+ registerMediaHandler("OtherUrl", new URLMediaHandler(\r
+ configuration.getString("Producer.Icon.BigAudio"),\r
+ configuration.getString("Producer.Icon.TinyAudio"),\r
+ "Url"));\r
+ }\r
+\r
+ /** returns the {@link MediaHandler} associated with name <code>aName</code> by way of\r
+ * an internal <code>Map</code>. This <code>Map</code> can be manipulated by calling\r
+ * <code>registerMediaHandler</code> and <code>unregisterMediaHandler</code>\r
+ */\r
+ public MediaHandler getHandler(String aName) {\r
+ synchronized (mediaHandlers) {\r
+ return (MediaHandler) mediaHandlers.get(aName);\r
+ }\r
+ }\r
+\r
+ /** adds a media handler to the registry */\r
+ public void registerMediaHandler(String aName, MediaHandler aHandler) {\r
+ synchronized (mediaHandlers) {\r
+ mediaHandlers.put(aName, aHandler);\r
+ }\r
+ }\r
+\r
+ /** removes a media handler from the registry*/\r
+ public void unregisterMediaHandler(String aName) {\r
+ synchronized (mediaHandlers) {\r
+ mediaHandlers.remove(aName);\r
+ }\r
+ }\r
+}
\ No newline at end of file
package mircoders.media;
-import mir.media.MirMedia;
+import mir.media.MediaHandler;
/**
* Handles audio media, like mp3 and maybe it could also handle some other.
* It is MediaHandlerGeneric with different icons.
*
* @see mir.media.MediaHandlerGeneric
- * @see mir.media.MirMedia
+ * @see mir.media.MediaHandler
* @author mh <mh@nadir.org>
- * @version $Id: MediaHandlerAudio.java,v 1.9.2.1 2003/08/13 02:43:56 zapata Exp $
+ * @version $Id: MediaHandlerAudio.java,v 1.9.2.2 2003/12/14 16:37:07 zapata Exp $
*/
-public class MediaHandlerAudio extends MediaHandlerGeneric implements MirMedia
+public class MediaHandlerAudio extends MediaHandlerGeneric implements MediaHandler
{
+ private String tinyIcon;
+ private String bigIcon;
- private static String tinyIcon;
- private static String bigIcon;
-
- static {
+ public MediaHandlerAudio() {
tinyIcon = configuration.getString("Producer.Icon.TinyAudio");
bigIcon = configuration.getString("Producer.Icon.BigAudio");
}
{
return "Audio";
}
-
- public boolean isAudio()
- {
- return true;
- }
-
}
import mir.log.LoggerWrapper;
import mir.media.MediaExc;
import mir.media.MediaFailure;
-import mir.media.MirMedia;
+import mir.media.MediaHandler;
import mir.misc.FileUtil;
import mir.misc.StringUtil;
* we don't have entered in the media_type table, (like RTF documents,
* PS, PDF, etc..)
* <p>
- * Of course it implements the MirMedia interface.
+ * Of course it implements the MirMediaHandler interface.
*
- * @see mir.media.MirMedia
+ * @see mir.media.MirMediaHandler
* @author mh <mh@nadir.org>
- * @version $Id: MediaHandlerGeneric.java,v 1.20.2.4 2003/11/28 16:46:36 rk Exp $
+ * @version $Id: MediaHandlerGeneric.java,v 1.20.2.5 2003/12/14 16:37:07 zapata Exp $
*/
-public class MediaHandlerGeneric implements MirMedia
+public class MediaHandlerGeneric implements MediaHandler
{
protected static MirPropertiesConfiguration configuration;
protected static String imageHost;
logger = new LoggerWrapper("Media.Generic");
}
- public void set (InputStream in, Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure {
+ public void store (InputStream in, Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure {
String ext = mediaTypeEnt.getValue("name");
String mediaFname = ent.getId() + "." + ext;
String date = ent.getValue("date");
String relPath = datePath+ent.getId()+"."+mediaTypeEnt.getValue("name");
String fname = getStoragePath()+relPath;
if(! new File(fname).exists())
- throw new MediaExc("error in MirMedia.produce(): " + relPath + " does not exist!");
+ throw new MediaExc("error in MirMediaHandler.produce(): " + relPath + " does not exist!");
}
public InputStream getMedia (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure {
String fname = getStoragePath()+publishPath;
File f = new File(fname);
if(! f.exists())
- throw new MediaExc("error in MirMedia.getMedia(): " + fname + " does not exist!");
+ throw new MediaExc("error in MirMediaHandler.getMedia(): " + fname + " does not exist!");
BufferedInputStream inputStream;
try {
return inputStream;
}
- public InputStream getIcon (Entity ent) throws MediaExc, MediaFailure {
+ public InputStream getThumbnail (Entity ent) throws MediaExc, MediaFailure {
return null;
}
- public String getIconMimeType (Entity aMediaEntity, Entity aMediaType) throws MediaExc, MediaFailure {
+ public String getThumbnailMimeType (Entity aMediaEntity, Entity aMediaType) throws MediaExc, MediaFailure {
ServletContext servletContext = MirPropertiesConfiguration.getContext();
String fileName = aMediaEntity.getId()+"."+aMediaType.getValue("name");
return theList;
}
- public boolean isVideo()
- {
- return false;
- }
-
- public boolean isAudio()
- {
- return false;
- }
-
- public boolean isImage()
- {
- return false;
- }
-
public String getDescr( Entity mediaType)
{
return mediaType.getValue("mime_type");
import mir.log.LoggerWrapper;
import mir.media.MediaExc;
import mir.media.MediaFailure;
-import mir.media.MirMedia;
+import mir.media.MediaHandler;
import mir.misc.FileUtil;
import mir.misc.StringUtil;
import mircoders.entity.EntityImages;
* written out to a file at the ProducerImages level.
* Remember that Handlers for specific image types, Gif, Jpeg, etc..
* should override it.
- * It implements the MirMedia interface.
+ * It implements the MirMediaHandler interface.
* <p>
* slowly starting to look better, a next step would be to have the
* representation stuff (WebdbImage) happen here.
* -mh 01.03.2002
*
- * @see mir.media.MirMedia
+ * @see mir.media.MirMediaHandler
* @author mh
- * @version $Id: MediaHandlerImages.java,v 1.23.2.2 2003/10/23 14:55:26 rk Exp $
+ * @version $Id: MediaHandlerImages.java,v 1.23.2.3 2003/12/14 16:37:07 zapata Exp $
*/
-public abstract class MediaHandlerImages implements MirMedia
+public abstract class MediaHandlerImages implements MediaHandler
{
protected static MirPropertiesConfiguration configuration;
protected static final String PNG = "PNG";
return inputStream;
}
- public void set(InputStream in, Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure {
+ public void store(InputStream in, Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure {
try {
((EntityImages)ent).setImage(in, getType());
}
- public InputStream getIcon(Entity ent) throws MediaExc, MediaFailure {
+ public InputStream getThumbnail(Entity ent) throws MediaExc, MediaFailure {
InputStream in;
try {
in = ((EntityImages)ent).getIcon();
public String getIconAltName() {
return "Image";
}
-
- public boolean isVideo() {
- return false;
- }
-
- public boolean isAudio() {
- return false;
- }
-
- public boolean isImage () {
- return true;
- }
-
public String getDescr(Entity mediaType) {
return "image/jpeg";
}
return "Image";
}
- public boolean isVideo()
- {
- return false;
- }
-
- public boolean isAudio()
- {
- return false;
- }
-
- public boolean isImage ()
- {
- return true;
- }
-
public String getDescr(Entity mediaType)
{
return "image/jpeg";
package mircoders.media;
import mir.entity.Entity;
-import mir.media.MirMedia;
+import mir.media.MediaHandler;
/**
* This class handles saving, fetching creating representations
* for all JPeg images. The image content is stored in the DB. The content is
* written out to a file at the ProducerImages level.
- * It implements the MirMedia interface.
+ * It implements the MirMediaHandler interface.
* <p>
*
- * @see mir.media.MirMedia
+ * @see mir.media.MirMediaHandler
* @see mircoders.media.MediaHandlerImages
* @author mh, mir-coders group
- * @version $Id: MediaHandlerImagesJpeg.java,v 1.6 2003/04/29 02:36:50 zapata Exp $
+ * @version $Id: MediaHandlerImagesJpeg.java,v 1.6.2.1 2003/12/14 16:37:08 zapata Exp $
*/
-public class MediaHandlerImagesJpeg extends MediaHandlerImages implements MirMedia
+public class MediaHandlerImagesJpeg extends MediaHandlerImages implements MediaHandler
{
public String getType() {
return JPEG;
return "image/jpeg";
}
- public String getIconMimeType(Entity aMedia, Entity aMediaType) {
+ public String getThumbnailMimeType(Entity aMedia, Entity aMediaType) {
return "image/jpeg";
}
}
package mircoders.media;
import mir.entity.Entity;
-import mir.media.MirMedia;
+import mir.media.MediaHandler;
/**
* This class handles saving, fetching creating representations
* for all png images. The image content is stored in the DB. The content is
* written out to a file at the ProducerImages level.
- * It implements the MirMedia interface.
+ * It implements the MediaHandler interface.
* <p>
*
- * @see mir.media.MirMedia
+ * @see mir.media.MediaHandler
* @see mircoders.media.MediaHandlerImages
* @author mh ,mir-coders
- * @version $Id: MediaHandlerImagesPng.java,v 1.7 2003/04/29 02:36:50 zapata Exp $
+ * @version $Id: MediaHandlerImagesPng.java,v 1.7.2.1 2003/12/14 16:37:08 zapata Exp $
*/
-public class MediaHandlerImagesPng extends MediaHandlerImages implements MirMedia
+public class MediaHandlerImagesPng extends MediaHandlerImages implements MediaHandler
{
public String getType() {
return PNG;
return "image/png";
}
- public String getIconMimeType(Entity aMedia, Entity aMediaType) {
+ public String getThumbnailMimeType(Entity aMedia, Entity aMediaType) {
return "image/png";
}
}
import mir.log.LoggerWrapper;
import mir.media.MediaExc;
import mir.media.MediaFailure;
-import mir.media.MirMedia;
+import mir.media.MediaHandler;
import mir.misc.FileUtil;
import mir.misc.StringUtil;
*
* If the web server is not apache, then your on your own.
*
- * @see mir.media.MirMedia
+ * @see mir.media.MediaHandler
* @author mh <mh@nadir.org>
- * @version $Id: MediaHandlerMp3.java,v 1.15.2.2 2003/12/03 18:10:45 rk Exp $
+ * @version $Id: MediaHandlerMp3.java,v 1.15.2.3 2003/12/14 16:37:08 zapata Exp $
*/
-public class MediaHandlerMp3 extends MediaHandlerAudio implements MirMedia
+public class MediaHandlerMp3 extends MediaHandlerAudio implements MediaHandler
{
-
+
public MediaHandlerMp3() {
logger = new LoggerWrapper("Media.Audio.Mp3");
}
import mir.log.LoggerWrapper;
import mir.media.MediaExc;
import mir.media.MediaFailure;
-import mir.media.MirMedia;
+import mir.media.MediaHandler;
import mir.misc.FileUtil;
import mir.misc.StringUtil;
*
* If the web server is not apache, then your on your own.
*
- * @see mir.media.MirMedia
+ * @see mir.media.MediaHandler
* @author pietro <pietro@indymedia.org> - based on MediaHandlerMp3 by mh <mh@nadir.org>
- * @version $Id:
+ * @version $Id:
*/
-public class MediaHandlerOgg extends MediaHandlerAudio implements MirMedia
+public class MediaHandlerOgg extends MediaHandlerAudio implements MediaHandler
{
protected LoggerWrapper logger;
//first the .m3u since it only contains one line
//dont write the .m3u it is an ogg vorbis file
//FileUtil.write(getStoragePath() + "/" + datePath + "/" + mpegURLFile,
- //new StringReader(mp3Pointer), "US-ASCII");
+ //new StringReader(mp3Pointer), "US-ASCII");
//now the .pls file
FileUtil.write(getStoragePath() + "/" + datePath + "/" + playlistFile,
new StringReader(oggPointer), "US-ASCII");
import mir.log.LoggerWrapper;\r
import mir.media.MediaExc;\r
import mir.media.MediaFailure;\r
-import mir.media.MirMedia;\r
+import mir.media.MediaHandler;\r
import mir.misc.FileUtil;\r
import mir.misc.StringUtil;\r
\r
* 03.2002 - reworked Realmedia handling. -mh\r
*\r
* @see mir.media.MediaHandlerGeneric\r
- * @see mir.media.MirMedia\r
+ * @see mir.media.MediaHandler\r
* @author john <john@manifestor.org>, mh <heckmann@hbe.ca>\r
- * @version $Id: MediaHandlerRealAudio.java,v 1.19.2.1 2003/09/03 17:49:40 zapata Exp $\r
+ * @version $Id: MediaHandlerRealAudio.java,v 1.19.2.2 2003/12/14 16:37:08 zapata Exp $\r
*/\r
\r
\r
-public class MediaHandlerRealAudio extends MediaHandlerAudio implements MirMedia\r
+public class MediaHandlerRealAudio extends MediaHandlerAudio implements MediaHandler\r
{\r
public MediaHandlerRealAudio() {\r
logger = new LoggerWrapper("Media.Audio.Real");\r
import mir.log.LoggerWrapper;
import mir.media.MediaExc;
import mir.media.MediaFailure;
-import mir.media.MirMedia;
+import mir.media.MediaHandler;
import mir.misc.FileUtil;
import mir.misc.StringUtil;
* 03.2002 - reworked Realmedia handling. -mh
*
* @see mir.media.MediaHandlerGeneric
- * @see mir.media.MirMedia
+ * @see mir.media.MediaHandler
* @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 $
+ * @version $Id: MediaHandlerRealVideo.java,v 1.19.2.3 2003/12/14 16:37:08 zapata Exp $
*/
-public class MediaHandlerRealVideo extends MediaHandlerVideo implements MirMedia
+public class MediaHandlerRealVideo extends MediaHandlerVideo implements MediaHandler
{
-
+
public MediaHandlerRealVideo() {
logger = new LoggerWrapper("Media.Video.Real");
}
* 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.media;
-import mir.media.MirMedia;
+import mir.media.MediaHandler;
/**
* It is MediaHandlerGeneric with different icons.
*
* @see mir.media.MediaHandlerGeneric
- * @see mir.media.MirMedia
+ * @see mir.media.MediaHandler
* @author john <john@manifestor.org>
- * @version $Id: MediaHandlerVideo.java,v 1.9 2003/04/21 12:42:48 idfx Exp $
+ * @version $Id: MediaHandlerVideo.java,v 1.9.2.1 2003/12/14 16:37:08 zapata Exp $
*/
-public class MediaHandlerVideo extends MediaHandlerGeneric implements MirMedia
+public class MediaHandlerVideo extends MediaHandlerGeneric implements MediaHandler
{
private static String tinyIcon;
private static String bigIcon;
--- /dev/null
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with 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 mir.entity.Entity;\r
+import mir.storage.Database;\r
+import java.util.Map;\r
+import java.util.HashMap;\r
+import mircoders.global.*;\r
+import mircoders.storage.*;\r
+import mir.media.*;\r
+import mircoders.localizer.MirLocalizerExc;\r
+\r
+/**\r
+ * helper class to resolve media handlers using reflection\r
+ *\r
+ * @author mh\r
+ * @author Zapata\r
+ * @version 2003\r
+ */\r
+\r
+public final class MediaHelper {\r
+ private static Map nameToMediaHandler = new HashMap();\r
+ private static String defaultMediaHandler = null;\r
+\r
+ public static void addHandler(String aName, MediaHandler aHandler) {\r
+ synchronized (nameToMediaHandler) {\r
+ nameToMediaHandler.put(aName, aHandler);\r
+ }\r
+ }\r
+\r
+ public static MediaHandler getHandler(Entity aMediaType) throws MediaExc, MediaFailure {\r
+ String handlerName = aMediaType.getValue("classname");\r
+\r
+ try {\r
+ return MirGlobal.localizer().media().getHandler(handlerName);\r
+ }\r
+ catch (MirLocalizerExc e) {\r
+ throw new MediaFailure(e);\r
+ }\r
+ }\r
+\r
+ public static Database getStorage(Entity mediaType, String aTable) throws MediaExc, MediaFailure {\r
+ if (aTable.equals("Images"))\r
+ return DatabaseImages.getInstance();\r
+ else if (aTable.equals("Audio"))\r
+ return DatabaseAudio.getInstance();\r
+ if (aTable.equals("Video"))\r
+ return DatabaseVideo.getInstance();\r
+ if (aTable.equals("Other"))\r
+ return DatabaseOther.getInstance();\r
+\r
+ throw new MediaExc("Unknown storage specification: " + aTable);\r
+ }\r
+}\r
+\r
+\r
+\r
* 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.media;
import mir.entity.Entity;
import mir.media.MediaExc;
import mir.media.MediaFailure;
-import mir.media.MediaHelper;
-import mir.media.MirMedia;
+import mircoders.media.MediaHelper;
+import mir.media.MediaHandler;
import mir.misc.StringUtil;
import mir.session.UploadedFile;
import mir.storage.Database;
public class MediaUploadProcessor {
public static Entity processMediaUpload(UploadedFile aFile, Map aValues) throws MediaExc, MediaFailure {
String mediaId;
- MirMedia mediaHandler;
+ MediaHandler mediaHandler;
Entity mediaType;
ModuleMediaType mediaTypeModule;
Database mediaStorage;
mediaId = mediaEntity.insert();
try {
- mediaHandler.set(aFile.getInputStream(), mediaEntity, mediaType);
+ mediaHandler.store(aFile.getInputStream(), mediaEntity, mediaType);
}
catch (Throwable e) {
throw new MediaFailure(e);
--- /dev/null
+package mircoders.media;
+
+import mir.media.*;
+import java.io.InputStream;
+import mir.entity.*;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * <p>URLMediaHandler</p>
+ * <p>Description:
+ * This is a media handler for media that are only known by url.
+ * </p>
+ * @author Zapata
+ */
+
+public class URLMediaHandler implements MediaHandler {
+ private String bigIcon;
+ private String tinyIcon;
+ private String iconAlternative;
+
+ public URLMediaHandler(String aBigIcon, String aTinyIcon, String anIconAlternative) {
+ bigIcon = aBigIcon;
+ tinyIcon = aTinyIcon;
+ iconAlternative = anIconAlternative;
+ }
+
+ public void store(InputStream anInputStream, Entity anEntity, Entity aMediaTypeEntity) throws MediaExc, MediaFailure {
+ throw new UnsupportedOperationException();
+ };
+
+ public void produce(Entity anEntity, Entity aMediaTypeEntity) throws MediaExc, MediaFailure {
+ }
+
+ public InputStream getMedia(Entity anEntity, Entity aMediaTypeEntity) throws MediaExc, MediaFailure {
+ return null;
+ }
+
+ public InputStream getThumbnail(Entity anEntity) throws MediaExc, MediaFailure {
+ return null;
+ }
+
+ public String getThumbnailMimeType(Entity aMediaEntity, Entity aMediaTypeEntity) throws MediaExc, MediaFailure {
+ return "application/octetstream";
+ }
+
+ public List getURL(Entity aMediaEntity, Entity aMediaTypeEntity) throws MediaExc, MediaFailure {
+ List result = new ArrayList();
+ result.add(aMediaTypeEntity.getValue("publish_server")+aMediaTypeEntity.getValue("publish_path"));
+
+ return result;
+ }
+
+ public Object getURLs(Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure {
+ return null;
+ }
+
+ public String getStoragePath () throws MediaExc, MediaFailure {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getIconStoragePath () throws MediaExc, MediaFailure {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getPublishHost () throws MediaExc, MediaFailure {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getBigIconName () {
+ return bigIcon;
+ }
+
+ public String getTinyIconName () {
+ return tinyIcon;
+ }
+
+ public String getIconAltName () {
+ return iconAlternative;
+ }
+
+ public String getDescr (Entity mediaTypeEnt) {
+ return "Url";
+ }
+}
\ No newline at end of file
* 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.
*/
import mir.entity.Entity;
import mir.entity.adapter.EntityAdapter;
import mir.log.LoggerWrapper;
-import mir.media.MediaHelper;
-import mir.media.MirMedia;
+import mircoders.media.MediaHelper;
+import mir.media.MediaHandler;
import mir.producer.ProducerExc;
import mir.producer.ProducerNode;
import mir.util.ParameterExpander;
Entity entity;
EntityUploadedMedia uploadedMediaEntity = null;
Entity mediaType = null;
- MirMedia currentMediaHandler;
+ MediaHandler currentMediaHandler;
try {
import mir.entity.adapter.EntityAdapterModel;
import mir.entity.adapter.EntityIteratorAdapter;
import mir.log.LoggerWrapper;
-import mir.media.MediaHelper;
-import mir.media.MirMedia;
+import mircoders.media.MediaHelper;
+import mir.media.MediaHandler;
import mir.servlet.ServletModule;
import mir.servlet.ServletModuleExc;
import mir.servlet.ServletModuleFailure;
public void getMedia(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
String idParam = aRequest.getParameter("id");
+
if (idParam!=null && !idParam.equals("")) {
try {
- EntityUploadedMedia ent = (EntityUploadedMedia)mainModule.getById(idParam);
- Entity mediaType = ent.getMediaType();
- MirMedia mediaHandler;
+ EntityUploadedMedia entity = (EntityUploadedMedia)mainModule.getById(idParam);
+ Entity mediaType = entity.getMediaType();
+ MediaHandler mediaHandler;
ServletContext ctx = MirPropertiesConfiguration.getContext();
- String fName = ent.getId()+"."+mediaType.getValue("name");
+ String fName = entity.getId()+"."+mediaType.getValue("name");
mediaHandler = MediaHelper.getHandler(mediaType);
- InputStream in = mediaHandler.getMedia(ent, mediaType);
+ InputStream in = mediaHandler.getMedia(entity, mediaType);
aResponse.setContentType(ctx.getMimeType(fName));
//important that before calling this aResponse.getWriter was not called first
// no exception allowed
}
- public void getIcon(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+
+ /**
+ * @obsolete
+ *
+ * @param aRequest
+ * @param aResponse
+ * @throws ServletModuleExc
+ */
+ public void getIcon(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
+ getThumbnail(aRequest, aResponse);
+
+ }
+
+ /**
+ *
+ * @param aRequest
+ * @param aResponse
+ * @throws ServletModuleExc
+ */
+ public void getThumbnail(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
{
String idParam = aRequest.getParameter("id");
if (idParam!=null && !idParam.equals("")) {
try {
EntityUploadedMedia ent = (EntityUploadedMedia) mainModule.getById(idParam);
Entity mediaType = ent.getMediaType();
- MirMedia mediaHandler;
+ MediaHandler mediaHandler;
mediaHandler = MediaHelper.getHandler(mediaType);
- InputStream in = mediaHandler.getIcon(ent);
+ InputStream in = mediaHandler.getThumbnail(ent);
if (in==null)
throw new ServletModuleExc("no icon available");
- aResponse.setContentType(mediaHandler.getIconMimeType(ent, mediaType));
+ aResponse.setContentType(mediaHandler.getThumbnailMimeType(ent, mediaType));
//important that before calling this aResponse.getWriter was not called first
ServletOutputStream out = aResponse.getOutputStream();
}
else logger.error("showcomments: id not specified.");
}
-
}
\ No newline at end of file
<if module=="Images">
<img src="${config.actionRoot}?module=${module}&do=getIcon&id=${entry.id}" border=0></a>
<else>
- <img src="${config.docRoot}/img/${entry.big_icon}" border=0></a>
+ <img src="${config.docRoot}/img/${entry.info.bigIcon}" border=0></a>
</if>
</td>
<td>
</td>
<td>
- ${entry.media_descr}
+ ${entry.info.mediaType}
</td>
<td>
<if entry.mediafolder>
<tr>
<td align="right" valign="top">
<a href="${config.actionRoot}?module=${module}&do=getMedia&id=${uploadedmedia.id}">
- <img src="/img/${uploadedmedia.big_icon}" border=0></a>
+ <img src="${config.docRoot}/img/${uploadedmedia.info.bigIcon}" border=0></a>
</td>
<td valign="bottom" class="small">
- ${lang("media.created")}: ${uploadedmedia.webdb_create}
- <if uploadedmedia.webdb_lastchange>/ ${lang("media.changed")} ${uploadedmedia.webdb_lastchange}</if><br>
- <if uploadedmedia.is_published=="1">${lang("media.published")}: ${uploadedmedia.publish_date} / ${uploadedmedia.publish_server}${uploadedmedia.publish_path}<br></if>
- ${lang("media.format")}: ${uploadedmedia.mimetype} / ${uploadedmedia.media_descr}<br>
+ ${lang("media.created")}: ${uploadedmedia.creationdate.format(config["Mir.DefaultDateTimeFormat"])}
+ ${lang("media.urls")}: ${uploadedmedia.publish_server}${uploadedmedia.publish_path}<br>
+ ${lang("media.format")}: ${uploadedmedia.info.mediaType}<br>
${lang("media.size")}: ${uploadedmedia.human_readable_size}<br>
- ${lang("media.rights")}: <b>${uploadedmedia.rightsHashdata[to_rights]["name"]}</b><br>
</td>
</tr>
</if>
<tr>
<td align="right" valign="top">
<a href="JavaScript:openWin('${config.actionRoot}?module=${module}&do=getMedia&id=${uploadedmedia.id}')">
- <img src="${config.actionRoot}?module=${module}&do=getIcon&id=${uploadedmedia.id}" border=0>
+ <img src="${config.actionRoot}?module=${module}&do=getThumbnail&id=${uploadedmedia.id}" border=0>
</a>
</td>
<td valign="bottom" class="small">
- ${lang("media.created")}: ${uploadedmedia.webdb_create}
- <if uploadedmedia.webdb_lastchange>/ ${lang("media.changed")} ${uploadedmedia.webdb_lastchange}</if><br>
- <if uploadedmedia.is_published=="1">${lang("media.published")}: ${uploadedmedia.publish_date} / ${uploadedmedia.publish_server}${uploadedmedia.publish_path}<br></if>
- ${lang("media.format")}: ${uploadedmedia.mimetype} / ${uploadedmedia.media_descr}<br>
-<comment>
- ${lang("media.size")}: ${uploadedmedia.human_readable_size}<br>
- ${lang("media.rights")}: <b>${uploadedmedia.rightsHashdata[to_rights]["name"]}</b><br>
-</comment>
+ ${lang("media.created")}: ${uploadedmedia.creationdate.format(config["Mir.DefaultDateTimeFormat"])}
+ ${lang("media.urls")}: ${uploadedmedia.publish_server}${uploadedmedia.publish_path}<br>
+ ${lang("media.format")}: ${uploadedmedia.info.mediaType}<br>
</td>
</tr>
</if>
<tr>
<td align="right" valign="top">
<a href="${config.actionRoot}?module=${module}&do=getMedia&id=${uploadedmedia.id}">
- <img src="/img/${uploadedmedia.big_icon}" border=0></a>
+ <img src="${config.docRoot}/img/${uploadedmedia.info.bigIcon}" border=0></a>
</td>
<td valign="bottom" class="small">
- ${lang("media.created")}: ${uploadedmedia.webdb_create}
- <if uploadedmedia.webdb_lastchange>/ ${lang("media.changed")} ${uploadedmedia.webdb_lastchange}</if><br>
- <if uploadedmedia.is_published=="1">${lang("media.published")}: ${uploadedmedia.publish_date} / ${uploadedmedia.publish_server}${uploadedmedia.publish_path}<br></if>
- ${lang("media.format")}: ${uploadedmedia.mimetype} / ${uploadedmedia.media_descr}<br>
+ ${lang("media.created")}: ${uploadedmedia.creationdate.format(config["Mir.DefaultDateTimeFormat"])}
+ ${lang("media.urls")}: ${uploadedmedia.publish_server}${uploadedmedia.publish_path}<br>
+ ${lang("media.format")}: ${uploadedmedia.info.mediaType}<br>
${lang("media.size")}: ${uploadedmedia.human_readable_size}<br>
- ${lang("media.rights")}: <b>${uploadedmedia.rightsHashdata[to_rights]["name"]}</b><br>
</td>
</tr>
</if>
<tr>
<td align="right" valign="top">
<a href="${config.actionRoot}?module=${module}&do=getMedia&id=${uploadedmedia.id}">
- <img src="/img/${uploadedmedia.big_icon}" border=0></a>
+ <img src="${config.docRoot}/img/${uploadedmedia.info.bigIcon}" border=0></a>
</td>
<td valign="bottom" class="small">
- ${lang("media.created")}: ${uploadedmedia.webdb_create}
- <if uploadedmedia.webdb_lastchange>/ ${lang("media.changed")} ${uploadedmedia.webdb_lastchange}</if><br>
- <if uploadedmedia.is_published=="1">${lang("media.published")}: ${uploadedmedia.publish_date} / ${uploadedmedia.publish_server}${uploadedmedia.publish_path}<br></if>
- ${lang("media.format")}: ${uploadedmedia.mimetype} / ${uploadedmedia.media_descr}<br>
+ ${lang("media.created")}: ${uploadedmedia.creationdate.format(config["Mir.DefaultDateTimeFormat"])}
+ ${lang("media.urls")}: ${uploadedmedia.publish_server}${uploadedmedia.publish_path}<br>
+ ${lang("media.format")}: ${uploadedmedia.info.mediaType}<br>
${lang("media.size")}: ${uploadedmedia.human_readable_size}<br>
- ${lang("media.rights")}: <b>${uploadedmedia.rightsHashdata[to_rights]["name"]}</b><br>
</td>
</tr>
</if>