Search in sources :

Example 1 with UploadedFileBridgeImpl

use of com.liferay.faces.bridge.model.internal.UploadedFileBridgeImpl in project liferay-faces-bridge-impl by liferay.

the class ContextMapFactoryImpl method getUploadedFileMap.

@Override
public Map<String, List<UploadedFile>> getUploadedFileMap(PortletRequest portletRequest) {
    Map<String, List<UploadedFile>> bridgeUploadedFileMap = Collections.emptyMap();
    MultiPartFormData multiPartFormData = (MultiPartFormData) portletRequest.getAttribute(MULTIPART_FORM_DATA_FQCN);
    if (multiPartFormData != null) {
        Map<String, List<com.liferay.faces.util.model.UploadedFile>> uploadedFileMap = multiPartFormData.getUploadedFileMap();
        if (uploadedFileMap != null) {
            PortletSession portletSession = portletRequest.getPortletSession(true);
            PortletContext portletContext = portletSession.getPortletContext();
            Map<String, Object> applicationScopeMap = getApplicationScopeMap(portletContext, true);
            ExternalContext externalContext = new ExternalContextProductImpl(applicationScopeMap);
            ProductFactory productFactory = (ProductFactory) FactoryExtensionFinder.getFactory(externalContext, ProductFactory.class);
            Product PRIMEFACES = productFactory.getProductInfo(Product.Name.PRIMEFACES);
            boolean primeFacesDetected = PRIMEFACES.isDetected();
            int primeFacesMajorVersion = PRIMEFACES.getMajorVersion();
            bridgeUploadedFileMap = new HashMap<String, List<UploadedFile>>(uploadedFileMap.size());
            Set<Map.Entry<String, List<com.liferay.faces.util.model.UploadedFile>>> entrySet = uploadedFileMap.entrySet();
            for (Map.Entry<String, List<com.liferay.faces.util.model.UploadedFile>> mapEntry : entrySet) {
                List<com.liferay.faces.util.model.UploadedFile> uploadedFileList = mapEntry.getValue();
                if (uploadedFileList != null) {
                    List<UploadedFile> bridgeUploadedFileList = new ArrayList<UploadedFile>(uploadedFileList.size());
                    for (com.liferay.faces.util.model.UploadedFile uploadedFile : uploadedFileList) {
                        bridgeUploadedFileList.add(new UploadedFileBridgeImpl(uploadedFile, primeFacesDetected, primeFacesMajorVersion));
                    }
                    bridgeUploadedFileMap.put(mapEntry.getKey(), bridgeUploadedFileList);
                }
            }
        }
    }
    return bridgeUploadedFileMap;
}
Also used : ProductFactory(com.liferay.faces.util.product.ProductFactory) ArrayList(java.util.ArrayList) Product(com.liferay.faces.util.product.Product) UploadedFileBridgeImpl(com.liferay.faces.bridge.model.internal.UploadedFileBridgeImpl) ExternalContext(javax.faces.context.ExternalContext) ArrayList(java.util.ArrayList) List(java.util.List) MultiPartFormData(com.liferay.faces.util.context.map.MultiPartFormData) UploadedFile(com.liferay.faces.bridge.model.UploadedFile) PortletSession(javax.portlet.PortletSession) PortletContext(javax.portlet.PortletContext) HashMap(java.util.HashMap) Map(java.util.Map) FacesRequestParameterMap(com.liferay.faces.util.context.map.FacesRequestParameterMap)

Aggregations

UploadedFile (com.liferay.faces.bridge.model.UploadedFile)1 UploadedFileBridgeImpl (com.liferay.faces.bridge.model.internal.UploadedFileBridgeImpl)1 FacesRequestParameterMap (com.liferay.faces.util.context.map.FacesRequestParameterMap)1 MultiPartFormData (com.liferay.faces.util.context.map.MultiPartFormData)1 Product (com.liferay.faces.util.product.Product)1 ProductFactory (com.liferay.faces.util.product.ProductFactory)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ExternalContext (javax.faces.context.ExternalContext)1 PortletContext (javax.portlet.PortletContext)1 PortletSession (javax.portlet.PortletSession)1