error handling!
[mir.git] / source / mircoders / producer / ProducerFeature.java
1 package mircoders.producer;
2
3 import java.io.*;
4 import java.lang.*;
5 import java.util.*;
6 import java.sql.*;
7
8 import freemarker.template.*;
9
10 import mir.misc.*;
11 import mir.storage.*;
12 import mir.module.*;
13 import mir.entity.*;
14
15 import mircoders.module.*;
16 import mircoders.entity.*;
17 import mircoders.storage.*;
18
19
20
21 public class ProducerFeature extends ProducerList {
22
23
24         public void setAdditional(String key, TemplateModel value) {
25                 additional.put(key,value);
26         }
27
28         public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync)
29                 throws StorageObjectException, ModuleException {
30                 orderBy="date desc";
31                 listTemplate = MirConfig.getProp("Producer.FeatureList.Template");
32                 EntityList featureEntityList = featureModule.getByWhereClause("","title", -1);
33                 SimpleList featureList = HTMLTemplateProcessor.makeSimpleList(featureEntityList);
34                 boolean first=true;
35                 whereClause="is_published!=true AND to_article_type=0 AND id IN (";
36                 for(int i=0; i < featureEntityList.size(); i++){
37
38             try {
39                 EntityTopics currentTopic = (EntityTopics)featureEntityList.elementAt(i);
40                 EntityList contentEntityList = DatabaseContentToTopics.getInstance().getContent(currentTopic);
41                 if(first==false) {
42                     whereClause += ",";
43                 }
44                 whereClause += currentTopic.getId();
45                 fileDesc = currentTopic.getValue("filename").trim();
46                 setAdditional("topic",HTMLTemplateProcessor.makeSimpleHash(currentTopic));
47             } catch (Exception e) {
48                 logHTML(htmlout, "problem with feature skipping");
49             }
50
51                         first = false;
52                 }
53                 whereClause += ")";
54                 handleIt(htmlout,user,force);
55         }
56
57         public static void main(String argv[]){
58                 try {
59                         new ProducerOpenPosting().handle(new PrintWriter(System.out), null,false, false);
60                 } catch(Exception e) {
61                         System.err.println(e.toString());
62                 }
63         }
64 }