/** Populate the state object, if needed, concerning paging */
  protected void initState(SessionState state, VelocityPortlet portlet, JetspeedRunData rundata) {
    super.initState(state, portlet, rundata);

    if (state.getAttribute(STATE_PAGESIZE) == null) {
      state.setAttribute(STATE_PAGESIZE, new Integer(DEFAULT_PAGE_SIZE));
      PortletConfig config = portlet.getPortletConfig();

      try {
        Integer size = new Integer(config.getInitParameter(PARAM_PAGESIZE));
        if (size.intValue() <= 0) {
          size = new Integer(DEFAULT_PAGE_SIZE);
          if (Log.getLogger("chef").isDebugEnabled())
            Log.debug(
                "chef",
                this
                    + ".initState: size parameter invalid: "
                    + config.getInitParameter(PARAM_PAGESIZE));
        }
        state.setAttribute(STATE_PAGESIZE, size);
      } catch (Exception any) {
        if (Log.getLogger("chef").isDebugEnabled())
          Log.debug("chef", this + ".initState: size parameter invalid: " + any.toString());
        state.setAttribute(STATE_PAGESIZE, new Integer(DEFAULT_PAGE_SIZE));
      }
    }
  } // initState
  public void init(PortletConfig config) throws UnavailableException {
    super.init(config);
    try {
      this.layoutMgr =
          (LayoutManagerService) config.getContext().getService(LayoutManagerService.class);
      this.userManagerService =
          (UserManagerService) config.getContext().getService(UserManagerService.class);

    } catch (PortletServiceException e) {
      log.error("Unable to initialize services!", e);
    }
    /* moved to doRender
            String themesPath = getPortletConfig().getContext().getRealPath("/themes");

            File f = new File(themesPath);
            if (f.isDirectory()) {
                themes = f.list();
            }
    */
    DEFAULT_VIEW_PAGE = "doRender";
    DEFAULT_HELP_PAGE = "layout/help.jsp";
  }
  @Override
  public void serveResource(ResourceRequest portletReq, ResourceResponse portletResp)
      throws PortletException, IOException {
    LOGGER.entering(LOG_CLASS, "main portlet serveResource entry");

    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);

    PrintWriter writer = portletResp.getWriter();

    // Now do the actual dispatch
    String target =
        SERVLET_PREFIX
            + "DispatcherTests_SPEC2_19_ForwardServletResource_servlet"
            + SERVLET_SUFFIX
            + "?"
            + QUERY_STRING;
    PortletRequestDispatcher rd = portletConfig.getPortletContext().getRequestDispatcher(target);
    rd.forward(portletReq, portletResp);
  }
  @Override
  public void processAction(ActionRequest portletReq, ActionResponse portletResp)
      throws PortletException, IOException {
    LOGGER.entering(LOG_CLASS, "main portlet processAction entry");

    portletResp.setRenderParameters(portletReq.getParameterMap());
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);

    StringWriter writer = new StringWriter();

    // Now do the actual dispatch
    String target =
        JSP_PREFIX
            + "DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse"
            + JSP_SUFFIX
            + "?"
            + QUERY_STRING;
    PortletRequestDispatcher rd = portletConfig.getPortletContext().getRequestDispatcher(target);
    rd.include(portletReq, portletResp);
  }