get rid of deprecated makeSimpleList and makeSimpleHash usage. this should be it...
[mir.git] / source / mircoders / producer / ProducerAll.java
1 package mircoders.producer;
2
3 import java.io.*;
4 import java.lang.*;
5 import java.util.*;
6
7 import freemarker.template.*;
8
9 import mir.misc.*;
10 import mir.storage.*;
11 import mir.module.*;
12 import mir.entity.*;
13
14 import mircoders.module.*;
15 import mircoders.entity.*;
16 import mircoders.storage.*;
17
18
19 public class ProducerAll extends Producer{
20
21         private boolean rsync;
22
23         public static void main(String argv[])
24         {
25                 try {   new ProducerAll().handle(new PrintWriter(System.out), null, false,false);       }
26                 catch(Exception e) { System.err.println(e.toString()); }
27         }
28
29         // handle all
30         public void handle(PrintWriter htmlout, EntityUsers user, boolean force,boolean sync)
31     {
32                 printHTML(htmlout, "Producer.All: started");
33
34                 long                sessionConnectTime = 0;
35                 long                startTime = (new java.util.Date()).getTime();
36     
37         try {
38             //new ProducerImages().handle(htmlout, user, force,sync);
39             new ProducerMedia().handle(htmlout, user, force,sync);
40         } catch (Exception e) {
41             logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
42                 +" in Producer.Media continuing "+ e.toString());
43         }
44         try {
45             new ProducerStartPage().handle(htmlout, user, force,sync);
46         } catch (Exception e) {
47             logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
48                 +" in Producer.StartPage continuing "+ e.toString());
49         }
50         try {
51             new ProducerContent().handle(htmlout, user, force,sync);
52         } catch (Exception e) {
53             logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
54                 +" in Producer.Content continuing "+ e.toString());
55         }
56         try {
57             new ProducerOpenPosting().handle(htmlout, user, force,sync);
58         } catch (Exception e) {
59             logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
60                 +" in Producer.OpenPosting continuing "+ e.toString());
61         }
62         try {
63             new ProducerTopics().handle(htmlout, user, force,sync);
64         } catch (Exception e) {
65             logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
66                 +" in Producer.Topics continuing "+ e.toString());
67         }
68         try {
69             new ProducerNavigation().handle(htmlout, user, force,sync);
70         } catch (Exception e) {
71             logHTML(htmlout, "Producer.All <font color=\"red\">ERROR:</font>"
72                 +" in Producer.Navigation continuing "+ e.toString());
73         }
74
75                 // Finish
76                 sessionConnectTime = new java.util.Date().getTime() - startTime;
77                 logHTML(htmlout, "Producer.All finished: " + sessionConnectTime + " ms.");
78
79                 // do we have to rsync the site
80                 if (sync==true){
81                         sessionConnectTime = 0;
82                         if (Helper.rsync()!=0){
83                                 sessionConnectTime = new java.util.Date().getTime() - startTime;
84                                 logHTML(htmlout, "Rsync failed: " + sessionConnectTime + " ms.");
85                         } else {
86                                 sessionConnectTime = new java.util.Date().getTime() - startTime;
87                                 logHTML(htmlout, "Rsync succeded: " + sessionConnectTime + " ms.");
88                         }
89                 }
90         }
91
92         // handle all
93         public void handle2(PrintWriter htmlout, EntityUsers user, boolean force,boolean sync)
94                 throws StorageObjectException, ModuleException {
95                 printHTML(htmlout, "Producer.All: started");
96
97                 long                sessionConnectTime = 0;
98                 long                startTime = (new java.util.Date()).getTime();
99                 EntityContent   currentContent;
100
101                 //get all new unproduced content-entities
102                 String whereClause="is_produced='0' && to_article_type>0";
103                 String orderBy="date desc";
104                 EntityList entityList = contentModule.getContent(whereClause,orderBy,0,-1,null);
105
106                 //get their values
107                 while (entityList != null) {
108                         for(int i=0;i<entityList.size();i++) {
109                                 currentContent = (EntityContent)entityList.elementAt(i);
110                                 EntityList topicEntityList = DatabaseContentToTopics.getInstance().getTopics(currentContent);
111                                 SimpleHash topicHash = HTMLTemplateProcessor.makeSimpleHash(topicEntityList);
112
113                                 try {
114                                         //check if this content item is related to a topic
115                                         if(currentContent.getId().equals(topicHash.get("content_id"))){
116                                                 // produce the ToicsList
117                                                 new ProducerTopics().handle(htmlout, user, force,sync,topicHash.get("topic_id").toString());
118                                         }
119                                 } catch (TemplateModelException e) {
120                                         logHTML(htmlout, e.toString());
121                                 }
122                         }
123                 }
124
125                 new ProducerContent().handle(htmlout, user, force,sync);
126                 new ProducerOpenPosting().handle(htmlout, user, force,sync);
127                 new ProducerStartPage().handle(htmlout, user, force,sync);
128                 new ProducerTopics().handle(htmlout, user, force,sync);
129
130                 // Finish
131                 sessionConnectTime = new java.util.Date().getTime() - startTime;
132                 logHTML(htmlout, "Producer.All finished: " + sessionConnectTime + " ms.");
133         }
134 }
135