1 package mircoders.producer;
7 import freemarker.template.*;
14 import mircoders.module.*;
15 import mircoders.storage.*;
16 import mircoders.entity.*;
19 public class ProducerWap extends Producer {
21 static String wapTemplate;
22 static int itemsPerPage;
23 static int newsPerPage;
27 wapTemplate = MirConfig.getProp("Producer.Wap.Template");
28 itemsPerPage = Integer.parseInt(MirConfig.getProp("Producer.Wap.Items"));
31 public static void main(String argv[]){
33 // do we need the following? -mh <heckmann@hbe.ca>
34 //Configuration.initConfig(argv[0]);
35 new ProducerWap().handle(new PrintWriter(System.out), null);
36 } catch(Exception e) {
37 System.err.println(e.toString());
41 public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync)
42 throws StorageObjectException, ModuleException
44 printHTML(htmlout, "Producer.StartPage: started");
46 long sessionConnectTime = 0;
47 long startTime = (new java.util.Date()).getTime();
48 String nowWebdbDate = StringUtil.date2webdbDate(new GregorianCalendar());
51 FileWriter outputFile;
54 EntityContent currentContent;
55 EntityList entityList;
56 SimpleHash wapPageModel;
57 SimpleList contentList;
58 String currentMediaId;
59 SimpleHash imageHash = new SimpleHash();
62 // get the breaking news
64 ModuleBreaking breakingModule = new ModuleBreaking(DatabaseBreaking.getInstance());
65 entityList = breakingModule.getByWhereClause(null,"webdb_create desc",0,itemsPerPage);
66 SimpleList breakingList = HTMLTemplateProcessor.makeSimpleList(entityList);
70 // Zusaetzlich Informationen
71 wapPageModel = new SimpleHash();
72 wapPageModel.put("breaking", breakingList);
74 xmlFileName = producerDocRoot + "/wap/index.xml";
75 wmlFileName = producerDocRoot + "/wap/index.wml";
77 produce(wapTemplate, xmlFileName, wapPageModel, new LineFilterWriter(htmlout));
79 XmlSaxonStyler styler = XmlSaxonStyler.getInstance();
81 // XslStyleCache.clear();
84 InputStream is = new FileInputStream(producerStorageRoot+xmlFileName);
85 OutputStream os = new FileOutputStream(producerStorageRoot+wmlFileName);
86 String contentXsl = MirConfig.getProp("Home") + "templates/" + MirConfig.getProp("Xsl.Wap");
87 logHTML(htmlout,"using style " + contentXsl);
88 styler.style(contentXsl,is,os);
91 logHTML(htmlout,"styling done.");
92 logHTML(htmlout, "html erstellt: <a href=\"" + producerProductionHost+ wmlFileName + "\">" + wmlFileName + "</a>");
93 } catch (FileNotFoundException e) {
94 System.err.println(e.toString());
95 } catch (IOException e) {
96 System.err.println(e.toString());
97 } catch (org.xml.sax.SAXException e) {
98 logHTML(htmlout,e.toString());
99 System.err.println(e.toString());
103 sessionConnectTime = new java.util.Date().getTime() - startTime;
104 logHTML(htmlout, "Producer.Startseite finished: " + sessionConnectTime + " ms.");