From: idfx Date: Fri, 14 Sep 2001 13:12:19 +0000 (+0000) Subject: direct op X-Git-Tag: prexmlproducerconfig~488 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=10f8008d76b07f1e6d2ed16c391d3411f0abf184;p=mir.git direct op --- diff --git a/source/OpenMir.java b/source/OpenMir.java index fe9e1c96..4b1d1785 100755 --- a/source/OpenMir.java +++ b/source/OpenMir.java @@ -24,9 +24,8 @@ import mircoders.storage.*; */ -public class OpenMir extends AbstractServlet -{ - private static Logfile theLog; +public class OpenMir extends AbstractServlet { + private static boolean confed=false; private static String lang; public HttpSession session; @@ -42,12 +41,13 @@ public class OpenMir extends AbstractServlet long startTime = (new java.util.Date()).getTime(); long sessionConnectTime=0; - session = req.getSession(true); if (!confed){ confed = getConfig(req); } - + + session = req.getSession(); + if(session.getAttribute("Language")==null){ setLanguage(session,getAcceptLanguage(req)); } @@ -56,7 +56,10 @@ public class OpenMir extends AbstractServlet try { ServletModuleDispatch.dispatch(ServletModuleOpenIndy.getInstance(),req,res); } - catch (ServletModuleException e){ handleError(res,res.getWriter(), "OpenIndy :: ServletException in Module ServletModule -- " + e.toString()); } + catch (ServletModuleException e){ + e.printStackTrace(); + handleError(res,res.getWriter(), "OpenIndy :: ServletException in Module ServletModule -- " + e.toString()); + } // timing... sessionConnectTime = new java.util.Date().getTime() - startTime; theLog.printInfo("EXECTIME (ServletModuleOpenIndy): " + sessionConnectTime + " ms"); diff --git a/source/mir/misc/Configuration.java b/source/mir/misc/Configuration.java index a31e93d7..b8f5d4d5 100755 --- a/source/mir/misc/Configuration.java +++ b/source/mir/misc/Configuration.java @@ -21,6 +21,7 @@ public class Configuration { private static HashMap confs = new HashMap(); // key: conffilename, confHash private static HashMap c = new HashMap(); private String confFilename; + private static String defaultconfFilename; private static int instances=0; static ResourceBundle conf; @@ -85,7 +86,7 @@ public class Configuration { * Checks if open posting should be direct or indirect * @return true if open posting should be direct */ - public static boolean directOp() { // default + public static boolean directOp() { String op = conf.getString("DirectOpenposting"); if(op.equals("yes") || op.equals("Yes") || op.equals("y") || op.equals("Y")){ return true; diff --git a/source/mircoders/producer/ProducerStartPage.java b/source/mircoders/producer/ProducerStartPage.java index 5c69f205..1659b744 100755 --- a/source/mircoders/producer/ProducerStartPage.java +++ b/source/mircoders/producer/ProducerStartPage.java @@ -18,114 +18,114 @@ import mircoders.entity.*; 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"); + } + } } diff --git a/source/mircoders/servlet/ServletModuleOpenIndy.java b/source/mircoders/servlet/ServletModuleOpenIndy.java index 9a124062..3c218d51 100755 --- a/source/mircoders/servlet/ServletModuleOpenIndy.java +++ b/source/mircoders/servlet/ServletModuleOpenIndy.java @@ -37,7 +37,7 @@ public class ServletModuleOpenIndy extends ServletModule private String postingFormTemplate, postingFormDoneTemplate; private ModuleContent contentModule; private ModuleImages imageModule; - private boolean directOp; + private String directOp ="yes"; // Singelton / Kontruktor private static ServletModuleOpenIndy instance = new ServletModuleOpenIndy(); @@ -50,7 +50,8 @@ public class ServletModuleOpenIndy extends ServletModule commentFormDoneTemplate = Configuration.getProperty("ServletModule.OpenIndy.CommentDoneTemplate"); postingFormTemplate = Configuration.getProperty("ServletModule.OpenIndy.PostingTemplate"); postingFormDoneTemplate = Configuration.getProperty("ServletModule.OpenIndy.PostingDoneTemplate"); - directOp = Configuration.directOp(); + directOp = Configuration.getProperty("DirectOpenposting").toLowerCase(); + //directOp="yes"; mainModule = new ModuleComment(DatabaseComment.getInstance()); contentModule = new ModuleContent(DatabaseContent.getInstance()); imageModule = new ModuleImages(DatabaseImages.getInstance()); @@ -198,7 +199,7 @@ public class ServletModuleOpenIndy extends ServletModule // op-articles are immediatly published withValues.put("is_published","1"); // if op direct article-type == newswire - if (directOp==true) withValues.put("to_article_type","1"); + if (directOp.equals("yes")) withValues.put("to_article_type","1"); theLog.printDebugInfo("direct op: "+directOp); // owner is openposting user @@ -227,7 +228,7 @@ public class ServletModuleOpenIndy extends ServletModule // producing new page new ProducerContent().handle(null, null, false, false,id); //if direct op producing startpage - if (directOp==true) new ProducerStartPage().handle(null,null,false,false); + if (directOp.equals("yes")) new ProducerStartPage().handle(null,null); // sync the server