KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.enhydra.snapper.Log;
14 import org.enhydra.snapper.presentation.html.*;
15 import org.enhydra.snapper.spec.*;
16 import org.enhydra.xml.xmlc.XMLObject;
17
18 import org.enhydra.snapper.SnapperManager;
19
20 import com.lutris.appserver.server.httpPresentation.ClientPageRedirectException;
21
22
23 public class UpdateSitePresentation 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     private static String JavaDoc EML = "site_EMLInput";
42     private static String JavaDoc PPT = "site_PPTInput";
43     private static String JavaDoc PPS = "site_PPSInput";
44     private static String JavaDoc ZIP = "site_ZIPInput";
45     private static String JavaDoc OO = "site_OOInput";
46     
47     private static String JavaDoc SEARCH = "site_SearchInput";
48     private static String JavaDoc DL = "site_DownloadableInput";
49     private static String JavaDoc INDEXDIR = "site_IndexDirInput";
50     private static String JavaDoc DB = "site_FilterDBInput";
51     private static String JavaDoc TABLE = "site_FilterTableInput";
52     private static String JavaDoc COLUMN = "site_FilterColumnInput";
53     
54
55       protected XMLObject getDOM() throws Exception JavaDoc {
56
57         UpdateSiteHTML updateSite;
58         updateSite = (UpdateSiteHTML)comms.xmlcFactory.create(UpdateSiteHTML.class);
59         String JavaDoc action = comms.request.getParameter("action");
60         if (action != null && action.equals("update")){
61             String JavaDoc name = comms.request.getParameter(SITE_NAME);
62             String JavaDoc language = comms.request.getParameter(LANGUAGE);
63             String JavaDoc size = comms.request.getParameter(MAX_SIZE);
64             String JavaDoc age = comms.request.getParameter(MAX_AGE);
65             String JavaDoc rtf = comms.request.getParameter(RTF);
66             String JavaDoc doc = comms.request.getParameter(DOC);
67             String JavaDoc txt = comms.request.getParameter(TXT);
68             String JavaDoc html = comms.request.getParameter(HTML);
69             String JavaDoc msg = comms.request.getParameter(MSG);
70             String JavaDoc pdf = comms.request.getParameter(PDF);
71             String JavaDoc xls = comms.request.getParameter(XLS);
72             String JavaDoc eml = comms.request.getParameter(EML);
73             String JavaDoc ppt = comms.request.getParameter(PPT);
74             String JavaDoc pps = comms.request.getParameter(PPS);
75             String JavaDoc zip = comms.request.getParameter(ZIP);
76             String JavaDoc oo = comms.request.getParameter(OO);
77             String JavaDoc search = comms.request.getParameter(SEARCH);
78             String JavaDoc dl = comms.request.getParameter(DL);
79             String JavaDoc id = comms.request.getParameter(INDEXDIR);
80             String JavaDoc db = comms.request.getParameter(DB);
81             String JavaDoc table = comms.request.getParameter(TABLE);
82             String JavaDoc column = comms.request.getParameter(COLUMN);
83             try{
84             Site site= SiteFactory.getSite("org.enhydra.snapper.business.SiteImpl").findSiteByID(comms.request.getParameter("site_oidInput"), dbTransaction);
85             site.setSize(size);
86             site.setAge(age);
87             site.setRTF(rtf);
88             site.setDOC(doc);
89             site.setTXT(txt);
90             site.setHTML(html);
91             site.setMSG(msg);
92             site.setPDF(pdf);
93             site.setXLS(xls);
94             site.setEML(eml);
95             site.setPPT(ppt);
96             site.setPPS(pps);
97             site.setZIP(zip);
98             site.setOO(oo);
99             site.setOTHER(comms.request.getParameter("site_OTHERInput"));
100
101             site.setSEARCH(search);
102             site.setDOWNLOAD(dl);
103             if(SnapperManager.getInstance().getFileSeparatorConvention()!=null &&
104                SnapperManager.getInstance().getFileSeparatorConvention().equalsIgnoreCase("unix"))
105                   id=id.replaceAll("\\\\","/");
106             site.setINDEXDIR(id);
107             String JavaDoc option = comms.request.getParameter("R1");
108             if (option.equals("VF")){
109                 site.setFILTERDB(comms.request.getParameter("site_FilterDBInput"));
110                 site.setFILTERTABLE(comms.request.getParameter("site_FilterTableInput"));
111                 site.setFILTERCOLUMN(comms.request.getParameter("site_FilterColumnInput"));
112                 site.setINCLUDEDB(comms.request.getParameter(""));
113                 site.setINCLUDETABLE(comms.request.getParameter(""));
114                 site.setINCLUDECOLUMN(comms.request.getParameter(""));
115                 site.setINCLUDECOLUMNMODIFIED(comms.request.getParameter(""));
116            
117             }
118             else {
119                 site.setFILTERDB(comms.request.getParameter(""));
120                 site.setFILTERTABLE(comms.request.getParameter(""));
121                 site.setFILTERCOLUMN(comms.request.getParameter(""));
122                 site.setINCLUDEDB(comms.request.getParameter("site_IncludeDB"));
123                 site.setINCLUDETABLE(comms.request.getParameter("site_IncludeTable"));
124                 site.setINCLUDECOLUMN(comms.request.getParameter("site_IncludeColumn"));
125                 site.setINCLUDECOLUMNMODIFIED(comms.request.getParameter("site_IncludeColumnModified"));
126             }
127             String JavaDoc includeDB = comms.request.getParameter("site_IncludeDB");
128             if (includeDB != null && includeDB.length() != 0){
129                 site.setINCLUDEDB(includeDB);
130                 site.setINCLUDETABLE(comms.request.getParameter("site_IncludeTable"));
131                 site.setINCLUDECOLUMN(comms.request.getParameter("site_IncludeColumn"));
132                 site.setINCLUDECOLUMNMODIFIED(comms.request.getParameter("site_IncludeColumnModified"));
133             }
134             
135             String JavaDoc metaDB = comms.request.getParameter("site_MetadataDB");
136             if (metaDB != null && metaDB.length()!= 0 ){
137                 site.setMETADB(metaDB);
138                 site.setMETATABLE(comms.request.getParameter("site_MetadataTable"));
139                 site.setMETAFILE(comms.request.getParameter("site_MetadataColumnFile"));
140                 site.setMETAKEY(comms.request.getParameter("site_MetadataColumnKey"));
141                 site.setMETAVALUE(comms.request.getParameter("site_MetadataColumnValue"));
142          
143             }
144             site.save();
145             } catch (Exception JavaDoc ex) {System.out.println(ex.toString());}
146             
147             throw new ClientPageRedirectException(comms.request.getAppFileURIPath("SiteListPresentation.po"));
148             
149         }
150         
151
152             
153              try {
154                 Site site = null;
155                 site= SiteFactory.getSite("org.enhydra.snapper.business.SiteImpl").findSiteByID(comms.request.getParameter("id"), dbTransaction);
156                 updateSite.getElementTemplateLanguage().setValue(site.getLanguage());
157                 //updateSite.getElementNameInput().setValue(site.getName());
158
updateSite.getElementMaxAgeInput().setValue(String.valueOf(site.getAge()));
159                 updateSite.getElementMaxSizeInput().setValue(String.valueOf(site.getSize()));
160                 updateSite.getElementDOCInput().setChecked(site.getDOC());
161                 updateSite.getElementSite_EMLInput().setChecked(site.getEML());
162                 updateSite.getElementHTMLInput().setChecked(site.getHTML());
163                 updateSite.getElementSite_MSGInput().setChecked(site.getMSG());
164                 updateSite.getElementPDFInput().setChecked(site.getPDF());
165                 updateSite.getElementSite_PPSInput().setChecked(site.getPPS());
166                 updateSite.getElementSite_PPTInput().setChecked(site.getPPT());
167                 updateSite.getElementRTFInput().setChecked(site.getRTF());
168                 updateSite.getElementSite_OOInput().setChecked(site.getOO());
169                 updateSite.getElementTXTInput().setChecked(site.getTXT());
170                 updateSite.getElementXLSInput().setChecked(site.getXLS());
171                 updateSite.getElementSite_ZIPInput().setChecked(site.getZIP());
172                 updateSite.getElementSite_SearchInput().setChecked(site.getSEARCH());
173                 updateSite.getElementSite_DownloadableInput().setChecked(site.getDOWNLOAD());
174                 updateSite.getElementSite_IndexDirInput().setValue(site.getINDEXDIR());
175                 updateSite.getElementSite_FilterDBInput().setValue(site.getFILTERDB());
176                 updateSite.getElementSite_FilterColumnInput().setValue(site.getFILTERCOLUMN());
177                 updateSite.getElementSite_FilterTableInput().setValue(site.getFILTERTABLE());
178                 updateSite.getElementSite_oidInput().setValue(site.getID());
179                 updateSite.getElementSite_OTHERInput().setChecked(site.getOTHER());
180                 
181                 updateSite.getElementSite_FilterDBInput().setValue(site.getFILTERDB());
182                 updateSite.getElementSite_FilterTableInput().setValue(site.getFILTERTABLE());
183                 updateSite.getElementSite_FilterColumnInput().setValue(site.getFILTERCOLUMN());
184                 updateSite.getElementSite_IncludeDB().setValue(site.getINCLUDEDB());
185                 updateSite.getElementSite_IncludeTable().setValue(site.getINCLUDETABLE());
186                 updateSite.getElementSite_IncludeColumn().setValue(site.getINCLUDECOLUMN());
187                 updateSite.getElementSite_IncludeColumnModified().setValue(site.getINCLUDECOLUMNMODIFIED());
188                 updateSite.getElementSite_MetadataDB().setValue(site.getMETADB());
189                 updateSite.getElementSite_MetadataTable().setValue(site.getMETATABLE());
190                 updateSite.getElementSite_MetadataColumnFile().setValue(site.getMETAFILE());
191                 updateSite.getElementSite_MetadataColumnKey().setValue(site.getMETAKEY());
192                 updateSite.getElementSite_MetadataColumnValue().setValue(site.getMETAVALUE());
193                 
194                 updateSite.getElementAction().setValue("update");
195                 
196                 //String link = "UpdateSitePresentation.po?action=update&id=" + comms.request.getParameter("id");
197
//updateSite.getElementUpdateLink().setHref(link);
198
//Log.log("Site '" + name + "' successfully created!");
199

200             
201              } catch (Exception JavaDoc ex) {
202                 //newCreated.setTextCreated("Error creating Site!");
203
Log.logException(ex);
204                 System.out.println(ex.toString());}
205         //}
206

207         //else {
208
// throw new ClientPageRedirectException(comms.request.getAppFileURIPath("NewSitePresentation.po?err=notCreated"));
209
//}
210

211         //throw new ClientPageRedirectException(comms.request.getAppFileURIPath("SiteListPresentation.po"));
212
return updateSite;
213         
214
215     }
216 }
217
218
Popular Tags