2 * put your module comment here
16 * Interfacedefinition für Datenbank-Adpatoren. Die Adaptoren legen
17 * jeweils das Verhalten und die Befehlsmächtigkeit der Datenbank
24 public class MediaHandlerGeneric implements MirMedia
27 private static String imageRoot = MirConfig.getProp("Producer.ImageRoot");
28 private Logfile theLog = Logfile.getInstance(MirConfig.getProp("Home")+"log/media.log");
29 public boolean set (byte[] uploadedData, Entity ent, Entity mediaTypeEnt ) {
30 String ext = mediaTypeEnt.getValue("name");
31 String dir = MirConfig.getProp("Producer.Media.Path");
32 String mediaHost = MirConfig.getProp("Producer.Media.Host");
33 String mediaFname = ent.getId()+"."+ext;
34 String date = ent.getValue("date");
35 String datePath = StringUtil.webdbDate2path(date);
36 Integer size = new Integer(uploadedData.length);
37 //hack: make it a config option to use "dated" dirs
38 //we can't cause of stallman -mh
39 //if(FileUtil.write(dir+"/"+datePath+"/"+mediaFname, uploadedData)) {
40 if(FileUtil.write(dir+"/"+mediaFname, uploadedData)) {
42 ent.setValueForProperty("is_produced", "1");
43 ent.setValueForProperty("icon_is_produced", "1");
44 //hack: make it a config option to use "dated" dirs
45 //we can't cause of stallman -mh
46 //ent.setValueForProperty("publish_path",datePath+"/"+mediaFname);
47 ent.setValueForProperty("publish_path", mediaFname);
48 ent.setValueForProperty("publish_server", mediaHost);
49 ent.setValueForProperty("size", size.toString());
51 } catch (StorageObjectException e) {
52 theLog.printError("StorageObjectException: "+e.toString());
56 theLog.printError("could not write FILE!");
63 //a class that will probably never get used..
64 private byte[] getFile (String fileName) {
65 long size = FileUtil.getSize(fileName);
66 if (size < 0) return null;
68 byte[] container = new byte[(int)size];
70 if(!FileUtil.read(fileName, container))
76 public byte[] get (Entity ent, Entity mediaTypeEnt) {
80 public byte[] getIcon (Entity ent) {
81 String name = "/path/to/some/generic/icon";
85 public String getStoragePath()
87 return MirConfig.getProp("Producer.Media.Path");
90 public String getIconStoragePath()
92 return MirConfig.getProp("Producer.Image.IconPath");
95 public String getPublishHost()
97 return MirConfig.getProp("Producer.Media.Host");
100 public String getTinyIcon()
102 return MirConfig.getProp("Producer.Icon.TinyText");
105 public String getBigIcon()
107 return MirConfig.getProp("Producer.Icon.BigText");
110 public String getIconAlt()
112 return "Generic media";
115 public String getURL(Entity ent, Entity mediaTypeEnt)
117 String title = ent.getValue("title")+
118 " - "+mediaTypeEnt.getValue("name")+" "+
119 ent.getValue("size")+" Bytes";
120 return StringUtil.createURLLinks(ent.getValue("publish_server")+"/"+
121 ent.getValue("publish_path"), title, imageRoot, getBigIcon());
124 public boolean isVideo()
129 public boolean isAudio()
134 public boolean isImage()