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 Logfile theLog = Logfile.getInstance(MirConfig.getProp("Home")+"log/media.log");
28 public boolean set (byte[] uploadedData, Entity ent, Entity mediaTypeEnt ) {
29 String ext = mediaTypeEnt.getValue("name");
30 String dir = MirConfig.getProp("Producer.Media.Path");
31 String mediaHost = MirConfig.getProp("Producer.Media.Host");
32 String mediaFname = ent.getId()+"."+ext;
33 String date = ent.getValue("date");
34 String datePath = StringUtil.webdbDate2path(date);
35 //hack: make it a config option to use "dated" dirs
36 //we can't cause of stallman -mh
37 //if(FileUtil.write(dir+"/"+datePath+"/"+mediaFname, uploadedData)) {
38 if(FileUtil.write(dir+"/"+mediaFname, uploadedData)) {
40 ent.setValueForProperty("is_produced", "1");
41 ent.setValueForProperty("icon_is_produced", "1");
42 //hack: make it a config option to use "dated" dirs
43 //we can't cause of stallman -mh
44 //ent.setValueForProperty("publish_path",datePath+"/"+mediaFname);
45 ent.setValueForProperty("publish_path", mediaFname);
46 ent.setValueForProperty("publish_server", mediaHost);
48 } catch (StorageObjectException e) {
49 theLog.printError("StorageObjectException: "+e.toString());
53 theLog.printError("could not write FILE!");
60 //a class that will probably never get used..
61 private byte[] getFile (String fileName) {
62 long size = FileUtil.getSize(fileName);
63 if (size < 0) return null;
65 byte[] container = new byte[(int)size];
67 if(!FileUtil.read(fileName, container))
73 public byte[] get (Entity ent, Entity mediaTypeEnt) {
77 public byte[] getIcon (Entity ent) {
78 String name = "/path/to/some/generic/icon";
82 public String getStoragePath()
84 return MirConfig.getProp("Producer.Media.Path");
87 public String getIconStoragePath()
89 return MirConfig.getProp("Producer.Image.IconPath");
92 public String getPublishHost()
94 return MirConfig.getProp("Producer.Media.Host");