public class ProducerStartPage extends Producer {
- private static String startPageTemplate = Configuration.getProperty("Producer.StartPage.Template");
- private static int itemsPerPage = Integer.parseInt(Configuration.getProperty("Producer.StartPage.Items"));
+ private static String startPageTemplate = Configuration.getProperty("Producer.StartPage.Template");
+ private static int itemsPerPage = Integer.parseInt(Configuration.getProperty("Producer.StartPage.Items"));
private static int newsPerPage = Integer.parseInt(Configuration.getProperty("Producer.StartPage.Newswire"));
- public static void main(String argv[]){
- try {
- 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
- {
- printHTML(htmlout, "Producer.StartPage: started");
-
- 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 nowWebdbDate = StringUtil.date2webdbDate(new GregorianCalendar());
- String whereClause;
- String orderBy;
- FileWriter outputFile;
- String htmlFileName;
- EntityContent currentContent;
- EntityList entityList;
- SimpleHash startPageModel;
- SimpleList contentList;
- String currentMediaId;
- SimpleHash imageHash = new SimpleHash();
-
- // get the topiclist
- entityList = topicsModule.getByWhereClause("","title",-1);
- SimpleList topicList = HTMLTemplateProcessor.makeSimpleList(entityList);
-
- // get the newswire
- whereClause="is_published=true AND to_article_type >= 1";
- entityList = contentModule.getContent(whereClause,"date desc, webdb_create desc",0,newsPerPage);
- SimpleList newsWireList = HTMLTemplateProcessor.makeSimpleList(entityList);
-
- // get the startarticle and the related images
- whereClause="is_published=true AND to_article_type=4";
- entityList = contentModule.getContent(whereClause,"date desc, webdb_create desc",0,1);
- //if no startspecial exists
- if (entityList==null || entityList.size()==0){
- whereClause="is_published=true AND to_article_type=3";
- entityList = contentModule.getContent(whereClause,"date desc, webdb_create desc",0,1);
- }
- SimpleList startItemList = HTMLTemplateProcessor.makeSimpleList(entityList);
- for (int i=0; i < entityList.size();i++) {
- currentContent = (EntityContent)entityList.elementAt(i);
- currentMediaId = currentContent.getValue("to_media");
- if (currentMediaId!=null && !currentMediaId.equals("")) {
- imageHash.put(currentMediaId, HTMLTemplateProcessor.makeSimpleHash(imageModule.getById(currentMediaId)));
- }
- }
-
- // get the breaking news
- // only the first 5
- ModuleBreaking breakingModule = new ModuleBreaking(DatabaseBreaking.getInstance());
- entityList = breakingModule.getByWhereClause(null,"webdb_create desc",0,5);
- SimpleList breakingList = HTMLTemplateProcessor.makeSimpleList(entityList);
-
- // get the articles
- whereClause="is_published=true AND to_article_type=2";
- orderBy="date desc, webdb_create desc";
- entityList = contentModule.getContent(whereClause, orderBy, 0, itemsPerPage);
- for (int i=0; i < entityList.size();i++) {
- currentContent = (EntityContent)entityList.elementAt(i);
- /**
- if (currentContent.get("is_html").equals("0")) {
- currentContent.put("content_data",StringUtil.createHTML((String)currentContent.get("content_data"),imageRoot,mailLinkName,extLinkName,intLinkName));
- currentContent.put("description",StringUtil.createHTML((String)currentContent.get("description"),imageRoot,mailLinkName,extLinkName,intLinkName));
- }
- */
- currentMediaId = currentContent.getValue("to_media");
- if (currentMediaId!=null && !currentMediaId.equals("")) {
- imageHash.put(currentMediaId, HTMLTemplateProcessor.makeSimpleHash(imageModule.getById(currentMediaId)));
- }
- }
- SimpleList itemList = HTMLTemplateProcessor.makeSimpleList(entityList);
-
- // Zusaetzlich Informationen
- startPageModel = new SimpleHash();
- startPageModel.put("breaking", breakingList);
- startPageModel.put("topics", topicList);
- startPageModel.put("newswire", newsWireList);
- startPageModel.put("start", startItemList);
- startPageModel.put("items", itemList);
- startPageModel.put("images", imageHash);
-
- htmlFileName = producerDocRoot + "/index.shtml";
-
- produce(startPageTemplate, htmlFileName, startPageModel, new LineFilterWriter(htmlout));
-
- // Finish
- sessionConnectTime = new java.util.Date().getTime() - startTime;
- logHTML(htmlout, "Producer.Startseite finished: " + sessionConnectTime + " ms.");
- if(sync==true){
- Helper.rsync();
- logHTML(htmlout, "Producer.Startseite: rsync done");
- }
- }
+ public static void main(String argv[]){
+ try {
+ 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
+ {
+ printHTML(htmlout, "Producer.StartPage: started");
+
+ 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 nowWebdbDate = StringUtil.date2webdbDate(new GregorianCalendar());
+ String whereClause;
+ String orderBy;
+ FileWriter outputFile;
+ String htmlFileName;
+ EntityContent currentContent;
+ EntityList entityList;
+ SimpleHash startPageModel;
+ SimpleList contentList;
+ String currentMediaId;
+ SimpleHash imageHash = new SimpleHash();
+
+ // get the topiclist
+ entityList = topicsModule.getByWhereClause("","title",-1);
+ SimpleList topicList = HTMLTemplateProcessor.makeSimpleList(entityList);
+
+ // get the newswire
+ whereClause="is_published=true AND to_article_type >= 1";
+ entityList = contentModule.getContent(whereClause,"date desc, webdb_create desc",0,newsPerPage);
+ SimpleList newsWireList = HTMLTemplateProcessor.makeSimpleList(entityList);
+
+ // get the startarticle and the related images
+ whereClause="is_published=true AND to_article_type=4";
+ entityList = contentModule.getContent(whereClause,"date desc, webdb_create desc",0,1);
+ //if no startspecial exists
+ if (entityList==null || entityList.size()==0){
+ whereClause="is_published=true AND to_article_type=3";
+ entityList = contentModule.getContent(whereClause,"date desc, webdb_create desc",0,1);
+ }
+ SimpleList startItemList = HTMLTemplateProcessor.makeSimpleList(entityList);
+ for (int i=0; i < entityList.size();i++) {
+ currentContent = (EntityContent)entityList.elementAt(i);
+ currentMediaId = currentContent.getValue("to_media");
+ if (currentMediaId!=null && !currentMediaId.equals("")) {
+ imageHash.put(currentMediaId, HTMLTemplateProcessor.makeSimpleHash(imageModule.getById(currentMediaId)));
+ }
+ }
+
+ // get the breaking news
+ // only the first 5
+ ModuleBreaking breakingModule = new ModuleBreaking(DatabaseBreaking.getInstance());
+ entityList = breakingModule.getByWhereClause(null,"webdb_create desc",0,5);
+ SimpleList breakingList = HTMLTemplateProcessor.makeSimpleList(entityList);
+
+ // get the articles
+ whereClause="is_published=true AND to_article_type=2";
+ orderBy="date desc, webdb_create desc";
+ entityList = contentModule.getContent(whereClause, orderBy, 0, itemsPerPage);
+ for (int i=0; i < entityList.size();i++) {
+ currentContent = (EntityContent)entityList.elementAt(i);
+ /**
+ if (currentContent.get("is_html").equals("0")) {
+ currentContent.put("content_data",StringUtil.createHTML((String)currentContent.get("content_data"),imageRoot,mailLinkName,extLinkName,intLinkName));
+ currentContent.put("description",StringUtil.createHTML((String)currentContent.get("description"),imageRoot,mailLinkName,extLinkName,intLinkName));
+ }
+ */
+ currentMediaId = currentContent.getValue("to_media");
+ if (currentMediaId!=null && !currentMediaId.equals("")) {
+ imageHash.put(currentMediaId, HTMLTemplateProcessor.makeSimpleHash(imageModule.getById(currentMediaId)));
+ }
+ }
+ SimpleList itemList = HTMLTemplateProcessor.makeSimpleList(entityList);
+
+ // Zusaetzlich Informationen
+ startPageModel = new SimpleHash();
+ startPageModel.put("breaking", breakingList);
+ startPageModel.put("topics", topicList);
+ startPageModel.put("newswire", newsWireList);
+ startPageModel.put("start", startItemList);
+ startPageModel.put("items", itemList);
+ startPageModel.put("images", imageHash);
+
+ htmlFileName = producerDocRoot + "/index.shtml";
+
+ produce(startPageTemplate, htmlFileName, startPageModel, htmlout);
+
+ // Finish
+ sessionConnectTime = new java.util.Date().getTime() - startTime;
+ logHTML(htmlout, "Producer.Startseite finished: " + sessionConnectTime + " ms.");
+ if(sync==true){
+ Helper.rsync();
+ logHTML(htmlout, "Producer.Startseite: rsync done");
+ }
+ }
}