From 4426a4f2f04df1c22eba6bcc28cb4dc9c4583b37 Mon Sep 17 00:00:00 2001 From: rk Date: Sun, 17 Feb 2002 21:56:51 +0000 Subject: [PATCH] producerContent cleaned & bugfix for contentn.template --- source/Mir.java | 6 +- source/config.properties-dist | 5 +- source/mircoders/entity/EntityContent.java | 6 +- source/mircoders/producer/ProducerContent.java | 98 +++++++++++++------------- 4 files changed, 58 insertions(+), 57 deletions(-) diff --git a/source/Mir.java b/source/Mir.java index be881e52..123f32a6 100755 --- a/source/Mir.java +++ b/source/Mir.java @@ -42,7 +42,7 @@ public class Mir extends AbstractServlet { public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException, UnavailableException { - long startTime = (new java.util.Date()).getTime(); + long startTime = System.currentTimeMillis(); long sessionConnectTime=0; String http=""; @@ -166,7 +166,7 @@ public class Mir extends AbstractServlet { } // timing... - sessionConnectTime = new java.util.Date().getTime() - startTime; + sessionConnectTime = System.currentTimeMillis() - startTime; theLog.printInfo("EXECTIME (" + moduleName + "): " + sessionConnectTime + " ms"); } @@ -278,7 +278,7 @@ public class Mir extends AbstractServlet { mergeData.put("session",sessionUrl); mergeData.put("login_user", userEntity); if (messageModule == null) messageModule = new ModuleMessage(DatabaseMessages.getInstance()); - mergeData.put("messages", HTMLTemplateProcessor.makeSimpleList(messageModule.getByWhereClause(null, "webdb_create desc",0,10))); + mergeData.put("messages", messageModule.getByWhereClause(null, "webdb_create desc",0,10)); HTMLTemplateProcessor.process(res,getLanguage(req,session)+"/"+startTemplate, mergeData,out); } catch(Exception e) { diff --git a/source/config.properties-dist b/source/config.properties-dist index 589b2872..f5bc4cf1 100755 --- a/source/config.properties-dist +++ b/source/config.properties-dist @@ -294,7 +294,6 @@ Producer.Logfile=log/producer.log Producer.Navigation.Template=producer/navigation.template Producer.Content.Template=producer/content.template -Producer.Content.Batchsize=20 Producer.Startseite.Template=producer/startseite.template Producer.Startseite.Entries=7 @@ -321,8 +320,8 @@ Producer.StartPage.Template=producer/startpage.template Producer.StartPage.Items=10 Producer.StartPage.Newswire=30 -Producer.Wap.Template=producer/wap.template -Producer.Wap.Items=10 + +# todo: do we need those? Xsl.Content=producer/content.xsl Xsl.Fo.Content=producer/frontpage_fo.xsl diff --git a/source/mircoders/entity/EntityContent.java b/source/mircoders/entity/EntityContent.java index bccc7cf8..1ac0f8ca 100755 --- a/source/mircoders/entity/EntityContent.java +++ b/source/mircoders/entity/EntityContent.java @@ -56,9 +56,11 @@ public class EntityContent extends Entity public void setProduced(boolean yesno) throws StorageObjectException { - Connection con=null;Statement stmt=null; String value = (yesno) ? "1":"0"; - String sql = "update content set is_produced='" + value + "' where id='" + getId()+"'"; + if (value.equals( getValue("is_produced") )) return; + + Connection con=null;Statement stmt=null; + String sql = "update content set is_produced='" + value + "' where id='" + getId()+"'"; try { con = theStorageObject.getPooledCon(); /** @todo should be preparedStatement: faster!! */ diff --git a/source/mircoders/producer/ProducerContent.java b/source/mircoders/producer/ProducerContent.java index b489a9ba..290bd154 100755 --- a/source/mircoders/producer/ProducerContent.java +++ b/source/mircoders/producer/ProducerContent.java @@ -17,18 +17,26 @@ import mircoders.storage.*; public class ProducerContent extends Producer { + private String contentTemplate = MirConfig.getProp("Producer.Content.Template"); + public static void main(String argv[]){ /** * Why are we reloading the config here? * Can someone please explain this? * Hope I didn't break anything * -mh. + * + * This is the entry point for standalone production. The code + * is then running in a new virtual machine, e.g. when called + * from cron-script. In that case the config has to be initliased. + * Don't know if is ok that way //rk + * */ //Configuration.initConfig("config"); System.out.println(MirConfig.getProp("Producer.DocRoot")); try { - new ProducerContent().handle(new PrintWriter(System.out), null, + new ProducerContent().handle(new PrintWriter(System.out), null, false,false); } catch(Exception e) { System.err.println(e.toString()); @@ -45,15 +53,12 @@ public class ProducerContent extends Producer { } public void handle(PrintWriter htmlout, EntityUsers user, boolean force, - boolean sync, String id) - throws StorageObjectException, ModuleException { + boolean sync, String id) throws StorageObjectException, ModuleException + { + + long startTime = System.currentTimeMillis(); - String contentTemplate = MirConfig.getProp("Producer.Content.Template"); - int contentBatchsize = - Integer.parseInt(MirConfig.getProp("Producer.Content.Batchsize")); - long sessionConnectTime = 0; - long startTime = (new java.util.Date()).getTime(); String whereClause = " "; String orderBy = " "; String htmlFileName = null; @@ -61,8 +66,9 @@ public class ProducerContent extends Producer { EntityList batchEntityList; EntityUsers userEntity=null; - // production of the content-pages + + /** @todo this should be moved to ModuleContent */ orderBy="date desc, webdb_lastchange desc"; if(force==true){ whereClause="is_published='1'"; @@ -71,7 +77,7 @@ public class ProducerContent extends Producer { whereClause += " AND id="+id; } batchEntityList = contentModule.getContent(whereClause, orderBy, 0, - contentBatchsize, userEntity); + -1, userEntity); } else { whereClause="is_produced='0' AND is_published='1'"; //if true produces a single contentitem @@ -79,50 +85,44 @@ public class ProducerContent extends Producer { whereClause += " AND id="+id; } batchEntityList = contentModule.getContent(whereClause, orderBy, 0, - contentBatchsize, userEntity); + -1, userEntity); } - while (batchEntityList != null) { - for(int i=0;i