2 * Copyright (C) 2001, 2002 The Mir-coders group
4 * This file is part of Mir.
6 * Mir is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * Mir is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Mir; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * In addition, as a special exception, The Mir-coders gives permission to link
21 * the code of this program with the com.oreilly.servlet library, any library
22 * licensed under the Apache Software License, The Sun (tm) Java Advanced
23 * Imaging library (JAI), The Sun JIMI library (or with modified versions of
24 * the above that use the same license as the above), and distribute linked
25 * combinations including the two. You must obey the GNU General Public
26 * License in all respects for all of the code used other than the above
27 * mentioned libraries. If you modify this file, you may extend this exception
28 * to your version of the file, but you are not obligated to do so. If you do
29 * not wish to do so, delete this exception statement from your version.
32 package mircoders.producer;
38 import freemarker.template.*;
45 import mircoders.module.*;
46 import mircoders.entity.*;
47 import mircoders.storage.*;
50 public class ProducerAll extends Producer{
52 private boolean rsync;
54 public static void main(String argv[])
56 try { new ProducerAll().handle(new PrintWriter(System.out), null, false,false); }
57 catch(Exception e) { System.err.println(e.toString()); }
61 public void handle(PrintWriter htmlout, EntityUsers user, boolean force,boolean sync)
63 printHTML(htmlout, "Producer.All: started");
65 long sessionConnectTime = 0;
66 long startTime = (new java.util.Date()).getTime();
69 new ProducerImages().handle(htmlout, user, force,sync);
70 } catch (Exception e) {
71 logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
72 +" in ProducerImages continuing "+ e.toString());
75 new ProducerAudio().handle(htmlout, user, force,sync);
76 } catch (Exception e) {
77 logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
78 +" in ProducerAudio continuing "+ e.toString());
81 new ProducerVideo().handle(htmlout, user, force,sync);
82 } catch (Exception e) {
83 logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
84 +" in ProducerVideo continuing "+ e.toString());
87 new ProducerOther().handle(htmlout, user, force,sync);
88 } catch (Exception e) {
89 logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
90 +" in ProducerOther continuing "+ e.toString());
93 new ProducerStartPage().handle(htmlout, user, force,sync);
94 } catch (Exception e) {
95 logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
96 +" in Producer.StartPage continuing "+ e.toString());
99 new ProducerContent().handle(htmlout, user, force,sync);
100 } catch (Exception e) {
101 logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
102 +" in Producer.Content continuing "+ e.toString());
105 new ProducerOpenPosting().handle(htmlout, user, force,sync);
106 } catch (Exception e) {
107 logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
108 +" in Producer.OpenPosting continuing "+ e.toString());
111 new ProducerTopics().handle(htmlout, user, force,sync);
112 } catch (Exception e) {
113 logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
114 +" in Producer.Topics continuing "+ e.toString());
117 new ProducerNavigation().handle(htmlout, user, force,sync);
118 } catch (Exception e) {
119 logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
120 +" in Producer.Navigation continuing "+ e.toString());
124 sessionConnectTime = new java.util.Date().getTime() - startTime;
125 logHTML(htmlout, "Producer.All finished: " + sessionConnectTime + " ms.");
127 // do we have to rsync the site
129 sessionConnectTime = 0;
130 if (Helper.rsync()!=0){
131 sessionConnectTime = new java.util.Date().getTime() - startTime;
132 logHTML(htmlout, "Rsync failed: " + sessionConnectTime + " ms.");
134 sessionConnectTime = new java.util.Date().getTime() - startTime;
135 logHTML(htmlout, "Rsync succeded: " + sessionConnectTime + " ms.");
141 public void handle2(PrintWriter htmlout, EntityUsers user, boolean force,boolean sync)
142 throws StorageObjectException, ModuleException {
143 printHTML(htmlout, "Producer.All: started");
145 long sessionConnectTime = 0;
146 long startTime = (new java.util.Date()).getTime();
147 EntityContent currentContent;
149 //get all new unproduced content-entities
150 String whereClause="is_produced='0' && to_article_type>0";
151 String orderBy="date desc";
152 EntityList entityList = contentModule.getContent(whereClause,orderBy,0,-1,null);
155 while (entityList != null) {
156 for(int i=0;i<entityList.size();i++) {
157 currentContent = (EntityContent)entityList.elementAt(i);
158 EntityList topicEntityList = DatabaseContentToTopics.getInstance().getTopics(currentContent);
159 SimpleHash topicHash = HTMLTemplateProcessor.makeSimpleHash(topicEntityList);
162 //check if this content item is related to a topic
163 if(currentContent.getId().equals(topicHash.get("content_id"))){
164 // produce the ToicsList
165 new ProducerTopics().handle(htmlout, user, force,sync,topicHash.get("topic_id").toString());
167 } catch (TemplateModelException e) {
168 logHTML(htmlout, e.toString());
173 new ProducerContent().handle(htmlout, user, force,sync);
174 new ProducerOpenPosting().handle(htmlout, user, force,sync);
175 new ProducerStartPage().handle(htmlout, user, force,sync);
176 new ProducerTopics().handle(htmlout, user, force,sync);
179 sessionConnectTime = new java.util.Date().getTime() - startTime;
180 logHTML(htmlout, "Producer.All finished: " + sessionConnectTime + " ms.");