-/*
- * 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
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
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
}\r
\r
\r
-
\ No newline at end of file
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);
}
}
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() {
}
}
catch (Throwable t) {
- throw new ProducerFailure(t.getMessage(), t);
+ aLogger.println("Exception occurred inside an EntityEnumeratingProducerNode: " + t.getMessage());
}
};
}
\ No newline at end of file
}
catch (Throwable t) {
aLogger.println(" error while generating: " + t.getClass().getName() + ": " + t.getMessage());
- t.printStackTrace(aLogger);
- aLogger.flush();
}
endTime = System.currentTimeMillis();
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);
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;
}
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) {
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) {
localizer = aLocalizer;
}
- public MirProducerLocalizer producers() throws MirLocalizerFailure, MirLocalizerException {
+ public MirProducerLocalizer producers() throws MirLocalizerFailure, MirLocalizerExc {
if (producerLocalizer==null) {
producerLocalizer = localizer.producers();
}
return producerLocalizer;
}
- public MirGeneratorLocalizer generators() throws MirLocalizerFailure, MirLocalizerException {
+ public MirGeneratorLocalizer generators() throws MirLocalizerFailure, MirLocalizerExc {
if (generatorLocalizer==null) {
generatorLocalizer = localizer.generators();
}
return generatorLocalizer;
}
- public MirOpenPostingLocalizer openPostings() throws MirLocalizerFailure, MirLocalizerException {
+ public MirOpenPostingLocalizer openPostings() throws MirLocalizerFailure, MirLocalizerExc {
if (openPostingsLocalizer==null) {
openPostingsLocalizer = localizer.openPostings();
}
return openPostingsLocalizer;
}
- public MirProducerAssistantLocalizer producerAssistant() throws MirLocalizerFailure, MirLocalizerException {
+ public MirProducerAssistantLocalizer producerAssistant() throws MirLocalizerFailure, MirLocalizerExc {
if (producerAssistantLocalizer==null) {
producerAssistantLocalizer = localizer.producerAssistant();
}
return producerAssistantLocalizer;
}
- public MirDataModelLocalizer dataModel() throws MirLocalizerFailure, MirLocalizerException {
+ public MirDataModelLocalizer dataModel() throws MirLocalizerFailure, MirLocalizerExc {
if (dataModelLocalizer==null) {
dataModelLocalizer = localizer.dataModel();
}
return dataModelLocalizer;
}
- public MirAdminInterfaceLocalizer adminInterface() throws MirLocalizerFailure, MirLocalizerException {
+ public MirAdminInterfaceLocalizer adminInterface() throws MirLocalizerFailure, MirLocalizerExc {
if (adminInterfaceLocalizer==null) {
adminInterfaceLocalizer = localizer.adminInterface();
}
-/*
- * 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
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
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
--- /dev/null
+/*
+ * 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
+++ /dev/null
-/*
- * 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
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;
}
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();
}
private Map simpleCommentOperations;
private Map simpleArticleOperations;
- public MirBasicAdminInterfaceLocalizer() throws MirLocalizerFailure, MirLocalizerException {
+ public MirBasicAdminInterfaceLocalizer() throws MirLocalizerFailure, MirLocalizerExc {
simpleCommentOperations = new HashMap();
simpleArticleOperations = new HashMap();
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());
};
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"));
}
}
};
- public Generator.GeneratorLibrary makeAdminGeneratorLibrary() throws MirLocalizerException, MirLocalizerFailure {
+ public Generator.GeneratorLibrary makeAdminGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {
try {
return repository.constructCompositeLibrary(MirGlobal.getConfigProperty("Mir.Localizer.Admin.GeneratorLibrary"));
}
}
};
- public Generator.GeneratorLibrary makeOpenPostingGeneratorLibrary() throws MirLocalizerException, MirLocalizerFailure {
+ public Generator.GeneratorLibrary makeOpenPostingGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {
try {
return repository.constructCompositeLibrary(MirGlobal.getConfigProperty("Mir.Localizer.OpenPosting.GeneratorLibrary"));
}
}
};
- public WriterEngine makeWriterEngine() throws MirLocalizerException, MirLocalizerFailure {
+ public WriterEngine makeWriterEngine() throws MirLocalizerExc, MirLocalizerFailure {
return new MirBasicWriterEngine(MirGlobal.getConfigProperty("Mir.DefaultEncoding"));
}
}
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();
}
return new MirBasicDataModelLocalizer();
};
- public MirAdminInterfaceLocalizer adminInterface() throws MirLocalizerFailure, MirLocalizerException {
+ public MirAdminInterfaceLocalizer adminInterface() throws MirLocalizerFailure, MirLocalizerExc {
return new MirBasicAdminInterfaceLocalizer();
};
}
}
- public List factories() throws MirLocalizerException {
+ public List factories() throws MirLocalizerExc {
if (fileMonitor==null || producerFactories == null || fileMonitor.hasChanged()) {
try {
List newProducers = new Vector();
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);
setupFactories(aFactories);
}
- protected void setupFactories(List aFactories) throws MirLocalizerException, MirLocalizerFailure {
+ protected void setupFactories(List aFactories) throws MirLocalizerExc, MirLocalizerFailure {
CompositeProducerNode node;
try {
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.");
}
-*/
+}
+
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);
}
}
+ 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() {
};
}
+ 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";
};
}
-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";
return new PDFGeneratingProducerNode(generator,destination,stylesheet);
};
}
-
-
-/*
- TODO:
- [ ] Media Producing
-*/
-
}
generator.generate(aResponse.getWriter(), generationData, new PrintWriter(new NullWriter()));
}
catch (Throwable t) {
+ t.printStackTrace(System.out);
throw new ServletModuleException(t.getMessage());
}
}