X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmircoders%2Fproducer%2FProducerContent.java;h=4581b4f4cc02d6767750bb8e8287411b52c0dcbc;hb=7e9ceb1e66d027eff96ffa671892207e5ccd7e87;hp=c2a927c62d53fdcd4917da3a112b4124c54c4a7f;hpb=635db236fe78484b5f7f0158ad8054b189bf7a79;p=mir.git diff --git a/source/mircoders/producer/ProducerContent.java b/source/mircoders/producer/ProducerContent.java index c2a927c6..4581b4f4 100755 --- a/source/mircoders/producer/ProducerContent.java +++ b/source/mircoders/producer/ProducerContent.java @@ -1,157 +1,165 @@ -package mircoders.producer; - -import java.io.*; -import java.lang.*; -import java.util.*; - -import freemarker.template.*; - -import com.icl.saxon.trax.Transformer; - -import webdb.misc.*; -import webdb.storage.*; -import webdb.module.*; -import webdb.entity.*; - -import mir.module.*; -import mir.entity.*; -import mir.storage.*; - - -public class ProducerContent extends Producer { - - public static void main(String argv[]){ - Configuration.initConfig("config"); - System.out.println(Configuration.getProperty("Producer.DocRoot")); - try { - new ProducerContent().handle(new PrintWriter(System.out), null, false,false); - } catch(Exception e) { System.err.println(e.toString()); } - } - - 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 - { - - String contentTemplate = Configuration.getProperty("Producer.Content.Template"); - int contentBatchsize = Integer.parseInt(Configuration.getProperty("Producer.Content.Batchsize")); - String extLinkName = Configuration.getProperty("Producer.ExtLinkName"); - String intLinkName = Configuration.getProperty("Producer.IntLinkName"); - String mailLinkName = Configuration.getProperty("Producer.MailLinkName"); - String imageRoot = Configuration.getProperty("Producer.ImageRoot"); - - long sessionConnectTime = 0; - long startTime = (new java.util.Date()).getTime(); - String whereClause = " "; - String orderBy = " "; - String htmlFileName = null; - String currentMediaId; - EntityContent currentContent; - EntityList batchEntityList; - HashMap currentContentValues; - SimpleHash imageHash = new SimpleHash(); - EntityGruppen userEntity=null; - - // production of the content-pages - orderBy="date desc, webdb_lastchange desc"; - if(force==true){ - whereClause="is_published='1'"; - - // if true: produces a single content item - if(id !=null){ - whereClause += " AND id="+id; - } - batchEntityList = contentModule.getContent(whereClause, orderBy, 0, contentBatchsize, userEntity); - } else { - whereClause="is_produced='0' AND is_published='1'"; - - //if true produces a single contentitem - if(id !=null){ - whereClause += " AND id="+id; - } - batchEntityList = contentModule.getContent(whereClause, orderBy, 0, contentBatchsize, userEntity); - } - - while (batchEntityList != null) { - for(int i=0;i0){ - temp = StringUtil.createHTML(temp,imageRoot,mailLinkName,extLinkName,intLinkName); - temp = StringUtil.decodeHTMLinTags(temp); - currentContentValues.put("content_data",temp); - } - temp = (String)currentContentValues.get("description"); - if(temp!=null && temp.length()>0){ - temp = StringUtil.createHTML(temp,imageRoot,mailLinkName,extLinkName,intLinkName); - temp = StringUtil.decodeHTMLinTags(temp); - currentContentValues.put("description",temp); - } - } else { - String temp = (String)currentContentValues.get("content_data"); - if(temp!=null && temp.length()>0){ - temp = StringUtil.decodeHTMLinTags(temp); - currentContentValues.put("content_data",temp); - } - temp = (String)currentContentValues.get("description"); - if(temp!=null && temp.length()>0){ - temp = StringUtil.decodeHTMLinTags(temp); - currentContentValues.put("description",temp); - } - } - - SimpleHash mergeData = HTMLTemplateProcessor.makeSimpleHash(currentContentValues); - - // get the images - currentMediaId = currentContent.getValue("to_media"); - if (currentMediaId!=null && !currentMediaId.equals("")) { - imageHash.put(currentMediaId, HTMLTemplateProcessor.makeSimpleHash(imageModule.getById(currentMediaId))); - } - mergeData.put("images", imageHash); - - // get the comments for the article - mergeData.put("comments", currentContent.getComments()); - - // get the topics of this article - mergeData.put("topics",HTMLTemplateProcessor.makeSimpleList(DatabaseContentToTopics.getInstance().getTopics(currentContent))); - - boolean retVal = produce(contentTemplate, htmlFileName, mergeData, htmlout); - sessionConnectTime = new java.util.Date().getTime() - startTime; - if (retVal == true && !"1".equals(currentContent.getValue("is_produced"))) - currentContent.setProduced(true); - } - if (batchEntityList.hasNextBatch()){ - batchEntityList = contentModule.getContent(whereClause, orderBy, batchEntityList.getNextBatch(),contentBatchsize, userEntity); - //theLog.printDebugInfo("producing next batch"); - } else { - batchEntityList=null; - } - } - // Finish - sessionConnectTime = new java.util.Date().getTime() - startTime; - logHTML(htmlout, "Producer.Content finished: " + sessionConnectTime + " ms."); - - } - -} \ No newline at end of file +package mircoders.producer; + +import java.io.*; +import java.lang.*; +import java.util.*; + +import freemarker.template.*; + +import mir.misc.*; +import mir.storage.*; +import mir.module.*; +import mir.entity.*; + +import mircoders.entity.*; +import mircoders.storage.*; + + +public class ProducerContent extends Producer { + + public static void main(String argv[]){ + Configuration.initConfig("config"); + System.out.println(Configuration.getProperty("Producer.DocRoot")); + + try { + new ProducerContent().handle(new PrintWriter(System.out), null, false,false); + } catch(Exception e) { + System.err.println(e.toString()); + } + } + + + + 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 { + + String contentTemplate = Configuration.getProperty("Producer.Content.Template"); + int contentBatchsize = Integer.parseInt(Configuration.getProperty("Producer.Content.Batchsize")); + String extLinkName = Configuration.getProperty("Producer.ExtLinkName"); + String intLinkName = Configuration.getProperty("Producer.IntLinkName"); + String mailLinkName = Configuration.getProperty("Producer.MailLinkName"); + String imageRoot = Configuration.getProperty("Producer.ImageRoot"); + + long sessionConnectTime = 0; + long startTime = (new java.util.Date()).getTime(); + String whereClause = " "; + String orderBy = " "; + String htmlFileName = null; + String currentMediaId; + EntityContent currentContent; + EntityList batchEntityList; + HashMap currentContentValues; + SimpleHash imageHash = new SimpleHash(); + EntityGruppen userEntity=null; + + + + // production of the content-pages + orderBy="date desc, webdb_lastchange desc"; + if(force==true){ + whereClause="is_published='1'"; + // if true: produces a single content item + if(id !=null){ + whereClause += " AND id="+id; + } + batchEntityList = contentModule.getContent(whereClause, orderBy, 0, contentBatchsize, userEntity); + } else { + whereClause="is_produced='0' AND is_published='1'"; + //if true produces a single contentitem + if(id !=null){ + whereClause += " AND id="+id; + } + batchEntityList = contentModule.getContent(whereClause, orderBy, 0, contentBatchsize, userEntity); + } + + while (batchEntityList != null) { + for(int i=0;i0){ + temp = StringUtil.createHTML(temp,imageRoot,mailLinkName,extLinkName,intLinkName); + temp = StringUtil.decodeHTMLinTags(temp); + currentContentValues.put("content_data",temp); + } + temp = (String)currentContentValues.get("description"); + if(temp!=null && temp.length()>0){ + temp = StringUtil.createHTML(temp,imageRoot,mailLinkName,extLinkName,intLinkName); + temp = StringUtil.decodeHTMLinTags(temp); + currentContentValues.put("description",temp); + } + } else { + String temp = (String)currentContentValues.get("content_data"); + if(temp!=null && temp.length()>0){ + temp = StringUtil.decodeHTMLinTags(temp); + currentContentValues.put("content_data",temp); + } + temp = (String)currentContentValues.get("description"); + if(temp!=null && temp.length()>0){ + temp = StringUtil.decodeHTMLinTags(temp); + currentContentValues.put("description",temp); + } + } + + //create the freemarker-model + SimpleHash mergeData = HTMLTemplateProcessor.makeSimpleHash(currentContentValues); + + // get the images + currentMediaId = currentContent.getValue("to_media"); + if (currentMediaId!=null && !currentMediaId.equals("")) { + imageHash.put(currentMediaId, HTMLTemplateProcessor.makeSimpleHash(imageModule.getById(currentMediaId))); + } + mergeData.put("images", imageHash); + + // get the comments for the article + mergeData.put("comments", currentContent.getComments()); + + // get the topics of this article + mergeData.put("topics",HTMLTemplateProcessor.makeSimpleList(DatabaseContentToTopics.getInstance().getTopics(currentContent))); + + //produce html + boolean retVal = produce(contentTemplate, htmlFileName, mergeData, htmlout); + sessionConnectTime = new java.util.Date().getTime() - startTime; + if (retVal == true && !"1".equals(currentContent.getValue("is_produced"))) + currentContent.setProduced(true); + } + + if (batchEntityList.hasNextBatch()){ + batchEntityList = contentModule.getContent(whereClause, orderBy, batchEntityList.getNextBatch(),contentBatchsize, userEntity); + } else { + batchEntityList=null; + } + } + + // timing an message to browser + sessionConnectTime = new java.util.Date().getTime() - startTime; + logHTML(htmlout, "Producer.Content finished: " + sessionConnectTime + " ms."); + } + +}