KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > snapper > presentation > CreatedPresentation


1 /*
2  * snapper
3  *
4  * Enhydra super-servlet presentation object
5  *
6  */

7
8 package org.enhydra.snapper.presentation;
9
10
11 // Enhydra SuperServlet specification imports
12

13 import java.sql.Timestamp JavaDoc;
14
15 import org.enhydra.snapper.SnapperManager;
16 import org.enhydra.snapper.presentation.html.*;
17 import org.enhydra.snapper.spec.*;
18 import org.enhydra.xml.xmlc.XMLObject;
19
20 import com.lutris.appserver.server.httpPresentation.ClientPageRedirectException;
21
22
23 public class CreatedPresentation extends BasePO {
24     
25     /**
26      * Constants representing HTTP parameters passed in from
27      * the form submission
28      */

29     private static String JavaDoc SITE_NAME = "site_nameInput";
30     private static String JavaDoc LANGUAGE = "site_languageInput";
31     private static String JavaDoc MAX_SIZE = "site_MaxSizeInput";
32     private static String JavaDoc MAX_AGE = "site_MaxAgeInput";
33     private static String JavaDoc RTF = "site_RTFInput";
34     private static String JavaDoc DOC = "site_DOCInput";
35     private static String JavaDoc TXT = "site_TXTInput";
36     private static String JavaDoc HTML = "site_HTMLInput";
37     private static String JavaDoc MSG = "site_MSGInput";
38     private static String JavaDoc PDF = "site_PDFInput";
39     private static String JavaDoc XLS = "site_XLSInput";
40
41     
42     private static String JavaDoc EML = "site_EMLInput";
43     private static String JavaDoc PPT = "site_PPTInput";
44     private static String JavaDoc PPS = "site_PPSInput";
45     private static String JavaDoc ZIP = "site_ZIPInput";
46     private static String JavaDoc OO = "site_OOInput";
47     
48     private static String JavaDoc SEARCH = "site_SearchInput";
49     private static String JavaDoc DL = "site_DownloadableInput";
50     private static String JavaDoc INDEXDIR = "site_IndexDirInput";
51     
52
53       protected XMLObject getDOM() throws Exception JavaDoc {
54
55         CreatedHTML newCreated;
56         newCreated = (CreatedHTML)comms.xmlcFactory.create(CreatedHTML.class);
57
58         
59         String JavaDoc name = comms.request.getParameter(SITE_NAME);
60         String JavaDoc language = comms.request.getParameter(LANGUAGE);
61         String JavaDoc size = comms.request.getParameter(MAX_SIZE);
62         String JavaDoc age = comms.request.getParameter(MAX_AGE);
63         String JavaDoc rtf = comms.request.getParameter(RTF);
64         String JavaDoc doc = comms.request.getParameter(DOC);
65         String JavaDoc txt = comms.request.getParameter(TXT);
66         String JavaDoc html = comms.request.getParameter(HTML);
67         String JavaDoc msg = comms.request.getParameter(MSG);
68         String JavaDoc pdf = comms.request.getParameter(PDF);
69         String JavaDoc xls = comms.request.getParameter(XLS);
70         String JavaDoc eml = comms.request.getParameter(EML);
71         String JavaDoc ppt = comms.request.getParameter(PPT);
72         String JavaDoc pps = comms.request.getParameter(PPS);
73         String JavaDoc zip = comms.request.getParameter(ZIP);
74         String JavaDoc oo = comms.request.getParameter(OO);
75         String JavaDoc search = comms.request.getParameter(SEARCH);
76         String JavaDoc dl = comms.request.getParameter(DL);
77         String JavaDoc id = comms.request.getParameter(INDEXDIR);
78         
79         
80         if (name.length() != 0 && language.length() != 0
81                 && size.length() != 0 && age.length() != 0) {
82             
83              try {
84                 Site site = null;
85                 site= SiteFactory.getSite("org.enhydra.snapper.business.SiteImpl");
86                 site.createNew(dbTransaction);
87                 
88                 site.setName(name);
89                 site.setLanguage(language);
90                 site.setSize(size);
91                 site.setAge(age);
92                 site.setRTF(rtf);
93                 site.setDOC(doc);
94                 site.setTXT(txt);
95                 site.setHTML(html);
96                 site.setMSG(msg);
97                 site.setPDF(pdf);
98                 site.setXLS(xls);
99                 site.setEML(eml);
100                 site.setPPT(ppt);
101                 site.setPPS(pps);
102                 site.setZIP(zip);
103                 site.setOO(oo);
104                 site.setFILENR(0);
105                 site.setQUERYNR(0);
106                 site.setLASTQUERY(null);
107                 site.setLASTUPDATE(null);
108                 site.setSEARCH(search);
109                 site.setDOWNLOAD(dl);
110                 if(SnapperManager.getInstance().getFileSeparatorConvention()!=null &&
111                      SnapperManager.getInstance().getFileSeparatorConvention().equalsIgnoreCase("unix"))
112                         id=id.replaceAll("\\\\","/");
113                 site.setINDEXDIR(id);
114                 site.setLOCKED(null);
115
116                 String JavaDoc option = comms.request.getParameter("R1");
117                 if (option.equals("V3")){
118                     site.setFILTERDB(comms.request.getParameter("site_FilterDBInput"));
119                     site.setFILTERTABLE(comms.request.getParameter("site_FilterTableInput"));
120                     site.setFILTERCOLUMN(comms.request.getParameter("site_FilterColumnInput"));
121                 }
122                 else {
123                     site.setINCLUDEDB(comms.request.getParameter("site_IncludeDB"));
124                     site.setINCLUDETABLE(comms.request.getParameter("site_IncludeTable"));
125                     site.setINCLUDECOLUMN(comms.request.getParameter("site_IncludeColumn"));
126                     site.setINCLUDECOLUMNMODIFIED(comms.request.getParameter("site_IncludeColumnModified"));
127                 }
128                 
129                 site.setMETADB(comms.request.getParameter("site_MetadataDB"));
130                 site.setMETATABLE(comms.request.getParameter("site_MetadataTable"));
131                 site.setMETAFILE(comms.request.getParameter("site_MetadataColumnFile"));
132                 site.setMETAKEY(comms.request.getParameter("site_MetadataColumnKey"));
133                 site.setMETAVALUE(comms.request.getParameter("site_MetadataColumnValue"));
134                 
135                 site.setOTHER(comms.request.getParameter("site_OTHERInput"));
136                 
137                 site.save();
138                 
139                 try{
140                 SnapperManager.getInstance().getLoggingManager().info("Site '" + name + "' successfully created!");
141                 } catch (Exception JavaDoc e){
142                     System.out.println("Site '" + name + "' successfully created!");
143                 }
144             
145              } catch (Exception JavaDoc ex) {
146                 newCreated.setTextCreated("Error creating Site!");
147                 try{
148                     SnapperManager.getInstance().getLoggingManager().error("Error creating Site!");
149                     } catch (Exception JavaDoc e){
150                         System.out.println("Error creating Site!");
151                     }
152                 System.out.println(ex.toString());}
153         }
154         
155         else {
156             throw new ClientPageRedirectException(comms.request.getAppFileURIPath("NewSitePresentation.po?err=notCreated"));
157         }
158         
159         throw new ClientPageRedirectException(comms.request.getAppFileURIPath("SiteListPresentation.po"));
160         //return newCreated;
161

162
163     }
164 }
165
166
Popular Tags