//from the content-type.
//we use the media type entry to lookup the
//media Handler/Storage classes
- String wc = " mime_type='"+contentType+"'";
+ //String wc = " mime_type = '"+contentType+"'";
+
+ // @todo this should probably be moved to DatabaseMediaType -mh
+ String[] cTypeSplit = StringUtil.split(contentType, "/");
+ String wc = " mime_type LIKE '"+cTypeSplit[0]+"%'";
DatabaseMediaType mediaTypeStor = DatabaseMediaType.getInstance();
EntityList mediaTypesList = mediaTypeStor.selectByWhereClause(wc);
//if we found an entry matching the
//content-type int the table.
if (mediaTypesList.size() > 0) {
+ Entity mediaType = null;
+
+ // find out if we an exact content-type match if so take it.
+ // otherwise just use the first one.
+ // @todo this should probably be moved to DatabaseMediaType -mh
+ for(int j=0;i<mediaTypesList.size();j++) {
+ if(contentType.equals(
+ mediaTypesList.elementAt(j).getValue("mime_type")))
+ mediaType = mediaTypesList.elementAt(j);
+ }
+
+ if( mediaType == null )
+ mediaType = mediaTypesList.elementAt(0);
+
//get the class names from the media_type table.
- mediaTypeId = mediaTypesList.elementAt(0).getId();
+ mediaTypeId = mediaType.getId();
try {
// ############### @todo: merge these and the getURL call into one
// getURL helper call that just takes the Entity as a parameter
// along with media_type
- mediaHandler = MediaHelper.getHandler(mediaTypesList.elementAt(0));
- mediaStorage = MediaHelper.getStorage(mediaTypesList.elementAt(0),
+ mediaHandler = MediaHelper.getHandler(mediaType);
+ mediaStorage = MediaHelper.getStorage(mediaType,
"mircoders.storage.Database");
} catch (MirMediaException e) {
+ theLog.printError("getting media handler failed: "+e.toString());
+ contentModule.deleteById(cid);
throw new ServletModuleException("getting media handler failed: "
+e.toString());
}
//save and store the media data/metadata
mediaHandler.set(mpReq.getMedia(), mediaEnt,
- mediaTypesList.elementAt(0));
+ mediaType);
//were done with mpReq at this point, dereference it.
//as it contains mucho mem. -mh 01.10.2001