Source Code Cross Referenced for DM_DownloadPO.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:        package org.enhydra.snapperAdmin.presentation;
002:
003:        import java.io.File;
004:
005:        import org.enhydra.snapperAdmin.presentation.BasePO;
006:        import org.enhydra.snapperAdmin.presentation.FileDownloadBO;
007:        import org.enhydra.snapperAdmin.Log;
008:        import org.enhydra.snapperAdmin.spec.Download;
009:        import org.enhydra.snapperAdmin.spec.DownloadFactory;
010:        import org.enhydra.snapperAdmin.spec.Site;
011:        import org.enhydra.snapperAdmin.spec.SiteList;
012:        import org.enhydra.snapperAdmin.spec.SiteListFactory;
013:        import org.enhydra.xml.xmlc.XMLObject;
014:
015:        public class DM_DownloadPO extends BasePO {
016:
017:            protected XMLObject getDOM() throws Exception {
018:                try {
019:
020:                    String url = comms.request.getParameter("url");
021:                    String type = comms.request.getParameter("type");
022:                    String siteName = comms.request.getParameter("id");
023:
024:                    int indexOf = -1;
025:                    indexOf = url.lastIndexOf(".");
026:                    if (indexOf != -1)
027:                        type = url.substring(indexOf + 1);
028:
029:                    String ftype = type;
030:
031:                    if (type != null)
032:                        type = manageType(type);
033:
034:                    if (checkIsGrantedDownload(siteName)) {
035:
036:                        if (url.startsWith("ftp"))
037:                            downloadFtpFile(url, ftype, siteName);
038:                        else if (url.startsWith("http")) {
039:                            downloadWebDavFile(url, ftype, siteName);
040:                        } else
041:                            downloadFile(url, type);
042:
043:                    }
044:                } catch (Exception e) {
045:                    Log.logException(e);
046:                }
047:
048:                return null;
049:            }
050:
051:            protected void downloadFile(String filePath, String type)
052:                    throws Exception {
053:                try {
054:                    FileDownloadBO theBO = new FileDownloadBO(
055:                            new File(filePath), comms);
056:                    theBO.setContentType(type);
057:                    theBO.download();
058:                } catch (Exception e) {
059:                    Log.logException(e);
060:                }
061:            }
062:
063:            public void downloadFtpFile(String id, String type, String siteName) {
064:                try {
065:                    Download dw = DownloadFactory
066:                            .getDownload("org.enhydra.snapperAdmin.business.DownloadImpl");
067:                    File tempFile = dw.downloadFtpFile(id, type, siteName);
068:                    if (tempFile != null) {
069:                        FileDownloadBO theBO = new FileDownloadBO(tempFile,
070:                                comms);
071:                        theBO.setContentType(manageType(type));
072:                        theBO.download();
073:                        tempFile.delete();
074:                    } else {
075:                        return;
076:                    }
077:                } catch (Exception e) {
078:                    Log.logException(e);
079:                }
080:            }
081:
082:            public void downloadWebDavFile(String id, String type,
083:                    String siteName) {
084:                try {
085:                    Download dw = DownloadFactory
086:                            .getDownload("org.enhydra.snapperAdmin.business.DownloadImpl");
087:                    File tempFile = dw.downloadWebDavFile(id, type, siteName);
088:
089:                    if (tempFile != null) {
090:                        FileDownloadBO theBO = new FileDownloadBO(tempFile,
091:                                comms);
092:                        theBO.setContentType(manageType(type));
093:                        theBO.download();
094:                        tempFile.delete();
095:                    } else {
096:                        return;
097:                    }
098:                } catch (Exception e) {
099:                    Log.logException(e);
100:                }
101:            }
102:
103:            public boolean checkIsGrantedDownload(String siteName) {
104:                if (siteName == null)
105:                    return false;
106:                try {
107:                    SiteList sl = SiteListFactory
108:                            .getSiteList("org.enhydra.snapperAdmin.business.SiteListImpl");
109:
110:                    Site site = sl.findSiteByName(siteName);
111:
112:                    if (site != null)
113:                        return site.getDOWNLOAD();
114:                    else
115:                        return false;
116:
117:                } catch (Exception e) {
118:                    Log.logException(e);
119:                    return false;
120:                }
121:
122:            }
123:
124:            protected String manageType(String type) {
125:                String result;
126:                if (type.equalsIgnoreCase("html"))
127:                    result = FileDownloadBO.HTML_CONTENT_TYPE;
128:                else if (type.equalsIgnoreCase("pdf"))
129:                    result = FileDownloadBO.PDF_CONTENT_TYPE;
130:                else if (type.equalsIgnoreCase("xls"))
131:                    result = FileDownloadBO.EXCEL_CONTENT_TYPE;
132:                else if (type.equalsIgnoreCase("doc"))
133:                    result = FileDownloadBO.WORD_CONTENT_TYPE;
134:                else if (type.equalsIgnoreCase("rtf"))
135:                    result = FileDownloadBO.RTF_CONTENT_TYPE;
136:                else if (type.equalsIgnoreCase("sxw"))
137:                    result = FileDownloadBO.SXW_CONTENT_TYPE;
138:                else if (type.equalsIgnoreCase("stw"))
139:                    result = FileDownloadBO.STW_CONTENT_TYPE;
140:                else if (type.equalsIgnoreCase("sxg"))
141:                    result = FileDownloadBO.SXG_CONTENT_TYPE;
142:                else if (type.equalsIgnoreCase("sxc"))
143:                    result = FileDownloadBO.SXC_CONTENT_TYPE;
144:                else if (type.equalsIgnoreCase("stc"))
145:                    result = FileDownloadBO.STC_CONTENT_TYPE;
146:                else if (type.equalsIgnoreCase("sxi"))
147:                    result = FileDownloadBO.SXI_CONTENT_TYPE;
148:                else if (type.equalsIgnoreCase("sti"))
149:                    result = FileDownloadBO.STI_CONTENT_TYPE;
150:                else if (type.equalsIgnoreCase("sxd"))
151:                    result = FileDownloadBO.SXD_CONTENT_TYPE;
152:                else if (type.equalsIgnoreCase("std"))
153:                    result = FileDownloadBO.STD_CONTENT_TYPE;
154:                else if (type.equalsIgnoreCase("sxm"))
155:                    result = FileDownloadBO.SXM_CONTENT_TYPE;
156:                else if (type.equalsIgnoreCase("msg"))
157:                    result = FileDownloadBO.EML_CONTENT_TYPE;
158:                else if (type.equalsIgnoreCase("pst"))
159:                    result = FileDownloadBO.EML_CONTENT_TYPE;
160:                else if (type.equalsIgnoreCase("ppt"))
161:                    result = FileDownloadBO.PPT_CONTENT_TYPE;
162:                else if (type.equalsIgnoreCase("pps"))
163:                    result = FileDownloadBO.PPS_CONTENT_TYPE;
164:                else if (type.equalsIgnoreCase("zip"))
165:                    result = FileDownloadBO.ZIP_CONTENT_TYPE;
166:                else if (type.equalsIgnoreCase("eml"))
167:                    result = FileDownloadBO.EML_CONTENT_TYPE;
168:                else if (type.equalsIgnoreCase("txt"))
169:                    result = FileDownloadBO.HTML_CONTENT_TYPE;
170:                else if (type.equalsIgnoreCase("ico"))
171:                    result = "image/x-icon";
172:                else if (type.equalsIgnoreCase("xlc"))
173:                    result = FileDownloadBO.EXCEL_CONTENT_TYPE;
174:                else if (type.equalsIgnoreCase("xlt"))
175:                    result = FileDownloadBO.EXCEL_CONTENT_TYPE;
176:                else if (type.equalsIgnoreCase("xla"))
177:                    result = FileDownloadBO.EXCEL_CONTENT_TYPE;
178:                else if (type.equalsIgnoreCase("text"))
179:                    result = "text/plain";
180:                else if (type.equalsIgnoreCase("bib"))
181:                    result = "text/plain";
182:                else if (type.equalsIgnoreCase("err"))
183:                    result = "text/plain";
184:                else if (type.equalsIgnoreCase("faq"))
185:                    result = "text/plain";
186:                else if (type.equalsIgnoreCase("log"))
187:                    result = "text/plain";
188:                else if (type.equalsIgnoreCase("csv"))
189:                    result = "text/plain";
190:                else if (type.equalsIgnoreCase("sql"))
191:                    result = "text/plain";
192:                else if (type.equalsIgnoreCase("xml"))
193:                    result = "application/xml";
194:                else if (type.equalsIgnoreCase("xsl"))
195:                    result = "application/xml";
196:                else if (type.equalsIgnoreCase("xslt"))
197:                    result = "application/xml";
198:                else if (type.equalsIgnoreCase("js"))
199:                    result = "text/plain";
200:                else if (type.equalsIgnoreCase("jsp"))
201:                    result = "text/plain";
202:                else if (type.equalsIgnoreCase("jspx"))
203:                    result = "text/plain";
204:                else if (type.equalsIgnoreCase("css"))
205:                    result = "text/plain";
206:                else if (type.equalsIgnoreCase("php"))
207:                    result = "text/plain";
208:                else if (type.equalsIgnoreCase("php3"))
209:                    result = "text/plain";
210:                else if (type.equalsIgnoreCase("php4"))
211:                    result = "text/plain";
212:                else if (type.equalsIgnoreCase("php5"))
213:                    result = "text/plain";
214:                else if (type.equalsIgnoreCase("asp"))
215:                    result = "text/plain";
216:                else if (type.equalsIgnoreCase("aspx"))
217:                    result = "text/plain";
218:                else if (type.equalsIgnoreCase("cfm"))
219:                    result = "text/plain";
220:                else if (type.equalsIgnoreCase("htx"))
221:                    result = "text/plain";
222:                else if (type.equalsIgnoreCase("java"))
223:                    result = "text/plain";
224:                else if (type.equalsIgnoreCase("properties"))
225:                    result = "text/plain";
226:                else if (type.equalsIgnoreCase("c"))
227:                    result = "text/plain";
228:                else if (type.equalsIgnoreCase("cpp"))
229:                    result = "text/plain";
230:                else if (type.equalsIgnoreCase("h"))
231:                    result = "text/plain";
232:                else if (type.equalsIgnoreCase("cgi"))
233:                    result = "text/plain";
234:                else if (type.equalsIgnoreCase("dtd"))
235:                    result = "text/plain";
236:                else if (type.equalsIgnoreCase("pl"))
237:                    result = "text/plain";
238:                else if (type.equalsIgnoreCase("rar"))
239:                    result = FileDownloadBO.ZIP_CONTENT_TYPE;
240:                else if (type.equalsIgnoreCase("gz"))
241:                    result = FileDownloadBO.ZIP_CONTENT_TYPE;
242:                else if (type.equalsIgnoreCase("bz2"))
243:                    result = FileDownloadBO.ZIP_CONTENT_TYPE;
244:                else
245:                    result = "";
246:                return result;
247:
248:            }
249:
250:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.