- protected static String imageHost = MirConfig.getProp("Producer.Image.Host");
- protected static String imageRoot = MirConfig.getProp("Producer.ImageRoot");
- protected static Logfile theLog = Logfile.getInstance(
- MirConfig.getProp("Home")+
- "log/media.log");
- private final String sepChar = File.separator;
-
- public void set (InputStream in, Entity ent, Entity mediaTypeEnt )
- throws MirMediaException {
-
- String ext = mediaTypeEnt.getValue("name");
- String mediaFname = ent.getId()+"."+ext;
- String date = ent.getValue("date");
- String datePath = StringUtil.webdbDate2path(date);
- try {
- long size = FileUtil.write(getStoragePath()+sepChar+datePath+
- sepChar+mediaFname, in);
- ent.setValueForProperty("publish_path",datePath+mediaFname);
- ent.setValueForProperty("size", new Long(size).toString());
- ent.update();
- } catch (Exception e) {
- theLog.printError(e.toString());
- throw new MirMediaException(e.toString());
- }
-
- }
-
- public void produce (Entity ent, Entity mediaTypeEnt )
- throws MirMediaException {
+ protected static MirPropertiesConfiguration configuration;
+ protected static String imageHost;
+ protected static String imageRoot;
+
+ protected LoggerWrapper logger;
+
+ static {
+ try {
+ configuration = MirPropertiesConfiguration.instance();
+ }
+ catch (PropertiesConfigExc e) {
+ }
+ imageHost = configuration.getString("Producer.Image.Host");
+ imageRoot = configuration.getString("Producer.ImageRoot");
+ }
+
+ public MediaHandlerGeneric() {
+ logger = new LoggerWrapper("Media.Generic");
+ }
+
+ public void set (InputStream in, Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure {
+ String ext = mediaTypeEnt.getValue("name");
+ String mediaFname = ent.getId() + "." + ext;
+ String date = ent.getValue("date");
+ String datePath = StringUtil.webdbDate2path(date);
+ try {
+ long size = FileUtil.write(getStoragePath() + File.separator + datePath +
+ File.separator + mediaFname, in);
+ ent.setValueForProperty("publish_path", datePath + mediaFname);
+ ent.setValueForProperty("size", new Long(size).toString());
+ ent.update();
+ }
+ catch (Throwable e) {
+ logger.error("MediaHandlerGeneric.set: " + e.toString());
+ throw new MediaFailure(e);
+ }
+ }