Example usage for com.liferay.portal.kernel.util SessionParamUtil getString

List of usage examples for com.liferay.portal.kernel.util SessionParamUtil getString

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util SessionParamUtil getString.

Prototype

public static String getString(PortletRequest portletRequest, String param, String defaultValue) 

Source Link

Usage

From source file:io.gatling.liferay.recorder.RecorderFilter.java

License:Apache License

/**
 * Gatling's recorder filter. It records all the url visited from the <i>Portlet Config</i> in the plugin <b>Gatling Liferay</b>.
 * /*from  ww w  .  j  a  va  2  s.c  o m*/
 * It uses session to store all the visited URLs and next saves it in DB.
 */
@SuppressWarnings("unchecked")
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    LOG.debug("doFilterCalled");
    HttpServletRequest httpRequest = (HttpServletRequest) request;
    HttpSession session = httpRequest.getSession();

    // ToogleRecord and prepare session with the request attributes
    toogleRecord(httpRequest, session);

    String infosRecorder = SessionParamUtil.getString(httpRequest, "GATLING_RECORD_STATE", null);
    if (infosRecorder != null) {
        String[] infos = infosRecorder.split(",");

        List<RecordURL> currentRecords = (List<RecordURL>) session.getAttribute("recordURL");
        if (currentRecords == null) { // if empty session recordURL create one
            currentRecords = new ArrayList<RecordURL>();
        }

        if (infos[INFO_RECORD_STATE].equalsIgnoreCase("RECORD")) {
            saveURL(httpRequest, response, session, currentRecords);
        } else if (infos[INFO_RECORD_STATE].equalsIgnoreCase("STOP")) {
            request.setAttribute("recordName", infos[INFO_RECORD_NAME]);
            stopRecording(session, infos, currentRecords);
        }
    }
    chain.doFilter(request, response);
}