public class MediaHandlerGeneric implements MirMedia
{
+ private static String imageRoot = MirConfig.getProp("Producer.ImageRoot");
private Logfile theLog = Logfile.getInstance(MirConfig.getProp("Home")+"log/media.log");
public boolean set (byte[] uploadedData, Entity ent, Entity mediaTypeEnt ) {
String ext = mediaTypeEnt.getValue("name");
String mediaFname = ent.getId()+"."+ext;
String date = ent.getValue("date");
String datePath = StringUtil.webdbDate2path(date);
+ Integer size = new Integer(uploadedData.length);
//hack: make it a config option to use "dated" dirs
//we can't cause of stallman -mh
//if(FileUtil.write(dir+"/"+datePath+"/"+mediaFname, uploadedData)) {
//ent.setValueForProperty("publish_path",datePath+"/"+mediaFname);
ent.setValueForProperty("publish_path", mediaFname);
ent.setValueForProperty("publish_server", mediaHost);
+ ent.setValueForProperty("size", size.toString());
ent.update();
} catch (StorageObjectException e) {
theLog.printError("StorageObjectException: "+e.toString());
return MirConfig.getProp("Producer.Icon.TinyText");
}
+ public String getBigIcon()
+ {
+ return MirConfig.getProp("Producer.Icon.BigText");
+ }
+
public String getIconAlt()
{
return "Generic media";
}
+ public String getURL(Entity ent, Entity mediaTypeEnt)
+ {
+ String title = ent.getValue("title")+
+ " - "+mediaTypeEnt.getValue("name")+" "+
+ ent.getValue("size")+" Bytes";
+ return StringUtil.createURLLinks(ent.getValue("publish_server")+
+ ent.getValue("publish_path"), title, imageRoot, getBigIcon());
+ }
+
public boolean isVideo()
{
return false;