String uid = queryParamMap.get(FileUploadConstants.UPLOAD_FILES_ID);
if (uid != null) {
if (isMultipartRequest(httpRequest)) {
MultipartRequest multipartRequest = new MultipartRequest(httpRequest, createTempFiles, maxRequestSize, uid);
Map<String, MultipartRequest> sessionsMap = null;
Map<String, Object> percentMap = null;
try {
if (isFileSizeRestricted(request, maxRequestSize)) {
boolean sendError = Boolean.parseBoolean(queryParamMap.get(SEND_HTTP_ERROR));
if (sendError) {
response.sendError(HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE);
System.err.println("ERROR " + HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE + "request entity is larger than the server is willing or able to process.");
return;
} else {
printResponse(response, "<html id=\"_richfaces_file_upload_size_restricted\"></html>");
}
} else if (!checkFileCount(httpRequest, queryParamMap.get("id"))) {
printResponse(response, "<html id=\"_richfaces_file_upload_forbidden\"></html>");
} else {
HttpSession session = httpRequest.getSession();
synchronized (session) {
sessionsMap = (Map<String, MultipartRequest>) session.getAttribute(FileUploadConstants.REQUESTS_SESSIONS_BEAN_NAME);
percentMap = (Map<String, Object>) session.getAttribute(FileUploadConstants.PERCENT_BEAN_NAME);
if (sessionsMap == null) {
sessionsMap = Collections.synchronizedMap(new HashMap<String, MultipartRequest>());
session.setAttribute(FileUploadConstants.REQUESTS_SESSIONS_BEAN_NAME, sessionsMap);
}
if (percentMap == null) {
percentMap = new HashMap<String, Object>();
session.setAttribute(FileUploadConstants.PERCENT_BEAN_NAME, percentMap);
}
}
/* associate percent value with file entry uid */
percentMap.put(uid, 0);
sessionsMap.put(uid, multipartRequest);
if (multipartRequest.parseRequest()) {
handleRequest(multipartRequest, multipartRequest.isFormUpload() ? response :
new HttpServletResponseWrapper(response){
@Override
public void setContentType(String type) {
super.setContentType(BaseXMLFilter.TEXT_HTML + ";charset=UTF-8");
}