some misc. maintenance
authorzapata <zapata>
Mon, 4 Nov 2002 20:32:45 +0000 (20:32 +0000)
committerzapata <zapata>
Mon, 4 Nov 2002 20:32:45 +0000 (20:32 +0000)
23 files changed:
source/mir/entity/adapter/EntityAdapterModel.java
source/mir/entity/adapter/EntityIteratorAdapter.java
source/mir/producer/EntityEnumeratingProducerNode.java
source/mir/producer/GeneratingProducerNode.java
source/mir/producer/reader/DefaultProducerNodeBuilders.java
source/mir/producer/reader/ProducerNodeBuilder.java
source/mir/producer/reader/ProducerNodeBuilderLibrary.java
source/mircoders/global/ProducerEngine.java
source/mircoders/localizer/MirCachingLocalizerDecorator.java
source/mircoders/localizer/MirDataModelLocalizer.java
source/mircoders/localizer/MirGeneratorLocalizer.java
source/mircoders/localizer/MirLocalizer.java
source/mircoders/localizer/MirLocalizerExc.java [new file with mode: 0755]
source/mircoders/localizer/MirLocalizerException.java [deleted file]
source/mircoders/localizer/MirProducerAssistantLocalizer.java
source/mircoders/localizer/MirProducerLocalizer.java
source/mircoders/localizer/basic/MirBasicAdminInterfaceLocalizer.java
source/mircoders/localizer/basic/MirBasicGeneratorLocalizer.java
source/mircoders/localizer/basic/MirBasicLocalizer.java
source/mircoders/localizer/basic/MirBasicProducerLocalizer.java
source/mircoders/producer/MediaGeneratingProducerNode.java
source/mircoders/producer/reader/SupplementalProducerNodeBuilders.java
source/mircoders/servlet/ServletModuleProducer.java

index 154b161..586200e 100755 (executable)
@@ -1,34 +1,34 @@
-/*
- * Copyright (C) 2001, 2002  The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Mir is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with the com.oreilly.servlet library, any library
- * licensed under the Apache Software License, The Sun (tm) Java Advanced
- * Imaging library (JAI), The Sun JIMI library (or with modified versions of
- * the above that use the same license as the above), and distribute linked
- * combinations including the two.  You must obey the GNU General Public
- * License in all respects for all of the code used other than the above
- * mentioned libraries.  If you modify this file, you may extend this exception
- * to your version of the file, but you are not obligated to do so.  If you do
- * not wish to do so, delete this exception statement from your version.
- */
-
+/*\r
+ * Copyright (C) 2001, 2002  The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two.  You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries.  If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so.  If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
 package mir.entity.adapter;\r
 \r
 import java.util.*;\r
@@ -43,12 +43,9 @@ public class EntityAdapterModel {
     entityAdapterMappings = new HashMap();\r
   }\r
 \r
-  public EntityAdapter makeEntityAdapter( String aName, Entity anEntity ) {\r
+  public EntityAdapter makeEntityAdapter( String aName, Entity anEntity ) throws EntityAdapterExc {\r
     Mapping mapping = getMappingForName( aName );\r
 \r
-    if (mapping == null )\r
-      throw new RuntimeException( "Adapter definition with name '" + aName + "' not present in model" );\r
-\r
     return mapping.getDefinition().makeEntityAdapter( anEntity, this );\r
   }\r
 \r
@@ -56,7 +53,10 @@ public class EntityAdapterModel {
     entityAdapterMappings.put( aName, new Mapping( aStorage, aDefinition ) );\r
     }\r
 \r
-  public Mapping getMappingForName( String aName ) {\r
+  public Mapping getMappingForName( String aName ) throws EntityAdapterExc {\r
+    if (!entityAdapterMappings.containsKey(aName))\r
+      throw new EntityAdapterExc( "'" + aName + "' not present in model" );\r
+\r
     return (Mapping) entityAdapterMappings.get( aName );\r
   }\r
 \r
@@ -80,4 +80,3 @@ public class EntityAdapterModel {
 }\r
 \r
 \r
-                                                                                                   
\ No newline at end of file
index 438020a..9ff1be9 100755 (executable)
@@ -47,11 +47,15 @@ public class EntityIteratorAdapter implements RewindableIterator {
     definitionName = aDefinitionName;
   }
 
-  public EntityIteratorAdapter(String aWhereClause, String anOrderByClause, int aBatchSize, EntityAdapterModel aModel, String aDefinitionName ) throws StorageObjectException {
+  public EntityIteratorAdapter(String aWhereClause, String anOrderByClause,
+          int aBatchSize, EntityAdapterModel aModel, String aDefinitionName )
+          throws StorageObjectException, EntityAdapterExc {
     this(new EntityBrowser(aModel.getMappingForName(aDefinitionName).getStorage(), aWhereClause, anOrderByClause, aBatchSize), aModel, aDefinitionName);
   }
 
-  public EntityIteratorAdapter(String aWhereClause, String anOrderByClause, int aBatchSize, EntityAdapterModel aModel, String aDefinitionName, int aLimit, int aSkip) throws StorageObjectException {
+  public EntityIteratorAdapter(String aWhereClause, String anOrderByClause,
+          int aBatchSize, EntityAdapterModel aModel, String aDefinitionName,
+          int aLimit, int aSkip) throws StorageObjectException, EntityAdapterExc {
     this(new EntityBrowser(aModel.getMappingForName(aDefinitionName).getStorage(), aWhereClause, anOrderByClause, aBatchSize, aLimit, aSkip), aModel, aDefinitionName);
   }
 
@@ -60,7 +64,12 @@ public class EntityIteratorAdapter implements RewindableIterator {
   }
 
   public Object next() {
-    return model.makeEntityAdapter(definitionName, (Entity) iterator.next());
+    try {
+      return model.makeEntityAdapter(definitionName, (Entity) iterator.next());
+    }
+    catch (EntityAdapterExc e) {
+      return null;
+    }
   }
 
   public void remove() {
index 4b16de6..85a5a9d 100755 (executable)
@@ -86,7 +86,7 @@ public class EntityEnumeratingProducerNode extends ProducerNodeDecorator {
       }
     }
     catch (Throwable t) {
-      throw new ProducerFailure(t.getMessage(), t);
+      aLogger.println("Exception occurred inside an EntityEnumeratingProducerNode: " + t.getMessage());
     }
   };
 }
\ No newline at end of file
index ba3dc05..ba9a34f 100755 (executable)
@@ -82,8 +82,6 @@ public class GeneratingProducerNode implements ProducerNode {
     }
     catch (Throwable t) {
       aLogger.println("  error while generating: " + t.getClass().getName() + ": " + t.getMessage());
-      t.printStackTrace(aLogger);
-      aLogger.flush();
     }
     endTime = System.currentTimeMillis();
 
index 3c28b99..b8617d3 100755 (executable)
@@ -41,7 +41,7 @@ public class DefaultProducerNodeBuilders {
 
   public static void registerBuilders(ProducerNodeBuilderLibrary aBuilderLibrary,
        EntityAdapterModel aModel, Generator.GeneratorLibrary aGeneratorLibrary,
-       WriterEngine aWriterEngine, String aSourceBasePath, String aDestinationBasePath) {
+       WriterEngine aWriterEngine, String aSourceBasePath, String aDestinationBasePath) throws ProducerConfigExc {
 
     aBuilderLibrary.registerBuilder("Set", EvaluatedAssignmentProducerNodeBuilder.class);
     aBuilderLibrary.registerBuilder("Define", ExpandedAssignmentProducerNodeBuilder.class);
index 0b45d6c..c374db5 100755 (executable)
@@ -47,7 +47,10 @@ public interface ProducerNodeBuilder  {
   public class DefaultProducerNodeBuilderFactory implements ProducerNodeBuilderFactory {
     private Class producerNodeBuilderClass;
 
-    public DefaultProducerNodeBuilderFactory(Class aProducerNodeBuilderClass) {
+    public DefaultProducerNodeBuilderFactory(Class aProducerNodeBuilderClass) throws ProducerConfigExc {
+      if (!ProducerNodeBuilder.class.isAssignableFrom(aProducerNodeBuilderClass))
+        throw new ProducerConfigExc("supplied class is not a ProducerNodeBuilder class but a " + aProducerNodeBuilderClass.getClass().getName());
+
       producerNodeBuilderClass = aProducerNodeBuilderClass;
     }
 
index 0bbd15f..8480589 100755 (executable)
@@ -41,8 +41,13 @@ public class ProducerNodeBuilderLibrary {
     nodeBuilders = new HashMap();
   }
 
-  public void registerBuilder(String aName, Class aProducerNodeBuilderClass) {
-    registerFactory(aName, new ProducerNodeBuilder.DefaultProducerNodeBuilderFactory( aProducerNodeBuilderClass ));
+  public void registerBuilder(String aName, Class aProducerNodeBuilderClass) throws ProducerConfigExc, ProducerConfigFailure {
+    try {
+      registerFactory(aName, new ProducerNodeBuilder.DefaultProducerNodeBuilderFactory( aProducerNodeBuilderClass ));
+    }
+    catch (Throwable t) {
+      throw new ProducerConfigFailure("Error while registering builder '"+aName+"': "+t.getMessage(), t);
+    }
   }
 
   public void registerFactory(String aName, ProducerNodeBuilder.ProducerNodeBuilderFactory aFactory) {
index 20bbc5e..4748dae 100755 (executable)
@@ -60,8 +60,6 @@ public class ProducerEngine {
 
   public void addJob(String aProducerFactory, String aVerb) {
     producerJobQueue.appendJob(new ProducerJob(aProducerFactory, aVerb));
-    log.println(aProducerFactory+"."+aVerb+" added to queue");
-    log.flush();
   }
 
   public void addTask(ProducerTask aTask) {
index c7651bd..0c4a825 100755 (executable)
@@ -44,7 +44,7 @@ public class MirCachingLocalizerDecorator implements MirLocalizer {
     localizer = aLocalizer;
   }
 
-  public MirProducerLocalizer producers() throws MirLocalizerFailure, MirLocalizerException {
+  public MirProducerLocalizer producers() throws MirLocalizerFailure, MirLocalizerExc {
     if (producerLocalizer==null) {
       producerLocalizer = localizer.producers();
     }
@@ -52,7 +52,7 @@ public class MirCachingLocalizerDecorator implements MirLocalizer {
     return producerLocalizer;
   }
 
-  public MirGeneratorLocalizer generators() throws MirLocalizerFailure, MirLocalizerException {
+  public MirGeneratorLocalizer generators() throws MirLocalizerFailure, MirLocalizerExc {
     if (generatorLocalizer==null) {
       generatorLocalizer = localizer.generators();
     }
@@ -60,7 +60,7 @@ public class MirCachingLocalizerDecorator implements MirLocalizer {
     return generatorLocalizer;
   }
 
-  public MirOpenPostingLocalizer openPostings() throws MirLocalizerFailure, MirLocalizerException {
+  public MirOpenPostingLocalizer openPostings() throws MirLocalizerFailure, MirLocalizerExc {
     if (openPostingsLocalizer==null) {
       openPostingsLocalizer = localizer.openPostings();
     }
@@ -68,7 +68,7 @@ public class MirCachingLocalizerDecorator implements MirLocalizer {
     return openPostingsLocalizer;
   }
 
-  public MirProducerAssistantLocalizer producerAssistant() throws MirLocalizerFailure, MirLocalizerException {
+  public MirProducerAssistantLocalizer producerAssistant() throws MirLocalizerFailure, MirLocalizerExc {
     if (producerAssistantLocalizer==null) {
       producerAssistantLocalizer = localizer.producerAssistant();
     }
@@ -76,7 +76,7 @@ public class MirCachingLocalizerDecorator implements MirLocalizer {
     return producerAssistantLocalizer;
   }
 
-  public MirDataModelLocalizer dataModel() throws MirLocalizerFailure, MirLocalizerException {
+  public MirDataModelLocalizer dataModel() throws MirLocalizerFailure, MirLocalizerExc {
     if (dataModelLocalizer==null) {
       dataModelLocalizer = localizer.dataModel();
     }
@@ -84,7 +84,7 @@ public class MirCachingLocalizerDecorator implements MirLocalizer {
     return dataModelLocalizer;
   }
 
-  public MirAdminInterfaceLocalizer adminInterface() throws MirLocalizerFailure, MirLocalizerException {
+  public MirAdminInterfaceLocalizer adminInterface() throws MirLocalizerFailure, MirLocalizerExc {
     if (adminInterfaceLocalizer==null) {
       adminInterfaceLocalizer = localizer.adminInterface();
     }
index 374012f..cb8d87e 100755 (executable)
@@ -1,38 +1,38 @@
-/*
- * Copyright (C) 2001, 2002  The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Mir is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with the com.oreilly.servlet library, any library
- * licensed under the Apache Software License, The Sun (tm) Java Advanced
- * Imaging library (JAI), The Sun JIMI library (or with modified versions of
- * the above that use the same license as the above), and distribute linked
- * combinations including the two.  You must obey the GNU General Public
- * License in all respects for all of the code used other than the above
- * mentioned libraries.  If you modify this file, you may extend this exception
- * to your version of the file, but you are not obligated to do so.  If you do
- * not wish to do so, delete this exception statement from your version.
- */
-
+/*\r
+ * Copyright (C) 2001, 2002  The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two.  You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries.  If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so.  If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
 package mircoders.localizer;\r
 \r
 import mir.entity.adapter.*;\r
 \r
 public interface MirDataModelLocalizer {\r
-  public EntityAdapterModel adapterModel() throws MirLocalizerException, MirLocalizerFailure;\r
+  public EntityAdapterModel adapterModel() throws MirLocalizerExc, MirLocalizerFailure;\r
 }
\ No newline at end of file
index b6a9290..7cd27cf 100755 (executable)
@@ -34,9 +34,9 @@ package mircoders.localizer;
 import mir.generator.*;
 
 public interface MirGeneratorLocalizer {
-  public WriterEngine makeWriterEngine() throws MirLocalizerException, MirLocalizerFailure;
+  public WriterEngine makeWriterEngine() throws MirLocalizerExc, MirLocalizerFailure;
 
-  public Generator.GeneratorLibrary makeProducerGeneratorLibrary() throws MirLocalizerException, MirLocalizerFailure;
-  public Generator.GeneratorLibrary makeAdminGeneratorLibrary() throws MirLocalizerException, MirLocalizerFailure;
-  public Generator.GeneratorLibrary makeOpenPostingGeneratorLibrary() throws MirLocalizerException, MirLocalizerFailure;
+  public Generator.GeneratorLibrary makeProducerGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure;
+  public Generator.GeneratorLibrary makeAdminGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure;
+  public Generator.GeneratorLibrary makeOpenPostingGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure;
 }
\ No newline at end of file
index 18e76e3..4d487ae 100755 (executable)
 package mircoders.localizer;
 
 public interface MirLocalizer {
-  public MirProducerLocalizer producers() throws MirLocalizerFailure, MirLocalizerException;
-  public MirAdminInterfaceLocalizer adminInterface() throws MirLocalizerFailure, MirLocalizerException;
-  public MirOpenPostingLocalizer openPostings() throws MirLocalizerFailure, MirLocalizerException;
-  public MirProducerAssistantLocalizer producerAssistant() throws MirLocalizerFailure, MirLocalizerException;
-  public MirGeneratorLocalizer generators() throws MirLocalizerFailure, MirLocalizerException;
-  public MirDataModelLocalizer dataModel() throws MirLocalizerFailure, MirLocalizerException;
+  public MirProducerLocalizer producers() throws MirLocalizerFailure, MirLocalizerExc;
+  public MirAdminInterfaceLocalizer adminInterface() throws MirLocalizerFailure, MirLocalizerExc;
+  public MirOpenPostingLocalizer openPostings() throws MirLocalizerFailure, MirLocalizerExc;
+  public MirProducerAssistantLocalizer producerAssistant() throws MirLocalizerFailure, MirLocalizerExc;
+  public MirGeneratorLocalizer generators() throws MirLocalizerFailure, MirLocalizerExc;
+  public MirDataModelLocalizer dataModel() throws MirLocalizerFailure, MirLocalizerExc;
 
 }
\ No newline at end of file
diff --git a/source/mircoders/localizer/MirLocalizerExc.java b/source/mircoders/localizer/MirLocalizerExc.java
new file mode 100755 (executable)
index 0000000..927a951
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2001, 2002  The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with the com.oreilly.servlet library, any library
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of
+ * the above that use the same license as the above), and distribute linked
+ * combinations including the two.  You must obey the GNU General Public
+ * License in all respects for all of the code used other than the above
+ * mentioned libraries.  If you modify this file, you may extend this exception
+ * to your version of the file, but you are not obligated to do so.  If you do
+ * not wish to do so, delete this exception statement from your version.
+ */
+
+package mircoders.localizer;
+
+import multex.Exc;
+
+public class MirLocalizerExc extends Exc {
+
+  public MirLocalizerExc(String aMessage) {
+    super(aMessage);
+  }
+}
\ No newline at end of file
diff --git a/source/mircoders/localizer/MirLocalizerException.java b/source/mircoders/localizer/MirLocalizerException.java
deleted file mode 100755 (executable)
index 55fcb4f..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2001, 2002  The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Mir is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with the com.oreilly.servlet library, any library
- * licensed under the Apache Software License, The Sun (tm) Java Advanced
- * Imaging library (JAI), The Sun JIMI library (or with modified versions of
- * the above that use the same license as the above), and distribute linked
- * combinations including the two.  You must obey the GNU General Public
- * License in all respects for all of the code used other than the above
- * mentioned libraries.  If you modify this file, you may extend this exception
- * to your version of the file, but you are not obligated to do so.  If you do
- * not wish to do so, delete this exception statement from your version.
- */
-
-package mircoders.localizer;
-
-import multex.Exc;
-
-public class MirLocalizerException extends Exc {
-
-  public MirLocalizerException(String aMessage) {
-    super(aMessage);
-  }
-}
\ No newline at end of file
index 0d8b696..86044d5 100755 (executable)
@@ -35,6 +35,6 @@ import java.util.*;
 import java.io.*;
 
 public interface MirProducerAssistantLocalizer {
-  public void initializeGenerationValueSet(Map aValueSet) throws MirLocalizerException, MirLocalizerFailure;
-  public String filterText(String aText) throws MirLocalizerException, MirLocalizerFailure;
+  public void initializeGenerationValueSet(Map aValueSet) throws MirLocalizerExc, MirLocalizerFailure;
+  public String filterText(String aText) throws MirLocalizerExc, MirLocalizerFailure;
 }
index 475fb4e..8434e68 100755 (executable)
@@ -35,7 +35,7 @@ import java.util.List;
 import mir.producer.ProducerFactory;
 
 public interface MirProducerLocalizer {
-  public List factories() throws MirLocalizerException, MirLocalizerFailure;
+  public List factories() throws MirLocalizerExc, MirLocalizerFailure;
   public ProducerFactory getFactoryForName(String aName);
   public void produceAllNew();
 }
index e680a6c..a5f9f2c 100755 (executable)
@@ -44,7 +44,7 @@ public class MirBasicAdminInterfaceLocalizer implements MirAdminInterfaceLocaliz
   private Map simpleCommentOperations;
   private Map simpleArticleOperations;
 
-  public MirBasicAdminInterfaceLocalizer() throws MirLocalizerFailure, MirLocalizerException {
+  public MirBasicAdminInterfaceLocalizer() throws MirLocalizerFailure, MirLocalizerExc {
     simpleCommentOperations = new HashMap();
     simpleArticleOperations = new HashMap();
 
@@ -60,12 +60,12 @@ public class MirBasicAdminInterfaceLocalizer implements MirAdminInterfaceLocaliz
     return simpleArticleOperations;
   };
 
-  public void buildSimpleCommentOperations(Map anOperations) throws MirLocalizerFailure, MirLocalizerException {
+  public void buildSimpleCommentOperations(Map anOperations) throws MirLocalizerFailure, MirLocalizerExc {
     anOperations.put("hide", new HideCommentOperation());
     anOperations.put("unhide", new UnhideCommentOperation());
   };
 
-  public void buildSimpleArticleOperations(Map anOperations)  throws MirLocalizerFailure, MirLocalizerException {
+  public void buildSimpleArticleOperations(Map anOperations)  throws MirLocalizerFailure, MirLocalizerExc {
     anOperations.put("hide", new HideArticleOperation());
     anOperations.put("unhide", new UnhideArticleOperation());
   };
index 5ee08d9..4bccee0 100755 (executable)
@@ -51,7 +51,7 @@ public class MirBasicGeneratorLocalizer implements MirGeneratorLocalizer {
     aRepository.registerLibraryFactory("freemarker", new FreemarkerGenerator.FreemarkerGeneratorLibraryFactory( MirGlobal.getConfigProperty("Home") ) );
   }
 
-  public Generator.GeneratorLibrary makeProducerGeneratorLibrary() throws MirLocalizerException, MirLocalizerFailure {
+  public Generator.GeneratorLibrary makeProducerGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {
     try {
       return repository.constructCompositeLibrary(MirGlobal.getConfigProperty("Mir.Localizer.Producer.GeneratorLibrary"));
     }
@@ -60,7 +60,7 @@ public class MirBasicGeneratorLocalizer implements MirGeneratorLocalizer {
     }
   };
 
-  public Generator.GeneratorLibrary makeAdminGeneratorLibrary() throws MirLocalizerException, MirLocalizerFailure {
+  public Generator.GeneratorLibrary makeAdminGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {
     try {
       return repository.constructCompositeLibrary(MirGlobal.getConfigProperty("Mir.Localizer.Admin.GeneratorLibrary"));
     }
@@ -69,7 +69,7 @@ public class MirBasicGeneratorLocalizer implements MirGeneratorLocalizer {
     }
   };
 
-  public Generator.GeneratorLibrary makeOpenPostingGeneratorLibrary() throws MirLocalizerException, MirLocalizerFailure {
+  public Generator.GeneratorLibrary makeOpenPostingGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {
     try {
       return repository.constructCompositeLibrary(MirGlobal.getConfigProperty("Mir.Localizer.OpenPosting.GeneratorLibrary"));
     }
@@ -78,7 +78,7 @@ public class MirBasicGeneratorLocalizer implements MirGeneratorLocalizer {
     }
   };
 
-  public WriterEngine makeWriterEngine() throws MirLocalizerException, MirLocalizerFailure {
+  public WriterEngine makeWriterEngine() throws MirLocalizerExc, MirLocalizerFailure {
     return new MirBasicWriterEngine(MirGlobal.getConfigProperty("Mir.DefaultEncoding"));
   }
 }
index 94ecca0..0422ec0 100755 (executable)
@@ -38,7 +38,7 @@ import mircoders.localizer.*;
 public class MirBasicLocalizer implements MirLocalizer {
   protected static Logfile logger = Logfile.getInstance( MirGlobal.getConfigProperty("Home") + "/" + MirGlobal.getConfigProperty("Mir.Localizer.Logfile"));
 
-  public MirProducerLocalizer producers() throws MirLocalizerFailure, MirLocalizerException {
+  public MirProducerLocalizer producers() throws MirLocalizerFailure, MirLocalizerExc {
     return new MirBasicProducerLocalizer();
   }
 
@@ -58,7 +58,7 @@ public class MirBasicLocalizer implements MirLocalizer {
     return new MirBasicDataModelLocalizer();
   };
 
-  public MirAdminInterfaceLocalizer adminInterface() throws MirLocalizerFailure, MirLocalizerException {
+  public MirAdminInterfaceLocalizer adminInterface() throws MirLocalizerFailure, MirLocalizerExc {
     return new MirBasicAdminInterfaceLocalizer();
   };
 
index 0c0f9ce..c1be724 100755 (executable)
@@ -77,7 +77,7 @@ public class MirBasicProducerLocalizer implements MirProducerLocalizer {
     }
   }
 
-  public List factories() throws MirLocalizerException {
+  public List factories() throws MirLocalizerExc {
     if (fileMonitor==null || producerFactories == null || fileMonitor.hasChanged()) {
       try {
         List newProducers = new Vector();
@@ -103,14 +103,19 @@ public class MirBasicProducerLocalizer implements MirProducerLocalizer {
     return producerFactories;
   };
 
-  protected void setupProducerNodeBuilderLibrary(ProducerNodeBuilderLibrary aLibrary) {
-    DefaultProducerNodeBuilders.registerBuilders(
-      aLibrary, model, generatorLibrary, writerEngine,
-      MirGlobal.getConfigProperty("Home"), MirGlobal.getConfigProperty("Producer.StorageRoot"));
-    SupplementalProducerNodeBuilders.registerBuilders(aLibrary, model);
+  protected void setupProducerNodeBuilderLibrary(ProducerNodeBuilderLibrary aLibrary) throws MirLocalizerFailure {
+    try {
+      DefaultProducerNodeBuilders.registerBuilders(
+          aLibrary, model, generatorLibrary, writerEngine,
+          MirGlobal.getConfigProperty("Home"), MirGlobal.getConfigProperty("Producer.StorageRoot"));
+      SupplementalProducerNodeBuilders.registerBuilders(aLibrary, model);
+    }
+    catch (Throwable t) {
+      throw new MirLocalizerFailure(t.getMessage(), t);
+    }
   }
 
-  protected void setupFactories(List aFactories, FileMonitor aFileMonitor) throws MirLocalizerException, MirLocalizerFailure {
+  protected void setupFactories(List aFactories, FileMonitor aFileMonitor) throws MirLocalizerExc, MirLocalizerFailure {
     ProducerConfigReader reader;
     ProducerNodeBuilderLibrary library = new ProducerNodeBuilderLibrary();
     setupProducerNodeBuilderLibrary(library);
@@ -128,7 +133,7 @@ public class MirBasicProducerLocalizer implements MirProducerLocalizer {
     setupFactories(aFactories);
   }
 
-  protected void setupFactories(List aFactories) throws MirLocalizerException, MirLocalizerFailure {
+  protected void setupFactories(List aFactories) throws MirLocalizerExc, MirLocalizerFailure {
     CompositeProducerNode node;
 
     try {
index e76831b..93ffab9 100755 (executable)
@@ -52,118 +52,54 @@ public class MediaGeneratingProducerNode implements ProducerNode {
     mediaEntityKey = aMediaEntityKey;
   }
 
-  public void produce(Map aValueMap, String aVerb, PrintWriter aLogger) throws ProducerFailure {
+  public void produce(Map aValueMap, String aVerb, PrintWriter aLogger) throws ProducerFailure, ProducerExc {
     Object data;
     Entity entity;
-    Entity currentMediaType;
+    EntityUploadedMedia uploadedMediaEntity = null;
+    Entity mediaType = null;
     MirMedia currentMediaHandler;
 
     try {
+
       data = ParameterExpander.findValueForKey( aValueMap, mediaEntityKey );
 
       if (!(data instanceof EntityAdapter)) {
-        throw new ProducerFailure("MediaGeneratingProducerNode: value of '"+mediaEntityKey+"' is not an EntityAdapter, but an " + data.getClass().getName(), null);
+        throw new ProducerExc("MediaGeneratingProducerNode: value of '"+mediaEntityKey+"' is not an EntityAdapter, but an " + data.getClass().getName());
       }
 
       entity = ((EntityAdapter) data).getEntity();
       if (! (entity instanceof EntityUploadedMedia)) {
-        throw new ProducerFailure("MediaGeneratingProducerNode: value of '"+mediaEntityKey+"' is not an uploaded media EntityAdapter, but a " + entity.getClass().getName() + " adapter", null);
+        throw new ProducerExc("MediaGeneratingProducerNode: value of '"+mediaEntityKey+"' is not an uploaded media EntityAdapter, but a " + entity.getClass().getName() + " adapter");
       }
 
-      currentMediaType = DatabaseUploadedMedia.getInstance().getMediaType(entity);
+      uploadedMediaEntity = (EntityUploadedMedia) entity;
+
+      mediaType = DatabaseUploadedMedia.getInstance().getMediaType(entity);
 
-      currentMediaHandler = MediaHelper.getHandler( currentMediaType );
-      currentMediaHandler.produce(entity,currentMediaType);
+      currentMediaHandler = MediaHelper.getHandler( mediaType );
+      currentMediaHandler.produce(entity, mediaType);
       entity.setValueForProperty("publish_server", currentMediaHandler.getPublishHost());
       entity.setValueForProperty("icon_is_produced", "1");
       entity.setValueForProperty("is_produced", "1");
       entity.update();
-    }
-    catch (Throwable t) {
-      aLogger.println("Error while generating media: " + t.getMessage());
-      t.printStackTrace(aLogger);
 
-      throw new ProducerFailure(t.getMessage(), t);
+      aLogger.println("media with id "+uploadedMediaEntity.getValue("id") + ", mediaType " + mediaType.getValue("name") + " successfully produced");
     }
-  }
-}
-
-
-/*
-
-
-  abstract Database getStorage() throws StorageObjectException;
-
-  public void handle(PrintWriter htmlout, EntityUsers user, boolean force,
-    boolean sync) throws StorageObjectException, ModuleException {
-    handle(htmlout,user,force,sync,null);
-  }
-
-  public void handle(PrintWriter htmlout,EntityUsers user,boolean force,
-    boolean sync, String id) throws StorageObjectException, ModuleException
-  {
-    long                sessionConnectTime = 0;
-    long                startTime = (new java.util.Date()).getTime();
-    String              whereClause;
-    String              orderBy;
-    Entity              currentMedia;
-    MirMedia            currentMediaHandler;
-    EntityList          batchEntityList;
-
-    int contentBatchsize =
-            Integer.parseInt(MirConfig.getProp("Producer.Content.Batchsize"));
-    orderBy = "date desc, webdb_lastchange desc";
-
-    // get batch of non-produced medias, that are to be published
-    whereClause="is_published='1'";
-    if (id!= null) {
-      whereClause += " and id="+id;
-      // optimization to avoid select count(*)..
-      contentBatchsize = -1;
-    }
-    if (force==false) whereClause += " and is_produced='0'";
-
-    batchEntityList = getStorage().selectByWhereClause(whereClause,
-                                                orderBy, 0, contentBatchsize);
-
-    while (batchEntityList != null) {
-      for(int i=0;i<batchEntityList.size();i++) {
-        currentMedia = (Entity)batchEntityList.elementAt(i);
-        try {
-          Entity currentMediaType =
-                DatabaseUploadedMedia.getInstance().getMediaType(currentMedia);
-          currentMediaHandler = MediaHelper.getHandler( currentMediaType );
-
-          // now produce
-          currentMediaHandler.produce(currentMedia,currentMediaType);
-          currentMedia.setValueForProperty("publish_server",
-                                        currentMediaHandler.getPublishHost());
-          currentMedia.setValueForProperty("icon_is_produced", "1");
-          currentMedia.setValueForProperty("is_produced", "1");
-          currentMedia.update();
-          logHTML(htmlout,"produced media id "+currentMedia.getId()
-                  +": "+currentMediaType.getValue("mime_type")+" success");
-        } catch (Exception e) {
-          // don't throw and exception here, just log.
-          // we don't want to make the admin interface unuseable
-          theLog.printError("media exception: "+currentMedia.getId()+
-                            e.toString());
-          logHTML(htmlout, "problem with media id: "+currentMedia.getId()+
-                  " <font color=\"Red\"> failed!</font>: "+e.toString());
-          e.printStackTrace(htmlout);
+    catch (Throwable t) {
+      String message = "Error while generating media";
+      try {
+        if (uploadedMediaEntity!=null)
+          message = message +  " with id "+uploadedMediaEntity.getValue("id");
+        if (mediaType!=null) {
+          message = message + ", mediaType " + mediaType.getValue("name");
         }
       }
-
-      // if next batch get it...
-      if (batchEntityList.hasNextBatch()){
-        batchEntityList = uploadedMediaModule.getByWhereClause(whereClause,
-          orderBy, batchEntityList.getNextBatch(),contentBatchsize);
-      } else {
-        batchEntityList=null;
+      catch (Throwable s) {
       }
+
+      message = message + ": " + t.getMessage();
+      aLogger.println(message);
     }
-    // Finish
-    sessionConnectTime = new java.util.Date().getTime() - startTime;
-    logHTML(htmlout, "Producer.Media finished: " + sessionConnectTime + " ms.");
   }
-*/
+}
+
index 2630d0d..ff7d0f1 100755 (executable)
@@ -41,22 +41,26 @@ import mircoders.producer.*;
 
 public class SupplementalProducerNodeBuilders {
 
-  public static void registerBuilders(ProducerNodeBuilderLibrary aBuilderLibrary, EntityAdapterModel aModel) {
+  public static void registerBuilders(ProducerNodeBuilderLibrary aBuilderLibrary, EntityAdapterModel aModel) throws ProducerConfigExc {
     aBuilderLibrary.registerBuilder("ModifyContent", ContentModifyingProducerNodeBuilder.class);
-    aBuilderLibrary.registerBuilder("MarkContent", ContentMartkingProducerNodeBuilder.class);
+    aBuilderLibrary.registerBuilder("MarkContent", ContentMarkingProducerNodeBuilder.class);
+    aBuilderLibrary.registerBuilder("GenerateMedia", MediaGeneratingProducerNodeBuilder.class);
+
+
     aBuilderLibrary.registerBuilder("PDFPreFormat", PDFPreFormattingProducerNodeBuilder.class);
     aBuilderLibrary.registerBuilder("PDFGenerate", PDFGeneratingProducerNodeBuilder.class);
   }
 
-  public static class ContentMartkingProducerNodeBuilder extends DefaultProducerNodeBuilders.AbstractProducerNodeBuilder {
-    private final static String   MARKER_KEY_ATTRIBUTE = DefaultProducerNodeBuilders.KEY_ATTRIBUTE;
-    private final static String[] MARKER_REQUIRED_ATTRIBUTES = { MARKER_KEY_ATTRIBUTE };
-    private final static String[] MARKER_OPTIONAL_ATTRIBUTES = {};
-    private final static String[] MARKER_SUBNODES = {};
+  private final static String   MARKER_KEY_ATTRIBUTE = DefaultProducerNodeBuilders.KEY_ATTRIBUTE;
+  private final static String[] MARKER_REQUIRED_ATTRIBUTES = { MARKER_KEY_ATTRIBUTE };
+  private final static String[] MARKER_OPTIONAL_ATTRIBUTES = {};
+  private final static String[] MARKER_SUBNODES = {};
+
+  public static class ContentMarkingProducerNodeBuilder extends DefaultProducerNodeBuilders.AbstractProducerNodeBuilder {
 
     private String key;
 
-    public ContentMartkingProducerNodeBuilder() {
+    public ContentMarkingProducerNodeBuilder() {
       super(MARKER_SUBNODES);
     }
 
@@ -72,28 +76,29 @@ public class SupplementalProducerNodeBuilders {
   }
 
 
+  private final static String   CONTENT_MODIFIER_KEY_ATTRIBUTE = DefaultProducerNodeBuilders.KEY_ATTRIBUTE;
+  private final static String   CONTENT_MODIFIER_FIELD_ATTRIBUTE = "field";
+  private final static String   CONTENT_MODIFIER_VALUE_ATTRIBUTE = "value";
+  private final static String[] CONTENT_MODIFIER_REQUIRED_ATTRIBUTES = { CONTENT_MODIFIER_KEY_ATTRIBUTE, CONTENT_MODIFIER_FIELD_ATTRIBUTE, CONTENT_MODIFIER_VALUE_ATTRIBUTE };
+  private final static String[] CONTENT_MODIFIER_OPTIONAL_ATTRIBUTES = {};
+  private final static String[] CONTENT_MODIFIER_SUBNODES = {};
+
   public static class ContentModifyingProducerNodeBuilder extends DefaultProducerNodeBuilders.AbstractProducerNodeBuilder {
-    private final static String   MODIFYER_KEY_ATTRIBUTE = DefaultProducerNodeBuilders.KEY_ATTRIBUTE;
-    private final static String   MODIFYER_FIELD_ATTRIBUTE = "field";
-    private final static String   MODIFYER_VALUE_ATTRIBUTE = "value";
-    private final static String[] MODIFYER_REQUIRED_ATTRIBUTES = { MODIFYER_KEY_ATTRIBUTE, MODIFYER_FIELD_ATTRIBUTE, MODIFYER_VALUE_ATTRIBUTE };
-    private final static String[] MODIFYER_OPTIONAL_ATTRIBUTES = {};
-    private final static String[] MODIFYER_SUBNODES = {};
 
     private String key;
     private String field;
     private String value;
 
     public ContentModifyingProducerNodeBuilder() {
-      super(MODIFYER_SUBNODES);
+      super(CONTENT_MODIFIER_SUBNODES);
     }
 
     public void setAttributes(Map anAttributes) throws ProducerConfigExc {
-      ReaderTool.checkAttributes(anAttributes, MODIFYER_REQUIRED_ATTRIBUTES, MODIFYER_OPTIONAL_ATTRIBUTES);
+      ReaderTool.checkAttributes(anAttributes, CONTENT_MODIFIER_REQUIRED_ATTRIBUTES, CONTENT_MODIFIER_OPTIONAL_ATTRIBUTES);
 
-      key = (String) anAttributes.get(MODIFYER_KEY_ATTRIBUTE);
-      field = (String) anAttributes.get(MODIFYER_FIELD_ATTRIBUTE);
-      value = (String) anAttributes.get(MODIFYER_VALUE_ATTRIBUTE);
+      key = (String) anAttributes.get(CONTENT_MODIFIER_KEY_ATTRIBUTE);
+      field = (String) anAttributes.get(CONTENT_MODIFIER_FIELD_ATTRIBUTE);
+      value = (String) anAttributes.get(CONTENT_MODIFIER_VALUE_ATTRIBUTE);
     };
 
     public ProducerNode constructNode() {
@@ -101,6 +106,30 @@ public class SupplementalProducerNodeBuilders {
     };
   }
 
+  private final static String   MEDIA_KEY_ATTRIBUTE = DefaultProducerNodeBuilders.KEY_ATTRIBUTE;
+  private final static String[] MEDIA_REQUIRED_ATTRIBUTES = { MEDIA_KEY_ATTRIBUTE };
+  private final static String[] MEDIA_OPTIONAL_ATTRIBUTES = {};
+  private final static String[] MEDIA_SUBNODES = {};
+
+  public static class MediaGeneratingProducerNodeBuilder extends DefaultProducerNodeBuilders.AbstractProducerNodeBuilder {
+
+    private String key;
+
+    public MediaGeneratingProducerNodeBuilder() {
+      super(MEDIA_SUBNODES);
+    }
+
+    public void setAttributes(Map anAttributes) throws ProducerConfigExc {
+      ReaderTool.checkAttributes(anAttributes, MEDIA_REQUIRED_ATTRIBUTES, MEDIA_OPTIONAL_ATTRIBUTES);
+
+      key = (String) anAttributes.get(MEDIA_KEY_ATTRIBUTE);
+    };
+
+    public ProducerNode constructNode() {
+      return new MediaGeneratingProducerNode(key);
+    };
+  }
+
   public static class PDFPreFormattingProducerNodeBuilder extends DefaultProducerNodeBuilders.AbstractProducerNodeBuilder {
     private final static String   MARKER_KEY_ATTRIBUTE = DefaultProducerNodeBuilders.KEY_ATTRIBUTE;
     private final static String   PDF_NUM_LINES_ATTRIBUTE = "numLinesBetweenImages";
@@ -141,7 +170,7 @@ public class SupplementalProducerNodeBuilders {
     };
   }
 
-public static class PDFGeneratingProducerNodeBuilder extends DefaultProducerNodeBuilders.AbstractProducerNodeBuilder {
+  public static class PDFGeneratingProducerNodeBuilder extends DefaultProducerNodeBuilders.AbstractProducerNodeBuilder {
     private final static String   MARKER_KEY_ATTRIBUTE = DefaultProducerNodeBuilders.KEY_ATTRIBUTE;
     private final static String   PDF_GENERATOR_ATTRIBUTE = "generator";
     private final static String   PDF_DESTINATION_ATTRIBUTE = "destination";
@@ -171,13 +200,6 @@ public static class PDFGeneratingProducerNodeBuilder extends DefaultProducerNode
       return new PDFGeneratingProducerNode(generator,destination,stylesheet);
     };
   }
-
-
-/*
-  TODO:
-        [ ] Media Producing
-*/
-
 }
 
 
index b37a344..9321229 100755 (executable)
@@ -145,6 +145,7 @@ public class ServletModuleProducer extends ServletModule
       generator.generate(aResponse.getWriter(), generationData, new PrintWriter(new NullWriter()));
     }
     catch (Throwable t) {
+      t.printStackTrace(System.out);
       throw new ServletModuleException(t.getMessage());
     }
   }