first cut of merge of STABLE-pre1_0 into HEAD. I won't even guarantee that it
[mir.git] / source / mircoders / producer / ProducerMedia.java
index 8a9dea4..5d38acb 100755 (executable)
@@ -12,6 +12,7 @@ import mir.module.*;
 import mir.entity.*;
 import mir.media.*;
 
+import mircoders.media.*;
 import mircoders.entity.*;
 import mircoders.storage.*;
 import mir.storage.*;
@@ -40,6 +41,7 @@ public class ProducerMedia extends Producer {
         boolean             mediaProduced = false;
                String              whereClause;
                String              mediaHost;
+               String              id2=null;
                String              iconPath;
                String              mediaPath;
                String              iconFilename;
@@ -48,7 +50,7 @@ public class ProducerMedia extends Producer {
                Entity              currentMedia;
                EntityList          batchEntityList;
 
-    int contentBatchsize = Integer.parseInt(MirConfig.getProp("Producer.Content.Batchsize"));
+        int contentBatchsize = Integer.parseInt(MirConfig.getProp("Producer.Content.Batchsize"));
 
                // get batch of non-produced medias, that are to be published
                whereClause="is_published='1'";
@@ -65,43 +67,45 @@ public class ProducerMedia extends Producer {
 
                     Entity currentMediaType = DatabaseUploadedMedia.getInstance().getMediaType(currentMedia);
                     String mediaHandlerName = currentMediaType.getValue("classname");
-                    Class mediaHandlerClass = Class.forName("mir.media.MediaHandler"+mediaHandlerName);
-                    MirMedia currentMediaHandler = (MirMedia)mediaHandlerClass.newInstance();       
-                        
+                    Class mediaHandlerClass = Class.forName("mircoders.media.MediaHandler"+mediaHandlerName);
+                    MirMedia currentMediaHandler = (MirMedia)mediaHandlerClass.newInstance();
+
                     String date = currentMedia.getValue("date");
                     String datePath = StringUtil.webdbDate2path(date);
 
                     // do icon
-                    if (currentMedia.getValue("icon_is_produced") != "1") {
+                    if (!currentMedia.getValue("icon_is_produced").equals("1")) {
                         iconPath = currentMediaHandler.getIconStoragePath();
                         iconFilename = producerDocRoot+iconPath+datePath+
                             currentMedia.getId()+"."+currentMediaType.getValue("name");
                         iconProduced = produceFile(iconFilename, currentMediaHandler.getIcon(currentMedia), htmlout, true);
                         if(iconProduced) {
                             currentMedia.setValueForProperty("icon_path",iconFilename);
-                            logHTML(htmlout,"icon : " + iconFilename + (( iconProduced==true )? " succeded":" <font color=\"Red\" failed!</font>"));
+                            logHTML(htmlout,"icon : " + iconFilename + (( iconProduced==true )? " succeded":" <font color=\"Red\"> failed!</font>"));
                         }
 
                     } else {
                         iconProduced = true;
                     }
-                    
+
                     //now produce the media content
 
                     mediaHost = currentMediaHandler.getPublishHost();
                     mediaPath = currentMediaHandler.getStoragePath();
+                    id2 = currentMedia.getId();
                     mediaFilename = currentMedia.getId()+"."+currentMediaType.getValue("name");
                     //hack: make this a config option. -mh
-                    //productionPath = mediaPath+datePath+"/"+ mediaFilename ;
-                    productionPath = mediaPath+"/"+mediaFilename ;
+                    productionPath = mediaPath+datePath+"/"+ mediaFilename ;
+                    //productionPath = mediaPath+"/"+mediaFilename ;
 
                     //hack: see above. -mh.
-                    //currentMedia.setValueForProperty("publish_path",datePath+"/"+mediaFilename);
-                    currentMedia.setValueForProperty("publish_path",mediaFilename);
+                    currentMedia.setValueForProperty("publish_path",datePath+"/"+mediaFilename);
+                    //currentMedia.setValueForProperty("publish_path",mediaFilename);
                     currentMedia.setValueForProperty("publish_server", mediaHost);
 
+                    theLog.printError("ABOUT OT FILE"+id2);
                     mediaProduced = produceFile(productionPath, currentMediaHandler.get(currentMedia, currentMediaType), htmlout, false);
-                    logHTML(htmlout,"media: " + productionPath + ((mediaProduced==true)?" succeded":" <font color=\"Red\" failed!</font>"));
+                    logHTML(htmlout,"media: " + productionPath + ((mediaProduced==true)?" succeded":" <font color=\"Red\"> failed!</font>"));
 
                     // update media-data
                     if (iconProduced && mediaProduced) {
@@ -109,9 +113,16 @@ public class ProducerMedia extends Producer {
                         currentMedia.setValueForProperty("is_produced", "1");
                         currentMedia.update();
                     }
-
+                } catch (MirMediaException e) {
+                    theLog.printError("media exception: "+id+e.toString());
+                    logHTML(htmlout, "problem with media id: "
+                        +id+" <font color=\"Red\"> failed!</font>: "
+                        +e.toString());
                 } catch (Exception e) {
-                    theLog.printError("failed in reflection: "+e);
+                    theLog.printError("failed in reflection: "+id+e.toString());
+                    logHTML(htmlout, "reflection problem in media id: "
+                        +id+" <font color=\"Red\"> failed!</font>: "
+                        +e.toString());
                 }
                        }