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 = Configuration.getProperty("Producer.Wap.Template");
28 itemsPerPage = Integer.parseInt(Configuration.getProperty("Producer.Wap.Items"));
31 public static void main(String argv[]){
33 Configuration.initConfig(argv[0]);
34 new ProducerWap().handle(new PrintWriter(System.out), null);
35 } catch(Exception e) {
36 System.err.println(e.toString());
40 public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync)
41 throws StorageObjectException, ModuleException
43 printHTML(htmlout, "Producer.StartPage: started");
45 long sessionConnectTime = 0;
46 long startTime = (new java.util.Date()).getTime();
47 String nowWebdbDate = StringUtil.date2webdbDate(new GregorianCalendar());
50 FileWriter outputFile;
53 EntityContent currentContent;
54 EntityList entityList;
55 SimpleHash wapPageModel;
56 SimpleList contentList;
57 String currentMediaId;
58 SimpleHash imageHash = new SimpleHash();
61 // get the breaking news
63 ModuleBreaking breakingModule = new ModuleBreaking(DatabaseBreaking.getInstance());
64 entityList = breakingModule.getByWhereClause(null,"webdb_create desc",0,itemsPerPage);
65 SimpleList breakingList = HTMLTemplateProcessor.makeSimpleList(entityList);
69 // Zusaetzlich Informationen
70 wapPageModel = new SimpleHash();
71 wapPageModel.put("breaking", breakingList);
73 xmlFileName = producerDocRoot + "/wap/index.xml";
74 wmlFileName = producerDocRoot + "/wap/index.wml";
76 produce(wapTemplate, xmlFileName, wapPageModel, new LineFilterWriter(htmlout));
78 XmlSaxonStyler styler = XmlSaxonStyler.getInstance();
80 // XslStyleCache.clear();
83 InputStream is = new FileInputStream(producerStorageRoot+xmlFileName);
84 OutputStream os = new FileOutputStream(producerStorageRoot+wmlFileName);
85 String contentXsl = Configuration.getProperty("Home") + "templates/" + Configuration.getProperty("Xsl.Wap");
86 logHTML(htmlout,"using style " + contentXsl);
87 styler.style(contentXsl,is,os);
90 logHTML(htmlout,"styling done.");
91 logHTML(htmlout, "html erstellt: <a href=\"" + producerProductionHost+ wmlFileName + "\">" + wmlFileName + "</a>");
92 } catch (FileNotFoundException e) {
93 System.err.println(e.toString());
94 } catch (IOException e) {
95 System.err.println(e.toString());
96 } catch (org.xml.sax.SAXException e) {
97 logHTML(htmlout,e.toString());
98 System.err.println(e.toString());
102 sessionConnectTime = new java.util.Date().getTime() - startTime;
103 logHTML(htmlout, "Producer.Startseite finished: " + sessionConnectTime + " ms.");