You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by de...@apache.org on 2017/09/17 12:29:53 UTC
[myfaces-trinidad] 10/12: porting TRINIDAD-1757 to a different
branch
This is an automated email from the ASF dual-hosted git repository.
deki pushed a commit to branch 1.2.12.1.2-branch
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad.git
commit 6f4a03a2f7e3dde0b5edb4ce7b90b1671bf508c5
Author: Matthias Wessendorf <ma...@apache.org>
AuthorDate: Tue Apr 6 09:20:13 2010 +0000
porting TRINIDAD-1757 to a different branch
---
.../webapp/ChainedUploadedFileProcessor.java | 105 +++++++++++++
.../trinidad/webapp/UploadedFileProcessor.java | 6 +-
trinidad-examples/trinidad-demo/pom.xml | 6 +
.../myfaces/trinidaddemo/ProfanityScanner.java | 76 +++++++++
.../org/apache/myfaces/trinidaddemo/UIBean.java | 5 +-
.../src/main/webapp/WEB-INF/trinidad-config.xml | 3 +
.../trinidadinternal/config/ConfigParser.java | 67 +++++++-
...ava => CompositeUploadedFileProcessorImpl.java} | 169 +++++++++++++++++++--
.../config/upload/UploadedFileProcessorImpl.java | 6 +-
9 files changed, 418 insertions(+), 25 deletions(-)
diff --git a/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/ChainedUploadedFileProcessor.java b/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/ChainedUploadedFileProcessor.java
new file mode 100644
index 0000000..6a80ffb
--- /dev/null
+++ b/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/ChainedUploadedFileProcessor.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.trinidad.webapp;
+
+import java.io.IOException;
+import org.apache.myfaces.trinidad.model.UploadedFile;
+
+/**
+ * Interface responsible for processing file uploads by multiple processors one
+ * after another in a chained fashion. An Apache Trinidad application could have
+ * multiple <code>ChainedUploadedFileProcessor</code> instances. A composite UploadedFileProcessor
+ * is accessible from the {@link org.apache.myfaces.trinidad.context.RequestContext},
+ * but will be invoked automatically by the framework as needed. Developers
+ * can implement this interface and chain many of them up together using space
+ * separated class names in <code>trinidad-config.xml</code> file under
+ * <code>uploaded-file-processor</code> element. The order in which the processors
+ * will be instantated and called will be the same as how it appears inside the element.
+ * <p>
+ * To configure file uploads, the default instance supports three context
+ * initialization parameters :
+ * <ul>
+ * <li>org.apache.myfaces.trinidad.UPLOAD_MAX_MEMORY: the maximum amount of memory
+ * that can be used in a single request to store
+ * uploaded files. (Default of 100K)
+ * <li>org.apache.myfaces.trinidad.UPLOAD_MAX_DISK_SPACE: the maximum amount of
+ * disk space that can be used in a single request to store
+ * uploaded files. (Default of 2000K)
+ * <li>org.apache.myfaces.trinidad.UPLOAD_TEMP_DIR: the name of a directory
+ * to store temporary files. (Defaults to the user's temporary directory)
+ * </ul>
+ *
+ * @see org.apache.myfaces.trinidad.model.UploadedFile
+ */
+public interface ChainedUploadedFileProcessor extends UploadedFileProcessor
+{
+ /**
+ * Initialize the ChainedUploadedFileProcessor with access to the current
+ * web application context. The order of call is same as it
+ * appears in trinidad-config.xml
+ *
+ * @param context the current ServletContext or PortletContext
+ */
+ public void init(Object context);
+
+ /**
+ * Process a single uploaded file. An implementation of this
+ * method must process an incoming <code>UploadedFile</code> object
+ * and return a new <code>UploadedFile</code> instance that will
+ * remain valid for the duration of this request. The properties of the incoming
+ * <code>UploadedFile</code> object depends on the implementation detail of
+ * the previous ChainedUploadedFileProcessor in the chain. In general all the
+ * implementations must strive to return a <code>UploadedFile</code> that
+ * should at the least comply to following:
+ * <ul>
+ * <li>{@link UploadedFile#getInputStream} may only be called once</li>
+ * <li>{@link UploadedFile#getLength} returns length as it should be available</li>
+ * <li>{@link UploadedFile#getFilename} may have been internationalized; users should not
+ * rely on its value, but simply use it unmodified in the
+ * outgoing <code>UploadedFile</code></li>
+ * </ul>
+ * <p>
+ * First ChainedUploadedFileProcessor in the list gets an <code>UploadedFile</code> implementation
+ * from the framework with the above properties and the following few more:
+ * <ul>
+ * <li>{@link UploadedFile#getInputStream} may be called multiple times. Each call gives a new InputStream</li>
+ * <li>{@link UploadedFile#getLength} returns length</li>
+ * </ul>
+ * Due to the above properties, if there was no change made to the underlying stream
+ * significantly by the current ChainedUploadedFileProcessor, this <code>UploadedFile</code> object could
+ * be returned intact for subsequent processing by the framework. This avoids creation of
+ * new <code>UploadedFile</code> for simple ChainedUploadedFileProcessor implementations.
+ * </p>
+ * <p>
+ * The framework guarantees that {@link UploadedFile#dispose}</code> will be called before
+ * the request completes for each UploadedFile returned by every ChainedUploadedFileProcessor.
+ * The order in which dispose() will be called is the revers of the order
+ * they are declared in trinidad-config.xml. If same UploadedFile
+ * was returned by more than one processors, dispose() will be called only once
+ * on it. Any exception that happenes during dispose() call will be logged
+ * as warning and the processing continues with the rest of the UploadedFile(s).
+ * </p>
+ * @param request the current servlet or portlet request
+ * @param file a temporary file object
+ * @return a new instance of UploadedFile. It is legal to return null,
+ * in which case the file will not be available later in the request.
+ */
+ public UploadedFile processFile(
+ Object request, UploadedFile file) throws IOException;
+}
diff --git a/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UploadedFileProcessor.java b/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UploadedFileProcessor.java
index 1be1a41..d4ac76e 100644
--- a/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UploadedFileProcessor.java
+++ b/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UploadedFileProcessor.java
@@ -24,8 +24,10 @@ import org.apache.myfaces.trinidad.model.UploadedFile;
/**
* Interface responsible for processing file uploads. An Apache Trinidad
- * application has a single <code>UploadedFileProcessor</code> instance.
- * It is accessible from the {@link org.apache.myfaces.trinidad.context.RequestContext},
+ * application has a single <code>UploadedFileProcessor</code> instance. For
+ * more simpler, multiple chained UploadedFileProcessor option please look at
+ * {@link org.apache.myfaces.trinidad.webapp.ChainedUploadedFileProcessor}.
+ * UploadedFileProcessor is accessible from the {@link org.apache.myfaces.trinidad.context.RequestContext},
* but will be invoked automatically by the framework as needed. Developers
* can replace the standard processor using the
* <code>trinidad-config.xml</code> file.
diff --git a/trinidad-examples/trinidad-demo/pom.xml b/trinidad-examples/trinidad-demo/pom.xml
index a5c5307..7811b80 100644
--- a/trinidad-examples/trinidad-demo/pom.xml
+++ b/trinidad-examples/trinidad-demo/pom.xml
@@ -157,6 +157,12 @@
</profile>
<!-- To run jetty, issue "mvn clean -PjettyConfig jetty:run" -->
+ <!-- To Debug using a remote debugger, issue
+ "export MAVEN_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000"
+ and then issue
+ "mvn clean -PjettyConfig jetty:run"
+ Then connect the remote debugger to localhost:8000 -->
+
<profile>
<id>pluto-embedded</id>
<dependencyManagement>
diff --git a/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/ProfanityScanner.java b/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/ProfanityScanner.java
new file mode 100644
index 0000000..e3c4388
--- /dev/null
+++ b/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/ProfanityScanner.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.trinidaddemo;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.apache.myfaces.trinidad.model.UploadedFile;
+import org.apache.myfaces.trinidad.webapp.ChainedUploadedFileProcessor;
+
+/**
+ * This class checks if the uploaded file contains the word "crap" in it and
+ * rejects if found.
+ *
+ */
+public class ProfanityScanner implements ChainedUploadedFileProcessor
+{
+
+ public void init(Object context)
+ {
+ _LOG.log(Level.INFO, "ProfanityScanner just got initialized...");
+ }
+
+ public UploadedFile processFile(Object request, UploadedFile file) throws IOException
+ {
+ _LOG.log(Level.INFO, "Scanning for profanity...");
+
+ BufferedReader br = new BufferedReader(new InputStreamReader(file.getInputStream()));
+ String line;
+ try
+ {
+ while ((line = br.readLine()) != null)
+ {
+ if (line.indexOf("crap") != -1)
+ {
+ throw new IOException("ProfanityScanner rejected this file as " +
+ "it contained the word \"crap\" in it!!!\n" + request);
+ }
+ }
+ }
+ finally
+ {
+ br.close();
+ }
+
+ _LOG.log(Level.INFO, "Done Scanning for profanity...");
+
+ /**
+ * Since we did not change anything in the Inputstream we got from the parameter
+ * its ok to return the same object. The file argument is backed by the buffer
+ * hence subsequent processors will be able to access the stream again.
+ */
+ return file;
+ }
+
+ static private final Logger _LOG =
+ Logger.getLogger(ProfanityScanner.class.getName());
+}
diff --git a/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/UIBean.java b/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/UIBean.java
index 298bfef..d0e3a27 100644
--- a/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/UIBean.java
+++ b/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/UIBean.java
@@ -59,7 +59,7 @@ public class UIBean
_panelPage = panelPage;
}
- public void fileUploaded(ValueChangeEvent event)
+ public void fileUploaded(ValueChangeEvent event) throws IOException
{
UploadedFile file = (UploadedFile) event.getNewValue();
if (file != null)
@@ -67,7 +67,8 @@ public class UIBean
FacesContext context = FacesContext.getCurrentInstance();
FacesMessage message = new FacesMessage(
"Uploaded file " + file.getFilename() +
- " (" + file.getLength() + " bytes)");
+ " (" + file.getLength() + " bytes)"+". Bytes available to read: " +
+ file.getInputStream().available());
context.addMessage(event.getComponent().getClientId(context), message);
}
}
diff --git a/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-config.xml b/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-config.xml
index af3f1a5..ff4c222 100644
--- a/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-config.xml
+++ b/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-config.xml
@@ -33,6 +33,9 @@
<skin-family>#{prefs.proxy.skinFamily}</skin-family>
+ <uploaded-file-processor>org.apache.myfaces.trinidaddemo.ProfanityScanner org.apache.myfaces.trinidaddemo.ProfanityScanner</uploaded-file-processor>
+
+ <!--uploaded-file-processor>org.apache.myfaces.trinidaddemo.ProfanityScanner</uploaded-file-processor-->
<!--
<output-mode>portlet</output-mode>
diff --git a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/ConfigParser.java b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/ConfigParser.java
index 25a2b53..1730c4f 100644
--- a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/ConfigParser.java
+++ b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/ConfigParser.java
@@ -20,6 +20,9 @@ package org.apache.myfaces.trinidadinternal.config;
import java.io.IOException;
import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;
@@ -36,8 +39,9 @@ import org.apache.myfaces.trinidad.context.AccessibilityProfile;
import org.apache.myfaces.trinidad.context.RequestContext;
import org.apache.myfaces.trinidad.logging.TrinidadLogger;
import org.apache.myfaces.trinidad.util.ClassLoaderUtils;
+import org.apache.myfaces.trinidad.webapp.ChainedUploadedFileProcessor;
import org.apache.myfaces.trinidad.webapp.UploadedFileProcessor;
-import org.apache.myfaces.trinidadinternal.config.upload.UploadedFileProcessorImpl;
+import org.apache.myfaces.trinidadinternal.config.upload.CompositeUploadedFileProcessorImpl;
import org.apache.myfaces.trinidadinternal.context.RequestContextBean;
import org.apache.myfaces.trinidadinternal.util.nls.LocaleUtils;
import org.apache.myfaces.trinidadinternal.util.DateUtils;
@@ -102,29 +106,78 @@ public class ConfigParser
}
}
- String className = (String)
+ String classNameString = (String)
bean.getProperty(RequestContextBean.UPLOADED_FILE_PROCESSOR_KEY);
- if (className != null)
+ if (classNameString != null)
{
- className = className.trim();
+ classNameString = classNameString.trim();
+ //check if this contains multiple class names for chained processors usecase.
+ // Usually the class named are separated by space char.
+ String classNames[] = classNameString.split("[ ]+");
+ if(classNames.length == 1)
+ {
+ //This could be a single processor full override usecase or a chained
+ //processor usecase that has only one processor.
try
{
- Class<?> clazz = ClassLoaderUtils.loadClass(className);
+ Class<UploadedFileProcessor> clazz = (Class<UploadedFileProcessor>)
+ ClassLoaderUtils.loadClass(classNames[0]);
+ if(ChainedUploadedFileProcessor.class.isAssignableFrom(clazz))
+ {
+ //this single chained processor case
+ ChainedUploadedFileProcessor cufp[] =
+ {
+ (ChainedUploadedFileProcessor) clazz.newInstance()
+ };
bean.setProperty(RequestContextBean.UPLOADED_FILE_PROCESSOR_KEY,
+ new CompositeUploadedFileProcessorImpl(Arrays.asList(cufp)));
+ }
+ else
+ {
+ //this is full override usecase
+ bean.setProperty(RequestContextBean.UPLOADED_FILE_PROCESSOR_KEY,
clazz.newInstance());
}
+
+
+ }
catch (Exception e)
{
_LOG.severe("CANNOT_INSTANTIATE_UPLOADEDFILEPROCESSOR", e);
bean.setProperty(RequestContextBean.UPLOADED_FILE_PROCESSOR_KEY,
- new UploadedFileProcessorImpl());
+ new CompositeUploadedFileProcessorImpl());
+ }
+ }
+ else
+ {
+ try
+ {
+ //chained processors usecase, Multiple processors
+ List<ChainedUploadedFileProcessor> processors =
+ new ArrayList<ChainedUploadedFileProcessor>(classNames.length);
+ for (String className : classNames)
+ {
+ Class<ChainedUploadedFileProcessor> clazz =
+ (Class<ChainedUploadedFileProcessor>) ClassLoaderUtils.loadClass(className);
+ processors.add(clazz.newInstance());
+ }
+ bean.setProperty(RequestContextBean.UPLOADED_FILE_PROCESSOR_KEY,
+ new CompositeUploadedFileProcessorImpl(processors));
+ }
+ catch(Exception e)
+ {
+ _LOG.severe("CANNOT_INSTANTIATE_UPLOADEDFILEPROCESSOR", e);
+ bean.setProperty(RequestContextBean.UPLOADED_FILE_PROCESSOR_KEY,
+ new CompositeUploadedFileProcessorImpl());
+ }
}
}
else
{
+ //nothing specified, hence use default.
bean.setProperty(RequestContextBean.UPLOADED_FILE_PROCESSOR_KEY,
- new UploadedFileProcessorImpl());
+ new CompositeUploadedFileProcessorImpl());
}
UploadedFileProcessor ufp = (UploadedFileProcessor)
diff --git a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/UploadedFileProcessorImpl.java b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/CompositeUploadedFileProcessorImpl.java
similarity index 66%
copy from trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/UploadedFileProcessorImpl.java
copy to trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/CompositeUploadedFileProcessorImpl.java
index 1e0b2de..28b6da3 100644
--- a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/UploadedFileProcessorImpl.java
+++ b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/CompositeUploadedFileProcessorImpl.java
@@ -18,9 +18,14 @@
*/
package org.apache.myfaces.trinidadinternal.config.upload;
+
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Collections;
import java.util.Map;
import javax.portlet.ActionRequest;
@@ -41,15 +46,149 @@ import org.apache.myfaces.trinidadinternal.context.external.ServletApplicationMa
import org.apache.myfaces.trinidadinternal.context.external.ServletInitParameterMap;
import org.apache.myfaces.trinidadinternal.context.external.ServletRequestMap;
-
-public class UploadedFileProcessorImpl implements UploadedFileProcessor
+/**
+ * This is the default implementaion of UploadedFileProcessor. It works with
+ * multiple ChainedUploadedFileProcessor declared in trinidad-config.xml by dispatching
+ * the lifecycle calls to them in the order of declaration.
+ **/
+public class CompositeUploadedFileProcessorImpl implements UploadedFileProcessor
{
- public UploadedFileProcessorImpl()
+
+ public CompositeUploadedFileProcessorImpl()
{
+ chainedProcessors = Collections.emptyList();
}
+ public CompositeUploadedFileProcessorImpl(
+ List<? extends UploadedFileProcessor> chainedProcessors)
+ {
+ this.chainedProcessors = chainedProcessors;
+ }
+
+ @Override
public void init(Object context)
{
+ _init(context);
+ for(UploadedFileProcessor processor: chainedProcessors)
+ {
+ //call other chained processor's init
+ processor.init(context);
+ }
+
+ }
+
+ @Override
+ public UploadedFile processFile(Object request, UploadedFile tempFile) throws IOException
+ {
+ //NOTE: The following optimization was suggested at one point:
+ // Check if there are any processors in the list. If yes then call _processFile
+ // else just return tempFile we got. Calling _processFile buffers the entire
+ // file content. tempFile arg however is not buffered. If there are no
+ // ChainedUploadedFileProcessor in the list, then there is no need to buffer.
+ // BUT, the call to getLength() and dispose() on tempFile fails.
+ // This is becasue, the impl of these 2 methods are not complete -
+ // Bug - https://issues.apache.org/jira/browse/TRINIDAD-1765
+ // This bug could not be fixed due to the explanatio in the bug.
+
+ //call _processFile first. This will create the auto buffer that we want.
+ UploadedFile original = _processFile(request, tempFile);
+ if(chainedProcessors.isEmpty())
+ {
+ return original;
+ }
+ else
+ {
+ List<UploadedFile> files = new ArrayList<UploadedFile>(chainedProcessors.size()+1);
+ files.add(original);
+ for(UploadedFileProcessor processor: chainedProcessors)
+ {
+ original = processor.processFile(request, original);
+ files.add(original);
+ }
+ //the dispose order should be reverse!
+ Collections.reverse(files);
+ return new WrappedUploadedFileImpl(original, files);
+ }
+ }
+
+
+ /**
+ * Wrapper around UploadedFileImpl to listen for dispose() call and dispatch to
+ * other UploadedFileImpls returned by other chained processors
+ */
+ private static class WrappedUploadedFileImpl implements UploadedFile{
+
+ public WrappedUploadedFileImpl(UploadedFile original, List<UploadedFile> files)
+ {
+ this.original = original;
+ this.files = files;
+ }
+
+ public void dispose()
+ {
+ try
+ {
+ original.dispose();
+ }
+ catch(Exception e)
+ {
+ _LOG.warning("Exception while disposing!", e);
+ //log and continue disposing the rest.
+ }
+ if(!files.isEmpty())
+ {
+ List<UploadedFile> disposed = new ArrayList<UploadedFile>();
+ disposed.add(original);
+ for(UploadedFile file: files)
+ {
+ if(!disposed.contains(file))
+ {
+ try
+ {
+ file.dispose();
+ }
+ catch(Exception e)
+ {
+ _LOG.warning("Exception while disposing!", e);
+ //log and continue disposing the rest.
+ }
+ disposed.add(file);
+ }
+ }
+ }
+ }
+
+ public String getFilename()
+ {
+ return original.getFilename();
+ }
+
+ public String getContentType()
+ {
+ return original.getContentType();
+ }
+
+ public long getLength()
+ {
+ return original.getLength();
+ }
+
+ public Object getOpaqueData()
+ {
+ return original.getOpaqueData();
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ return original.getInputStream();
+ }
+
+ private final UploadedFile original;
+ private final List<UploadedFile> files;
+ }
+
+ private void _init(Object context)
+ {
ContextInfo info;
if(_PORTLET_CONTEXT_CLASS != null && _PORTLET_CONTEXT_CLASS.isInstance(context))
{
@@ -118,13 +257,13 @@ public class UploadedFileProcessorImpl implements UploadedFileProcessor
}
}
- public UploadedFile processFile(
+ private UploadedFile _processFile(
Object request, UploadedFile tempFile) throws IOException
{
RequestInfo info = _getRequestInfo(request);
int contentLength = getContentLength(request);
Map<String, Object> requestMap;
-
+
if (_isPortletRequestClass(request))
requestMap = _getPortletRequestMap(request);
else
@@ -133,20 +272,20 @@ public class UploadedFileProcessorImpl implements UploadedFileProcessor
Long maxMemory = (Long)requestMap.get(MAX_MEMORY_PARAM_NAME);
Long maxDiskSpace = (Long)requestMap.get(MAX_DISK_SPACE_PARAM_NAME);
String tempDir = (String)requestMap.get(TEMP_DIR_PARAM_NAME);
-
+
if (maxMemory != null)
{
_maxMemory = maxMemory;
}
-
+
if (maxDiskSpace != null)
{
_maxDiskSpace = maxDiskSpace;
}
-
+
if (tempDir != null)
_tempDir = tempDir;
-
+
if(contentLength>_maxDiskSpace)
{
return new ErrorFile();
@@ -195,7 +334,7 @@ public class UploadedFileProcessorImpl implements UploadedFileProcessor
return length;
}
-
+
private RequestInfo _getRequestInfo(Object request)
{
Map<String, Object> attributes;
@@ -219,7 +358,7 @@ public class UploadedFileProcessorImpl implements UploadedFileProcessor
return info;
}
-
+
private boolean _isPortletRequestClass(Object request)
{
return (_PORTLET_REQUEST_CLASS != null && _PORTLET_REQUEST_CLASS.isInstance(request));
@@ -299,11 +438,11 @@ public class UploadedFileProcessorImpl implements UploadedFileProcessor
private static final long _DEFAULT_MAX_MEMORY = 102400;
private static final long _DEFAULT_MAX_DISK_SPACE = 2048000;
- private static final String _REQUEST_INFO_KEY = UploadedFileProcessorImpl.class.getName()+
+ private static final String _REQUEST_INFO_KEY = CompositeUploadedFileProcessorImpl.class.getName()+
".UploadedFilesInfo";
private static final TrinidadLogger _LOG =
- TrinidadLogger.createTrinidadLogger(UploadedFileProcessorImpl.class);
+ TrinidadLogger.createTrinidadLogger(CompositeUploadedFileProcessorImpl.class);
private static final Class<?> _PORTLET_CONTEXT_CLASS;
private static final Class<?> _PORTLET_REQUEST_CLASS;
@@ -328,4 +467,8 @@ public class UploadedFileProcessorImpl implements UploadedFileProcessor
_PORTLET_CONTEXT_CLASS = context;
_PORTLET_REQUEST_CLASS = request;
}
+
+
+ private final List<? extends UploadedFileProcessor> chainedProcessors;
+
}
diff --git a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/UploadedFileProcessorImpl.java b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/UploadedFileProcessorImpl.java
index 1e0b2de..6c109a1 100644
--- a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/UploadedFileProcessorImpl.java
+++ b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/UploadedFileProcessorImpl.java
@@ -41,7 +41,11 @@ import org.apache.myfaces.trinidadinternal.context.external.ServletApplicationMa
import org.apache.myfaces.trinidadinternal.context.external.ServletInitParameterMap;
import org.apache.myfaces.trinidadinternal.context.external.ServletRequestMap;
-
+/**
+ * @deprecated This implementation is merged to CompositeUploadedFileProcessorImpl.
+ * This class will be removed in the next release.
+ *
+ */
public class UploadedFileProcessorImpl implements UploadedFileProcessor
{
public UploadedFileProcessorImpl()
--
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.