protected void setRequestParameters(
      PortletRequest portletRequest, PortletResponse portletResponse, OAuthRequest oAuthRequest) {

    setBaseRequestParameters(portletRequest, portletResponse, oAuthRequest);

    Map<String, String[]> parameterMap = new HashMap<>();

    MapUtil.copy(portletRequest.getParameterMap(), parameterMap);

    processPortletParameterMap(portletRequest, portletResponse, parameterMap);

    String serverNamespace = getServerNamespace();

    for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
      String key = entry.getKey();
      String[] values = entry.getValue();

      if (key.equals("remoteWindowState")) {
        key = "p_p_state";
      } else {
        key = serverNamespace.concat(key);
      }

      if (ArrayUtil.isEmpty(values) || Validator.isNull(values[0])) {
        continue;
      }

      addOAuthParameter(oAuthRequest, key, values[0]);
    }
  }
  protected void processEvent(
      PortletRequestImpl portletRequestImpl,
      StateAwareResponseImpl stateAwareResponseImpl,
      List<LayoutTypePortlet> layoutTypePortlets,
      LayoutTypePortlet layoutTypePortlet,
      Portlet portlet,
      Event event)
      throws Exception {

    HttpServletRequest request = portletRequestImpl.getHttpServletRequest();
    HttpServletResponse response = stateAwareResponseImpl.getHttpServletResponse();
    HttpSession session = request.getSession();

    String portletId = portlet.getPortletId();

    ServletContext servletContext = (ServletContext) request.getAttribute(WebKeys.CTX);

    InvokerPortlet invokerPortlet = PortletInstanceFactoryUtil.create(portlet, servletContext);

    PortletConfig portletConfig = PortletConfigFactoryUtil.create(portlet, servletContext);
    PortletContext portletContext = portletConfig.getPortletContext();

    WindowState windowState = null;

    if (layoutTypePortlet.hasStateMaxPortletId(portletId)) {
      windowState = WindowState.MAXIMIZED;
    } else if (layoutTypePortlet.hasStateMinPortletId(portletId)) {
      windowState = WindowState.MINIMIZED;
    } else {
      windowState = WindowState.NORMAL;
    }

    PortletMode portletMode = null;

    if (layoutTypePortlet.hasModeAboutPortletId(portletId)) {
      portletMode = LiferayPortletMode.ABOUT;
    } else if (layoutTypePortlet.hasModeConfigPortletId(portletId)) {
      portletMode = LiferayPortletMode.CONFIG;
    } else if (layoutTypePortlet.hasModeEditPortletId(portletId)) {
      portletMode = PortletMode.EDIT;
    } else if (layoutTypePortlet.hasModeEditDefaultsPortletId(portletId)) {
      portletMode = LiferayPortletMode.EDIT_DEFAULTS;
    } else if (layoutTypePortlet.hasModeEditGuestPortletId(portletId)) {
      portletMode = LiferayPortletMode.EDIT_GUEST;
    } else if (layoutTypePortlet.hasModeHelpPortletId(portletId)) {
      portletMode = PortletMode.HELP;
    } else if (layoutTypePortlet.hasModePreviewPortletId(portletId)) {
      portletMode = LiferayPortletMode.PREVIEW;
    } else if (layoutTypePortlet.hasModePrintPortletId(portletId)) {
      portletMode = LiferayPortletMode.PRINT;
    } else {
      portletMode = PortletMode.VIEW;
    }

    User user = stateAwareResponseImpl.getUser();
    Layout layout = stateAwareResponseImpl.getLayout();

    PortletPreferences portletPreferences = portletRequestImpl.getPreferencesImpl();

    EventRequestImpl eventRequestImpl =
        EventRequestFactory.create(
            request,
            portlet,
            invokerPortlet,
            portletContext,
            windowState,
            portletMode,
            portletPreferences,
            layoutTypePortlet.getLayout().getPlid());

    eventRequestImpl.setEvent(serializeEvent(event, invokerPortlet.getPortletClassLoader()));

    EventResponseImpl eventResponseImpl =
        EventResponseFactory.create(eventRequestImpl, response, portletId, user, layout);

    eventRequestImpl.defineObjects(portletConfig, eventResponseImpl);

    try {
      try {
        InvokerPortletImpl.clearResponse(
            session,
            layout.getPrimaryKey(),
            portletId,
            LanguageUtil.getLanguageId(eventRequestImpl));

        invokerPortlet.processEvent(eventRequestImpl, eventResponseImpl);

        if (eventResponseImpl.isCalledSetRenderParameter()) {
          Map<String, String[]> renderParameterMap = new HashMap<String, String[]>();

          MapUtil.copy(eventResponseImpl.getRenderParameterMap(), renderParameterMap);

          RenderParametersPool.put(request, layout.getPlid(), portletId, renderParameterMap);
        }
      } catch (UnavailableException ue) {
        throw ue;
      }

      processEvents(eventRequestImpl, eventResponseImpl, layoutTypePortlets);
    } finally {
      eventRequestImpl.cleanUp();
    }
  }