Source Code Cross Referenced for BaseUploadService.java in  » Web-Framework » TURBINE » org » apache » turbine » services » upload » 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 » Web Framework » TURBINE » org.apache.turbine.services.upload 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.turbine.services.upload;
002:
003:        /*
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *   http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:
022:        import javax.servlet.ServletConfig;
023:        import javax.servlet.http.HttpServletRequest;
024:
025:        import org.apache.turbine.Turbine;
026:        import org.apache.turbine.services.TurbineBaseService;
027:        import org.apache.turbine.services.servlet.TurbineServlet;
028:        import org.apache.turbine.util.ServletUtils;
029:        import org.apache.turbine.util.TurbineException;
030:        import org.apache.turbine.util.parser.ParameterParser;
031:
032:        /**
033:         * <p> This class is a base implementation of
034:         * {@link org.apache.turbine.services.upload.UploadService}.
035:         *
036:         * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
037:         * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
038:         * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
039:         * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
040:         * @version $Id: BaseUploadService.java 534527 2007-05-02 16:10:59Z tv $
041:         */
042:        public abstract class BaseUploadService extends TurbineBaseService
043:                implements  UploadService {
044:            /**
045:             * A maximum lenght of a single header line that will be
046:             * parsed. (1024 bytes).
047:             */
048:            public static final int MAX_HEADER_SIZE = 1024;
049:
050:            /**
051:             * Initializes the service.
052:             *
053:             * This method processes the repository path, to make it relative to the
054:             * web application root, if neccessary
055:             */
056:            public void init() {
057:                String path = getProperties().getProperty(
058:                        UploadService.REPOSITORY_KEY,
059:                        UploadService.REPOSITORY_DEFAULT.toString());
060:                if (!path.startsWith("/")) {
061:                    String realPath = TurbineServlet.getRealPath(path);
062:                    if (realPath != null) {
063:                        path = realPath;
064:                    }
065:                }
066:                getProperties().setProperty(UploadService.REPOSITORY_KEY, path);
067:                setInit(true);
068:            }
069:
070:            /**
071:             * <p> Processes an <a href="http://rf.cx/rfc1867.html">RFC
072:             * 1867</a> compliant <code>multipart/form-data</code> stream.
073:             *
074:             * @param req The servlet request to be parsed.
075:             * @param params The ParameterParser instance to insert form
076:             * fields into.
077:             * @param path The location where the files should be stored.
078:             * @exception TurbineException If there are problems reading/parsing
079:             * the request or storing files.
080:             */
081:            public abstract void parseRequest(HttpServletRequest req,
082:                    ParameterParser params, String path)
083:                    throws TurbineException;
084:
085:            /**
086:             * <p> Retrieves the value of <code>size.max</code> property of the
087:             * {@link org.apache.turbine.services.upload.UploadService}.
088:             *
089:             * @return The maximum upload size.
090:             */
091:            public long getSizeMax() {
092:                return getConfiguration().getLong(UploadService.SIZE_MAX_KEY,
093:                        UploadService.SIZE_MAX_DEFAULT);
094:            }
095:
096:            /**
097:             * <p> Retrieves the value of <code>size.threshold</code> property of
098:             * {@link org.apache.turbine.services.upload.UploadService}.
099:             *
100:             * @return The threshold beyond which files are written directly to disk.
101:             */
102:            public int getSizeThreshold() {
103:                return getConfiguration().getInt(
104:                        UploadService.SIZE_THRESHOLD_KEY,
105:                        UploadService.SIZE_THRESHOLD_DEFAULT);
106:            }
107:
108:            /**
109:             * <p> Retrieves the value of the <code>repository</code> property of
110:             * {@link org.apache.turbine.services.upload.UploadService}.
111:             *
112:             * @return The repository.
113:             */
114:            public String getRepository() {
115:                // get the reposity value from TR.props
116:                String tmpPath = getConfiguration().getString(
117:                        UploadService.REPOSITORY_KEY,
118:                        UploadService.REPOSITORY_DEFAULT);
119:
120:                // return the expanded path name
121:                ServletConfig config = Turbine.getTurbineServletConfig();
122:                return ServletUtils.expandRelative(config, tmpPath);
123:
124:            }
125:
126:            /**
127:             * Retrieves the value of the 'automatic' property of {@link
128:             * UploadService}. This reports whether the Parameter parser
129:             * should allow "automatic" uploads if it is submitted to
130:             * Turbine.
131:             *
132:             * @return The value of 'automatic' property of {@link
133:             * UploadService}.
134:             */
135:            public boolean getAutomatic() {
136:                return getConfiguration().getBoolean(
137:                        UploadService.AUTOMATIC_KEY,
138:                        UploadService.AUTOMATIC_DEFAULT);
139:            }
140:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.