protected FacesRequestParameterMap getFacesRequestParameterMap(BridgeContext bridgeContext) { FacesRequestParameterMap facesRequestParameterMap = null; PortletRequest portletRequest = bridgeContext.getPortletRequest(); PortletResponse portletResponse = bridgeContext.getPortletResponse(); String namespace = portletResponse.getNamespace(); BridgeRequestScope bridgeRequestScope = bridgeContext.getBridgeRequestScope(); String defaultRenderKitId = bridgeContext.getDefaultRenderKitId(); Map<String, String> facesViewParameterMap = getFacesViewParameterMap(bridgeContext); if (portletRequest instanceof ClientDataRequest) { ClientDataRequest clientDataRequest = (ClientDataRequest) portletRequest; String contentType = clientDataRequest.getContentType(); // Note: ICEfaces ace:fileEntry relies on its own mechanism for handling file upload. if (!ICEFACES_DETECTED && (contentType != null) && contentType.toLowerCase().startsWith(BridgeConstants.MULTIPART_CONTENT_TYPE_PREFIX)) { MultiPartFormData multiPartFormData = (MultiPartFormData) portletRequest.getAttribute(MULTIPART_FORM_DATA_FQCN); if (multiPartFormData == null) { facesRequestParameterMap = new FacesRequestParameterMapImpl( namespace, bridgeRequestScope, facesViewParameterMap, defaultRenderKitId); MultiPartFormDataProcessor multiPartFormDataProcessor = new MultiPartFormDataProcessorImpl(); Map<String, List<UploadedFile>> uploadedFileMap = multiPartFormDataProcessor.process( clientDataRequest, bridgeContext.getPortletConfig(), facesRequestParameterMap); multiPartFormData = new MultiPartFormDataImpl(facesRequestParameterMap, uploadedFileMap); // Save the multipart/form-data in a request attribute so that it can be referenced // later-on in the // JSF lifecycle by file upload component renderers. portletRequest.setAttribute(MULTIPART_FORM_DATA_FQCN, multiPartFormData); } else { facesRequestParameterMap = multiPartFormData.getFacesRequestParameterMap(); } } } if (facesRequestParameterMap == null) { Map<String, String[]> parameterMap = portletRequest.getParameterMap(); facesRequestParameterMap = new FacesRequestParameterMapImpl( parameterMap, namespace, bridgeRequestScope, facesViewParameterMap, defaultRenderKitId); } return facesRequestParameterMap; }
@Override public Map<String, List<UploadedFile>> getUploadedFileMap(BridgeContext bridgeContext) { PortletRequest portletRequest = bridgeContext.getPortletRequest(); MultiPartFormData multiPartFormData = (MultiPartFormData) portletRequest.getAttribute(MULTIPART_FORM_DATA_FQCN); Map<String, List<UploadedFile>> uploadedFileMap = null; if (multiPartFormData != null) { uploadedFileMap = multiPartFormData.getUploadedFileMap(); } return uploadedFileMap; }
protected Map<String, List<UploadedFile>> getUploadedFileMap( FacesContext facesContext, String location) { Map<String, List<UploadedFile>> uploadedFileMap = null; if (LIFERAY_FACES_BRIDGE_DETECTED) { Map<String, Object> requestAttributeMap = facesContext.getExternalContext().getRequestMap(); MultiPartFormData multiPartFormData = (MultiPartFormData) requestAttributeMap.get(MultiPartFormData.class.getName()); if (multiPartFormData != null) { uploadedFileMap = multiPartFormData.getUploadedFileMap(); } } else { InputFileDecoder inputFileDecoder = getInputFileDecoder(); uploadedFileMap = inputFileDecoder.decode(facesContext, location); } return uploadedFileMap; }