From 6e0cd0d8650db7143b8c21f156df52a51902564d Mon Sep 17 00:00:00 2001 From: zapata Date: Sun, 14 Dec 2003 16:37:06 +0000 Subject: [PATCH] - redid part of the media handling - added an url media handler, for media known only by url --- bundles/admin_en.properties | 3 +- .../mir/media/{MirMedia.java => MediaHandler.java} | 456 +++--- source/mircoders/entity/EntityImages.java | 6 +- source/mircoders/entity/EntityUploadedMedia.java | 307 ++-- .../localizer/MirCachingLocalizerDecorator.java | 329 ++--- source/mircoders/localizer/MirLocalizer.java | 15 +- source/mircoders/localizer/MirMediaLocalizer.java | 43 + .../basic/MirBasicDataModelLocalizer.java | 1489 +++++++++++--------- .../localizer/basic/MirBasicLocalizer.java | 138 +- .../localizer/basic/MirBasicMediaLocalizer.java | 127 ++ source/mircoders/media/MediaHandlerAudio.java | 21 +- source/mircoders/media/MediaHandlerGeneric.java | 35 +- source/mircoders/media/MediaHandlerImages.java | 27 +- .../mircoders/media/MediaHandlerImagesExtern.java | 15 - source/mircoders/media/MediaHandlerImagesJpeg.java | 12 +- source/mircoders/media/MediaHandlerImagesPng.java | 12 +- source/mircoders/media/MediaHandlerMp3.java | 10 +- source/mircoders/media/MediaHandlerOgg.java | 10 +- source/mircoders/media/MediaHandlerRealAudio.java | 8 +- source/mircoders/media/MediaHandlerRealVideo.java | 10 +- source/mircoders/media/MediaHandlerVideo.java | 22 +- source/{mir => mircoders}/media/MediaHelper.java | 164 +-- source/mircoders/media/MediaUploadProcessor.java | 22 +- source/mircoders/media/URLMediaHandler.java | 85 ++ .../producer/MediaGeneratingProducerNode.java | 20 +- .../servlet/ServletModuleUploadedMedia.java | 43 +- templates/admin/FUNCTIONS_media.template | 4 +- templates/admin/audio.template | 10 +- templates/admin/image.template | 13 +- templates/admin/other.template | 10 +- templates/admin/video.template | 10 +- 31 files changed, 1876 insertions(+), 1600 deletions(-) rename source/mir/media/{MirMedia.java => MediaHandler.java} (84%) create mode 100755 source/mircoders/localizer/MirMediaLocalizer.java create mode 100755 source/mircoders/localizer/basic/MirBasicMediaLocalizer.java rename source/{mir => mircoders}/media/MediaHelper.java (52%) create mode 100755 source/mircoders/media/URLMediaHandler.java diff --git a/bundles/admin_en.properties b/bundles/admin_en.properties index 0ffbeec0..081841af 100755 --- a/bundles/admin_en.properties +++ b/bundles/admin_en.properties @@ -1,6 +1,6 @@ ########## 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 @@ -47,6 +47,7 @@ list.previous=previous # media - used by image, audio, video and other media +media.urls = Urls media.created=created media.changed=last modification media.published=published diff --git a/source/mir/media/MirMedia.java b/source/mir/media/MediaHandler.java similarity index 84% rename from source/mir/media/MirMedia.java rename to source/mir/media/MediaHandler.java index e706d9aa..c6d607e6 100755 --- a/source/mir/media/MirMedia.java +++ b/source/mir/media/MediaHandler.java @@ -1,241 +1,221 @@ -/* - * 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; - +/* + * 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; import java.util.List; -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: - *

- * id | name | mime_type | classname | tablename | dcname
- *---+---------+--------------------------+-----------+---------------+-------
- * 2 | unknown | application/octet-stream | -- | UploadedMedia |
- * 3 | jpg | image/gif | ImagesGif | Images |
- * 4 | mp3 | audio/mp3 | Audio | UploadedMedia |
- *

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

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

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

- * The "classname" field is the name of the media handler (e.g MediaHandlerAudio) - * we use it to call the MediaHandler methods via reflection. - *

- * 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. - * - * Most media handlers should just extend MediaHandlerGeneric (i.e inherit from - * ) and just override the things that need to be specific. see MediaHandlerAudio - * - * @author , the Mir-coders group - * @version $Id: MirMedia.java,v 1.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 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: + *

+ * id | name | mime_type | classname | tablename | dcname
+ *---+---------+--------------------------+-----------+---------------+-------
+ * 2 | unknown | application/octet-stream | -- | UploadedMedia |
+ * 3 | jpg | image/gif | ImagesGif | Images |
+ * 4 | mp3 | audio/mp3 | Audio | UploadedMedia |
+ *

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

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

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

+ * The "classname" field is the name of the media handler (e.g MediaHandlerAudio) + * we use it to call the MediaHandler methods via reflection. + *

+ * 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. + * + * Most media handlers should just extend MediaHandlerGeneric (i.e inherit from + * ) and just override the things that need to be specific. see MediaHandlerAudio + * + * @author , the Mir-coders group + * @version $Id: MediaHandler.java,v 1.1.2.1 2003/12/14 16:37:06 zapata Exp $ + */ + +public interface MediaHandler { + /** + * 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 void store(InputStream in, Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure; + + public 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 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 InputStream getThumbnail(Entity ent) throws MediaExc, MediaFailure; + + + /** + * + * @param ent + * @return + * @throws MediaExc + * @throws MediaFailure + */ + public String getThumbnailMimeType(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 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 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 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 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 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 String getTinyIconName (); + + /** + * Returns the IMG SRC "ALT" text to be used + * for the Icon representations + * @return String, the ALT text. + */ + public String getIconAltName (); + + /** + * returns a brief text dscription of what this + * media type is. + * @return String + */ + public String getDescr (Entity mediaTypeEnt); + +} + + diff --git a/source/mircoders/entity/EntityImages.java b/source/mircoders/entity/EntityImages.java index 1569a1c0..f821483d 100755 --- a/source/mircoders/entity/EntityImages.java +++ b/source/mircoders/entity/EntityImages.java @@ -51,10 +51,9 @@ import org.postgresql.largeobject.LargeObject; 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 $ */ @@ -272,7 +271,8 @@ public class EntityImages extends EntityUploadedMedia try { _con.setAutoCommit(true); theStorageObject.freeConnection(_con,_stmt); - } catch (Exception e) { + } + catch (Exception e) { throw new IOException("close(): "+e.toString()); } } diff --git a/source/mircoders/entity/EntityUploadedMedia.java b/source/mircoders/entity/EntityUploadedMedia.java index 0d69b1b1..de17fc22 100755 --- a/source/mircoders/entity/EntityUploadedMedia.java +++ b/source/mircoders/entity/EntityUploadedMedia.java @@ -1,206 +1,101 @@ -/* - * 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; - } - -} +/* + * 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 mircoders.media.MediaHelper; +import mir.media.MediaHandler; +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.4 2003/12/14 16:37:07 zapata 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 content_id=content.id and media_id=" + getId()+")"); + 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()+")"); + } + 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; + } +} diff --git a/source/mircoders/localizer/MirCachingLocalizerDecorator.java b/source/mircoders/localizer/MirCachingLocalizerDecorator.java index 220797e8..ab828f20 100755 --- a/source/mircoders/localizer/MirCachingLocalizerDecorator.java +++ b/source/mircoders/localizer/MirCachingLocalizerDecorator.java @@ -1,161 +1,170 @@ -/* - * 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; - }; - } - +/* + * 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; + private MirMediaLocalizer mediaLocalizer; + + 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; + }; + + public MirMediaLocalizer media() throws MirLocalizerFailure, MirLocalizerExc { + if (mediaLocalizer==null) { + mediaLocalizer = localizer.media(); + } + + return mediaLocalizer; + } + + 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; + }; + } + } \ No newline at end of file diff --git a/source/mircoders/localizer/MirLocalizer.java b/source/mircoders/localizer/MirLocalizer.java index ae9610fb..6d6bda03 100755 --- a/source/mircoders/localizer/MirLocalizer.java +++ b/source/mircoders/localizer/MirLocalizer.java @@ -18,13 +18,13 @@ * 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. */ @@ -37,4 +37,5 @@ public interface MirLocalizer { 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 diff --git a/source/mircoders/localizer/MirMediaLocalizer.java b/source/mircoders/localizer/MirMediaLocalizer.java new file mode 100755 index 00000000..f4b7e5e4 --- /dev/null +++ b/source/mircoders/localizer/MirMediaLocalizer.java @@ -0,0 +1,43 @@ +/* + * 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 aName */ + public MediaHandler getHandler(String aName); +} \ No newline at end of file diff --git a/source/mircoders/localizer/basic/MirBasicDataModelLocalizer.java b/source/mircoders/localizer/basic/MirBasicDataModelLocalizer.java index fcc01860..1523560d 100755 --- a/source/mircoders/localizer/basic/MirBasicDataModelLocalizer.java +++ b/source/mircoders/localizer/basic/MirBasicDataModelLocalizer.java @@ -1,661 +1,828 @@ -/* - * 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()); - } - } - } -} +/* + * 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 mircoders.media.MediaHelper; +import mir.misc.NumberUtils; +import mir.media.MediaHandler; +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()); + definition.addCalculatedField("human_readable_size", new HumanReadableSizeField("value")); + definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone")); + definition.addCalculatedField("info", new MediaToMediaInfoField()); + result.addMapping( "uploadedMedia", DatabaseUploadedMedia.getInstance(), definition); + definition = new EntityAdapterDefinition(); + definition.addCalculatedField("mediafolder", new MediaToMediaFolderField()); + definition.addCalculatedField("human_readable_size", new HumanReadableSizeField("value")); + definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone")); + definition.addCalculatedField("info", new MediaToMediaInfoField()); + definition.addCalculatedField("big_icon", new MediaToBigIconField()); + result.addMapping( "image", DatabaseImages.getInstance(), definition); + definition = new EntityAdapterDefinition(); + definition.addCalculatedField("mediafolder", new MediaToMediaFolderField()); + definition.addCalculatedField("human_readable_size", new HumanReadableSizeField("value")); + definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone")); + definition.addCalculatedField("info", new MediaToMediaInfoField()); + definition.addCalculatedField("big_icon", new MediaToBigIconField()); + result.addMapping( "audio", DatabaseAudio.getInstance(), definition); + definition = new EntityAdapterDefinition(); + definition.addCalculatedField("mediafolder", new MediaToMediaFolderField()); + definition.addCalculatedField("human_readable_size", new HumanReadableSizeField("value")); + definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone")); + definition.addCalculatedField("info", new MediaToMediaInfoField()); + definition.addCalculatedField("big_icon", new MediaToBigIconField()); + result.addMapping( "video", DatabaseVideo.getInstance(), definition); + definition = new EntityAdapterDefinition(); + definition.addCalculatedField("mediafolder", new MediaToMediaFolderField()); + definition.addCalculatedField("human_readable_size", new HumanReadableSizeField("value")); + definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone")); + definition.addCalculatedField("info", new MediaToMediaInfoField()); + definition.addCalculatedField("big_icon", new MediaToBigIconField()); + 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()); + } + } + } + + public static class MediaInfo { + private MediaHandler mediaHandler; + + public MediaInfo(MediaHandler aHandler) { + mediaHandler = aHandler; + } + public String getBigIcon() { + if (mediaHandler == null) + return "bla"; + else + return mediaHandler.getBigIconName(); + } + + public String getSmallIcon() { + if (mediaHandler == null) + return "bla"; + else + return mediaHandler.getTinyIconName(); + } + + public String getMediaType() { + return ""; + } + } + + protected class MediaToMediaInfoField implements EntityAdapterDefinition.CalculatedField { + public Object getValue(EntityAdapter anEntityAdapter) { + try { + MediaHandler mediaHandler = MediaHelper.getHandler(((EntityUploadedMedia) anEntityAdapter.getEntity()).getMediaType()); + + return new MediaInfo(mediaHandler); + } + catch (Throwable t) { + throw new RuntimeException(t.getMessage()); + } + } + } + + protected class MediaToBigIconField implements EntityAdapterDefinition.CalculatedField { + public Object getValue(EntityAdapter anEntityAdapter) { + try { + return MediaHelper.getHandler(((EntityUploadedMedia) anEntityAdapter.getEntity()).getMediaType()).getBigIconName(); + } + 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; + MediaHandler 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 ); + + 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 HumanReadableSizeField implements EntityAdapterDefinition.CalculatedField { + private String fieldName; + + public HumanReadableSizeField(String aFieldName) { + fieldName= aFieldName; + } + + public Object getValue(EntityAdapter anEntityAdapter) { + try { + String size = (String) anEntityAdapter.get(fieldName); + if (size!=null) + return NumberUtils.humanReadableSize(Double.parseDouble(size)); + else + return ""; + } + 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()); + } + } + } +} + + +/* + 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 + 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() { + if (this instanceof EntityImages) + return "image"; + if (this instanceof EntityAudio) + return "audio"; + if (this instanceof EntityVideo) + return "video"; + else + return "other"; + } + +private String getBigIconName() { + MediaHandler 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() { + MediaHandler 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() { + MediaHandler 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; +} +*/ \ No newline at end of file diff --git a/source/mircoders/localizer/basic/MirBasicLocalizer.java b/source/mircoders/localizer/basic/MirBasicLocalizer.java index 9210a468..b59521b5 100755 --- a/source/mircoders/localizer/basic/MirBasicLocalizer.java +++ b/source/mircoders/localizer/basic/MirBasicLocalizer.java @@ -1,68 +1,72 @@ -/* - * 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(); - }; - +/* + * 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; +import mircoders.localizer.MirMediaLocalizer; + +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(); + } + + public MirMediaLocalizer media() throws MirLocalizerFailure, MirLocalizerExc { + return new MirBasicMediaLocalizer(); + } } \ No newline at end of file diff --git a/source/mircoders/localizer/basic/MirBasicMediaLocalizer.java b/source/mircoders/localizer/basic/MirBasicMediaLocalizer.java new file mode 100755 index 00000000..4835d69d --- /dev/null +++ b/source/mircoders/localizer/basic/MirBasicMediaLocalizer.java @@ -0,0 +1,127 @@ +/* + * 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.Map; + +import mir.media.MediaHandler; +import mir.config.*; +import mircoders.localizer.MirLocalizerExc; +import mircoders.localizer.MirLocalizerFailure; +import mircoders.localizer.MirMediaLocalizer; +import mircoders.media.*; + +/** + *

Title:

+ *

Description:

+ *

Copyright: Copyright (c) 2003

+ *

Company:

+ * @author not attributable + * @version 1.0 + */ + +public class MirBasicMediaLocalizer implements MirMediaLocalizer { + private Map mediaHandlers; + + /** + * + * @throws MirLocalizerExc + * @throws MirLocalizerFailure + */ + public MirBasicMediaLocalizer() throws MirLocalizerExc, MirLocalizerFailure { + MirPropertiesConfiguration configuration; + + try { + configuration = MirPropertiesConfiguration.instance(); + } + catch (Throwable t) { + throw new MirLocalizerFailure("Can't get configuration", t); + } + + mediaHandlers = new HashMap(); + + + registerMediaHandler("Audio", new MediaHandlerAudio()); + registerMediaHandler("Generic", new MediaHandlerGeneric()); + registerMediaHandler("ImagesExtern", new MediaHandlerImagesExtern()); + registerMediaHandler("ImagesJpeg", new MediaHandlerImagesJpeg()); + registerMediaHandler("ImagesPng", new MediaHandlerImagesPng()); + registerMediaHandler("Mp3", new MediaHandlerMp3()); + registerMediaHandler("Ogg", new MediaHandlerOgg()); + registerMediaHandler("RealAudio", new MediaHandlerRealAudio()); + registerMediaHandler("RealVideo", new MediaHandlerRealVideo()); + registerMediaHandler("Video", new MediaHandlerVideo()); + + registerMediaHandler("VideoUrl", new URLMediaHandler( + configuration.getString("Producer.Icon.BigVideo"), + configuration.getString("Producer.Icon.TinyVideo"), + "Video Url")); + + registerMediaHandler("AudioUrl", new URLMediaHandler( + configuration.getString("Producer.Icon.BigAudio"), + configuration.getString("Producer.Icon.TinyAudio"), + "Audio Url")); + + registerMediaHandler("ImageUrl", new URLMediaHandler( + configuration.getString("Producer.Icon.BigImage"), + configuration.getString("Producer.Icon.TinyImage"), + "Image Url")); + + registerMediaHandler("OtherUrl", new URLMediaHandler( + configuration.getString("Producer.Icon.BigAudio"), + configuration.getString("Producer.Icon.TinyAudio"), + "Url")); + } + + /** returns the {@link MediaHandler} associated with name aName by way of + * an internal Map. This Map can be manipulated by calling + * registerMediaHandler and unregisterMediaHandler + */ + public MediaHandler getHandler(String aName) { + synchronized (mediaHandlers) { + return (MediaHandler) mediaHandlers.get(aName); + } + } + + /** adds a media handler to the registry */ + public void registerMediaHandler(String aName, MediaHandler aHandler) { + synchronized (mediaHandlers) { + mediaHandlers.put(aName, aHandler); + } + } + + /** removes a media handler from the registry*/ + public void unregisterMediaHandler(String aName) { + synchronized (mediaHandlers) { + mediaHandlers.remove(aName); + } + } +} \ No newline at end of file diff --git a/source/mircoders/media/MediaHandlerAudio.java b/source/mircoders/media/MediaHandlerAudio.java index cc60e707..14a04403 100755 --- a/source/mircoders/media/MediaHandlerAudio.java +++ b/source/mircoders/media/MediaHandlerAudio.java @@ -30,25 +30,24 @@ 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 - * @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"); } @@ -67,10 +66,4 @@ public class MediaHandlerAudio extends MediaHandlerGeneric implements MirMedia { return "Audio"; } - - public boolean isAudio() - { - return true; - } - } diff --git a/source/mircoders/media/MediaHandlerGeneric.java b/source/mircoders/media/MediaHandlerGeneric.java index e7946f05..0f76167f 100755 --- a/source/mircoders/media/MediaHandlerGeneric.java +++ b/source/mircoders/media/MediaHandlerGeneric.java @@ -43,7 +43,7 @@ import mir.entity.Entity; 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; @@ -61,14 +61,14 @@ import mir.misc.StringUtil; * we don't have entered in the media_type table, (like RTF documents, * PS, PDF, etc..) *

- * Of course it implements the MirMedia interface. + * Of course it implements the MirMediaHandler interface. * - * @see mir.media.MirMedia + * @see mir.media.MirMediaHandler * @author mh - * @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; @@ -90,7 +90,7 @@ public class MediaHandlerGeneric implements MirMedia 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"); @@ -117,7 +117,7 @@ public class MediaHandlerGeneric implements MirMedia 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 { @@ -125,7 +125,7 @@ public class MediaHandlerGeneric implements MirMedia 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 { @@ -138,11 +138,11 @@ public class MediaHandlerGeneric implements MirMedia 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"); @@ -186,21 +186,6 @@ public class MediaHandlerGeneric implements MirMedia 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"); diff --git a/source/mircoders/media/MediaHandlerImages.java b/source/mircoders/media/MediaHandlerImages.java index e3f8cb8c..38da566f 100755 --- a/source/mircoders/media/MediaHandlerImages.java +++ b/source/mircoders/media/MediaHandlerImages.java @@ -40,7 +40,7 @@ import mir.entity.Entity; 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; @@ -51,19 +51,19 @@ 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. *

* 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"; @@ -101,7 +101,7 @@ public abstract class MediaHandlerImages implements MirMedia 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()); @@ -149,7 +149,7 @@ public abstract class MediaHandlerImages implements MirMedia } - public InputStream getIcon(Entity ent) throws MediaExc, MediaFailure { + public InputStream getThumbnail(Entity ent) throws MediaExc, MediaFailure { InputStream in; try { in = ((EntityImages)ent).getIcon(); @@ -191,19 +191,6 @@ public abstract class MediaHandlerImages implements MirMedia 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"; } diff --git a/source/mircoders/media/MediaHandlerImagesExtern.java b/source/mircoders/media/MediaHandlerImagesExtern.java index 5f17d18a..5df1112c 100755 --- a/source/mircoders/media/MediaHandlerImagesExtern.java +++ b/source/mircoders/media/MediaHandlerImagesExtern.java @@ -171,21 +171,6 @@ public class MediaHandlerImagesExtern extends MediaHandlerGeneric 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"; diff --git a/source/mircoders/media/MediaHandlerImagesJpeg.java b/source/mircoders/media/MediaHandlerImagesJpeg.java index 751b6e13..b6c23038 100755 --- a/source/mircoders/media/MediaHandlerImagesJpeg.java +++ b/source/mircoders/media/MediaHandlerImagesJpeg.java @@ -30,23 +30,23 @@ 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. *

* - * @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; @@ -56,7 +56,7 @@ public class MediaHandlerImagesJpeg extends MediaHandlerImages implements MirMed return "image/jpeg"; } - public String getIconMimeType(Entity aMedia, Entity aMediaType) { + public String getThumbnailMimeType(Entity aMedia, Entity aMediaType) { return "image/jpeg"; } } diff --git a/source/mircoders/media/MediaHandlerImagesPng.java b/source/mircoders/media/MediaHandlerImagesPng.java index cbc9d0a4..240111ea 100755 --- a/source/mircoders/media/MediaHandlerImagesPng.java +++ b/source/mircoders/media/MediaHandlerImagesPng.java @@ -30,23 +30,23 @@ 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. *

* - * @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; @@ -56,7 +56,7 @@ public class MediaHandlerImagesPng extends MediaHandlerImages implements MirMedi return "image/png"; } - public String getIconMimeType(Entity aMedia, Entity aMediaType) { + public String getThumbnailMimeType(Entity aMedia, Entity aMediaType) { return "image/png"; } } diff --git a/source/mircoders/media/MediaHandlerMp3.java b/source/mircoders/media/MediaHandlerMp3.java index e17cfb1d..f1dbe8d5 100755 --- a/source/mircoders/media/MediaHandlerMp3.java +++ b/source/mircoders/media/MediaHandlerMp3.java @@ -39,7 +39,7 @@ import mir.entity.Entity; 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; @@ -65,14 +65,14 @@ 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 - * @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"); } diff --git a/source/mircoders/media/MediaHandlerOgg.java b/source/mircoders/media/MediaHandlerOgg.java index 0b772462..f3c537f7 100755 --- a/source/mircoders/media/MediaHandlerOgg.java +++ b/source/mircoders/media/MediaHandlerOgg.java @@ -39,7 +39,7 @@ import mir.entity.Entity; 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; @@ -64,12 +64,12 @@ 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 - based on MediaHandlerMp3 by mh - * @version $Id: + * @version $Id: */ -public class MediaHandlerOgg extends MediaHandlerAudio implements MirMedia +public class MediaHandlerOgg extends MediaHandlerAudio implements MediaHandler { protected LoggerWrapper logger; @@ -94,7 +94,7 @@ public class MediaHandlerOgg extends MediaHandlerAudio implements MirMedia //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"); diff --git a/source/mircoders/media/MediaHandlerRealAudio.java b/source/mircoders/media/MediaHandlerRealAudio.java index a2c9e087..de0842d7 100755 --- a/source/mircoders/media/MediaHandlerRealAudio.java +++ b/source/mircoders/media/MediaHandlerRealAudio.java @@ -39,7 +39,7 @@ import mir.entity.Entity; 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; @@ -51,13 +51,13 @@ import mir.misc.StringUtil; * 03.2002 - reworked Realmedia handling. -mh * * @see mir.media.MediaHandlerGeneric - * @see mir.media.MirMedia + * @see mir.media.MediaHandler * @author john , mh - * @version $Id: MediaHandlerRealAudio.java,v 1.19.2.1 2003/09/03 17:49:40 zapata Exp $ + * @version $Id: MediaHandlerRealAudio.java,v 1.19.2.2 2003/12/14 16:37:08 zapata Exp $ */ -public class MediaHandlerRealAudio extends MediaHandlerAudio implements MirMedia +public class MediaHandlerRealAudio extends MediaHandlerAudio implements MediaHandler { public MediaHandlerRealAudio() { logger = new LoggerWrapper("Media.Audio.Real"); diff --git a/source/mircoders/media/MediaHandlerRealVideo.java b/source/mircoders/media/MediaHandlerRealVideo.java index 613f1cc0..1d1b5ef7 100755 --- a/source/mircoders/media/MediaHandlerRealVideo.java +++ b/source/mircoders/media/MediaHandlerRealVideo.java @@ -40,7 +40,7 @@ import mir.entity.Entity; 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; @@ -52,15 +52,15 @@ import mir.misc.StringUtil; * 03.2002 - reworked Realmedia handling. -mh * * @see mir.media.MediaHandlerGeneric - * @see mir.media.MirMedia + * @see mir.media.MediaHandler * @author john , mh - * @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"); } diff --git a/source/mircoders/media/MediaHandlerVideo.java b/source/mircoders/media/MediaHandlerVideo.java index 681d002b..c5830a1a 100755 --- a/source/mircoders/media/MediaHandlerVideo.java +++ b/source/mircoders/media/MediaHandlerVideo.java @@ -18,18 +18,18 @@ * 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; /** @@ -38,12 +38,12 @@ import mir.media.MirMedia; * It is MediaHandlerGeneric with different icons. * * @see mir.media.MediaHandlerGeneric - * @see mir.media.MirMedia + * @see mir.media.MediaHandler * @author john - * @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; diff --git a/source/mir/media/MediaHelper.java b/source/mircoders/media/MediaHelper.java similarity index 52% rename from source/mir/media/MediaHelper.java rename to source/mircoders/media/MediaHelper.java index a4d43779..b61f9fc5 100755 --- a/source/mir/media/MediaHelper.java +++ b/source/mircoders/media/MediaHelper.java @@ -1,79 +1,85 @@ -/* - * 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); - } - } - -} - - - +/* + * Copyright (C) 2001, 2002 The Mir-coders group + * + * This file is part of Mir. + * + * Mir is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Mir is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Mir; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, The Mir-coders gives permission to link + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. + * If you do not wish to do so, delete this exception statement from your version. + */ +package mircoders.media; + +import mir.entity.Entity; +import mir.storage.Database; +import java.util.Map; +import java.util.HashMap; +import mircoders.global.*; +import mircoders.storage.*; +import mir.media.*; +import mircoders.localizer.MirLocalizerExc; + +/** + * helper class to resolve media handlers using reflection + * + * @author mh + * @author Zapata + * @version 2003 + */ + +public final class MediaHelper { + private static Map nameToMediaHandler = new HashMap(); + private static String defaultMediaHandler = null; + + public static void addHandler(String aName, MediaHandler aHandler) { + synchronized (nameToMediaHandler) { + nameToMediaHandler.put(aName, aHandler); + } + } + + public static MediaHandler getHandler(Entity aMediaType) throws MediaExc, MediaFailure { + String handlerName = aMediaType.getValue("classname"); + + try { + return MirGlobal.localizer().media().getHandler(handlerName); + } + catch (MirLocalizerExc e) { + throw new MediaFailure(e); + } + } + + public static Database getStorage(Entity mediaType, String aTable) throws MediaExc, MediaFailure { + if (aTable.equals("Images")) + return DatabaseImages.getInstance(); + else if (aTable.equals("Audio")) + return DatabaseAudio.getInstance(); + if (aTable.equals("Video")) + return DatabaseVideo.getInstance(); + if (aTable.equals("Other")) + return DatabaseOther.getInstance(); + + throw new MediaExc("Unknown storage specification: " + aTable); + } +} + + + diff --git a/source/mircoders/media/MediaUploadProcessor.java b/source/mircoders/media/MediaUploadProcessor.java index f7318635..072046f9 100755 --- a/source/mircoders/media/MediaUploadProcessor.java +++ b/source/mircoders/media/MediaUploadProcessor.java @@ -18,13 +18,13 @@ * 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; @@ -36,8 +36,8 @@ import java.util.Map; 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; @@ -46,7 +46,7 @@ import mircoders.module.ModuleMediaType; 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; @@ -93,7 +93,7 @@ public class MediaUploadProcessor { mediaId = mediaEntity.insert(); try { - mediaHandler.set(aFile.getInputStream(), mediaEntity, mediaType); + mediaHandler.store(aFile.getInputStream(), mediaEntity, mediaType); } catch (Throwable e) { throw new MediaFailure(e); diff --git a/source/mircoders/media/URLMediaHandler.java b/source/mircoders/media/URLMediaHandler.java new file mode 100755 index 00000000..55b86022 --- /dev/null +++ b/source/mircoders/media/URLMediaHandler.java @@ -0,0 +1,85 @@ +package mircoders.media; + +import mir.media.*; +import java.io.InputStream; +import mir.entity.*; +import java.util.List; +import java.util.ArrayList; + +/** + *

URLMediaHandler

+ *

Description: + * This is a media handler for media that are only known by url. + *

+ * @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 diff --git a/source/mircoders/producer/MediaGeneratingProducerNode.java b/source/mircoders/producer/MediaGeneratingProducerNode.java index 042a10d1..8d5e2de2 100755 --- a/source/mircoders/producer/MediaGeneratingProducerNode.java +++ b/source/mircoders/producer/MediaGeneratingProducerNode.java @@ -18,13 +18,13 @@ * 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. */ @@ -35,8 +35,8 @@ import java.util.Map; 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; @@ -55,7 +55,7 @@ public class MediaGeneratingProducerNode implements ProducerNode { Entity entity; EntityUploadedMedia uploadedMediaEntity = null; Entity mediaType = null; - MirMedia currentMediaHandler; + MediaHandler currentMediaHandler; try { diff --git a/source/mircoders/servlet/ServletModuleUploadedMedia.java b/source/mircoders/servlet/ServletModuleUploadedMedia.java index 1f0d3a87..beb06903 100755 --- a/source/mircoders/servlet/ServletModuleUploadedMedia.java +++ b/source/mircoders/servlet/ServletModuleUploadedMedia.java @@ -49,8 +49,8 @@ import mir.entity.adapter.EntityAdapter; 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; @@ -441,17 +441,18 @@ public abstract class ServletModuleUploadedMedia extends ServletModule { 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 @@ -473,22 +474,41 @@ public abstract class ServletModuleUploadedMedia extends ServletModule { // 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(); @@ -556,5 +576,4 @@ public abstract class ServletModuleUploadedMedia extends ServletModule { } else logger.error("showcomments: id not specified."); } - } \ No newline at end of file diff --git a/templates/admin/FUNCTIONS_media.template b/templates/admin/FUNCTIONS_media.template index a73e1b6d..eea0e7ee 100755 --- a/templates/admin/FUNCTIONS_media.template +++ b/templates/admin/FUNCTIONS_media.template @@ -98,7 +98,7 @@ - + @@ -111,7 +111,7 @@ - ${entry.media_descr}  + ${entry.info.mediaType}  diff --git a/templates/admin/audio.template b/templates/admin/audio.template index aab208ac..8ffe80d9 100755 --- a/templates/admin/audio.template +++ b/templates/admin/audio.template @@ -4,15 +4,13 @@ -    +    - ${lang("media.created")}: ${uploadedmedia.webdb_create} - / ${lang("media.changed")} ${uploadedmedia.webdb_lastchange}
- ${lang("media.published")}: ${uploadedmedia.publish_date} / ${uploadedmedia.publish_server}${uploadedmedia.publish_path}
- ${lang("media.format")}: ${uploadedmedia.mimetype} / ${uploadedmedia.media_descr}
+ ${lang("media.created")}: ${uploadedmedia.creationdate.format(config["Mir.DefaultDateTimeFormat"])} + ${lang("media.urls")}: ${uploadedmedia.publish_server}${uploadedmedia.publish_path}
+ ${lang("media.format")}: ${uploadedmedia.info.mediaType}
${lang("media.size")}: ${uploadedmedia.human_readable_size}
- ${lang("media.rights")}: ${uploadedmedia.rightsHashdata[to_rights]["name"]}
diff --git a/templates/admin/image.template b/templates/admin/image.template index 32dc3540..7a8edd92 100755 --- a/templates/admin/image.template +++ b/templates/admin/image.template @@ -8,18 +8,13 @@ - +    - ${lang("media.created")}: ${uploadedmedia.webdb_create} - / ${lang("media.changed")} ${uploadedmedia.webdb_lastchange}
- ${lang("media.published")}: ${uploadedmedia.publish_date} / ${uploadedmedia.publish_server}${uploadedmedia.publish_path}
- ${lang("media.format")}: ${uploadedmedia.mimetype} / ${uploadedmedia.media_descr}
- - ${lang("media.size")}: ${uploadedmedia.human_readable_size}
- ${lang("media.rights")}: ${uploadedmedia.rightsHashdata[to_rights]["name"]}
-
+ ${lang("media.created")}: ${uploadedmedia.creationdate.format(config["Mir.DefaultDateTimeFormat"])} + ${lang("media.urls")}: ${uploadedmedia.publish_server}${uploadedmedia.publish_path}
+ ${lang("media.format")}: ${uploadedmedia.info.mediaType}
diff --git a/templates/admin/other.template b/templates/admin/other.template index 037cb208..c658d419 100755 --- a/templates/admin/other.template +++ b/templates/admin/other.template @@ -4,15 +4,13 @@ -    +    - ${lang("media.created")}: ${uploadedmedia.webdb_create} - / ${lang("media.changed")} ${uploadedmedia.webdb_lastchange}
- ${lang("media.published")}: ${uploadedmedia.publish_date} / ${uploadedmedia.publish_server}${uploadedmedia.publish_path}
- ${lang("media.format")}: ${uploadedmedia.mimetype} / ${uploadedmedia.media_descr}
+ ${lang("media.created")}: ${uploadedmedia.creationdate.format(config["Mir.DefaultDateTimeFormat"])} + ${lang("media.urls")}: ${uploadedmedia.publish_server}${uploadedmedia.publish_path}
+ ${lang("media.format")}: ${uploadedmedia.info.mediaType}
${lang("media.size")}: ${uploadedmedia.human_readable_size}
- ${lang("media.rights")}: ${uploadedmedia.rightsHashdata[to_rights]["name"]}
diff --git a/templates/admin/video.template b/templates/admin/video.template index 037cb208..c658d419 100755 --- a/templates/admin/video.template +++ b/templates/admin/video.template @@ -4,15 +4,13 @@ -    +    - ${lang("media.created")}: ${uploadedmedia.webdb_create} - / ${lang("media.changed")} ${uploadedmedia.webdb_lastchange}
- ${lang("media.published")}: ${uploadedmedia.publish_date} / ${uploadedmedia.publish_server}${uploadedmedia.publish_path}
- ${lang("media.format")}: ${uploadedmedia.mimetype} / ${uploadedmedia.media_descr}
+ ${lang("media.created")}: ${uploadedmedia.creationdate.format(config["Mir.DefaultDateTimeFormat"])} + ${lang("media.urls")}: ${uploadedmedia.publish_server}${uploadedmedia.publish_path}
+ ${lang("media.format")}: ${uploadedmedia.info.mediaType}
${lang("media.size")}: ${uploadedmedia.human_readable_size}
- ${lang("media.rights")}: ${uploadedmedia.rightsHashdata[to_rights]["name"]}
-- 2.11.0