2 * put your module comment here
14 * Interface for Media handling in Mir. All media handlers
15 * must implement this interface. Each specific media type,
16 * be it Gif, Jpeg, Mp3 audio, Real Audio or quicktime video
17 * has special needs when it comes to representation on the various
18 * pages (article, list, summary), must be stored differently and has a
19 * different URL, etc... This interface allows Mir to support
20 * an infinite (I hope) number of media types. Once this is done,
21 * no code at any other level in Mir needs to be changed other than
22 * adding the content-type <-> media handler name mapping in the
23 * media_type table. The following is an example of the media_type
26 * id | name | mime_type | classname | tablename | dcname<br>
27 *---+---------+--------------------------+-----------+---------------+-------<br>
28 * 2 | unknown | application/octet-stream | -- | UploadedMedia | <br>
29 * 3 | jpg | image/gif | ImagesGif | Images | <br>
30 * 4 | mp3 | audio/mp3 | Audio | UploadedMedia | <br>
32 * The "id" field is used as a mapping in the table that contains the media type
33 * to the media_type table. For example, the images table has a to_media_type
34 * field that contains the id in the media_type table.
36 * The "name" field is used for various display/filenaming purposes. it should
37 * match a valid file extension name for a media_type (we could have used the
38 * content-type map for this....).
40 * The "mime_type" field is the most important as it does maps the type to Java
41 * classes (the storage and media_handler name). We call those classes using
42 * reflection. This way, once a Handler for a specific media type is implemented
43 * and entered into the media_type table, no other Mir code needs to be modified.
45 * The "classname" field is the name of the media handler (e.g MediaHandlerAudio)
46 * we use it to call the MediaHandler methods via reflection.
48 * The "tablename" is the name of the database storage classes (e.g DatabaseImages
49 * and EntityImages). We use this to fetch/storage the media (meta)data in the db.
51 * The "dcname" field is as of yet unused. Do search for "Dublin Core" on google
54 * Most media handlers should just extend MediaHandlerGeneric (i.e inherit from
55 * ) and just override the things that need to be specific. see MediaHandlerAudio
57 * @author mh <heckmann@hbe.ca>
61 public interface MirMedia{
64 * Takes the uploaded media data itself, along with the media Entity
65 * which contains the Media metadata plus the MediaType entity containing
66 * all the info for the specific media type itself. It's job is store the
67 * Media data (content) itself, this could be on the local filesystem, in the
68 * DB or even on a remote host. It then inserts the MetaData in the DB.
69 * @param uploadedData, a byte array containing the uploaded data.
70 * @param ent, an Entity holding the media MetaData
71 * @param mediaType, an Entity holding the media_table entry
72 * @return boolean, success/fail
73 * @see mir.entity.Entity
75 public abstract boolean set (byte[] uploadedData, Entity ent, Entity mediaTypeEnt );
78 * Get's the media data from storage and returns it as a byte array
79 * Not very useful for most media types as they are stored in a file,
80 * but very usefull for ones stored in the DB as it is necessary to get
81 * it first before making a file out of it (in Producer*).
82 * @param ent, an Entity holding the media MetaData
83 * @param mediaType, an Entity holding the media_table entry
85 * @see mir.entity.Entity
87 public abstract byte[] get (Entity ent, Entity mediaTypeEnt);
90 * Pretty much like get() above. But get's the specific Icon
91 * representation. useful for media stored in the DB.
92 * @param ent, an Entity holding the media MetaData
94 * @see mir.entity.Entity
96 public abstract byte[] getIcon (Entity ent);
99 * gets the final content representation for the media
100 * in the form of a URL (String) that allows someone to
101 * download, look at or listen to the media. (HREF, img src
102 * streaming link, etc..)
103 * It should use the helper functions in the StringUtil class to
104 * build URL's safely, eliminating any *illegal* user input.
105 * @param ent, an Entity holding the media MetaData
106 * @param mediaTypeEnt, an Entity holding the media_table entry
107 * @return String, the url.
108 * @see mir.entity.Entity
109 * @see mir.misc.StringUtil
111 public abstract String getURL (Entity ent, Entity mediaTypeEnt);
114 * gets the summary representation for the media
115 * in the form of a URL (String). Usually the URL points
116 * to some sort of an icon that previews what kind of
117 * media an article will contain.
118 * It should use the helper functions in the StringUtil class to
119 * build URL's safely, eliminating any *illegal* user input.
120 * @param ent, an Entity holding the media MetaData
121 * @param mediaTypeEnt, an Entity holding the media_table entry
122 * @return String, the url.
123 * @see mir.entity.Entity
124 * @see mir.misc.StringUtil
126 public abstract String getListView (Entity ent, Entity mediaTypeEnt);
129 * Returns the absolute filesystem path to where the media
130 * content should be stored. This path is usually defined
131 * in the configuration wich is accessible through the MirConfig
133 * @return String, the path.
134 * @see mir.misc.MirConfig
136 public abstract String getStoragePath ();
139 * Returns the *relative* filesystem path to where the media
140 * icon content should be stored. It is relative to the path
141 * returned by getStoragePath()
142 * This path is usually defined
143 * in the configuration wich is accessible through the MirConfig
145 * @return String, the path.
146 * @see mir.misc.MirConfig
148 public abstract String getIconStoragePath ();
151 * Returns the base URL to that the media is accessible from
152 * to the end user. This could be a URL to another host.
153 * This is used in the Metadata stored in the DB and later on
154 * ,the templates use it.
155 * It is usually defined
156 * in the configuration wich is accessible through the MirConfig
158 * @return String, the base URL to the host.
159 * @see mir.misc.MirConfig
161 public abstract String getPublishHost ();
164 * Returns the file name of the Icon representing the media type.
165 * It is used in the summary view.
166 * It is usually defined
167 * in the configuration wich is accessible through the MirConfig
169 * @return String, the icon filename.
170 * @see mir.misc.MirConfig
172 public abstract String getBigIcon ();
175 * Returns the file name of the small Icon representing
177 * It is used in the right hand newswire list of the startpage.
178 * It is usually defined
179 * in the configuration wich is accessible through the MirConfig
181 * @return String, the icon filename.
182 * @see mir.misc.MirConfig
184 public abstract String getTinyIcon ();
187 * Returns the IMG SRC "ALT" text to be used
188 * for the Icon representations
189 * @return String, the ALT text.
191 public abstract String getIconAlt ();
194 * your all smart enough to figure it out.
197 public abstract boolean isVideo ();
200 * your all smart enough to figure it out.
203 public abstract boolean isAudio ();
206 * your all smart enough to figure it out.
209 public abstract boolean isImage ();