From: zapata Date: Fri, 25 Oct 2002 03:25:13 +0000 (+0000) Subject: - producer links are moved to an "advanced" page, not intended for normal X-Git-Tag: BEFORE_MERGE_1_1~492 X-Git-Url: http://erislabs.net/gitweb/?p=mir.git;a=commitdiff_plain;h=5b2d2279e1d26546a38c5cd3ba3e4f72192e351b - producer links are moved to an "advanced" page, not intended for normal users. Normal users have only 1 link "generate all new" - used br1's support for log4j at 1 place (ServletModuleDispatch) - misc. small changes/fixes here and there --- diff --git a/bundles/admin_en.properties b/bundles/admin_en.properties index 6cebf698..cac3bb9a 100755 --- a/bundles/admin_en.properties +++ b/bundles/admin_en.properties @@ -1,6 +1,6 @@ ########## admin ########## # language: english -# $Id: admin_en.properties,v 1.21 2002/10/20 03:22:44 maulwurf Exp $ +# $Id: admin_en.properties,v 1.22 2002/10/25 03:25:13 zapata Exp $ # general yes=yes @@ -229,21 +229,11 @@ start.content.with_media=with media start.content.last_changes=latest changes start.content.with_comments=with internal comments start.content.search=search -start.generate.title=GENERATE MANUALLY -start.generate.all.title=all areas -start.generate.all.new=all new (standard, update to www > 5min.) -start.generate.parts.title=specific parts of the site -start.generate.startpages.new=new startpage -start.generate.all_forced=all (forced) -start.generate.all_sync=all (forced + sync) -start.generate.content.new=new content -start.generate.topics.new=new topics -start.generate.postings.new=new openpostings -start.generate.images.new=new images -start.generate.audio.new=new audio files -start.generate.video.new=new video files -start.generate.other.new=new other media -start.generate.navigation=navigation + +start.producers.title=GENERATE MANUALLY +start.producers.produceAllNew=Generate all new +start.producers.advanced=Advanced page (use with care!) + start.coverage.title=COVERAGE start.topics.title=TOPICS start.images.title=PICTURES @@ -285,14 +275,36 @@ head.logged_in=logged in foot.top=top + + +producer.producer = Producer name +producer.verb.name = Task name +producer.verb.description = Task description +producer.verb.enqueue = enqueue + +producer.job.name = Job +producer.job.status = Status +producer.job.date = Last change +producer.job.cancel = cancel +producer.job.abort = abort + +producer.jobqueue.title = Current jobs +producer.jobqueue.refresh = refresh +producer.producerlist.title = Add a new job + + + ########## error ########## -error.htmltitle=the system is the error -error.title=OOPS! -error.text=That can happen. Even if the following error message may not be very useful to you, it could be very helpful for {1}: -error.text2=So please send a mail with the red text and a detailed error description to {1}. Thanks! +error.htmltitle=the system caused an error +error.title=The system caused an error +error.text=This can happen. Even if the following error message is not be comprehensible for you, it might be helpful to {1}: +error.text2=So please send an e-mail with the red text and detailed information regarding the events that led to this error to {1}. Thanks! -usererror.htmltitle=input error -usererror.title=OOPS! +usererror.htmltitle=validation error +usererror.title=Validation error usererror.text=Your input caused the following error: usererror.what_to_do=Please press the back button and try it again + +infomessage.title = Information +infomessage.produceAllNewAddedToQueue = Your request has been added to the queue. diff --git a/etc/config.properties-dist b/etc/config.properties-dist index e8775a7d..a017bdc1 100755 --- a/etc/config.properties-dist +++ b/etc/config.properties-dist @@ -47,6 +47,10 @@ Mir.Version=1.1beta StandardLanguage=de DirectOpenposting=yes +Log.LogClass = mir.log.log4j.LoggerImpl +Log.log4j.ConfigurationFile = etc/log4j.properties +Log.Home = log + Mir.Localizer=mircoders.localizer.basic.MirBasicLocalizer Mir.Localizer.Logfile=log/localizer.log @@ -59,8 +63,14 @@ Mir.Localizer.Admin.GeneratorLibrary= default=freemarker(templates/admin/) Mir.Localizer.OpenPosting.GeneratorLibrary= default=freemarker(etc/open/) # Which producers need to be called after an article (resp. a comment) is posted -Mir.Localizer.OpenPosting.ContentProducers= media.new;articles.new;startpage.new;synchronization.run -Mir.Localizer.OpenPosting.CommentProducers= articles.new;synchronization.run +Mir.Localizer.OpenPosting.ContentProducers= media.new;articles.changed;startpage.generate;synchronization.run +Mir.Localizer.OpenPosting.CommentProducers= articles.changed;synchronization.run + +# Which producers need to be called after the "produce all new" link is clicked +from admin +Mir.Localizer.Producer.AllNewProducers= media.new;articles.changed;startpage.run;syn +chronization.run + #note that you can't make pdf's without making fo's GenerateFO=yes diff --git a/etc/log4j.properties b/etc/log4j.properties index 5fe42d85..72ffb6e2 100755 --- a/etc/log4j.properties +++ b/etc/log4j.properties @@ -1,9 +1,15 @@ -# Set root logger level to DEBUG and its only appender to A1. -log4j.rootLogger=DEBUG, A1 -# A1 is set to be a ConsoleAppender. +log4j.rootLogger= DEBUG, A1 +log4j.logger.servlet= INFO, ServletA + log4j.appender.A1=org.apache.log4j.ConsoleAppender +log4j.appender.ServletA=org.apache.log4j.RollingFileAppender +log4j.appender.ServletA.File=${log.home}/servlet.log + # A1 uses PatternLayout. log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n + +log4j.appender.ServletA.layout=org.apache.log4j.PatternLayout +log4j.appender.ServletA.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n diff --git a/etc/producer/producers.xml b/etc/producer/producers.xml index 934e668d..a5e6a298 100755 --- a/etc/producer/producers.xml +++ b/etc/producer/producers.xml @@ -242,8 +242,6 @@ - - + + + + + + + + + + + + + + + diff --git a/source/Mir.java b/source/Mir.java index ea6ddaa0..5ac36ec8 100755 --- a/source/Mir.java +++ b/source/Mir.java @@ -66,10 +66,16 @@ import mir.log.Log; /** * Mir.java - main servlet, that dispatches to servletmodules * - * @author $Author: bruno $ - * @version $Revision: 1.20 $ $Date: 2002/10/09 16:09:05 $ + * @author $Author: zapata $ + * @version $Revision: 1.21 $ $Date: 2002/10/25 03:25:13 $ * * $Log: Mir.java,v $ + * Revision 1.21 2002/10/25 03:25:13 zapata + * - producer links are moved to an "advanced" page, not intended for normal + * users. Normal users have only 1 link "generate all new" + * - used br1's support for log4j at 1 place (ServletModuleDispatch) + * - misc. small changes/fixes here and there + * * Revision 1.20 2002/10/09 16:09:05 bruno * contains only admin templates which should not be changed by users * @@ -229,10 +235,10 @@ public class Mir extends AbstractServlet { } catch (ServletModuleException e) { handleError(req, res, res.getWriter(), - "ServletException in Module " + moduleName + " -- " + e.toString()); + "ServletException in Module " + moduleName + " -- " + e.getMessage()); } catch (ServletModuleUserException e) { - handleUserError(req, res, res.getWriter(), e.getMsg()); + handleUserError(req, res, res.getWriter(), e.getMessage()); } // timing... @@ -272,7 +278,7 @@ public class Mir extends AbstractServlet { } catch (Exception e) { throw new ServletModuleException("*** error resolving classname for " + - moduleName + " -- " + e.toString()); + moduleName + " -- " + e.getMessage()); } } else @@ -292,7 +298,8 @@ public class Mir extends AbstractServlet { out.close(); } catch (Exception e) { - System.err.println("Error in ErrorTemplate"); + e.printStackTrace(System.out); + System.err.println("Error in ErrorTemplate: " + e.getMessage()); } } @@ -308,7 +315,7 @@ public class Mir extends AbstractServlet { out.close(); } catch (Exception e) { - System.err.println("Fehler in UserErrorTemplate"); + System.err.println("Error in UserErrorTemplate"); } } @@ -322,7 +329,7 @@ public class Mir extends AbstractServlet { return usersModule.getUserForLogin(user, password); } catch (Exception e) { - theLog.printDebugInfo(e.toString()); + theLog.printDebugInfo(e.getMessage()); e.printStackTrace(); return null; } @@ -361,6 +368,7 @@ public class Mir extends AbstractServlet { mergeData.put("articletypes", DatabaseArticleType.getInstance().selectByWhereClause("", "id", 0, 20)); +/* SimpleList producersData = new SimpleList(); Iterator i = MirGlobal.localizer().producers().factories().entrySet().iterator(); while (i.hasNext()) { @@ -379,14 +387,14 @@ public class Mir extends AbstractServlet { producersData.add(producerData); } mergeData.put("producers", producersData); - + */ HTMLTemplateProcessor.process(res, startTemplate, mergeData, out, getLocale(req)); } catch (Exception e) { e.printStackTrace(System.out); - handleError(req, res, out, "error while trying to send startpage. " + e.toString()); + handleError(req, res, out, "error while trying to send startpage. " + e.getMessage()); } } diff --git a/source/OpenMir.java b/source/OpenMir.java index aeefb126..2c6f0920 100755 --- a/source/OpenMir.java +++ b/source/OpenMir.java @@ -99,11 +99,11 @@ public class OpenMir extends AbstractServlet { ServletModuleDispatch.dispatch(ServletModuleOpenIndy.getInstance(),req,res); } catch (ServletModuleUserException e) { - handleUserError(req,res,res.getWriter(), e.getMsg()); + handleUserError(req,res,res.getWriter(), e.getMessage()); } catch (ServletModuleException e){ e.printStackTrace(); - handleError(req,res,res.getWriter(), "OpenIndy :: ServletException in Module ServletModule -- " + e.toString()); + handleError(req,res,res.getWriter(), "OpenIndy :: ServletException in Module ServletModule -- " + e.getMessage()); } // timing... sessionConnectTime = new java.util.Date().getTime() - startTime; @@ -122,7 +122,7 @@ public class OpenMir extends AbstractServlet { out.close(); } catch (Exception e) { - System.err.println("Fehler in UserErrorTemplate"); + System.err.println("Error in UserErrorTemplate"); } } @@ -140,7 +140,7 @@ public class OpenMir extends AbstractServlet { out.close(); } catch (Exception e) { - System.err.println("Fehler in ErrorTemplate"); + System.err.println("Error in ErrorTemplate"); } } diff --git a/source/mir/log/Logger.java b/source/mir/log/Logger.java index 8468fde1..9f1f4a1b 100755 --- a/source/mir/log/Logger.java +++ b/source/mir/log/Logger.java @@ -2,9 +2,9 @@ package mir.log; public interface Logger { - public void debug( Object o, String s); - public void info( Object o, String s); - public void warn( Object o, String s); - public void error( Object o, String s); - public void fatal( Object o, String s); + public void debug( Object o, String s); + public void info( Object o, String s); + public void warn( Object o, String s); + public void error( Object o, String s); + public void fatal( Object o, String s); } diff --git a/source/mir/log/LoggerWrapper.java b/source/mir/log/LoggerWrapper.java new file mode 100755 index 00000000..7912c50b --- /dev/null +++ b/source/mir/log/LoggerWrapper.java @@ -0,0 +1,30 @@ +package mir.log; + +public class LoggerWrapper { + private Object object; + + public LoggerWrapper( Object anObject ) { + object = anObject; + } + + public void debug( String aMessage ) { + Log.debug(object, aMessage); + }; + + public void info( String aMessage ) { + Log.info(object, aMessage); + }; + + public void warn( String aMessage ) { + Log.warn(object, aMessage); + }; + + + public void error( String aMessage ) { + Log.error(object, aMessage); + }; + + public void fatal( String aMessage ) { + Log.fatal(object, aMessage); + }; +} \ No newline at end of file diff --git a/source/mir/log/log4j/LoggerImpl.java b/source/mir/log/log4j/LoggerImpl.java index 298a6d92..d821f5cc 100755 --- a/source/mir/log/log4j/LoggerImpl.java +++ b/source/mir/log/log4j/LoggerImpl.java @@ -6,13 +6,16 @@ import org.apache.log4j.Logger; import java.util.Map; import java.util.HashMap; +import mir.misc.MirConfig; + public class LoggerImpl implements mir.log.Logger { private static Map loggers = new HashMap(); public LoggerImpl() { - PropertyConfigurator.configure("log4j.properties"); + System.setProperty("log.home", MirConfig.getPropWithHome("Log.Home")); + PropertyConfigurator.configure(MirConfig.getPropWithHome("Log.log4j.ConfigurationFile").trim()); } @@ -39,7 +42,10 @@ public class LoggerImpl implements mir.log.Logger { private Logger getLogger( Object o ) { String name; - if (o instanceof Class) { + + if (o instanceof String) { + name = (String) o; + } else if (o instanceof Class) { name = ((Class)o).getName(); } else if (o!=null) { name = o.getClass().getName(); diff --git a/source/mir/producer/AssignmentProducerNode.java b/source/mir/producer/AssignmentProducerNode.java index af35ad10..37bb08c8 100755 --- a/source/mir/producer/AssignmentProducerNode.java +++ b/source/mir/producer/AssignmentProducerNode.java @@ -58,5 +58,4 @@ public class AssignmentProducerNode extends ProducerNodeDecorator { throw new ProducerFailure(t.getMessage(), t); } }; - } \ No newline at end of file diff --git a/source/mir/producer/CompositeProducerNode.java b/source/mir/producer/CompositeProducerNode.java index b1dd3765..29c54508 100755 --- a/source/mir/producer/CompositeProducerNode.java +++ b/source/mir/producer/CompositeProducerNode.java @@ -68,22 +68,19 @@ public class CompositeProducerNode implements ProducerNode { subNodes.clear(); } - public void produce(Map aValueSet, String aVerb, PrintWriter aLogger) throws ProducerFailure, ProducerExc { - Iterator i = subNodes.iterator(); - - while (i.hasNext()) { - ProducerNode node = (ProducerNode) i.next(); - node.produce(aValueSet, aVerb, aLogger); - } + protected boolean isAborted(Map aValueMap) { + Object producerValue = aValueMap.get(NodedProducer.PRODUCER_KEY); + return ( + (producerValue instanceof NodedProducer) && + ((NodedProducer) producerValue).getIsAborted()); } - public Set buildVerbSet() { + public void produce(Map aValueMap, String aVerb, PrintWriter aLogger) throws ProducerFailure, ProducerExc { Iterator i = subNodes.iterator(); - Set result = new HashSet(); - while (i.hasNext()) - result.addAll(((ProducerNode) i.next()).buildVerbSet()); - - return result; + while (i.hasNext() && !isAborted(aValueMap)) { + ProducerNode node = (ProducerNode) i.next(); + node.produce(aValueMap, aVerb, aLogger); + } } } \ No newline at end of file diff --git a/source/mir/producer/ConditionalProducerNode.java b/source/mir/producer/ConditionalProducerNode.java index 6d5430f9..85e7eb28 100755 --- a/source/mir/producer/ConditionalProducerNode.java +++ b/source/mir/producer/ConditionalProducerNode.java @@ -61,8 +61,4 @@ public class ConditionalProducerNode implements ProducerNode { throw new ProducerFailure(e); } } - - public Set buildVerbSet() { - return new HashSet(); - } } \ No newline at end of file diff --git a/source/mir/producer/DirCopyingProducerNode.java b/source/mir/producer/DirCopyingProducerNode.java index c943c989..13d13b3c 100755 --- a/source/mir/producer/DirCopyingProducerNode.java +++ b/source/mir/producer/DirCopyingProducerNode.java @@ -64,8 +64,4 @@ public class DirCopyingProducerNode implements ProducerNode { throw new ProducerFailure("Copying " + source + " into " + destination + " failed: " + e.getMessage(), e); } } - - public Set buildVerbSet() { - return new HashSet(); - } } diff --git a/source/mir/producer/EntityBatchingProducerNode.java b/source/mir/producer/EntityBatchingProducerNode.java index fd8e8ba9..2f491158 100755 --- a/source/mir/producer/EntityBatchingProducerNode.java +++ b/source/mir/producer/EntityBatchingProducerNode.java @@ -39,8 +39,6 @@ import mir.storage.*; import mir.util.*; public class EntityBatchingProducerNode implements ProducerNode { - private Map verbs; - private String batchInfoKey; private String batchDataKey; private EntityAdapterModel model; @@ -50,7 +48,7 @@ public class EntityBatchingProducerNode implements ProducerNode { private String nrEntitiesToSkipExpression; private String nrEntitiesPerBatchExpression; private String minNrEntitiesInFirstBatchExpression; - private String defaultNrBatchesToProcessExpression; + private String nrBatchesToProcessExpression; private ProducerNode batchSubNode; private ProducerNode batchListSubNode; @@ -61,57 +59,16 @@ public class EntityBatchingProducerNode implements ProducerNode { String aDefinition, String aWhereClause, String anOrderByClause, - int anrEntitiesPerBatchExpression, - int aminNrEntitiesInFirstBatchExpression, - int anrEntitiesToSkipExpression, - ProducerNode aBatchSubNode) { - this(aBatchDataKey, aBatchInfoKey, aModel, aDefinition, aWhereClause, - anOrderByClause, anrEntitiesPerBatchExpression, aminNrEntitiesInFirstBatchExpression, anrEntitiesToSkipExpression, - aBatchSubNode, null); - } - - public EntityBatchingProducerNode( - String aBatchDataKey, - String aBatchInfoKey, - EntityAdapterModel aModel, - String aDefinition, - String aWhereClause, - String anOrderByClause, - int aNrEntitiesPerBatch, - int aMinNrEntitiesInFirstBatch, - int aNrEntitiesToSkip, - ProducerNode aBatchSubNode, - ProducerNode aBatchListSubNode) { - - this(aBatchDataKey, aBatchInfoKey, aModel, aDefinition, - aWhereClause, anOrderByClause, - Integer.toString(aNrEntitiesPerBatch), - Integer.toString(aMinNrEntitiesInFirstBatch), - Integer.toString(aNrEntitiesToSkip), - "1", - aBatchSubNode, aBatchListSubNode); - - } - - public EntityBatchingProducerNode( - String aBatchDataKey, - String aBatchInfoKey, - EntityAdapterModel aModel, - String aDefinition, - String aWhereClause, - String anOrderByClause, String anrEntitiesPerBatchExpression, String aminNrEntitiesInFirstBatchExpression, String anrEntitiesToSkipExpression, - String aDefaultNrBatchesToProcessExpression, + String aNrBatchesToProcessExpression, ProducerNode aBatchSubNode, ProducerNode aBatchListSubNode) { batchSubNode = aBatchSubNode; batchListSubNode = aBatchListSubNode; - verbs = new HashMap(); - batchDataKey = aBatchDataKey; batchInfoKey = aBatchInfoKey; model = aModel; @@ -121,7 +78,14 @@ public class EntityBatchingProducerNode implements ProducerNode { nrEntitiesToSkipExpression = anrEntitiesToSkipExpression; nrEntitiesPerBatchExpression = anrEntitiesPerBatchExpression; minNrEntitiesInFirstBatchExpression = aminNrEntitiesInFirstBatchExpression; - defaultNrBatchesToProcessExpression = aDefaultNrBatchesToProcessExpression; + nrBatchesToProcessExpression = aNrBatchesToProcessExpression; + } + + protected boolean isAborted(Map aValueMap) { + Object producerValue = aValueMap.get(NodedProducer.PRODUCER_KEY); + return ( + (producerValue instanceof NodedProducer) && + ((NodedProducer) producerValue).getIsAborted()); } public void produce(Map aValueMap, String aVerb, PrintWriter aLogger) throws ProducerFailure { @@ -136,7 +100,6 @@ public class EntityBatchingProducerNode implements ProducerNode { Map batchData; String expandedWhereClause; String expandedOrderByClause; - EntityBatchingProducerNodeVerb verb = (EntityBatchingProducerNodeVerb) verbs.get(aVerb); List batchLocations; BatchLocation location; @@ -150,12 +113,7 @@ public class EntityBatchingProducerNode implements ProducerNode { try { - if (verb==null) { - nrBatchesToProcess = ParameterExpander.evaluateIntegerExpressionWithDefault( aValueMap, defaultNrBatchesToProcessExpression, -1 ); - } - else { - nrBatchesToProcess=verb.nrBatchesToProcess; - } + nrBatchesToProcess = ParameterExpander.evaluateIntegerExpressionWithDefault( aValueMap, nrBatchesToProcessExpression, -1 ); expandedWhereClause = ParameterExpander.expandExpression( aValueMap, whereClause ); expandedOrderByClause = ParameterExpander.expandExpression( aValueMap, orderByClause ); @@ -196,7 +154,7 @@ public class EntityBatchingProducerNode implements ProducerNode { batchData.put("last", batchesData.get(batchesData.size()-1)); batchData.put("count", new Integer(batchesData.size())); - if (batchListSubNode!=null) { + if (batchListSubNode!=null && (!isAborted(aValueMap))) { batchListSubNode.produce(aValueMap, aVerb, aLogger); } @@ -205,7 +163,7 @@ public class EntityBatchingProducerNode implements ProducerNode { } if (batchSubNode!=null) { - for (i=0; ido auf. - * Ist kein Parameter angegeben, so wird versucht, in die defaultAction - * des ServletModules zu springen. - * - * @param req Http-Request, das vom Dispatcher an die Methode des - * ServletModules durchgereicht wird - * @param res Http-Response, die vom Dispatcher an die Methode des - * ServletModules durchgereicht wird - * @param sMod ServletModule, an das dispatched wird. - * @param mod Name des Modules als String (für Logfile) - */ + /** + * Die Dispatch-Routine ruft das von dem Hauptservlet kommende ServletModule + * mit dem per HttpServletRequest angegebenen Paramter do auf. + * Ist kein Parameter angegeben, so wird versucht, in die defaultAction + * des ServletModules zu springen. + * + * @param req Http-Request, das vom Dispatcher an die Methode des + * ServletModules durchgereicht wird + * @param res Http-Response, die vom Dispatcher an die Methode des + * ServletModules durchgereicht wird + * @param sMod ServletModule, an das dispatched wird. + * @param mod Name des Modules als String (für Logfile) + */ - public static void dispatch(ServletModule sMod, HttpServletRequest req, - HttpServletResponse res) throws ServletModuleException, ServletModuleUserException - { - //sMod.predeliver(req,res); + public static void dispatch(ServletModule sMod, HttpServletRequest req, + HttpServletResponse res) throws ServletModuleException, ServletModuleUserException + { + //sMod.predeliver(req,res); - String doParam = req.getParameter("do"); - theLog.printInfo("SerletModuleDispatch: " + sMod.toString() + " with method " + doParam); - if (doParam == null) { - if (sMod.defaultAction() != null) doParam = sMod.defaultAction(); - else throw new ServletModuleException("no parameter do supplied!"); - } + String doParam = req.getParameter("do"); + logger.info("ServletModuleDispatch: " + sMod.toString() + " with method " + doParam); + if (doParam == null) { + if (sMod.defaultAction() != null) + doParam = sMod.defaultAction(); + else + throw new ServletModuleException("no parameter do supplied!"); + } - try { - Method method = sMod.getClass().getMethod(doParam,SIGNATURE); - if (method != null) { - method.invoke(sMod,new Object[] {req,res} ); - return; - } - else theLog.printDebugInfo("method lookup unsuccesful"); - } - catch ( NoSuchMethodException e) { throw new ServletModuleException("no such method!" + e.toString());} - catch ( SecurityException e) { throw new ServletModuleException("method not allowed!" + e.toString());} - catch ( InvocationTargetException e) { - if (e.getTargetException().getClass().getName().equals("mir.servlet.ServletModuleUserException")) { - throw new ServletModuleUserException(((ServletModuleUserException)e.getTargetException()).getMsg()); - } else { - e.printStackTrace(); - throw new ServletModuleException(e.getTargetException().toString()); - } - } - catch ( IllegalAccessException e) { throw new ServletModuleException("illegal method not allowed!" + e.toString());} + try { + Method method = sMod.getClass().getMethod(doParam,SIGNATURE); + if (method != null) { + method.invoke(sMod,new Object[] {req,res} ); + return; + } + else logger.debug("method lookup unsuccesful"); + } + catch ( NoSuchMethodException e) { + throw new ServletModuleException("no such method '"+doParam+"' (" + e.getMessage() + ")"); + } + catch ( SecurityException e) { + throw new ServletModuleException("method not allowed!" + e.getMessage()); + } + catch ( InvocationTargetException e) { + System.out.println(e.getMessage()); + if (e.getTargetException() instanceof ServletModuleUserException) { + throw new ServletModuleUserException(e.getTargetException().getMessage()); + } + else { + e.printStackTrace(); + throw new ServletModuleException(e.getTargetException().getMessage()); + } + } + catch ( IllegalAccessException e) { + throw new ServletModuleException("illegal method not allowed!" + e.getMessage()); + } - //hopefully we don't get here ... - throw new ServletModuleException("delivery failed! -- "); - } +//hopefully we don't get here ... + throw new ServletModuleException("delivery failed! -- "); + } } diff --git a/source/mir/servlet/ServletModuleUserException.java b/source/mir/servlet/ServletModuleUserException.java index a7673b8f..5b85287b 100755 --- a/source/mir/servlet/ServletModuleUserException.java +++ b/source/mir/servlet/ServletModuleUserException.java @@ -38,22 +38,15 @@ import java.lang.*; * Return an Exception with a simple String Message Method * Differentiates user errors from System bugs/errors. * - * + * * @version 02.2002 * @author mh */ public final class ServletModuleUserException extends Exception { - String msg; - public ServletModuleUserException(String msg) { super(msg); - this.msg = msg; - } - - public String getMsg() { - return msg; } } diff --git a/source/mircoders/global/JobQueue.java b/source/mircoders/global/JobQueue.java index ab23c0f8..34dd7b09 100755 --- a/source/mircoders/global/JobQueue.java +++ b/source/mircoders/global/JobQueue.java @@ -37,82 +37,158 @@ import java.util.*; public class JobQueue { private Vector jobs; + private Vector finishedJobs; private Map dataToJob; + private Map identifierToJob; + private int nrJobs; public static final int STATUS_PENDING = 0; public static final int STATUS_PROCESSING = 1; public static final int STATUS_PROCESSED = 2; + public static final int STATUS_CANCELLED = 3; + public static final int STATUS_ABORTED = 4; + + public static final int PRIORITY_NORMAL = 100; + public static final int PRIORITY_LOW = 10; + public static final int PRIORITY_HIGH = 1000; + + public static final int FINISHEDJOBS_LOGSIZE = 10; public JobQueue() { + finishedJobs = new Vector(); jobs = new Vector(); dataToJob = new HashMap(); + identifierToJob = new HashMap(); + nrJobs = 0; } - public void appendJob(Object aData) { + public String appendJob(Object aData) { synchronized (jobs) { - Job job = new Job(aData); + Job job = new Job(aData, Integer.toString(nrJobs)); + nrJobs++; jobs.add(job); dataToJob.put(aData, job); + identifierToJob.put(job.getIdentifier(), job); + return job.getIdentifier(); } } public Object acquirePendingJob() { synchronized (jobs) { - Iterator i = jobs.iterator(); + int priorityFound= 0; + Job jobFound; - while (i.hasNext()) { - Job job = (Job) i.next(); + do { + jobFound = null; + Iterator i = jobs.iterator(); + while (i.hasNext()) { + Job job = (Job) i.next(); - if (job.setProcessing()) { - return job.getData(); + if (job.isPending() && (jobFound==null || priorityFoundFINISHEDJOBS_LOGSIZE) + finishedJobs.remove(finishedJobs.size()-1); + } } - public void flagOffJob(Object aData) { + public void jobProcessed(Object aData) { synchronized (jobs) { Job job = (Job) dataToJob.get(aData); if (job!=null) { job.setProcessed(); + finishJob(job); } } } - public void cleanupJobs() { + public void jobAborted(Object aData) { synchronized (jobs) { - Iterator i = jobs.iterator(); + Job job = (Job) dataToJob.get(aData); - while (i.hasNext()) { - Job job = (Job) i.next(); + if (job!=null) { + job.setAborted(); + finishJob(job); + } + } + } - if (job.hasBeenProcessed()) { - i.remove(); - } + public void cancelJob(Object aData) { + synchronized (jobs) { + Job job = (Job) dataToJob.get(aData); + + if (job!=null && job.setCancelled()) { + finishJob(job); } } } + public void makeJobListSnapshots(List aJobList, List aFinishedJobList) { + synchronized (jobs) { + aJobList.addAll(makeJobListSnapshot()); + aFinishedJobList.addAll(makeFinishedJobListSnapshot()); + } + } + public List makeJobListSnapshot() { synchronized (jobs) { return (List) jobs.clone(); } } + public List makeFinishedJobListSnapshot() { + synchronized (jobs) { + return (List) finishedJobs.clone(); + } + } + public class Job implements Cloneable { private Object data; + private Date lastChange; + private String identifier; private int status; + private int priority; - public Job(Object aData, int aStatus) { + public Job(Object aData, String anIdentifier, int aStatus, int aPriority, Date aLastChange) { data = aData; status = aStatus; + identifier = anIdentifier; + priority = aPriority; + lastChange = aLastChange; + } + + public Job(Object aData, String anIdentifier, int aStatus, int aPriority) { + this(aData, anIdentifier, aStatus, aPriority, (new GregorianCalendar()).getTime()); + } + + public Date getLastChange() { + return lastChange; + } + + public String getIdentifier() { + return identifier; } - public Job(Object aData) { - this(aData, STATUS_PENDING); + public Job(Object aData, String anIdentifier) { + this(aData, anIdentifier, STATUS_PENDING, PRIORITY_NORMAL); } public Object getData() { @@ -125,6 +201,10 @@ public class JobQueue { } } + public int getPriority() { + return priority; + } + protected boolean setProcessing() { return setStatus(STATUS_PENDING, STATUS_PROCESSING); } @@ -133,10 +213,30 @@ public class JobQueue { setStatus(STATUS_PROCESSING, STATUS_PROCESSED); } + protected void setAborted() { + setStatus(STATUS_PROCESSING, STATUS_ABORTED); + } + + protected boolean setCancelled() { + return setStatus(STATUS_PENDING, STATUS_CANCELLED); + } + public boolean hasBeenProcessed() { return getStatus() == STATUS_PROCESSED; } + public boolean hasBeenAborted() { + return getStatus() == STATUS_ABORTED; + } + + public boolean isCancelled() { + return getStatus() == STATUS_CANCELLED; + } + + public boolean isFinished() { + return hasBeenProcessed() || hasBeenAborted() || isCancelled(); + } + public boolean isProcessing() { return getStatus() == STATUS_PROCESSING; } @@ -149,6 +249,7 @@ public class JobQueue { synchronized(this) { if (status == anOldStatus) { status = aNewStatus; + lastChange = (new GregorianCalendar()).getTime(); return true; } else { @@ -159,7 +260,8 @@ public class JobQueue { protected Object clone() { synchronized(this) { - return new Job(data, status); + System.out.println(" blabla"); + return new Job(data, identifier, status, priority, lastChange); } } } diff --git a/source/mircoders/global/ProducerEngine.java b/source/mircoders/global/ProducerEngine.java index 128a947b..20bbc5e3 100755 --- a/source/mircoders/global/ProducerEngine.java +++ b/source/mircoders/global/ProducerEngine.java @@ -45,7 +45,6 @@ public class ProducerEngine { private PrintWriter log; protected ProducerEngine() { -// producers = MirGlobal.localizer().producers().factories(); producerJobQueue = new JobQueue(); try { RandomAccessFile raFile = (new RandomAccessFile(MirGlobal.getConfigProperty("Home") + "/" + MirGlobal.getConfigProperty("Producer.Logfile"), "rw")); @@ -53,7 +52,6 @@ public class ProducerEngine { log = new PrintWriter(new FileWriter( raFile.getFD())); } catch (Exception e) { -// throw new ProducerEngineRuntimeExc("Creating PrintWriter log failed",e); log = new PrintWriter(new NullWriter()); } queueThread = new Thread(new ProducerJobQueueThread()); @@ -78,76 +76,82 @@ public class ProducerEngine { } } - public void printQueueStatus(PrintWriter aWriter) { - Iterator iterator = producerJobQueue.makeJobListSnapshot().iterator(); - producerJobQueue.cleanupJobs(); - JobQueue.Job job; - - while (iterator.hasNext()) { - job = (JobQueue.Job) iterator.next(); - ProducerJob producerJob = (ProducerJob) job.getData(); - - aWriter.print(producerJob.factoryName + "." + producerJob.verb); - if (job.hasBeenProcessed()) - aWriter.print(" processed"); - else if (job.isProcessing()) - aWriter.print(" processing"); - else if (job.isPending()) - aWriter.print(" pending"); - else - aWriter.print(" unknown status"); - - aWriter.println("
"); - } + private String convertStatus(JobQueue.Job aJob) { + if (aJob.hasBeenProcessed()) + return "processed"; + if (aJob.isProcessing()) + return "processing"; + if (aJob.isPending()) + return "pending"; + if (aJob.isCancelled()) + return "cancelled"; + if (aJob.hasBeenAborted()) + return "aborted"; + + return "unknown"; } - private void produceNow(String aProducerFactory, String aVerb, PrintWriter aLogger) { - try { - long startTime; - long endTime; - Map startingMap = new HashMap(); + private Map convertJob(JobQueue.Job aJob) { + Map result = new HashMap(); + ProducerJob producerJob = (ProducerJob) aJob.getData(); - startTime = System.currentTimeMillis(); + result.put("identifier", aJob.getIdentifier()); + result.put("factory", producerJob.getFactoryName()); + result.put("verb", producerJob.getVerb()); + result.put("priority", new Integer(aJob.getPriority())); + result.put("status", convertStatus(aJob)); + result.put("lastchange", new DateToMapAdapter(aJob.getLastChange())); - aLogger.println("Producing (" + aProducerFactory + "," + aVerb + ")"); + return result; + } - ProducerFactory factory = (ProducerFactory) MirGlobal.localizer().producers().factories().get(aProducerFactory); + private void convertJobList(List aSourceJobList, List aDestination) { + Iterator i = aSourceJobList.iterator(); - if (factory == null ) - throw new Exception("No producer factory '"+aProducerFactory+"' present."); + while (i.hasNext()) + aDestination.add(convertJob((JobQueue.Job) i.next())); + } - MirGlobal.localizer().producerAssistant().initializeGenerationValueSet(startingMap); - Producer producer = factory.makeProducer(aVerb, startingMap); + public List getQueueStatus() { + List result = new Vector(); + List pendingJobs = new Vector(); + List finishedJobs = new Vector(); - producer.produce(aLogger); + producerJobQueue.makeJobListSnapshots(pendingJobs, finishedJobs); - endTime = System.currentTimeMillis(); + convertJobList(pendingJobs, result); + convertJobList(finishedJobs, result); - aLogger.println("Time: " + (endTime-startTime) + " ms
"); - } - catch (Throwable e) { - try { - aLogger.println("exception occurred:
"); - aLogger.println(e.getMessage()); - e.printStackTrace(aLogger); - } - catch (Throwable f) { - } - } + return result; } - private class ProducerJob { +private class ProducerJob { private String factoryName; private String verb; + private Producer producer; public ProducerJob(String aFactory, String aVerb) { factoryName = aFactory; verb = aVerb; + producer=null; + } + + public String getFactoryName() { + return factoryName; + } + + public String getVerb() { + return verb; + } + + public void abort() { + if (producer!=null) { + producer.abort(); + } } public void execute() { ProducerFactory factory; - Producer producer; long startTime; long endTime; Map startingMap = new HashMap(); @@ -156,7 +160,7 @@ public class ProducerEngine { log.println("Producing job: "+factoryName+"."+verb); try { - factory = (ProducerFactory) MirGlobal.localizer().producers().factories().get( factoryName ); + factory = MirGlobal.localizer().producers().getFactoryForName( factoryName ); if (factory!=null) { MirGlobal.localizer().producerAssistant().initializeGenerationValueSet(startingMap); @@ -174,10 +178,13 @@ public class ProducerEngine { t.printStackTrace(log); } log.println("Done producing job: "+factoryName+"."+verb); - endTime = System.currentTimeMillis(); + endTime = System.currentTimeMillis(); + log.println("Time: " + (endTime-startTime) + " ms"); + log.flush(); + } - log.println("Time: " + (endTime-startTime) + " ms"); - log.flush(); + boolean isAborted() { + return false; } } @@ -190,7 +197,10 @@ public class ProducerEngine { ProducerJob job = (ProducerJob) producerJobQueue.acquirePendingJob(); if (job!=null) { job.execute(); - producerJobQueue.flagOffJob(job); + if (job.isAborted()) + producerJobQueue.jobAborted(job); + else + producerJobQueue.jobProcessed(job); } else { @@ -204,6 +214,11 @@ public class ProducerEngine { } } + public static class ProducerEngineExc extends Exc { + public ProducerEngineExc(String aMessage) { + super(aMessage); + } + } public static class ProducerEngineRuntimeExc extends Failure { public ProducerEngineRuntimeExc(String msg, Exception cause){ @@ -227,5 +242,23 @@ public class ProducerEngine { public String getProducer() { return producer; } + + public static List parseProducerTaskList(String aList) throws ProducerEngineExc { + Iterator i; + List result = new Vector(); + + i = StringRoutines.splitString(aList, ";").iterator(); + while (i.hasNext()) { + String taskExpression = (String) i.next(); + List parts = StringRoutines.splitString(taskExpression, "."); + + if (parts.size()!=2) + throw new ProducerEngineExc("Invalid producer expression: '" + taskExpression + "'"); + else + result.add(new ProducerEngine.ProducerTask((String) parts.get(0), (String) parts.get(1))); + } + + return result; + } } } \ No newline at end of file diff --git a/source/mircoders/localizer/MirProducerLocalizer.java b/source/mircoders/localizer/MirProducerLocalizer.java index 07a4f013..475fb4ea 100755 --- a/source/mircoders/localizer/MirProducerLocalizer.java +++ b/source/mircoders/localizer/MirProducerLocalizer.java @@ -31,8 +31,11 @@ package mircoders.localizer; -import java.util.*; +import java.util.List; +import mir.producer.ProducerFactory; public interface MirProducerLocalizer { - public Map factories() throws MirLocalizerException, MirLocalizerFailure; + public List factories() throws MirLocalizerException, MirLocalizerFailure; + public ProducerFactory getFactoryForName(String aName); + public void produceAllNew(); } diff --git a/source/mircoders/localizer/basic/MirBasicOpenPostingLocalizer.java b/source/mircoders/localizer/basic/MirBasicOpenPostingLocalizer.java index e3060db4..55fa5eed 100755 --- a/source/mircoders/localizer/basic/MirBasicOpenPostingLocalizer.java +++ b/source/mircoders/localizer/basic/MirBasicOpenPostingLocalizer.java @@ -47,11 +47,16 @@ public class MirBasicOpenPostingLocalizer implements MirOpenPostingLocalizer { protected static Logfile logger = Logfile.getInstance( MirGlobal.getConfigProperty("Home") + "/" + MirGlobal.getConfigProperty("Mir.Localizer.Logfile")); public MirBasicOpenPostingLocalizer() { - String contentProducers = MirGlobal.getConfigProperty("Mir.Localizer.OpenPosting.ContentProducers"); - String commentProducers = MirGlobal.getConfigProperty("Mir.Localizer.OpenPosting.CommentProducers"); + try { + String contentProducers = MirGlobal.getConfigProperty("Mir.Localizer.OpenPosting.ContentProducers"); + String commentProducers = MirGlobal.getConfigProperty("Mir.Localizer.OpenPosting.CommentProducers"); - afterContentProducerTasks = parseProducerTaskList(contentProducers); - afterCommentProducerTasks = parseProducerTaskList(commentProducers); + afterContentProducerTasks = ProducerEngine.ProducerTask.parseProducerTaskList(contentProducers); + afterCommentProducerTasks = ProducerEngine.ProducerTask.parseProducerTaskList(commentProducers); + } + catch (Throwable t) { + logger.printError("Setting up MirBasicOpenPostingLocalizer failed: " + t.getMessage()); + } } public void afterContentPosting() { @@ -76,21 +81,4 @@ public class MirBasicOpenPostingLocalizer implements MirOpenPostingLocalizer { return locale.getLanguage(); } - protected List parseProducerTaskList(String aList) { - Iterator i; - List result = new Vector(); - - i = StringRoutines.splitString(aList, ";").iterator(); - while (i.hasNext()) { - String taskExpression = (String) i.next(); - List parts = StringRoutines.splitString(taskExpression, "."); - - if (parts.size()!=2) - logger.printError("Invalid producer expression: '" + taskExpression + "'"); - else - result.add(new ProducerEngine.ProducerTask((String) parts.get(0), (String) parts.get(1))); - } - - return result; - } } diff --git a/source/mircoders/localizer/basic/MirBasicProducerLocalizer.java b/source/mircoders/localizer/basic/MirBasicProducerLocalizer.java index 2b72ee78..0c0f9cec 100755 --- a/source/mircoders/localizer/basic/MirBasicProducerLocalizer.java +++ b/source/mircoders/localizer/basic/MirBasicProducerLocalizer.java @@ -46,7 +46,10 @@ import mircoders.producer.reader.*; import mircoders.producer.*; public class MirBasicProducerLocalizer implements MirProducerLocalizer { - private Map producerFactories; + private List producerFactories; + private Map nameToFactory; + private List allNewProducerTasks; + protected FileMonitor fileMonitor; protected EntityAdapterModel model; protected Generator.GeneratorLibrary generatorLibrary; @@ -56,11 +59,17 @@ public class MirBasicProducerLocalizer implements MirProducerLocalizer { public MirBasicProducerLocalizer() { + + try { - producerFactories = new HashMap(); + String allNewProducers = MirGlobal.getConfigProperty("Mir.Localizer.Producer.AllNewProducers"); + allNewProducerTasks = ProducerEngine.ProducerTask.parseProducerTaskList(allNewProducers); + + producerFactories = new Vector(); model = MirGlobal.localizer().dataModel().adapterModel(); generatorLibrary = MirGlobal.localizer().generators().makeProducerGeneratorLibrary(); writerEngine = MirGlobal.localizer().generators().makeWriterEngine(); + nameToFactory = new HashMap(); } catch (Throwable t) { logger.printError("MirBasicProducerLocalizer(): Exception "+t.getMessage()); @@ -68,16 +77,23 @@ public class MirBasicProducerLocalizer implements MirProducerLocalizer { } } - public Map factories() throws MirLocalizerException { + public List factories() throws MirLocalizerException { if (fileMonitor==null || producerFactories == null || fileMonitor.hasChanged()) { try { - Map newProducers = new HashMap(); + List newProducers = new Vector(); FileMonitor newFileMonitor = new FileMonitor(); setupFactories(newProducers, newFileMonitor); producerFactories = newProducers; fileMonitor = newFileMonitor; - logger.printError("MirBasicProducerLocalizer.factories(): successfully setup factories"); + logger.printInfo("MirBasicProducerLocalizer.factories(): successfully setup factories"); + + nameToFactory.clear(); + Iterator i = producerFactories.iterator(); + while (i.hasNext()) { + ProducerFactory factory = (ProducerFactory) i.next(); + nameToFactory.put(factory.getName(), factory); + } } catch (Throwable t) { logger.printError("MirBasicProducerLocalizer.factories(): Unable to setup factories: "+t.getMessage()); @@ -87,26 +103,6 @@ public class MirBasicProducerLocalizer implements MirProducerLocalizer { return producerFactories; }; - protected void setupContentFactory(CompositeProducerNode aProducerNode) { - } - - protected void setupStartPageFactory(CompositeProducerNode aProducerNode) { - } - - protected void setupSynchronizationFactory(CompositeProducerNode aProducerNode) { - if(MirGlobal.getConfigBooleanProperty("Rsync")){ - aProducerNode.addSubNode( - new ScriptCallingProducerNode(MirGlobal.getConfigProperty("Rsync.Script.Path")) - ); - } - } - - protected void setupStaticFactory(CompositeProducerNode aProducerNode) { - } - - protected void setupTopicsFactory(CompositeProducerNode aProducerNode) { - } - protected void setupProducerNodeBuilderLibrary(ProducerNodeBuilderLibrary aLibrary) { DefaultProducerNodeBuilders.registerBuilders( aLibrary, model, generatorLibrary, writerEngine, @@ -114,58 +110,34 @@ public class MirBasicProducerLocalizer implements MirProducerLocalizer { SupplementalProducerNodeBuilders.registerBuilders(aLibrary, model); } - protected void setupFactories(Map aFactoriesMap, FileMonitor aFileMonitor) throws MirLocalizerException, MirLocalizerFailure { + protected void setupFactories(List aFactories, FileMonitor aFileMonitor) throws MirLocalizerException, MirLocalizerFailure { ProducerConfigReader reader; ProducerNodeBuilderLibrary library = new ProducerNodeBuilderLibrary(); setupProducerNodeBuilderLibrary(library); List usedFiles = new Vector(); + Iterator i; aFileMonitor.clear(); reader = new ProducerConfigReader(); - reader.parseFile(MirGlobal.getConfigProperty("Home") + File.separatorChar + MirGlobal.getConfigProperty("Mir.Localizer.ProducerConfigFile"), library, aFactoriesMap, usedFiles); + reader.parseFile(MirGlobal.getConfigProperty("Home") + File.separatorChar + MirGlobal.getConfigProperty("Mir.Localizer.ProducerConfigFile"), library, aFactories, usedFiles); - Iterator i = usedFiles.iterator(); + i = usedFiles.iterator(); while (i.hasNext()) aFileMonitor.addFile((File) i.next()); - setupFactories(aFactoriesMap); + setupFactories(aFactories); } - protected void setupFactories(Map aFactoriesMap ) throws MirLocalizerException, MirLocalizerFailure { + protected void setupFactories(List aFactories) throws MirLocalizerException, MirLocalizerFailure { CompositeProducerNode node; try { - node = new CompositeProducerNode(); - setupContentFactory( node ); - if (node.getNrSubNodes()>0) - aFactoriesMap.put("content", new NodedProducerFactory(node)); - - node = new CompositeProducerNode(); - setupStartPageFactory( node ); - if (node.getNrSubNodes()>0) - aFactoriesMap.put("startpage", new NodedProducerFactory(node)); - - node = new CompositeProducerNode(); - setupSynchronizationFactory( node ); - if (node.getNrSubNodes()>0) - aFactoriesMap.put("synchronization", new NodedProducerFactory(node)); - - node = new CompositeProducerNode(); - setupStaticFactory( node ); - if (node.getNrSubNodes()>0) - aFactoriesMap.put("static", new NodedProducerFactory(node)); - - node = new CompositeProducerNode(); - setupTopicsFactory( node ); - if (node.getNrSubNodes()>0) - aFactoriesMap.put("topics", new NodedProducerFactory(node)); - - aFactoriesMap.put("media", - new CompositeProducerFactory( new ProducerFactory[] { - new OldProducerAdapterFactory(new ProducerImages()), - new OldProducerAdapterFactory(new ProducerAudio()), - new OldProducerAdapterFactory(new ProducerVideo()), - new OldProducerAdapterFactory(new ProducerOther()) + aFactories.add( + new CompositeProducerFactory("media", new ProducerFactory[] { + new OldProducerAdapterFactory("images", new ProducerImages()), + new OldProducerAdapterFactory("audio", new ProducerAudio()), + new OldProducerAdapterFactory("video", new ProducerVideo()), + new OldProducerAdapterFactory("other", new ProducerOther()) } ) ); } @@ -173,4 +145,12 @@ public class MirBasicProducerLocalizer implements MirProducerLocalizer { throw new MirLocalizerFailure(e); } }; + + public void produceAllNew() { + MirGlobal.producerEngine().addTasks(allNewProducerTasks); + }; + + public ProducerFactory getFactoryForName(String aName) { + return (ProducerFactory) nameToFactory.get(aName); + } } diff --git a/source/mircoders/producer/CompositeProducer.java b/source/mircoders/producer/CompositeProducer.java index c178ff4d..dd137434 100755 --- a/source/mircoders/producer/CompositeProducer.java +++ b/source/mircoders/producer/CompositeProducer.java @@ -36,8 +36,7 @@ import java.io.*; import mir.producer.*; public class CompositeProducer implements mir.producer.Producer { - - List producers; + private List producers; public CompositeProducer() { producers = new Vector(); @@ -55,4 +54,8 @@ public class CompositeProducer implements mir.producer.Producer { while (i.hasNext()) ((mir.producer.Producer) i.next()).produce(aLogger); } + + public void abort() { + + } } diff --git a/source/mircoders/producer/CompositeProducerFactory.java b/source/mircoders/producer/CompositeProducerFactory.java index 41844170..1a38be9c 100755 --- a/source/mircoders/producer/CompositeProducerFactory.java +++ b/source/mircoders/producer/CompositeProducerFactory.java @@ -36,14 +36,18 @@ import mir.entity.*; import mir.producer.*; public class CompositeProducerFactory implements ProducerFactory { - Map factories; // verb -> Vector ( ProducerFactory ) + private Map factories; // verb -> Vector ( ProducerFactory ) + private List verbs; + private String name; - public CompositeProducerFactory() { + public CompositeProducerFactory(String aName) { factories = new HashMap(); + verbs = new Vector(); + name = aName; } - public CompositeProducerFactory(ProducerFactory[] aSubProducerFactories) { - this(); + public CompositeProducerFactory(String aName, ProducerFactory[] aSubProducerFactories) { + this(aName); int i; @@ -52,15 +56,25 @@ public class CompositeProducerFactory implements ProducerFactory { } } - private List factoriesForVerb(String aVerb) { + private List findFactoriesForVerb(String aVerb) { + List result = (List) factories.get(aVerb); + + if (result==null) + result = new Vector(); + + return result; + } + + private List factoriesForVerb(ProducerVerb aVerb) { List result; - result=(List) factories.get(aVerb); + result=(List) factories.get(aVerb.getName()); if (result==null) { result=new Vector(); - factories.put(aVerb, result); + verbs.add(aVerb); + factories.put(aVerb.getName(), result); } return result; @@ -72,14 +86,14 @@ public class CompositeProducerFactory implements ProducerFactory { i=aFactory.verbs(); while (i.hasNext()) { - factoriesForVerb((String) i.next()).add(aFactory); + factoriesForVerb((ProducerVerb) i.next()).add(aFactory); } } public mir.producer.Producer makeProducer(String aVerb, Map aBasicValueSet) throws ProducerExc, ProducerFailure { CompositeProducer result = new CompositeProducer(); - Iterator i=factoriesForVerb(aVerb).iterator(); + Iterator i=findFactoriesForVerb(aVerb).iterator(); while (i.hasNext()) result.addProducer(((ProducerFactory) i.next()).makeProducer(aVerb, aBasicValueSet)); @@ -88,6 +102,10 @@ public class CompositeProducerFactory implements ProducerFactory { } public Iterator verbs() { - return factories.keySet().iterator(); + return verbs.iterator(); + } + + public String getName() { + return name; } } diff --git a/source/mircoders/producer/ContentMarkingProducerNode.java b/source/mircoders/producer/ContentMarkingProducerNode.java index c356f492..3b1018b3 100755 --- a/source/mircoders/producer/ContentMarkingProducerNode.java +++ b/source/mircoders/producer/ContentMarkingProducerNode.java @@ -72,8 +72,4 @@ public class ContentMarkingProducerNode implements ProducerNode { throw new ProducerFailure(t.getMessage(), t); } } - - public Set buildVerbSet() { - return new HashSet(); - } } \ No newline at end of file diff --git a/source/mircoders/producer/ContentModifyingProducerNode.java b/source/mircoders/producer/ContentModifyingProducerNode.java index a8bb7603..7034e60a 100755 --- a/source/mircoders/producer/ContentModifyingProducerNode.java +++ b/source/mircoders/producer/ContentModifyingProducerNode.java @@ -89,8 +89,4 @@ public class ContentModifyingProducerNode implements ProducerNode { throw new ProducerFailure(t.getMessage(), t); } } - - public Set buildVerbSet() { - return new HashSet(); - } } diff --git a/source/mircoders/producer/IndexingProducerNode.java b/source/mircoders/producer/IndexingProducerNode.java index b50b4f0f..d023198e 100755 --- a/source/mircoders/producer/IndexingProducerNode.java +++ b/source/mircoders/producer/IndexingProducerNode.java @@ -164,10 +164,6 @@ public class IndexingProducerNode implements ProducerNode { aLogger.println(" IndexTime: " + (endTime-startTime) + " ms
"); aLogger.flush(); } - - public Set buildVerbSet() { - return new HashSet(); - } } diff --git a/source/mircoders/producer/MediaGeneratingProducerNode.java b/source/mircoders/producer/MediaGeneratingProducerNode.java index 504c822f..e76831bd 100755 --- a/source/mircoders/producer/MediaGeneratingProducerNode.java +++ b/source/mircoders/producer/MediaGeneratingProducerNode.java @@ -86,8 +86,84 @@ public class MediaGeneratingProducerNode implements ProducerNode { throw new ProducerFailure(t.getMessage(), t); } } +} + + +/* + - public Set buildVerbSet() { - return new HashSet(); + 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 failed!: "+e.toString()); + e.printStackTrace(htmlout); + } + } + + // if next batch get it... + if (batchEntityList.hasNextBatch()){ + batchEntityList = uploadedMediaModule.getByWhereClause(whereClause, + orderBy, batchEntityList.getNextBatch(),contentBatchsize); + } else { + batchEntityList=null; + } + } + // Finish + sessionConnectTime = new java.util.Date().getTime() - startTime; + logHTML(htmlout, "Producer.Media finished: " + sessionConnectTime + " ms."); + } +*/ diff --git a/source/mircoders/producer/OldProducerAdapter.java b/source/mircoders/producer/OldProducerAdapter.java index c07df28b..8eb81c2c 100755 --- a/source/mircoders/producer/OldProducerAdapter.java +++ b/source/mircoders/producer/OldProducerAdapter.java @@ -52,4 +52,7 @@ public class OldProducerAdapter implements mir.producer.Producer { throw new ProducerFailure("Failure at handling old Producers",e); } } + + public void abort() { + } } \ No newline at end of file diff --git a/source/mircoders/producer/OldProducerAdapterFactory.java b/source/mircoders/producer/OldProducerAdapterFactory.java index b5d99ca3..5d702092 100755 --- a/source/mircoders/producer/OldProducerAdapterFactory.java +++ b/source/mircoders/producer/OldProducerAdapterFactory.java @@ -35,22 +35,30 @@ import mir.producer.*; import java.util.*; public class OldProducerAdapterFactory implements ProducerFactory { + private List verbs; + private String name; private mircoders.producer.Producer oldProducer; - public Iterator verbs() { - Vector verbList = new Vector(); + public OldProducerAdapterFactory(String aName, mircoders.producer.Producer anOldProducer) { + name = aName; + verbs = new Vector(); - verbList.add("new"); - verbList.add("all"); - return verbList.iterator(); - } + verbs.add(new SimpleProducerVerb("new", "generate only altered items")); + verbs.add(new SimpleProducerVerb("all", "generate all items")); - public OldProducerAdapterFactory(mircoders.producer.Producer anOldProducer) { oldProducer = anOldProducer; } + public Iterator verbs() { + return verbs.iterator(); + } + public mir.producer.Producer makeProducer(String aVerb, Map anInitialValues) { return new OldProducerAdapter(oldProducer, new Boolean(aVerb.equals("all"))); } + + public String getName() { + return name; + } } \ No newline at end of file diff --git a/source/mircoders/producer/PDFGeneratingProducerNode.java b/source/mircoders/producer/PDFGeneratingProducerNode.java index d739073f..1240bc58 100755 --- a/source/mircoders/producer/PDFGeneratingProducerNode.java +++ b/source/mircoders/producer/PDFGeneratingProducerNode.java @@ -62,7 +62,7 @@ public class PDFGeneratingProducerNode implements ProducerNode { destinationIdentifier = ParameterExpander.expandExpression( aValueMap, destinationExpression ); generatorIdentifier = ParameterExpander.expandExpression( aValueMap, generatorExpression ); - stylesheetIdentifier = ParameterExpander.expandExpression( aValueMap, stylesheet); + stylesheetIdentifier = ParameterExpander.expandExpression( aValueMap, stylesheet); aLogger.println("Generating " + generatorIdentifier + " into " + destinationIdentifier + " using "+ stylesheetIdentifier); aLogger.flush(); @@ -71,8 +71,8 @@ public class PDFGeneratingProducerNode implements ProducerNode { } catch (Throwable t) { - t.printStackTrace(); - aLogger.println(" error while generating: " + t.getMessage() + t.toString()); + t.printStackTrace(); + aLogger.println(" error while generating: " + t.getMessage() + t.toString()); aLogger.flush(); } endTime = System.currentTimeMillis(); @@ -80,10 +80,6 @@ public class PDFGeneratingProducerNode implements ProducerNode { aLogger.println(" Time: " + (endTime-startTime) + " ms
"); aLogger.flush(); } - - public Set buildVerbSet() { - return new HashSet(); - } } diff --git a/source/mircoders/producer/PDFPreFormattingProducerNode.java b/source/mircoders/producer/PDFPreFormattingProducerNode.java index e4f9f213..bcff7c92 100755 --- a/source/mircoders/producer/PDFPreFormattingProducerNode.java +++ b/source/mircoders/producer/PDFPreFormattingProducerNode.java @@ -47,8 +47,8 @@ import mircoders.storage.*; public class PDFPreFormattingProducerNode implements ProducerNode { private String contentKey; private int numLinesBetweenImages; - private float contentAreaWidthCM; - private float characterWidthCM; + private float contentAreaWidthCM; + private float characterWidthCM; private float pixelWidthCM; private float lineHeightCM; @@ -59,7 +59,7 @@ public class PDFPreFormattingProducerNode implements ProducerNode { characterWidthCM=(new Float(aCharacterWidthCM)).floatValue(); pixelWidthCM=(new Float(aPixelWidthCM)).floatValue(); lineHeightCM=(new Float(aLineHeightCM)).floatValue(); - + // float characterWidthCM = 0.17F; //float contentAreaWidthCM = 16; //float pixelWidthCM = .03F; @@ -85,121 +85,121 @@ public class PDFPreFormattingProducerNode implements ProducerNode { int currentPosition = 0; //int numLinesBetweenImages=3; - - + + int numCharsInAnImagelessRow = (new Float(numLinesBetweenImages * (contentAreaWidthCM/characterWidthCM))).intValue(); boolean outOfText = false; - ArrayList brokenUpContent = new ArrayList(); - + ArrayList brokenUpContent = new ArrayList(); + EntityList images=DatabaseContentToMedia.getInstance().getImages((EntityContent)entity); - String theContent = ((EntityContent) entity).getValue("content_data"); + String theContent = ((EntityContent) entity).getValue("content_data"); if (images == null){ - HashMap row = new HashMap(); - row.put("text",theContent); - row.put("hasImage","0"); - brokenUpContent.add(row); + HashMap row = new HashMap(); + row.put("text",theContent); + row.put("hasImage","0"); + brokenUpContent.add(row); } if (images != null){ - //need to add checks for out of content! - HashMap row0 = new HashMap(); - if (numCharsInAnImagelessRow>(theContent).length()){ - row0.put("text",theContent); - outOfText = true; - } - else { - //break on words so we don't split html entities - int lastSpaceAt = theContent.lastIndexOf(" ",numCharsInAnImagelessRow); - row0.put("text",theContent.substring(0,lastSpaceAt)); - currentPosition=lastSpaceAt; - } - row0.put("hasImage","0"); - brokenUpContent.add(row0); - aLogger.println("CP1 is "+ currentPosition); - while(images.hasNext()){ - HashMap row1 = new HashMap(); - HashMap row2 = new HashMap(); - EntityImages currentImage=(EntityImages) images.next(); - float img_width=(new Float(currentImage.getValue("img_width"))).floatValue(); - float img_height=(new Float(currentImage.getValue("img_height"))).floatValue(); - - //oversize images must be shrunk - if (img_width>400){ - img_height=(new Float((new Float(img_height*(400.0F/img_width))).intValue())).floatValue(); - img_width=400.0F; - } - - - //calculate how much text goes in the column(use 8 pixels to pad the column) - float text_widthCM = contentAreaWidthCM-((img_width+8)*pixelWidthCM); - float number_of_lines = img_height*pixelWidthCM/lineHeightCM; //don't worry we will make it an int - //add one line for image description - int text_amount= (new Float((text_widthCM/characterWidthCM)*(number_of_lines+1))).intValue(); - - row1.put("text_widthCM",Float.toString(text_widthCM)); - - row1.put("img_title",currentImage.getValue("title")); - - row1.put("img_width",Float.toString(img_width)); - row1.put("img_height",Float.toString(img_height)); - - aLogger.println("img_width " +Float.toString(img_width)); - aLogger.println("img_height "+Float.toString(img_height)); - - row1.put("img_src",currentImage.getValue("publish_path")); - row1.put("hasImage","1"); - if (! outOfText){ - try { - int lastSpaceAt = theContent.lastIndexOf(" ",currentPosition+text_amount); - row1.put("text",theContent.substring(currentPosition,lastSpaceAt)); - currentPosition=lastSpaceAt; - } - catch (IndexOutOfBoundsException e){ - row1.put("text",theContent.substring(currentPosition)); - outOfText = true; - } - } - aLogger.println("CP2 is "+ currentPosition); - brokenUpContent.add(row1); - - if (! outOfText){ - try { - int lastSpaceAt = theContent.lastIndexOf(" ",currentPosition+numCharsInAnImagelessRow); - row2.put("text",theContent.substring(currentPosition,lastSpaceAt)); - currentPosition=lastSpaceAt; - } - catch (IndexOutOfBoundsException e){ - row2.put("text",theContent.substring(currentPosition)); - outOfText = true; - } - } - row2.put("hasImage","0"); - brokenUpContent.add(row2); - - aLogger.println("CP3 is "+ currentPosition); - } - HashMap row3 = new HashMap(); - if (! outOfText){ - row3.put("text",theContent.substring(currentPosition)); - row3.put("hasImage","0"); - brokenUpContent.add(row3); - } - + //need to add checks for out of content! + HashMap row0 = new HashMap(); + if (numCharsInAnImagelessRow>(theContent).length()){ + row0.put("text",theContent); + outOfText = true; + } + else { + //break on words so we don't split html entities + int lastSpaceAt = theContent.lastIndexOf(" ",numCharsInAnImagelessRow); + row0.put("text",theContent.substring(0,lastSpaceAt)); + currentPosition=lastSpaceAt; + } + row0.put("hasImage","0"); + brokenUpContent.add(row0); + aLogger.println("CP1 is "+ currentPosition); + while(images.hasNext()){ + HashMap row1 = new HashMap(); + HashMap row2 = new HashMap(); + EntityImages currentImage=(EntityImages) images.next(); + float img_width=(new Float(currentImage.getValue("img_width"))).floatValue(); + float img_height=(new Float(currentImage.getValue("img_height"))).floatValue(); + + //oversize images must be shrunk + if (img_width>400){ + img_height=(new Float((new Float(img_height*(400.0F/img_width))).intValue())).floatValue(); + img_width=400.0F; + } + + + //calculate how much text goes in the column(use 8 pixels to pad the column) + float text_widthCM = contentAreaWidthCM-((img_width+8)*pixelWidthCM); + float number_of_lines = img_height*pixelWidthCM/lineHeightCM; //don't worry we will make it an int + //add one line for image description + int text_amount= (new Float((text_widthCM/characterWidthCM)*(number_of_lines+1))).intValue(); + + row1.put("text_widthCM",Float.toString(text_widthCM)); + + row1.put("img_title",currentImage.getValue("title")); + + row1.put("img_width",Float.toString(img_width)); + row1.put("img_height",Float.toString(img_height)); + + aLogger.println("img_width " +Float.toString(img_width)); + aLogger.println("img_height "+Float.toString(img_height)); + + row1.put("img_src",currentImage.getValue("publish_path")); + row1.put("hasImage","1"); + if (! outOfText){ + try { + int lastSpaceAt = theContent.lastIndexOf(" ",currentPosition+text_amount); + row1.put("text",theContent.substring(currentPosition,lastSpaceAt)); + currentPosition=lastSpaceAt; + } + catch (IndexOutOfBoundsException e){ + row1.put("text",theContent.substring(currentPosition)); + outOfText = true; + } + } + aLogger.println("CP2 is "+ currentPosition); + brokenUpContent.add(row1); + + if (! outOfText){ + try { + int lastSpaceAt = theContent.lastIndexOf(" ",currentPosition+numCharsInAnImagelessRow); + row2.put("text",theContent.substring(currentPosition,lastSpaceAt)); + currentPosition=lastSpaceAt; + } + catch (IndexOutOfBoundsException e){ + row2.put("text",theContent.substring(currentPosition)); + outOfText = true; + } + } + row2.put("hasImage","0"); + brokenUpContent.add(row2); + + aLogger.println("CP3 is "+ currentPosition); + } + HashMap row3 = new HashMap(); + if (! outOfText){ + row3.put("text",theContent.substring(currentPosition)); + row3.put("hasImage","0"); + brokenUpContent.add(row3); + } + } - - - - - + + + + + ParameterExpander.setValueForKey( - aValueMap, - "data.formatted_content", - new CachingRewindableIterator(brokenUpContent.iterator()) - ); + aValueMap, + "data.formatted_content", + new CachingRewindableIterator(brokenUpContent.iterator()) + ); } @@ -210,10 +210,6 @@ public class PDFPreFormattingProducerNode implements ProducerNode { throw new ProducerFailure(t.getMessage(), t); } } - - public Set buildVerbSet() { - return new HashSet(); - } } diff --git a/source/mircoders/servlet/ServletModuleComment.java b/source/mircoders/servlet/ServletModuleComment.java index 67d73e24..045378fc 100755 --- a/source/mircoders/servlet/ServletModuleComment.java +++ b/source/mircoders/servlet/ServletModuleComment.java @@ -174,8 +174,6 @@ public class ServletModuleComment extends ServletModule generator = MirGlobal.localizer().generators().makeAdminGeneratorLibrary().makeGenerator("admin/commentlist2.template"); model = MirGlobal.localizer().dataModel().adapterModel(); -// commentList = mainModule.getByWhereClause(whereClause, order, offset); - generationData = new HashMap(); MirGlobal.localizer().producerAssistant().initializeGenerationValueSet(generationData); diff --git a/source/mircoders/servlet/ServletModuleProducer.java b/source/mircoders/servlet/ServletModuleProducer.java index f0924e01..b37a3440 100755 --- a/source/mircoders/servlet/ServletModuleProducer.java +++ b/source/mircoders/servlet/ServletModuleProducer.java @@ -37,14 +37,18 @@ import java.util.*; import javax.servlet.*; import javax.servlet.http.*; +import org.apache.struts.util.MessageResources; + import freemarker.template.*; import mir.servlet.*; import mir.misc.*; import mir.producer.*; +import mir.generator.*; +import mir.producer.*; +import mir.entity.adapter.*; +import mir.util.*; -import mircoders.producer.*; -import mircoders.entity.*; import mircoders.global.*; /* Verteilerservlet, dass je nach Parameter task die Klasse Producer"TASK" @@ -56,70 +60,145 @@ import mircoders.global.*; public class ServletModuleProducer extends ServletModule { - private static ServletModuleProducer instance = new ServletModuleProducer(); - public static ServletModule getInstance() { return instance; } + private static ServletModuleProducer instance = new ServletModuleProducer(); + public static ServletModule getInstance() { return instance; } + + Object comments; + Map generationData; + Generator generator; + int totalNrComments; + List producersData; + + void generateResponse(String aGeneratorIdentifier, PrintWriter aWriter, Map aResponseData, Locale aLocale) throws ServletModuleException { + try { + generator = MirGlobal.localizer().generators().makeAdminGeneratorLibrary().makeGenerator(aGeneratorIdentifier); + MirGlobal.localizer().producerAssistant().initializeGenerationValueSet(aResponseData); + aResponseData.put( "lang", new ResourceBundleGeneratorFunction( aLocale, MessageResources.getMessageResources("bundles.admin"))); + generator.generate(aWriter, aResponseData, new PrintWriter(new NullWriter())); + } + catch (Throwable t) { + throw new ServletModuleException(t.getMessage()); + } + } + + private ServletModuleProducer() { + theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("ServletModule.Producer.Logfile")); + defaultAction="showProducerQueueStatus"; + } + + public void showMessage(PrintWriter aWriter, Locale aLocale, String aMessage, String anArgument1, String anArgument2) throws ServletModuleException { + Map responseData; + try { + responseData = new HashMap(); + responseData.put("message", aMessage); + responseData.put("argument1", anArgument1); + responseData.put("argument2", anArgument2); + generateResponse("infomessage.template", aWriter, responseData, aLocale); + } + catch (Throwable t) { + throw new ServletModuleException(t.getMessage()); + } + } - private ServletModuleProducer() { - theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("ServletModule.Producer.Logfile")); - defaultAction="produce"; - } + public void showProducerQueueStatus(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException { + Object comments; + Map generationData; + Generator generator; + int totalNrComments; + List producersData; - public void produce(HttpServletRequest req, HttpServletResponse res) - throws ServletModuleException - { - try { - PrintWriter out = res.getWriter(); + try { + generator = MirGlobal.localizer().generators().makeAdminGeneratorLibrary().makeGenerator("producerqueue.template"); + generationData = new HashMap(); + MirGlobal.localizer().producerAssistant().initializeGenerationValueSet(generationData); - if (req.getParameter("producer")!=null) { - // ML: new producer system: + generationData.put( "lang", new ResourceBundleGeneratorFunction( getLocale(aRequest), MessageResources.getMessageResources("bundles.admin"))); + generationData.put( "thisurl", "module=Producer&do=showProducerQueueStatus"); - String producerParam = req.getParameter("producer"); - String verbParam = req.getParameter("verb"); + producersData = new Vector(); + Iterator i = MirGlobal.localizer().producers().factories().iterator(); + while (i.hasNext()) { + ProducerFactory factory = (ProducerFactory) i.next(); - MirGlobal.producerEngine().addJob(producerParam, verbParam); - MirGlobal.producerEngine().printQueueStatus(out); + List producerVerbs = new Vector(); + Iterator j = factory.verbs(); + while (j.hasNext()) { + Map verbData = new HashMap(); + ProducerFactory.ProducerVerb verb = (ProducerFactory.ProducerVerb) j.next(); + verbData.put("name", verb.getName()); + verbData.put("description", verb.getDescription()); -// ProducerFactory factory = (ProducerFactory) MirGlobal.localizer().producers().factories().get(producerParam); -// mir.producer.Producer producer = factory.makeProducer(verbParam); + producerVerbs.add(verbData); + } -// producer.produce(out); + Map producerData = new HashMap(); + producerData.put("name", factory.getName()); + producerData.put("verbs", producerVerbs); + producersData.add(producerData); } - else - { - // ML: old producer system: - - String taskParam = req.getParameter("task"); - String forcedParam = req.getParameter("forced"); - String syncParam = req.getParameter("sync"); - theLog.printInfo("Starting Task: " + taskParam); - if (taskParam == null) { - throw new ServletModuleException("Kein Task angegeben!"); - } else { - Class producerModule = Class.forName("mircoders.producer.Producer" + taskParam); - mircoders.producer.Producer producer = (mircoders.producer.Producer) producerModule.newInstance(); - HttpSession session=req.getSession(false); - EntityUsers user = (EntityUsers)session.getAttribute("login.uid"); - - if (forcedParam!=null && !forcedParam.equals("")) { - if (syncParam!=null && !syncParam.equals("")) { - producer.handle(out, user, true, true); - } else { - producer.handle(out, user, true,false); - } - } else { - producer.handle(out, user, false,false); - } - - } - } - } - catch (Exception e) { - throw new ServletModuleException(e.toString()); + generationData.put("producers", producersData); + + generationData.put("queue", MirGlobal.producerEngine().getQueueStatus()); + generator.generate(aResponse.getWriter(), generationData, new PrintWriter(new NullWriter())); + } + catch (Throwable t) { + throw new ServletModuleException(t.getMessage()); } - } + } + + public void produce(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException { + /* + * This method will only be called by external scripts (e.g. from cron jobs). + * The output therefore is very simple. + * + */ + try { + PrintWriter out = res.getWriter(); + + if (req.getParameter("producer")!=null) { + String producerParam = req.getParameter("producer"); + String verbParam = req.getParameter("verb"); + + MirGlobal.producerEngine().addJob(producerParam, verbParam); + out.println("job added"); + } + } + catch (Exception e) { + throw new ServletModuleException(e.getMessage()); + } + } + + public void produceAllNew(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException { + try { + MirGlobal.localizer().producers().produceAllNew(); + showMessage(aResponse.getWriter(), getLocale(aRequest), "produceAllNewAddedToQueue", "", ""); + } + catch (Exception e) { + throw new ServletModuleException(e.getMessage()); + } + } + + public void enqueue(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException { + try { + if (aRequest.getParameter("producer")!=null) { + String producerParam = aRequest.getParameter("producer"); + String verbParam = aRequest.getParameter("verb"); + + MirGlobal.producerEngine().addJob(producerParam, verbParam); + + showProducerQueueStatus(aRequest, aResponse); + } + } + catch (Exception e) { + throw new ServletModuleException(e.getMessage()); + } + } + public void cancelAbortJob(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException { + // ML: to be coded + } } diff --git a/templates/admin/error.template b/templates/admin/error.template new file mode 100755 index 00000000..2a0395d0 --- /dev/null +++ b/templates/admin/error.template @@ -0,0 +1,37 @@ + + + ${config["Mir.Name"]} | ${lang("error.htmltitle")} + + + + + + + + + + + + + + + + + +
+

${lang("error.title")}

+
+
+

${lang("error.text", config["Mir.Tech-email.address"], config["Mir.Tech-email.name"])} +

+

+

${data.date} -- ${data.errorstring} +

+

+

+ ${lang("error.text2", config["Mir.Tech-email.address"], config["Mir.Tech-email.name"])} +

+

+ + + diff --git a/templates/admin/infomessage.template b/templates/admin/infomessage.template new file mode 100755 index 00000000..c5900188 --- /dev/null +++ b/templates/admin/infomessage.template @@ -0,0 +1,19 @@ + + + ${config["Mir.Name"]} | ${lang("error.htmltitle")} + + + + + + + + +
+

+ ${lang("infomessage."+message, argument1, argument2)} +

+

+ + + diff --git a/templates/admin/producerqueue.template b/templates/admin/producerqueue.template new file mode 100755 index 00000000..ad39d7c2 --- /dev/null +++ b/templates/admin/producerqueue.template @@ -0,0 +1,80 @@ + + + ${config["Mir.Name"]} | ${lang("producerqueue.htmltitle")} + + + + + + +${lang("producer.jobqueue.title")} +

+ + + + + + + + + + + + + + class="list1"class="list2"> + + + + + ML: needs to be implemented + + + + + + + + + + + +
${lang("producer.job.name")}${lang("producer.job.status")}${lang("producer.job.date")} 
${q.factory}${q.verb}${q.status}${q.lastchange["HH:mm:ss"]}${lang("producer.job.cancel")}
Queue is empty
+${lang("producer.jobqueue.refresh")}

+ +

+ +${lang("producer.producerlist.title")} +

+ + + + + + + + + + + class="list1"class="list2"> + + + + + class="list1"class="list2"> + + + + + + + + +
 ${lang("producer.verb.name")}${lang("producer.verb.description")} 
${p.name}
${v.name}${v.description}${lang("producer.verb.enqueue")} 
+ + + + + + + diff --git a/templates/admin/start_admin.template b/templates/admin/start_admin.template index 267b29b1..f73d34db 100755 --- a/templates/admin/start_admin.template +++ b/templates/admin/start_admin.template @@ -92,46 +92,20 @@   - - Localizer producers - - -

- - - - - - - - - - - - -
producerverbs
${p.key} - - - - - - -
- - ${v} - -
-
-
+ + ${lang("start.producers.title")} +

+ ${lang("start.producers.produceAllNew")}
+ ${lang("start.producers.advanced")} - +   - + + ${lang("start.topics.title")} @@ -206,7 +181,7 @@   ${lang("add")}

- + ${lang("start.imcs.title")} @@ -233,11 +208,12 @@ - + internal messageboard ${lang("start.messageboard.title")} -
${lang("add")}
+
${lang("add")} + ${lang("edit")}

diff --git a/templates/admin/usererror.template b/templates/admin/usererror.template new file mode 100755 index 00000000..fc61c25c --- /dev/null +++ b/templates/admin/usererror.template @@ -0,0 +1,37 @@ + + +${lang("usererror.htmltitle")} + + + + + + + + + + + + + + + + +
+

${lang("usererror.title")}

+
+
+

${lang("usererror.text")} +

+

+

${data.errorstring} +

+

+

+

${lang("usererror.what_to_do")} + +

+

+ + +