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;
  }
  public ExternalContextCompat_1_2_Impl(
      PortletContext portletContext,
      PortletRequest portletRequest,
      PortletResponse portletResponse) {

    this.portletContext = portletContext;
    this.portletRequest = portletRequest;
    this.portletResponse = portletResponse;

    // Get the BridgeContext.
    this.bridgeContext = BridgeContext.getCurrentInstance();

    this.incongruityContext = bridgeContext.getIncongruityContext();

    // Determine whether or not lifecycle incongruities should be managed.
    PortletConfig portletConfig = bridgeContext.getPortletConfig();
    this.manageIncongruities =
        PortletConfigParam.ManageIncongruities.getBooleanValue(portletConfig);
  }
  public ApplicationScopeMap(BridgeContext bridgeContext) {

    BeanManagerFactory beanManagerFactory =
        (BeanManagerFactory) BridgeFactoryFinder.getFactory(BeanManagerFactory.class);
    this.portletContext = bridgeContext.getPortletContext();

    String appConfigAttrName = ApplicationConfig.class.getName();
    ApplicationConfig applicationConfig =
        (ApplicationConfig) this.portletContext.getAttribute(appConfigAttrName);
    this.beanManager = beanManagerFactory.getBeanManager(applicationConfig.getFacesConfig());

    // Determines whether or not methods annotated with the @PreDestroy annotation are preferably
    // invoked
    // over the @BridgePreDestroy annotation.
    PortletConfig portletConfig = bridgeContext.getPortletConfig();
    this.preferPreDestroy = PortletConfigParam.PreferPreDestroy.getBooleanValue(portletConfig);

    PreDestroyInvokerFactory preDestroyInvokerFactory =
        (PreDestroyInvokerFactory) BridgeFactoryFinder.getFactory(PreDestroyInvokerFactory.class);
    this.preDestroyInvoker = preDestroyInvokerFactory.getPreDestroyInvoker(this);
  }