List of usage examples for com.liferay.portal.kernel.util HttpUtil parameterMapToString
public static String parameterMapToString(Map<String, String[]> parameterMap)
From source file:io.gatling.liferay.recorder.RecorderFilter.java
License:Apache License
/** * Save the URL of the request in the currentRecords and update the recordURL session attribute. * If a form is invalid, the function stores an error in a cookie. * @param request The HTTP request/*from w w w . j a v a 2 s . co m*/ * @param response The HTTP Response * @param session The current session * @param currentRecords The current recorded urls * @throws IOException If a buffering action failed */ private static void saveURL(HttpServletRequest request, ServletResponse response, HttpSession session, List<RecordURL> currentRecords) throws IOException { //Handle timer between two requests long start = (long) session.getAttribute("GATLING_PAUSE_TIME"); long now = System.nanoTime(); session.setAttribute("GATLING_PAUSE_TIME", now); int pauseTime = (int) Math.floor((now - start) / Math.pow(10, 9)); Map<String, String[]> parametersMap = request.getParameterMap(); String params = HttpUtil.parameterMapToString(filterParameters(parametersMap)); //TODO: In future, the base URL should be customizable String requestURL = request.getRequestURI().replace(URL_CONTROL_PANEL, ""); LOG.info("requestURL: " + requestURL); RecordURL record = null; if (request.getMethod().equalsIgnoreCase("post")) { if (request.getContentType() != null && request.getContentType().toLowerCase().contains("multipart/form-data")) { //Multipart Form case record = computeDataFromMultiParts(request, requestURL, params); } else { //Normal Form case record = computeParamsFromNormalForm(request, requestURL, params); } } else { //Get Case record = new GetURL(requestURL, params); } record.setPauseTime(pauseTime); LOG.debug(record); currentRecords.add(record); session.setAttribute("recordURL", currentRecords); }