};
protected void setupContentFactory(CompositeProducerFactory aContentFactory) {
- aContentFactory.addFactory(
- new ContentProducerFactory(
- MirGlobal.getConfigProperty("Producer.Content.Template"),
- "bundles.admin",
- MirGlobal.getConfigProperty("Producer.StorageRoot") + "/${contentyear}/${contentmonth}/${contentid}.shtml",
- Integer.parseInt(MirGlobal.getConfigProperty("Producer.Content.Batchsize"))));
}
protected void setupStartPageFactory(CompositeProducerFactory aStartPageFactory) {
- aStartPageFactory.addFactory(
- new StartPageProducerFactory(
- MirGlobal.getConfigProperty("Producer.StartPage.Template"),
- "bundles.admin",
- MirGlobal.getConfigProperty("Producer.StorageRoot") + "/index.shtml",
- MirGlobal.getConfigIntegerProperty("Producer.StartPage.Items"),
- MirGlobal.getConfigIntegerProperty("Producer.StartPage.Newswire")));
}
protected void setupSynchronizationFactory(CompositeProducerFactory aSynchronizationFactory) {
- if(MirGlobal.getConfigBooleanProperty("Rsync")){
- aSynchronizationFactory.addFactory(
- new ScriptCallProducerFactory(MirGlobal.getConfigProperty("Rsync.Script.Path")));
- }
- else {
- NullProducerFactory nullFactory = new NullProducerFactory();
- nullFactory.addVerb("run");
- aSynchronizationFactory.addFactory(nullFactory);
- }
}
protected void setupStaticFactory(CompositeProducerFactory aStaticFactory) {
- aStaticFactory.addFactory(
- new StaticProducerFactory(
- MirGlobal.getConfigProperty("Producer.Navigation.Template"),
- "bundles.admin",
- MirGlobal.getConfigProperty("Producer.StorageRoot") + "/navigation.inc"));
}
protected void setupFactories(Map aFactoriesMap ) {
+++ /dev/null
-package mircoders.producer;
-
-import java.io.*;
-import java.util.*;
-
-import mir.util.*;
-import mir.misc.*;
-import mir.entity.*;
-import mir.producer.*;
-import mir.generator.*;
-
-import mircoders.localizer.*;
-import mircoders.global.*;
-import mircoders.entity.*;
-import mircoders.entity.adapter.*;
-
-import org.apache.struts.util.MessageResources;
-
-public class ContentProducer implements mir.producer.Producer {
-
- private String generatorIdentifier;
- private String resourceBundle;
-
- private String outputFileExpression;
-
-
- EntityBrowser browser;
-
- public ContentProducer(
- EntityBrowser aBrowser,
- String aGeneratorIdentifier,
- String aResourceBundle,
- String anOutputFileExpression) {
-
- browser = aBrowser;
- generatorIdentifier = aGeneratorIdentifier;
- resourceBundle = aResourceBundle;
- outputFileExpression = anOutputFileExpression;
- }
-
- public void produce( PrintWriter aLogger ) throws ProducerFailure {
- EntityContent content;
-
- Map generationValues = new HashMap();
- Map dataMap = new HashMap();
- String fileName;
-
- MirGlobal.localizer().producerTool().initializeGenerationValueSet(generationValues);
-
- MessageResources messages = MessageResources.getMessageResources(resourceBundle);
- generationValues.put("lang", new MessageMethodModel(null, messages) );
- generationValues.put("data", dataMap);
-
- try {
- Generator generator = MirGlobal.localizer().generators().makeGenerator(generatorIdentifier);
-
- aLogger.println("ContentProducer.produce:");
- aLogger.println("generatorIdentifier = " + generatorIdentifier);
-
- while (browser.hasNext()) {
- content = (EntityContent) browser.next();
- dataMap.put("content", ContentAdapterDefinition.getInstance().makeEntityAdapter(content));
-
- String date = content.getValue("date");
-
- // ML: this will be done more elegantly soon!
- dataMap.put("contentmonth", date.substring(4,6));
- dataMap.put("contentyear", date.substring(0,4));
- dataMap.put("contentid", content.getValue("id"));
-
- aLogger.println("unparsed fileName = " + outputFileExpression);
-
- fileName = ParameterExpander.expandExpression(dataMap, outputFileExpression);
-
- aLogger.println("fileName = " + fileName);
-
- try {
- aLogger.println("generating: " + fileName);
-
- PrintWriter printWriter = MirGlobal.localizer().producerTool().openWriter(fileName);
-
- generator.generate(printWriter, generationValues, aLogger);
-
- MirGlobal.localizer().producerTool().closeWriter(printWriter);
-
- content.setProduced(true);
-
- aLogger.println("done generating: " + fileName);
- }
- catch (Exception e) {
- aLogger.println("exception while generating " + fileName + ":");
- aLogger.println(e.getMessage());
- e.printStackTrace(aLogger);
- aLogger.flush();
- }
- }
- }
- catch (Exception e) {
- aLogger.println("exception while generating:");
- aLogger.println(e.getMessage());
- e.printStackTrace(aLogger);
- aLogger.flush();
- }
-
- aLogger.println("ContentProducer.produce: done");
-
- }
-
-}
+++ /dev/null
-package mircoders.producer;
-
-import java.util.*;
-import mir.entity.*;
-import mir.producer.*;
-import mircoders.storage.*;
-
-public class ContentProducerFactory implements ProducerFactory {
- private String generatorIdentifier;
- private String resourceBundle;
- private String outputFileNameExpression;
- private int batchSize;
-
- public ContentProducerFactory(
- String aGeneratorIdentifier,
- String aResourceBundle,
- String anOutputFileNameExpression,
- int aBatchSize) {
-
- generatorIdentifier = aGeneratorIdentifier;
- resourceBundle = aResourceBundle;
- outputFileNameExpression = anOutputFileNameExpression;
- batchSize=aBatchSize;
- }
-
- public mir.producer.Producer makeProducer(String aVerb) throws ProducerFailure {
- try {
- QueryBuilder queryBuilder = new QueryBuilder();
-
- queryBuilder.appendAndCondition("is_published='1'");
-
- if (!aVerb.equals("all")) {
- queryBuilder.appendAndCondition("is_produced='0'");
- }
-
- return new ContentProducer(
- new EntityBrowser(
- DatabaseContent.getInstance(),
- queryBuilder.getWhereClause(),
- queryBuilder.getOrderByClause(),
- batchSize),
- generatorIdentifier,
- resourceBundle,
- outputFileNameExpression
- );
- } catch (Exception e) {
- throw new ProducerFailure("Creating Producer failed",e);
- }
- };
-
- public Iterator verbs() {
- Vector verbList = new Vector();
-
- verbList.add("new");
- verbList.add("all");
-
- return verbList.iterator();
- };
-}
-
+++ /dev/null
-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.module.*;
-import mircoders.entity.*;
-import mircoders.storage.*;
-
-
-public class ProducerAll extends Producer{
-
- private boolean rsync;
-
- public static void main(String argv[])
- {
- try { new ProducerAll().handle(new PrintWriter(System.out), null, false,false); }
- catch(Exception e) { System.err.println(e.toString()); }
- }
-
- // handle all
- public void handle(PrintWriter htmlout, EntityUsers user, boolean force,boolean sync)
- {
- printHTML(htmlout, "Producer.All: started");
-
- long sessionConnectTime = 0;
- long startTime = (new java.util.Date()).getTime();
-
- try {
- new ProducerImages().handle(htmlout, user, force,sync);
- } catch (Exception e) {
- logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
- +" in ProducerImages continuing "+ e.toString());
- }
- try {
- new ProducerAudio().handle(htmlout, user, force,sync);
- } catch (Exception e) {
- logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
- +" in ProducerAudio continuing "+ e.toString());
- }
- try {
- new ProducerVideo().handle(htmlout, user, force,sync);
- } catch (Exception e) {
- logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
- +" in ProducerVideo continuing "+ e.toString());
- }
- try {
- new ProducerOther().handle(htmlout, user, force,sync);
- } catch (Exception e) {
- logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
- +" in ProducerOther continuing "+ e.toString());
- }
- try {
- new ProducerStartPage().handle(htmlout, user, force,sync);
- } catch (Exception e) {
- logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
- +" in Producer.StartPage continuing "+ e.toString());
- }
- try {
- new ProducerContent().handle(htmlout, user, force,sync);
- } catch (Exception e) {
- logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
- +" in Producer.Content continuing "+ e.toString());
- }
- try {
- new ProducerOpenPosting().handle(htmlout, user, force,sync);
- } catch (Exception e) {
- logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
- +" in Producer.OpenPosting continuing "+ e.toString());
- }
- try {
- new ProducerTopics().handle(htmlout, user, force,sync);
- } catch (Exception e) {
- logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
- +" in Producer.Topics continuing "+ e.toString());
- }
- try {
- new ProducerNavigation().handle(htmlout, user, force,sync);
- } catch (Exception e) {
- logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
- +" in Producer.Navigation continuing "+ e.toString());
- }
-
- // Finish
- sessionConnectTime = new java.util.Date().getTime() - startTime;
- logHTML(htmlout, "Producer.All finished: " + sessionConnectTime + " ms.");
-
- // do we have to rsync the site
- if (sync==true){
- sessionConnectTime = 0;
- if (Helper.rsync()!=0){
- sessionConnectTime = new java.util.Date().getTime() - startTime;
- logHTML(htmlout, "Rsync failed: " + sessionConnectTime + " ms.");
- } else {
- sessionConnectTime = new java.util.Date().getTime() - startTime;
- logHTML(htmlout, "Rsync succeded: " + sessionConnectTime + " ms.");
- }
- }
- }
-
- // handle all
- public void handle2(PrintWriter htmlout, EntityUsers user, boolean force,boolean sync)
- throws StorageObjectException, ModuleException {
- printHTML(htmlout, "Producer.All: started");
-
- long sessionConnectTime = 0;
- long startTime = (new java.util.Date()).getTime();
- EntityContent currentContent;
-
- //get all new unproduced content-entities
- String whereClause="is_produced='0' && to_article_type>0";
- String orderBy="date desc";
- EntityList entityList = contentModule.getContent(whereClause,orderBy,0,-1,null);
-
- //get their values
- while (entityList != null) {
- for(int i=0;i<entityList.size();i++) {
- currentContent = (EntityContent)entityList.elementAt(i);
- EntityList topicEntityList = DatabaseContentToTopics.getInstance().getTopics(currentContent);
- SimpleHash topicHash = HTMLTemplateProcessor.makeSimpleHash(topicEntityList);
-
- try {
- //check if this content item is related to a topic
- if(currentContent.getId().equals(topicHash.get("content_id"))){
- // produce the ToicsList
- new ProducerTopics().handle(htmlout, user, force,sync,topicHash.get("topic_id").toString());
- }
- } catch (TemplateModelException e) {
- logHTML(htmlout, e.toString());
- }
- }
- }
-
- new ProducerContent().handle(htmlout, user, force,sync);
- new ProducerOpenPosting().handle(htmlout, user, force,sync);
- new ProducerStartPage().handle(htmlout, user, force,sync);
- new ProducerTopics().handle(htmlout, user, force,sync);
-
- // Finish
- sessionConnectTime = new java.util.Date().getTime() - startTime;
- logHTML(htmlout, "Producer.All finished: " + sessionConnectTime + " ms.");
- }
-}
-
+++ /dev/null
-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.*;
-
-//for pdf production
-import org.apache.fop.apps.* ;
-import org.xml.sax.InputSource;
-import org.xml.sax.XMLReader;
-import org.apache.log.*;
-
-public class ProducerContent extends Producer {
-
- private String contentTemplate=MirConfig.getProp("Producer.Content.Template");
- private String contentPrintableTemplate=MirConfig.getProp("Producer.PrintableContent.Template");
- private String html2foStyleSheetName=MirConfig.getProp("Producer.PrintableContent.html2foStyleSheetName");
- private String generateFO=MirConfig.getProp("GenerateFO");
- private String generatePDF=MirConfig.getProp("GeneratePDF");
- private String producerStorageRoot=MirConfig.getProp("Producer.StorageRoot");
- private Logger fopLog=null;
- private String templateDir = MirConfig.getPropWithHome("HTMLTemplateProcessor.Dir");
-
- 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. <heckmann@hbe.ca>
- *
- * 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
- *
- * ok, i figured that out a few months ago.. -mh
- *
- */
- //Configuration.initConfig("config");
- System.out.println(MirConfig.getProp("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
- {
-
- long startTime = System.currentTimeMillis();
- int pageCount=0;
-
- String whereClause = " ";
- String orderBy = " ";
- String htmlFileName = null;
- String foFileName = null;
- String pdfFileName = null;
- EntityContent currentContent;
- EntityList batchEntityList;
- EntityUsers userEntity=null;
-
- int contentBatchsize =
- Integer.parseInt(MirConfig.getProp("Producer.Content.Batchsize"));
- // 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'";
- // if true: produces a single content item
- if(id !=null){
- whereClause += " AND id="+id;
- // I think this avoids a select count(*)...
- contentBatchsize=-1;
- }
- 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;
- // this avoids a select count(*)...
- contentBatchsize=-1;
- }
- batchEntityList = contentModule.getContent(whereClause, orderBy, 0,
- contentBatchsize, userEntity);
- }
-
- while (batchEntityList!=null) {
- for(int i=0;i<batchEntityList.size();i++) {
- currentContent = (EntityContent)batchEntityList.elementAt(i);
-
- try {
-
- SimpleHash mergeData=new SimpleHash();
- mergeData.put("content", currentContent);
-
- /** @todo this should be assembled in entity */
- String date = currentContent.getValue("date");
- String year = date.substring(0,4);
- String month = date.substring(4,6);
- htmlFileName = producerDocRoot + "/" + year + "/" + month + "/" +
- currentContent.getValue("id") + ".shtml";
-
- //produce html
- boolean retVal = produce(contentTemplate, htmlFileName, mergeData, htmlout);
- if ( retVal ) currentContent.setProduced(true);
-
- //produce xsl:fo and pdf version(if desired)
- if (generateFO.toLowerCase().equals("yes")){
- foFileName = producerDocRoot + "/" + year + "/" + month + "/" + currentContent.getValue("id") + ".fo";
- boolean foRetVal = produce(contentPrintableTemplate, foFileName, mergeData, htmlout);
-
- if (generatePDF.toLowerCase().equals("yes")){
- pdfFileName = producerStorageRoot + producerDocRoot +"/" + year + "/" + month + "/" + currentContent.getValue("id") + ".pdf";
- Driver driver = new Driver();
-
- Hierarchy hierarchy = Hierarchy.getDefaultHierarchy();
- fopLog = hierarchy.getLoggerFor("fop");
- fopLog.setPriority(Priority.WARN);
-
- driver.setLogger(fopLog);
- driver.setRenderer(Driver.RENDER_PDF);
- File foFile=new File(producerStorageRoot + foFileName);
- File html2foStyleSheet=new File(templateDir+"/"+html2foStyleSheetName);
- InputHandler inputHandler = new XSLTInputHandler(foFile, html2foStyleSheet);
- XMLReader parser = inputHandler.getParser();
- driver.setOutputStream(new FileOutputStream(pdfFileName));
- driver.render(parser, inputHandler.getInputSource());
- }
- }
- } catch(Exception e) {
- String errorText = "Producer.Content <font color=red>ERROR</font> while producing content ID:"
- + currentContent.getId()+", skipping it :: "+e.toString();
- logHTML(htmlout, errorText);
- theLog.printError(errorText);
- e.printStackTrace();
- }
- pageCount++;
- }//for
- // if next batch get it...
- if (batchEntityList.hasNextBatch()){
- batchEntityList = contentModule.getContent(whereClause, orderBy,
- batchEntityList.getNextBatch(),
- contentBatchsize, userEntity);
- } else {
- batchEntityList=null;
- }
- }
- logHTMLFinish(htmlout, "Content", pageCount, startTime, System.currentTimeMillis());
- /** @todo why no syncing here? */
- }
-}
-
+++ /dev/null
-package mircoders.producer;
-
-import java.io.*;
-import java.lang.*;
-import java.util.*;
-import java.sql.*;
-
-import freemarker.template.*;
-
-import mir.misc.*;
-import mir.storage.*;
-import mir.module.*;
-import mir.entity.*;
-
-import mircoders.module.*;
-import mircoders.entity.*;
-import mircoders.storage.*;
-
-
-
-public class ProducerFeature extends ProducerList {
-
- public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync)
- throws StorageObjectException, ModuleException {
- orderBy="date desc";
- listTemplate = MirConfig.getProp("Producer.FeatureList.Template");
- EntityList featureEntityList = featureModule.getByWhereClause("","title", -1);
- boolean first=true;
- whereClause="is_published!=true AND to_article_type=0 AND id IN (";
- for(int i=0; i < featureEntityList.size(); i++){
-
- try {
- EntityTopics currentTopic = (EntityTopics)featureEntityList.elementAt(i);
- EntityList contentEntityList = DatabaseContentToTopics.getInstance().getContent(currentTopic);
- if(first==false) {
- whereClause += ",";
- }
- whereClause += currentTopic.getId();
- fileDesc = currentTopic.getValue("filename").trim();
- setAdditional("topic",currentTopic);
- } catch (Exception e) {
- logHTML(htmlout, "problem with feature skipping");
- }
-
- first = false;
- }
- whereClause += ")";
- handleIt(htmlout,user,force);
- }
-
- public static void main(String argv[]){
- try {
- new ProducerOpenPosting().handle(new PrintWriter(System.out), null,false, false);
- } catch(Exception e) {
- System.err.println(e.toString());
- }
- }
-}
+++ /dev/null
-package mircoders.producer;
-
-import java.io.*;
-import java.lang.*;
-import java.lang.reflect.*;
-import java.util.*;
-import java.sql.*;
-
-import freemarker.template.*;
-
-import mir.misc.*;
-import mir.media.*;
-import mir.storage.*;
-import mir.module.*;
-import mir.entity.*;
-
-import mircoders.module.*;
-import mircoders.entity.*;
-import mircoders.storage.*;
-
-
-
-abstract public class ProducerList extends Producer {
-
- public String listTemplate;
- public String whereClause;
- public String orderBy;
- public String fileDesc;
- protected HashMap additional = new HashMap();
-
-
-
- public void handle(PrintWriter htmlout, EntityUsers user, boolean sync, boolean force)
- throws StorageObjectException, ModuleException {
- handleIt(htmlout,user,force);
- }
-
- /** @todo this should return the number of pages produced! */
- public void handleIt(PrintWriter htmlout, EntityUsers user, boolean force)
- throws StorageObjectException, ModuleException {
-
- logHTML(htmlout, "Producer.List: started");
- int newsPerPage = Integer.parseInt(MirConfig.getProp("Producer.StartPage.Newswire"));
- long sessionConnectTime = 0;
- long startTime = (new java.util.Date()).getTime();
- String htmlFileName = "";
- String currentMediaId;
- EntityContent currentContent;
- EntityList list;
- EntityUsers userEntity=null;
- SimpleHash imageHash = new SimpleHash();
- int size = 0;
- int listSize = 0;
-
- int maxItemsOnPage = Integer.parseInt(MirConfig.getProp("Lists.Max.Items"));
-
- try {
- listSize = contentModule.getSize(whereClause);
- } catch (Exception e) {
- logHTML(htmlout,e.toString());
- }
-
- int modRest = listSize % maxItemsOnPage;
- int numberOfPages = (listSize - modRest) / maxItemsOnPage;
- boolean first=true;
- for (int i = 0;i < numberOfPages+1;i ++) {
- //break the loop, if only athe actuell pages should be produced
- if (force == false && i==3) {
- break;
- }
- //break, if only the first page has to be produced
- if (force == false && modRest != 0 && first==false){
- break;
- }
-
-
- if (first==true) {
- //get the data for the first page
- size=maxItemsOnPage + modRest;
- list = contentModule.getContent(whereClause, orderBy, 0, size, userEntity);
- first=false;
- } else {
- //get the data for the other pages
- list = contentModule.getContent(whereClause, orderBy, size, maxItemsOnPage, userEntity);
- size = size + maxItemsOnPage;
- }
-
- //now produce the pages
- if (list!=null || force==true) {
- SimpleHash mergeData = HTMLTemplateProcessor.makeSimpleHashWithEntitylistInfos(list);
- //process hashmap additional and add to mergedata
- if (additional != null) {
- Set set = additional.keySet();
- for (Iterator it = set.iterator();it.hasNext();) {
- String key = (String)it.next();
- mergeData.put(key,(TemplateModel)additional.get(key));
- }
- }
-
- if (i==0){
- htmlFileName = producerDocRoot + "/" + fileDesc + ".shtml";
- mergeData.put("filename",fileDesc + ".shtml");
- mergeData.put("previousPage","");
- if(numberOfPages<=1){
- mergeData.put("nextPage","");
- } else {
- mergeData.put("nextPage",fileDesc + (numberOfPages-1) + ".shtml");
- }
- } else {
- if (i==1 && numberOfPages > 2){
- mergeData.put("previousPage",fileDesc + ".shtml");
- mergeData.put("nextPage",fileDesc + (numberOfPages-2) + ".shtml");
- } else {
- if (i==(numberOfPages-1)){
- mergeData.put("previousPage",fileDesc + (numberOfPages-i+1) + ".shtml");
- mergeData.put("nextPage","");
- } else {
- mergeData.put("previousPage",fileDesc + (numberOfPages-(i-1)) + ".shtml");
- mergeData.put("nextPage",fileDesc + (numberOfPages-(i+1)) + ".shtml");
- }
- }
- htmlFileName = producerDocRoot + "/" + fileDesc + (numberOfPages-i) + ".shtml";
- mergeData.put("filename",fileDesc + (numberOfPages-i) + ".shtml");
- }
-
- //producing the html-files
- boolean retVal = produce(listTemplate, htmlFileName, mergeData, htmlout);
- } //end if
- }//end for
-
- sessionConnectTime = new java.util.Date().getTime() - startTime;
- logHTML(htmlout, "Producer.List finished: " + sessionConnectTime + " ms.");
- } //end handle
-
- public void setAdditional(String key, TemplateModel value) {
- additional.put(key,value);
- }
-
-}
+++ /dev/null
-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.*;
-
-/**
- * Title: mir - another content management system
- * Description:
- * Copyright: Copyright (c) 2001
- * Company: indymedia
- * @author idefix
- * @version 1.0
- */
-
-public class ProducerNavigation extends Producer {
-
- private static String naviPageTemplate = MirConfig.getProp("Producer.Navigation.Template");
-
- public void handle(PrintWriter htmlout, EntityUsers user, boolean forced, boolean sync)
- throws mir.module.ModuleException, mir.storage.StorageObjectException {
-
- printHTML(htmlout, "Producer.Navigation: started");
-
- long sessionConnectTime = 0;
- long startTime = (new java.util.Date()).getTime();
- String nowWebdbDate = StringUtil.date2webdbDate(new GregorianCalendar());
- String whereClause;
- String orderBy;
- FileWriter outputFile;
- String htmlFileName;
- EntityContent currentContent;
- EntityList entityList;
- SimpleHash naviPageModel;
-
- // get the imclinks
- entityList = linksImcsModule.getByWhereClause("", "sortpriority, title", -1);
- EntityList theParentList = linksImcsModule.getByWhereClause("to_parent_id=NULL", "sortpriority, title", -1);
-
- // put the informations into the navipagemodel
- naviPageModel = new SimpleHash();
- naviPageModel.put("topics", topicsModule.getTopicsList());
- naviPageModel.put("imclist", entityList);
- naviPageModel.put("parentlist", theParentList);
-
- htmlFileName = producerDocRoot + "/navigation.inc";
-
- produce(naviPageTemplate, htmlFileName, naviPageModel, new LineFilterWriter(htmlout));
-
- // Finish
- sessionConnectTime = new java.util.Date().getTime() - startTime;
- logHTML(htmlout, "Producer.Navigation finished: " + sessionConnectTime + " ms.");
-
- if(sync==true){
- Helper.rsync();
- logHTML(htmlout, "Producer.Startseite: rsync done");
- }
- }
-
-}
+++ /dev/null
-package mircoders.producer;
-
-import java.io.*;
-import java.lang.*;
-import java.util.*;
-import java.sql.*;
-
-import freemarker.template.*;
-
-import mir.misc.*;
-import mir.storage.*;
-import mir.module.*;
-import mir.entity.*;
-
-import mir.module.*;
-import mircoders.entity.*;
-import mir.storage.*;
-
-
-
-public class ProducerOpenPosting extends ProducerList {
-
-
-
- public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync)
- throws StorageObjectException, ModuleException
- {
- listTemplate = MirConfig.getProp("Producer.OpenPosting.Template");
- whereClause="is_published='1'";
- orderBy="date desc, webdb_create desc";
- fileDesc="open";
-
- setAdditional("topicslist",topicsModule.getTopicsList());
- setAdditional("title",new SimpleScalar("Open-Posting"));
- handleIt(htmlout,user,force);
- }
-
-
- public static void main(String argv[]){
- try {
- new ProducerOpenPosting().handle(new PrintWriter(System.out), null,false, false);
- } catch(Exception e) {
- System.err.println(e.toString());
- }
- }
-
-}
+++ /dev/null
-package mircoders.producer;
-
-import java.io.*;
-import java.util.*;
-
-import freemarker.template.*;
-
-import mir.entity.*;
-import mir.misc.*;
-import mir.module.*;
-import mir.storage.*;
-import mircoders.module.*;
-import mircoders.storage.*;
-import mircoders.entity.*;
-
-
-public class ProducerStartPage extends Producer {
-
- private static String startPageTemplate = MirConfig.getProp("Producer.StartPage.Template");
- private static String featuresRSSTemplate = MirConfig.getProp("Producer.FeaturesRSS.Template");
- private static int itemsPerPage = Integer.parseInt(MirConfig.getProp("Producer.StartPage.Items"));
- private static int newsPerPage = Integer.parseInt(MirConfig.getProp("Producer.StartPage.Newswire"));
-
- public static void main(String argv[]){
- try {
- // Why are we reloading the configuration here?
- // is there something I'm missing?
- // mh. <heckmann@hbe.ca>
- // Configuration.initConfig(argv[0]);
- new ProducerStartPage().handle(new PrintWriter(System.out), null);
- } catch(Exception e) {
- System.err.println(e.toString());
- }
- }
-
- public void handle(PrintWriter htmlout, EntityUsers user, boolean force,boolean sync)
- throws StorageObjectException, ModuleException
- {
- long startTime = System.currentTimeMillis();
- printHTML(htmlout, "Producer.StartPage: started");
- SimpleHash startPageModel = new SimpleHash();
-
- // breaking news
- ModuleBreaking breakingModule = new ModuleBreaking(DatabaseBreaking.getInstance());
- startPageModel.put("breakingnews", breakingModule.getBreakingNews());
- startPageModel.put("topics", topicsModule.getTopicsList());
- startPageModel.put("newswire", contentModule.getNewsWire(0,newsPerPage));
- startPageModel.put("startspecial", contentModule.getStartArticle());
- startPageModel.put("features", contentModule.getFeatures(0,itemsPerPage));
- startPageModel.put("dc_now", new SimpleScalar(StringUtil.date2w3DateTime(new GregorianCalendar())));
-
-
- /** @todo switch to compressed */
- produce(startPageTemplate, producerDocRoot + "/index.shtml", startPageModel, htmlout);
-
- /** should be mandatory in light of new www.indy newswire */
- produce(featuresRSSTemplate, producerDocRoot + "/features.1-0.rdf", startPageModel, htmlout);
-
- // finished
- logHTMLFinish(htmlout, "Startpage", 1, startTime, System.currentTimeMillis());
-
- if(sync==true){
- logHTML(htmlout, "Producer.Startpage: rsyncing...");
- Helper.rsync();
- printHTML(htmlout, "Producer.Startpage: rsync done");
- }
- }
-}
-
+++ /dev/null
-package mircoders.producer;
-
-import java.io.*;
-import java.lang.*;
-import java.lang.reflect.*;
-import java.util.*;
-import java.sql.*;
-
-import freemarker.template.*;
-
-import mir.misc.*;
-import mir.media.*;
-import mir.storage.*;
-import mir.module.*;
-import mir.entity.*;
-
-import mircoders.entity.*;
-import mircoders.storage.*;
-
-
-
-public class ProducerTopics extends ProducerList {
-
- public String where;
- String currentMediaId;
- EntityList upMediaEntityList;
- EntityList imageEntityList;
- EntityList currentMediaList;
- Entity mediaType;
- EntityMedia uploadedMedia;
- Class mediaHandlerClass=null;
- MirMedia mediaHandler=null;
- String mediaHandlerName=null;
- Database mediaStorage=null;
- String tinyIcon;
- String iconAlt;
-
- public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync, String id)
- throws StorageObjectException, ModuleException {
- where=id;
- handle(htmlout,user,force,sync);
- }
-
- public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync)
- throws StorageObjectException, ModuleException
- {
- long startTime = System.currentTimeMillis();
- int pageCount =0;
- logHTML(htmlout, "Producer.Topics: started");
-
- /** @todo should be done in static */
- listTemplate = MirConfig.getProp("Producer.TopicList.Template");
-
- orderBy="date desc, webdb_create desc";
- EntityList topicsEntityList;
- if(where==null){
- topicsEntityList = topicsModule.getByWhereClause("","title", -1);
- } else {
- topicsEntityList = topicsModule.getByWhereClause(where,"title", -1);
- }
-
- for(int i=0; i < topicsEntityList.size(); i++){
-
- EntityTopics currentTopic = (EntityTopics)topicsEntityList.elementAt(i);
-
- try {
- EntityList contentEntityList = DatabaseContentToTopics.getInstance().getContent(currentTopic);
- String whereClauseSpecial=null;
-
- if (contentEntityList!=null || force==true) {
- if (contentEntityList!=null){
- boolean first=true;
- whereClause="is_published='1' AND to_article_type >= 1 AND to_article_type <=2 AND id IN (";
- whereClauseSpecial="is_published='1' AND to_article_type=3 AND id IN (";
- for(int j=0; j < contentEntityList.size(); j++){
- if(first==false) {
- whereClause += ",";
- whereClauseSpecial += ",";
- }
- EntityContent currentContent = (EntityContent)contentEntityList.elementAt(j);
- whereClause += currentContent.getId();
- whereClauseSpecial += currentContent.getId();
-
- setAdditional("topic",currentTopic);
-
- first = false;
- }
- whereClause += ")";
- whereClauseSpecial += ")";
- }
-
- if(contentEntityList==null && force==true){
- //hihi, das ist eigentlich boese
- whereClause="is_published='1' AND to_article_type>=1 AND id IN (0)";
- }
-
- fileDesc = currentTopic.getValue("filename");
-
- // get the startarticle
- EntityList entityList = contentModule.getContent(whereClauseSpecial,"date desc, webdb_create desc",0,1);
- String currentMediaId = null;
- SimpleHash imageHash = new SimpleHash();
- EntityContent currentContent;
- if(entityList != null && entityList.size()==1){
- currentContent = (EntityContent)entityList.elementAt(0);
- try {
- setAdditional("special",currentContent);
- } catch (Exception e) {
- theLog.printError("ProducerTopics: problem with start special media: "+currentContent.getId()+" "+e.toString()+" <font color=\"red\">skipping</font>");
- logHTML(htmlout,"ProducerTopics: problem with start special media: "+currentContent.getId()+" "+e.toString());
- }
- }
-
- //set the list of topics
- setAdditional("topicslist",topicsEntityList);
-
- handleIt(htmlout,user,force);
- pageCount++;
- }
- } catch (Exception e) {
- theLog.printError("ProducerTopics: problem with start special media: "
- +e.toString()+" <font color=\"red\">skipping</font>");
- logHTML(htmlout,"ProducerTopics: problem with topic id: "
- +currentTopic.getId()+ "<font color=\"red\">skipping</font>");
- }
- }
- logHTMLFinish(htmlout, "Topics", pageCount, startTime, System.currentTimeMillis());
- }
-
- public static void main(String argv[]){
- try {
- new ProducerOpenPosting().handle(new PrintWriter(System.out), null,false, false);
- } catch(Exception e) {
- System.err.println(e.toString());
- }
- }
-}
+++ /dev/null
-package mircoders.producer;
-
-import mir.producer.*;
-import java.io.*;
-
-// ML: needs to be tested!
-
-public class ScriptCallProducer implements mir.producer.Producer {
- String script;
-
- public ScriptCallProducer(String aScript) {
- script = aScript;
- }
-
- public void produce( PrintWriter aLogger ) throws ProducerFailure {
- Process process;
- int returnValue;
-
- aLogger.println("Executing " + script + ":");
-
- try {
- process = Runtime.getRuntime().exec(script);
- returnValue = process.waitFor();
- aLogger.println("Terminated successfully, return value = " + returnValue + ".");
- }
- catch (Throwable e) {
- aLogger.println("Exception has occurred: " + e.getMessage() + ":");
- e.printStackTrace(aLogger);
- throw new ProducerFailure("Executing script failed",e);
- }
- }
-}
+++ /dev/null
-package mircoders.producer;
-
-import java.util.*;
-import mir.entity.*;
-import mir.producer.*;
-import mircoders.storage.*;
-
-public class ScriptCallProducerFactory implements ProducerFactory {
- private String script;
-
-
- public ScriptCallProducerFactory(String aScript) {
- script=aScript;
- }
-
- public mir.producer.Producer makeProducer(String aVerb) throws ProducerFailure {
-
-
- return new ScriptCallProducer(script);
- };
-
- public Iterator verbs() {
- Vector verbList = new Vector();
-
- verbList.add("run");
-
- return verbList.iterator();
- };
-}
-
+++ /dev/null
-package mircoders.producer;
-
-import java.io.*;
-import java.util.*;
-
-import mir.misc.*;
-import mir.entity.*;
-import mir.producer.*;
-import mir.generator.*;
-
-import mircoders.localizer.*;
-import mircoders.global.*;
-import mircoders.entity.*;
-
-import mircoders.module.*;
-
-import org.apache.struts.util.MessageResources;
-
-public class StartPageProducer implements mir.producer.Producer {
-
- private String generatorIdentifier;
- private String resourceBundle;
- private String outputFile;
- private EntityList newswireItems;
- private EntityList features;
- private EntityList topics;
- private EntityList breakingNews;
-
- EntityBrowser browser;
-
- public StartPageProducer(
- String aGeneratorIdentifier,
- String aResourceBundle,
- String anOutputFile,
-
- EntityList aNewswireItems,
- EntityList aFeatures,
- EntityList aTopics,
- EntityList aBreakingNews) {
-
- generatorIdentifier=aGeneratorIdentifier;
- resourceBundle=aResourceBundle;
- outputFile=anOutputFile;
- newswireItems = aNewswireItems;
- features = aFeatures;
- topics = aTopics;
- breakingNews = aBreakingNews;
- }
-
- public void produce( PrintWriter aLogger ) throws ProducerFailure {
- Map generationValues = new HashMap();
- Map dataMap = new HashMap();
-
- try {
- MirGlobal.localizer().producerTool().initializeGenerationValueSet(generationValues);
-
- MessageResources messages = MessageResources.getMessageResources(resourceBundle);
- generationValues.put("lang", new MessageMethodModel(null, messages) );
-
- generationValues.put("data", dataMap);
-
- dataMap.put("dc_now", StringUtil.date2w3DateTime(new GregorianCalendar()));
- dataMap.put("newswire", newswireItems);
- dataMap.put("features", features);
- dataMap.put("breakingnews", breakingNews);
- dataMap.put("topics", topics);
-
- aLogger.println("StartPageProducer.produce:");
- aLogger.println("generating: " + outputFile);
-
- Generator generator = MirGlobal.localizer().generators().makeGenerator(generatorIdentifier);
- PrintWriter printWriter = MirGlobal.localizer().producerTool().openWriter(outputFile);
- generator.generate(printWriter, generationValues, aLogger);
- MirGlobal.localizer().producerTool().closeWriter(printWriter);
-
- aLogger.println("done");
- }
- catch (Exception e) {
- aLogger.println("exception while generating " + outputFile + ":");
- aLogger.println(e.getMessage());
- e.printStackTrace(aLogger);
- aLogger.flush();
- }
- }
-}
+++ /dev/null
-package mircoders.producer;
-
-import java.util.*;
-import mir.entity.*;
-import mir.producer.*;
-import mircoders.storage.*;
-import mircoders.module.*;
-
-public class StartPageProducerFactory implements ProducerFactory {
- private String generatorIdentifier;
- private String resourceBundle;
- private String outputFile;
- private int nrNewswireItems;
- private int nrFeatures;
-
- public StartPageProducerFactory(
- String aGeneratorIdentifier,
- String aResourceBundle,
- String anOutputFile,
- int aNrFeatures,
- int aNrNewswireItems) {
-
- generatorIdentifier = aGeneratorIdentifier;
- resourceBundle = aResourceBundle;
- outputFile = anOutputFile;
- nrFeatures = aNrFeatures;
- nrNewswireItems = aNrNewswireItems;
- }
-
-
- public mir.producer.Producer makeProducer(String aVerb) throws ProducerFailure {
-
- try {
- ModuleContent contentModule = new ModuleContent(DatabaseContent.getInstance());
- ModuleTopics topicsModule = new ModuleTopics(DatabaseTopics.getInstance());
- ModuleBreaking breakingModule = new ModuleBreaking(DatabaseBreaking.getInstance());
-
- return new StartPageProducer(
- generatorIdentifier,
- resourceBundle,
- outputFile,
- contentModule.getNewsWire(0,nrNewswireItems),
- contentModule.getFeatures(0,nrFeatures),
- topicsModule .getTopicsList(),
- breakingModule.getBreakingNews());
- }
- catch (Throwable e) {
- throw new ProducerFailure("Creating StartPageProducer failed",e);
- }
- };
-
- public Iterator verbs() {
- Vector verbList = new Vector();
-
- verbList.add("all");
-
- return verbList.iterator();
- };
-}
-
+++ /dev/null
-package mircoders.producer;
-
-import java.io.*;
-import java.util.*;
-
-import mir.misc.*;
-//import mir.entity.*;
-import mir.producer.*;
-import mir.generator.*;
-
-import mircoders.localizer.*;
-import mircoders.global.*;
-//import mircoders.entity.*;
-
-//import mircoders.module.*;
-
-import org.apache.struts.util.MessageResources;
-
-public class StaticProducer implements mir.producer.Producer {
-
- private String generatorIdentifier;
- private String resourceBundle;
- private String outputFile;
-
- public StaticProducer(
- String aGeneratorIdentifier,
- String aResourceBundle,
- String anOutputFile) {
-
- generatorIdentifier=aGeneratorIdentifier;
- resourceBundle=aResourceBundle;
- outputFile=anOutputFile;
- }
-
- public void produce( PrintWriter aLogger ) throws ProducerFailure {
- Map generationValues = new HashMap();
- Map dataMap = new HashMap();
-
- try {
- MirGlobal.localizer().producerTool().initializeGenerationValueSet(generationValues);
-
- MessageResources messages = MessageResources.getMessageResources(resourceBundle);
- generationValues.put("lang", new MessageMethodModel(null, messages) );
-
- generationValues.put("data", dataMap);
-
- dataMap.put("dc_now", StringUtil.date2w3DateTime(new GregorianCalendar()));
-
- aLogger.println("StaticProducer.produce:");
- aLogger.println(" generating: " + outputFile + " from " + generatorIdentifier);
-
- Generator generator = MirGlobal.localizer().generators().makeGenerator(generatorIdentifier);
- PrintWriter printWriter = MirGlobal.localizer().producerTool().openWriter(outputFile);
- generator.generate(printWriter, generationValues, aLogger);
- MirGlobal.localizer().producerTool().closeWriter(printWriter);
-
- aLogger.println("done");
- }
- catch (Exception e) {
- aLogger.println("exception while generating " + outputFile + ":");
- aLogger.println(e.getMessage());
- e.printStackTrace(aLogger);
- aLogger.flush();
- }
- }
-}
+++ /dev/null
-package mircoders.producer;
-
-import java.util.*;
-import mir.producer.*;
-
-public class StaticProducerFactory implements ProducerFactory {
- private String generatorIdentifier;
- private String resourceBundle;
- private String outputFile;
-
- public StaticProducerFactory(
- String aGeneratorIdentifier,
- String aResourceBundle,
- String anOutputFile) {
-
- generatorIdentifier = aGeneratorIdentifier;
- resourceBundle = aResourceBundle;
- outputFile = anOutputFile;
- }
-
- public mir.producer.Producer makeProducer(String aVerb) throws ProducerFailure {
- try {
- return new StaticProducer( generatorIdentifier, resourceBundle, outputFile );
- }
- catch (Throwable e) {
- throw new ProducerFailure("Creating StaticProducer failed",e);
- }
- };
-
- public Iterator verbs() {
- Vector verbList = new Vector();
-
- verbList.add("all");
-
- return verbList.iterator();
- };
-}
-
+++ /dev/null
-package mircoders.producer;
-
-import java.util.*;
-import mir.entity.*;
-import mir.producer.*;
-import mir.util.*;
-import mircoders.storage.*;
-import mircoders.module.*;
-import mircoders.entity.*;
-import mircoders.global.*;
-import mircoders.localizer.*;
-
-
-public class TopicStartPageProducerFactory implements ProducerFactory {
- private String generatorIdentifier;
- private String resourceBundle;
- private String outputFileNameExpression;
- private int nrNewswireItems;
- private int nrFeatures;
-
- public TopicStartPageProducerFactory(
- String aGeneratorIdentifier,
- String aResourceBundle,
- String anOutputFileNameExpression,
- int aNrFeatures,
- int aNrNewswireItems) {
-
- generatorIdentifier = aGeneratorIdentifier;
- resourceBundle = aResourceBundle;
- outputFileNameExpression = anOutputFileNameExpression;
- nrFeatures = aNrFeatures;
- nrNewswireItems = aNrNewswireItems;
- }
-
-
- public mir.producer.Producer makeProducer(String aVerb) throws ProducerFailure {
- CompositeProducer result = new CompositeProducer();
- Map values = new HashMap();
-
-
- try {
- MirGlobal.localizer().producerTool().initializeGenerationValueSet(values);
-
- ModuleContent contentModule = new ModuleContent(DatabaseContent.getInstance());
- ModuleTopics topicsModule = new ModuleTopics(DatabaseTopics.getInstance());
- ModuleBreaking breakingModule = new ModuleBreaking(DatabaseBreaking.getInstance());
-
- EntityBrowser topicBrowser = new EntityBrowser(
- DatabaseTopics.getInstance(),
- "",
- "",
- 100);
-
- while (topicBrowser.hasNext()) {
- Entity topic = (Entity) topicBrowser.next();
- values.put("title", topic.getValue("title"));
- values.put("filename", topic.getValue("filename"));
- values.put("main_url", topic.getValue("main_url"));
- values.put("archiv_url", topic.getValue("archiv_url"));
-
-
-
- // ML: ok, this is way too low-level for this place:
- String orderBy = "webdb_create desc";
- String topicSelection = "exists (select * from content_x_topic where content_id=content.id and topic_id='"+topic.getValue("id")+"')";
- String featureWhereClause = "is_published='1' and to_article_type='2' and "+topicSelection;
- String newsWireWhereClause = "is_published='1' and to_article_type='1' and "+topicSelection;
-
- result.addProducer(
-
- // "exists (select * from content_x_topic where content_id=content.id and topic_id="+topic.getValue("id")
- new StartPageProducer(
- generatorIdentifier,
- resourceBundle,
- ParameterExpander.expandExpression(values, outputFileNameExpression),
- contentModule.getContent(newsWireWhereClause, orderBy, 0,nrNewswireItems),
- contentModule.getContent(featureWhereClause, orderBy, 0,nrFeatures),
- topicsModule .getTopicsList(),
- breakingModule.getBreakingNews()));
- }
-
- return result;
-
-
- }
- catch (Throwable e) {
- throw new ProducerFailure("Creating TopicStartPageProducer failed",e);
- }
- };
-
- public Iterator verbs() {
- Vector verbList = new Vector();
-
- verbList.add("all");
-
- return verbList.iterator();
- };
-}
-
protected void setupContentFactory(CompositeProducerFactory aContentFactory) {
- EntityEnumeratingProducerNode contentNode = null;
+/* EntityEnumeratingProducerNode contentNode = null;
try {
contentNode =
contentNode.addVerb( "new", "is_published='1' and is_produced='f'", "" );
aContentFactory.addFactory( new NodedProducerFactory( contentNode ) );
-
+*/
// public EntityEnumeratingProducerNode(String aKey, StorageObject aStorage, EntityAdapterDefinition aDefinition, ProducerNode aSubNode) {
}
protected void setupStaticFactory(CompositeProducerFactory aStaticFactory) {
- aStaticFactory.addFactory(
+/* aStaticFactory.addFactory(
new StaticProducerFactory(
"producer/nav.template",
"bundles.admin",
"producer/articlepost.template",
"bundles.admin",
MirGlobal.getConfigProperty("Producer.StorageRoot") + "/nl/articlepost.shtml"));
- }
+*/ }
}
}
protected void setupSynchronizationFactory(CompositeProducerFactory aSynchronizationFactory) {
- if(MirGlobal.getConfigBooleanProperty("Rsync")){
+/* if(MirGlobal.getConfigBooleanProperty("Rsync")){
aSynchronizationFactory.addFactory(
new ScriptCallProducerFactory(MirGlobal.getConfigProperty("Rsync.Script.Path")));
}
else {
- NullProducerFactory nullFactory = new NullProducerFactory();
+*/ NullProducerFactory nullFactory = new NullProducerFactory();
nullFactory.addVerb("run");
aSynchronizationFactory.addFactory(nullFactory);
- }
+/* }*/
}
protected void setupStaticFactory(CompositeProducerFactory aStaticFactory) {
}
protected void setupSynchronizationFactory(CompositeProducerFactory aSynchronizationFactory) {
- if(MirGlobal.getConfigBooleanProperty("Rsync")){
+/* if(MirGlobal.getConfigBooleanProperty("Rsync")){
aSynchronizationFactory.addFactory(
new ScriptCallProducerFactory(MirGlobal.getConfigProperty("Rsync.Script.Path")));
}
else {
+*/
NullProducerFactory nullFactory = new NullProducerFactory();
nullFactory.addVerb("run");
aSynchronizationFactory.addFactory(nullFactory);
+/*
}
+ */
}
protected void setupStaticFactory(CompositeProducerFactory aStaticFactory) {