Source Code Cross Referenced for PathListPresentation.java in  » Search-Engine » snapper » org » enhydra » snapperAdmin » presentation » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Search Engine » snapper » org.enhydra.snapperAdmin.presentation 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  snapper
003:         *
004:         *  Enhydra super-servlet presentation object
005:         *  
006:         */
007:
008:        package org.enhydra.snapperAdmin.presentation;
009:
010:        import java.util.Vector;
011:
012:        import org.w3c.dom.html.*;
013:        import org.w3c.dom.*;
014:
015:        // Enhydra SuperServlet specification imports
016:        import org.enhydra.snapperAdmin.spec.Path;
017:        import org.enhydra.snapperAdmin.spec.Site;
018:        import org.enhydra.snapperAdmin.spec.SiteList;
019:        import org.enhydra.snapperAdmin.spec.SiteListFactory;
020:
021:        import org.enhydra.snapper.SnapperManager;
022:
023:        import org.enhydra.snapperAdmin.presentation.BasePO;
024:        import org.enhydra.snapperAdmin.presentation.html.*;
025:        import org.enhydra.snapperAdmin.spec.*;
026:        import org.enhydra.xml.xmlc.XMLObject;
027:
028:        import com.lutris.appserver.server.httpPresentation.ClientPageRedirectException;
029:
030:        public class PathListPresentation extends BasePO {
031:
032:            protected XMLObject getDOM() throws Exception {
033:
034:                PathListHTML htmlPage;
035:                Path[] pathArray = null;
036:                Site[] list = null;
037:
038:                htmlPage = (PathListHTML) comms.xmlcFactory
039:                        .create(PathListHTML.class);
040:
041:                //  Check actions
042:
043:                String root = comms.request.getParameter("newPathRoot");
044:                String add = comms.request.getParameter("add");
045:                String change = comms.request.getParameter("change");
046:                String siteName = comms.request.getParameter("site");
047:
048:                //Add path
049:
050:                if (root != null && add != null && siteName != null) {
051:                    SiteList sl = SiteListFactory
052:                            .getSiteList("org.enhydra.snapperAdmin.business.SiteListImpl");
053:                    Site site = sl.findSiteByName(siteName);
054:
055:                    Path path = null;
056:                    try {
057:                        path = PathFactory
058:                                .getPath("org.enhydra.snapperAdmin.business.PathImpl");
059:
060:                        if (SnapperManager.getInstance()
061:                                .getFileSeparatorConvention() != null
062:                                && SnapperManager.getInstance()
063:                                        .getFileSeparatorConvention()
064:                                        .equalsIgnoreCase("unix"))
065:                            root = root.replaceAll("\\\\", "/");
066:
067:                        path.setRoot(root);
068:                        path.setType(comms.request.getParameter("newPathType"));
069:
070:                        if (comms.request.getParameter("host") != null) {
071:
072:                            String host = comms.request.getParameter("host");
073:                            String type = comms.request
074:                                    .getParameter("newPathType");
075:
076:                            if (type.endsWith("FTP") || type.equals("WebDAV")) {
077:
078:                                if (type.equals("WebDAV")
079:                                        && !host.startsWith("http://"))
080:                                    host = "http://" + host;
081:
082:                                if (!host.endsWith("/"))
083:                                    host = host + "/";
084:
085:                                if (root.startsWith("/"))
086:                                    root = root.substring(1);
087:
088:                            }
089:
090:                            path.setHost(host);
091:                            path.setRoot(root);
092:
093:                        } else
094:                            path.setHost("");
095:
096:                        if (comms.request.getParameter("newUser") != null
097:                                && !comms.request.getParameter("newUser")
098:                                        .equals(""))
099:                            path.setUser(comms.request.getParameter("newUser"));
100:
101:                        if (comms.request.getParameter("newPassword1") != null
102:                                && !comms.request.getParameter("newPassword1")
103:                                        .equals(""))
104:                            path.setPass(comms.request
105:                                    .getParameter("newPassword1"));
106:
107:                        if (comms.request.getParameter("newMappingRoot") != null
108:                                && !comms.request
109:                                        .getParameter("newMappingRoot").equals(
110:                                                ""))
111:                            path.setMappingRoot(comms.request
112:                                    .getParameter("newMappingRoot"));
113:
114:                        Path[] oldPathList = site.getPathList();
115:                        Path[] newPathList;
116:
117:                        if (oldPathList != null) {
118:
119:                            newPathList = new Path[oldPathList.length + 1];
120:
121:                            for (int i = 0; i < oldPathList.length; i++) {
122:                                newPathList[i] = oldPathList[i];
123:                            }
124:
125:                            newPathList[newPathList.length - 1] = path;
126:
127:                        } else {
128:                            newPathList = new Path[1];
129:                            newPathList[0] = path;
130:                        }
131:
132:                        site.setPathList(newPathList);
133:
134:                        sl.updateSite(site);
135:
136:                        throw new ClientPageRedirectException(comms.request
137:                                .getAppFileURIPath("PathListPresentation.po"));
138:
139:                    } catch (Exception e) {
140:                        throw new Exception("Could not create new PathType", e);
141:                    }
142:                }
143:
144:                try {
145:                    SiteList site = SiteListFactory
146:                            .getSiteList("org.enhydra.snapperAdmin.business.SiteListImpl");
147:                    list = site.getList();
148:
149:                    if (list == null || list.length == 0) {
150:                        blankHTML blankPage;
151:                        blankPage = (blankHTML) comms.xmlcFactory
152:                                .create(blankHTML.class);
153:                        blankPage.setTextNoSite("The are no sites defined!");
154:                        return blankPage;
155:                    }
156:
157:                    HTMLOptionElement templateOption = htmlPage
158:                            .getElementTemplateSiteList();
159:                    HTMLSelectElement select = htmlPage.getElementSiteList();
160:                    Node pathSelect = templateOption.getParentNode();
161:                    templateOption.removeAttribute("id");
162:                    templateOption.removeChild(templateOption.getFirstChild());
163:                    if (list.length != 0)
164:                        htmlPage.setTextSiteName(list[0].getNAME());
165:                    for (int num = 0; num < list.length; num++) {
166:
167:                        Site currentsite = list[num];
168:                        HTMLOptionElement clonedOption = (HTMLOptionElement) templateOption
169:                                .cloneNode(true);
170:                        clonedOption.setValue(currentsite.getNAME());
171:                        Node optionTextNode = clonedOption.getOwnerDocument()
172:                                .createTextNode(currentsite.getNAME());
173:                        clonedOption.appendChild(optionTextNode);
174:
175:                        pathSelect.appendChild(clonedOption);
176:
177:                        if (comms.request.getParameter("siteList") != null) {
178:                            if ((comms.request.getParameter("siteList"))
179:                                    .equals(currentsite.getNAME())) {
180:                                select.setSelectedIndex(num + 1);
181:                                htmlPage.setTextSiteName(currentsite.getNAME());
182:                            }
183:                        }
184:
185:                    }
186:                    if (list.length != 0)
187:                        templateOption.getParentNode().removeChild(
188:                                templateOption);
189:                }
190:
191:                catch (Exception ex) {
192:                    System.out.print(ex.toString());
193:                }
194:
195:                // Path table	        	
196:
197:                String siteOID = null;
198:
199:                if (list.length != 0) {
200:                    if (comms.request.getParameter("siteList") == null)
201:                        siteOID = list[0].getNAME();
202:                    else
203:                        siteOID = comms.request.getParameter("siteList");
204:                    try {
205:                        SiteList siteList = SiteListFactory
206:                                .getSiteList("org.enhydra.snapperAdmin.business.SiteListImpl");
207:
208:                        Site site = siteList.findSiteByName(siteOID);
209:
210:                        if (site != null)
211:                            pathArray = site.getPathList();
212:
213:                    } catch (Exception ex) {
214:                        System.out.println("Exception: " + ex);
215:                        pathArray = null;
216:                    }
217:                }
218:
219:                HTMLTableRowElement templateRow = htmlPage
220:                        .getElementTemplateRow();
221:
222:                HTMLElement pathTypeNameCellTemplate = htmlPage
223:                        .getElementPathTypeName();
224:                HTMLElement pathTypeCellTemplate = htmlPage
225:                        .getElementPathType();
226:
227:                templateRow.removeAttribute("id");
228:                pathTypeNameCellTemplate.removeAttribute("id");
229:
230:                Node pathTable = templateRow.getParentNode();
231:                String link;
232:                if (pathArray != null && list.length != 0) {
233:                    for (int num = 0; num < pathArray.length; num++) {
234:                        try {
235:                            Path currentPath = pathArray[num];
236:
237:                            if (currentPath == null)
238:                                continue;
239:
240:                            if (currentPath.getHost() != null) {
241:                                htmlPage.setTextPathTypeName(currentPath
242:                                        .getHost()
243:                                        + currentPath.getRoot());
244:                            } else {
245:                                if (currentPath.getRoot() != null)
246:                                    htmlPage.setTextPathTypeName(currentPath
247:                                            .getRoot());
248:                                else
249:                                    htmlPage.setTextPathTypeName("");
250:                            }
251:                            htmlPage.setTextPathType(currentPath.getType());
252:                            link = "DeletePath.po?id=" + siteOID + "&path="
253:                                    + currentPath.getRoot();
254:                            htmlPage.getElementDeleteLink().setHref(link);
255:
256:                            if (!SiteListPresentation.haveUpdater)
257:                                try {
258:                                    htmlPage
259:                                            .getElementDeleteLink()
260:                                            .getParentNode()
261:                                            .removeChild(
262:                                                    htmlPage
263:                                                            .getElementDeleteLink());
264:                                } catch (Exception e) {
265:                                }
266:
267:                            pathTable.appendChild(templateRow.cloneNode(true));
268:                        }
269:
270:                        catch (Exception ex) {
271:                            ex.printStackTrace();
272:                        }
273:                    }
274:                }
275:                templateRow.getParentNode().removeChild(templateRow);
276:
277:                if (list.length != 0) {
278:                    ////////////////////////////////
279:                    try {
280:
281:                        Vector pathList = new Vector();
282:                        pathList.add("FileSystem");
283:                        pathList.add("FTP");
284:                        pathList.add("UNC");
285:                        pathList.add("WebDAV");
286:
287:                        HTMLOptionElement templateOption = htmlPage
288:                                .getElementTemplateNewPathType();
289:                        Node pathSelect = templateOption.getParentNode();
290:                        templateOption.removeAttribute("id");
291:                        templateOption.removeChild(templateOption
292:                                .getFirstChild());
293:
294:                        for (int num = 0; num < pathList.size(); num++) {
295:
296:                            HTMLOptionElement clonedOption = (HTMLOptionElement) templateOption
297:                                    .cloneNode(true);
298:                            clonedOption.setValue((String) pathList.get(num));
299:                            Node optionTextNode = clonedOption
300:                                    .getOwnerDocument().createTextNode(
301:                                            (String) pathList.get(num));
302:                            clonedOption.appendChild(optionTextNode);
303:                            // Do only a shallow copy of the option as we don't want the text child
304:                            // of the node option
305:                            pathSelect.appendChild(clonedOption);
306:                        }
307:
308:                    } catch (Exception ex) {
309:                        System.out.print(ex.toString());
310:                    }
311:                }
312:
313:                if (comms.request.getParameter("siteList") != null) {
314:                    htmlPage.getElementSite().setValue(
315:                            comms.request.getParameter("siteList"));
316:                } else {
317:                    if (list.length != 0)
318:                        htmlPage.getElementSite().setValue(list[0].getNAME());
319:                }
320:
321:                if (!SiteListPresentation.haveUpdater) {
322:                    htmlPage.getElementFormNew().getParentNode().removeChild(
323:                            htmlPage.getElementFormNew());
324:                }
325:
326:                return htmlPage;
327:            }
328:
329:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.