error handling!
authormh <mh>
Tue, 5 Feb 2002 20:37:18 +0000 (20:37 +0000)
committermh <mh>
Tue, 5 Feb 2002 20:37:18 +0000 (20:37 +0000)
source/mircoders/producer/ProducerAll.java
source/mircoders/producer/ProducerFeature.java
source/mircoders/producer/ProducerImages.java
source/mircoders/producer/ProducerList.java
source/mircoders/producer/ProducerMedia.java
source/mircoders/producer/ProducerNavigation.java
source/mircoders/producer/ProducerOpenPosting.java
source/mircoders/producer/ProducerTopics.java

index 4f21327..88f324f 100755 (executable)
@@ -28,18 +28,49 @@ public class ProducerAll extends Producer{
 
        // handle all
        public void handle(PrintWriter htmlout, EntityUsers user, boolean force,boolean sync)
-               throws StorageObjectException, ModuleException {
+    {
                printHTML(htmlout, "Producer.All: started");
 
                long                sessionConnectTime = 0;
                long                startTime = (new java.util.Date()).getTime();
-               //new ProducerImages().handle(htmlout, user, force,sync);
-               new ProducerMedia().handle(htmlout, user, force,sync);
-               new ProducerStartPage().handle(htmlout, user, force,sync);
-               new ProducerContent().handle(htmlout, user, force,sync);
-               new ProducerOpenPosting().handle(htmlout, user, force,sync);
-               new ProducerTopics().handle(htmlout, user, force,sync);
-    new ProducerNavigation().handle(htmlout, user, force,sync);
+    
+        try {
+            //new ProducerImages().handle(htmlout, user, force,sync);
+            new ProducerMedia().handle(htmlout, user, force,sync);
+        } catch (Exception e) {
+            logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
+                +" in Producer.Media continuing "+ e.toString());
+        }
+        try {
+            new ProducerStartPage().handle(htmlout, user, force,sync);
+        } catch (Exception e) {
+            logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
+                +" in Producer.StartPage continuing "+ e.toString());
+        }
+        try {
+            new ProducerContent().handle(htmlout, user, force,sync);
+        } catch (Exception e) {
+            logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
+                +" in Producer.Content continuing "+ e.toString());
+        }
+        try {
+            new ProducerOpenPosting().handle(htmlout, user, force,sync);
+        } catch (Exception e) {
+            logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
+                +" in Producer.OpenPosting continuing "+ e.toString());
+        }
+        try {
+            new ProducerTopics().handle(htmlout, user, force,sync);
+        } catch (Exception e) {
+            logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
+                +" in Producer.Topics continuing "+ e.toString());
+        }
+        try {
+            new ProducerNavigation().handle(htmlout, user, force,sync);
+        } catch (Exception e) {
+            logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
+                +" in Producer.Navigation continuing "+ e.toString());
+        }
 
                // Finish
                sessionConnectTime = new java.util.Date().getTime() - startTime;
index a8c54d1..69adc50 100755 (executable)
@@ -34,15 +34,19 @@ public class ProducerFeature extends ProducerList {
                boolean first=true;
                whereClause="is_published!=true AND to_article_type=0 AND id IN (";
                for(int i=0; i < featureEntityList.size(); i++){
-                       if(first==false) {
-                               whereClause += ",";
-                       }
 
-                       EntityTopics currentTopic = (EntityTopics)featureEntityList.elementAt(i);
-                       EntityList contentEntityList = DatabaseContentToTopics.getInstance().getContent(currentTopic);
-                       whereClause += currentTopic.getId();
-                       fileDesc = currentTopic.getValue("filename").trim();
-                       setAdditional("topic",HTMLTemplateProcessor.makeSimpleHash(currentTopic));
+            try {
+                EntityTopics currentTopic = (EntityTopics)featureEntityList.elementAt(i);
+                EntityList contentEntityList = DatabaseContentToTopics.getInstance().getContent(currentTopic);
+                if(first==false) {
+                    whereClause += ",";
+                }
+                whereClause += currentTopic.getId();
+                fileDesc = currentTopic.getValue("filename").trim();
+                setAdditional("topic",HTMLTemplateProcessor.makeSimpleHash(currentTopic));
+            } catch (Exception e) {
+                logHTML(htmlout, "problem with feature skipping");
+            }
 
                        first = false;
                }
@@ -57,4 +61,4 @@ public class ProducerFeature extends ProducerList {
                        System.err.println(e.toString());
                }
        }
-}
\ No newline at end of file
+}
index f3ef690..45e5955 100755 (executable)
@@ -41,10 +41,10 @@ public class ProducerImages extends Producer {
                EntityImages         currentImage;
                EntityList          batchEntityList;
 
-    int contentBatchsize = Integer.parseInt(MirConfig.getProp("Producer.Content.Batchsize"));
-    String imageHost = MirConfig.getProp("Producer.Image.Host");
-         String imagePath = MirConfig.getProp("Producer.Image.Path");
-         String iconPath = MirConfig.getProp("Producer.Image.IconPath");
+        int contentBatchsize = Integer.parseInt(MirConfig.getProp("Producer.Content.Batchsize"));
+        String imageHost = MirConfig.getProp("Producer.Image.Host");
+        String imagePath = MirConfig.getProp("Producer.Image.Path");
+        String iconPath = MirConfig.getProp("Producer.Image.IconPath");
 
                // get batch of non-produced images, that are to be published
                whereClause="is_published='1'";
@@ -61,6 +61,7 @@ public class ProducerImages extends Producer {
                                theLog.printDebugInfo("trying image: " + i);
                                currentImage = (EntityImages)batchEntityList.elementAt(i);
 
+            try {
                                // make filenames
                                String date = currentImage.getValue("date");
 
@@ -71,8 +72,7 @@ public class ProducerImages extends Producer {
                                productionPath = imagePath + "/" + imageFilename ;
 
                                currentImage.setValueForProperty("icon_path",iconFilename);
-                               //currentImage.setValueForProperty("publish_path","imc/germany/" + imageFilename);
-        currentImage.setValueForProperty("publish_path",imageFilename);
+                currentImage.setValueForProperty("publish_path",imageFilename);
                                currentImage.setValueForProperty("publish_server", imageHost);
 
                                if (currentImage.getValue("icon_data")!= null && currentImage.getValue("image_data")!= null) {
@@ -90,7 +90,10 @@ public class ProducerImages extends Producer {
                                        }
 
                                }
-                       }
+            } catch (Exception e) {
+               logHTML(htmlout, "Producer.Images ERROR with: image ID " + currentImage.getId() + " <font color=\"Red\"> failed!</font>");
+            }
+                       }//end for
 
                        // if next batch get it...
                        if (batchEntityList.hasNextBatch()){
@@ -105,4 +108,4 @@ public class ProducerImages extends Producer {
 
        }
 
-}
\ No newline at end of file
+}
index a076578..3579294 100755 (executable)
@@ -106,7 +106,7 @@ abstract public class ProducerList extends Producer {
                 EntityList currentMediaList = DatabaseContentToMedia.getInstance().getUploadedMedia(currentContent);
                 SimpleList contentList = (SimpleList)mergeData.get("contentlist");
                 SimpleHash contentHash = (SimpleHash)contentList.get(k);
-                                                               if (currentMediaList!=null && currentMediaList.getCount()>=1) {
+                if (currentMediaList!=null && currentMediaList.getCount()>=1) {
                   SimpleList mediaListAudio = new SimpleList();
                   SimpleList mediaListImages = new SimpleList();
                   SimpleList mediaListVideo = new SimpleList();
@@ -116,30 +116,27 @@ abstract public class ProducerList extends Producer {
                     upMedia = currentMediaList.elementAt(n);
                     upMediaSimpleHash = HTMLTemplateProcessor.makeSimpleHash(upMedia);
                     mediaType = ((EntityMedia)upMedia).getMediaType();
-                    //must be a non-existant to_media_type entry..
-                    if (mediaType != null) {
-                      mediaHandlerName = mediaType.getValue("classname");
-                      mediaStorageName = mediaType.getValue("tablename");
-                      mediaStorageClass = Class.forName("mircoders.storage.Database"+mediaStorageName);
-                      mediaHandlerClass = Class.forName("mir.media.MediaHandler"+mediaHandlerName);
-                      mediaHandler = (MirMedia)mediaHandlerClass.newInstance();
-                      Method m = mediaStorageClass.getMethod("getInstance", null);
-                      mediaStorage = (Database)m.invoke(null, null);
-                      //we most likely need further info
-                      upMedia = mediaStorage.selectById(upMedia.getId());
-                      upMediaSimpleHash.put("url", mediaHandler.getListView(upMedia, mediaType));
-                      if (upMedia.getValue("is_published").equals("1")) {
-                          if (mediaHandler.isImage()) {
-                            mediaListImages.add(upMediaSimpleHash);
-                          } else if (mediaHandler.isAudio()) {
-                            mediaListAudio.add(upMediaSimpleHash);
-                          } else if (mediaHandler.isVideo()) {
-                            mediaListVideo.add(upMediaSimpleHash);
-                          } else {
-                            mediaListOther.add(upMediaSimpleHash);
-                          }
-                      } //end if is_published
-                    } //end if media_type != null
+                    mediaHandlerName = mediaType.getValue("classname");
+                    mediaStorageName = mediaType.getValue("tablename");
+                    mediaStorageClass = Class.forName("mircoders.storage.Database"+mediaStorageName);
+                    mediaHandlerClass = Class.forName("mir.media.MediaHandler"+mediaHandlerName);
+                    mediaHandler = (MirMedia)mediaHandlerClass.newInstance();
+                    Method m = mediaStorageClass.getMethod("getInstance", null);
+                    mediaStorage = (Database)m.invoke(null, null);
+                    //we most likely need further info
+                    upMedia = mediaStorage.selectById(upMedia.getId());
+                    upMediaSimpleHash.put("url", mediaHandler.getListView(upMedia, mediaType));
+                    if (upMedia.getValue("is_published").equals("1")) {
+                        if (mediaHandler.isImage()) {
+                          mediaListImages.add(upMediaSimpleHash);
+                        } else if (mediaHandler.isAudio()) {
+                          mediaListAudio.add(upMediaSimpleHash);
+                        } else if (mediaHandler.isVideo()) {
+                          mediaListVideo.add(upMediaSimpleHash);
+                        } else {
+                          mediaListOther.add(upMediaSimpleHash);
+                        }
+                    } //end if is_published
                   } //end for
 
 
index 9a3997f..76c2f63 100755 (executable)
@@ -49,7 +49,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'";
@@ -66,7 +66,6 @@ public class ProducerMedia extends Producer {
 
                     Entity currentMediaType = DatabaseUploadedMedia.getInstance().getMediaType(currentMedia);
                     String mediaHandlerName = currentMediaType.getValue("classname");
-                    theLog.printError("HANLDER"+mediaHandlerName);
                     Class mediaHandlerClass = Class.forName("mir.media.MediaHandler"+mediaHandlerName);
                     MirMedia currentMediaHandler = (MirMedia)mediaHandlerClass.newInstance();
 
@@ -81,7 +80,7 @@ public class ProducerMedia extends Producer {
                         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 {
@@ -90,7 +89,6 @@ public class ProducerMedia extends Producer {
 
                     //now produce the media content
 
-                    theLog.printError("ABOUT OT MED"+id2);
                     mediaHost = currentMediaHandler.getPublishHost();
                     mediaPath = currentMediaHandler.getStoragePath();
                     id2 = currentMedia.getId();
@@ -106,8 +104,7 @@ public class ProducerMedia extends Producer {
 
                     theLog.printError("ABOUT OT FILE"+id2);
                     mediaProduced = produceFile(productionPath, currentMediaHandler.get(currentMedia, currentMediaType), htmlout, false);
-                    theLog.printError("FILED"+id2);
-                    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) {
@@ -115,9 +112,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: "+id+e.toString());
+                    logHTML(htmlout, "reflection problem in media id: "
+                        +id+" <font color=\"Red\"> failed!</font>: "
+                        +e.toString());
                 }
                        }
 
index c612502..afbae4a 100755 (executable)
@@ -29,7 +29,7 @@ public class ProducerNavigation extends Producer {
   public void handle(PrintWriter htmlout, EntityUsers user, boolean forced, boolean sync)
     throws mir.module.ModuleException, mir.storage.StorageObjectException {
 
-    printHTML(htmlout, "Producer.Navigation: started");
+        printHTML(htmlout, "Producer.Navigation: started");
 
                long                sessionConnectTime = 0;
                long                startTime = (new java.util.Date()).getTime();
@@ -42,18 +42,18 @@ public class ProducerNavigation extends Producer {
                EntityList          entityList;
                SimpleHash          naviPageModel;
 
-    // get the imclinks
-    entityList = linksImcsModule.getByWhereClause("", "sortpriority, title", -1);
-    SimpleList imcList = HTMLTemplateProcessor.makeSimpleList(entityList);
+        // get the imclinks
+        entityList = linksImcsModule.getByWhereClause("", "sortpriority, title", -1);
+        SimpleList imcList = HTMLTemplateProcessor.makeSimpleList(entityList);
 
-    EntityList theParentList = linksImcsModule.getByWhereClause("to_parent_id=NULL", "sortpriority, title", -1);
-    SimpleList parentList = HTMLTemplateProcessor.makeSimpleList(theParentList);
+        EntityList theParentList = linksImcsModule.getByWhereClause("to_parent_id=NULL", "sortpriority, title", -1);
+        SimpleList parentList = HTMLTemplateProcessor.makeSimpleList(theParentList);
 
                // put the informations into the navipagemodel
                naviPageModel = new SimpleHash();
                naviPageModel.put("topics", topicsModule.getTopicsList());
-    naviPageModel.put("imclist", imcList);
-    naviPageModel.put("parentlist", parentList);
+        naviPageModel.put("imclist", imcList);
+        naviPageModel.put("parentlist", parentList);
 
                htmlFileName = producerDocRoot + "/navigation.inc";
 
@@ -69,4 +69,4 @@ public class ProducerNavigation extends Producer {
                }
        }
 
-}
\ No newline at end of file
+}
index 0ea292a..268a4dc 100755 (executable)
@@ -20,9 +20,9 @@ import mir.storage.*;
 
 public class ProducerOpenPosting extends ProducerList {
 
-  public void setAdditional(String key, TemplateModel value) {
-    additional.put(key,value);
-  }
+    public void setAdditional(String key, TemplateModel value) {
+        additional.put(key,value);
+    }
 
        public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync)
                throws StorageObjectException, ModuleException {
@@ -37,8 +37,8 @@ public class ProducerOpenPosting extends ProducerList {
     setAdditional("topicslist",topicsModule.getTopicsList());
     setAdditional("title",title);
 
-    handleIt(htmlout,user,force);
-  }
+        handleIt(htmlout,user,force);
+    }
 
        public static void main(String argv[]){
                try {
@@ -47,4 +47,4 @@ public class ProducerOpenPosting extends ProducerList {
                        System.err.println(e.toString());
                }
        }
-}
\ No newline at end of file
+}
index cbe4826..e03e68c 100755 (executable)
@@ -62,6 +62,8 @@ public class ProducerTopics extends ProducerList {
     for(int i=0; i < topicsEntityList.size(); i++){
 
       EntityTopics currentTopic = (EntityTopics)topicsEntityList.elementAt(i);
+
+      try {
       EntityList contentEntityList = DatabaseContentToTopics.getInstance().getContent(currentTopic);
       String whereClauseSpecial=null;
 
@@ -147,8 +149,8 @@ public class ProducerTopics extends ProducerList {
 
               setAdditional("special",specialHash);
           } catch (Exception e) {
-            theLog.printError("ProducerTopics: problem with start special: "+currentContent.getId()+" "+e.toString());
-            logHTML(htmlout,"ProducerTopics: problem with start special: "+currentContent.getId()+" "+e.toString());
+            theLog.printError("ProducerTopics: problem with start special media: "+currentContent.getId()+" "+e.toString()+" <font color=\"red\">skipping</font>");
+            logHTML(htmlout,"ProducerTopics: problem with start special media: "+currentContent.getId()+" "+e.toString());
           }
         }
 
@@ -157,6 +159,10 @@ public class ProducerTopics extends ProducerList {
 
         handleIt(htmlout,user,force);
       }
+      } catch (Exception e) {
+        logHTML(htmlout,"ProducerTopics: problem with topic id: "
+        +currentTopic.getId()+ "<font color=\"red\">skipping</font>");
+      }
     }
   }