/* (non-Javadoc)
   * @see org.apereo.portal.portlet.rendering.IPortletExecutionManager#getPortletTitle(org.apereo.portal.portlet.om.IPortletWindowId, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
   */
  @Override
  public String getPortletTitle(
      IPortletWindowId portletWindowId, HttpServletRequest request, HttpServletResponse response) {
    final IPortletDefinition portletDefinition = getPortletDefinition(portletWindowId, request);
    final IPortletDefinitionParameter disableDynamicTitle =
        portletDefinition.getParameter("disableDynamicTitle");

    if (disableDynamicTitle == null || !Boolean.parseBoolean(disableDynamicTitle.getValue())) {
      try {
        final PortletRenderResult portletRenderResult =
            getPortletRenderResult(portletWindowId, request, response);
        if (portletRenderResult != null) {
          final String title = portletRenderResult.getTitle();
          if (title != null) {
            return title;
          }
        }
      } catch (Exception e) {
        logger.warn(
            "unable to get portlet title, falling back to title defined in channel definition for portletWindowId "
                + portletWindowId);
      }
    }

    // we assume that response locale has been set to correct value
    String locale = response.getLocale().toString();

    // return portlet title from channel definition
    return portletDefinition.getTitle(locale);
  }
  /* (non-Javadoc)
   * @see org.apereo.portal.portlet.rendering.IPortletExecutionManager#doPortletAction(org.apereo.portal.portlet.om.IPortletWindowId, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
   */
  @Override
  public void doPortletAction(
      IPortletWindowId portletWindowId, HttpServletRequest request, HttpServletResponse response) {
    final long timeout = getPortletActionTimeout(portletWindowId, request);

    final IPortletExecutionWorker<Long> portletActionExecutionWorker =
        this.portletWorkerFactory.createActionWorker(request, response, portletWindowId);
    portletActionExecutionWorker.submit();

    try {
      portletActionExecutionWorker.get(timeout);
    } catch (Exception e) {
      // put the exception into the error map for the session
      final Map<IPortletWindowId, Exception> portletFailureMap = getPortletErrorMap(request);
      portletFailureMap.put(portletWindowId, e);
    }

    // If the worker is still running add it to the hung-workers queue
    if (!portletActionExecutionWorker.isComplete()) {
      cancelWorker(request, portletActionExecutionWorker);
    }

    // Is this portlet permitted to emit events?  (Or is it disablePortletEvents=true?)
    final IPortletWindow portletWindow =
        portletWindowRegistry.getPortletWindow(request, portletWindowId);
    IPortletDefinition portletDefinition = portletWindow.getPortletEntity().getPortletDefinition();
    IPortletDefinitionParameter disablePortletEvents =
        portletDefinition.getParameter(DISABLE_PORTLET_EVENTS_PARAMETER);
    if (disablePortletEvents != null && Boolean.parseBoolean(disablePortletEvents.getValue())) {
      logger.info(
          "Ignoring portlet events for portlet '{}' because they have been disabled.",
          portletDefinition.getFName());
    } else {
      // Proceed with events...
      final PortletEventQueue portletEventQueue =
          this.eventCoordinationService.getPortletEventQueue(request);
      this.doPortletEvents(portletEventQueue, request, response);
    }
  }