Override handleRequest to perform processing necessary for this component. This is used to handle the server-side
collapsible mode and to synchronise with the client-side state for the other modes.

@param request the request being responded to.
172810
@Override
	public void handleRequest(final Request request) {
		String clientState = request.getParameter(getId());

		if (clientState != null) {
			setCollapsed(clientState.equalsIgnoreCase("closed"));
		}
	}
446994
private void fireRequestSent(final AbstractBody request) {
        assertUnlocked();

        BOSHMessageEvent event = null;
        for (BOSHClientRequestListener listener : requestListeners) {
            if (event == null) {
                event = BOSHMessageEvent.createRequestSentEvent(this, request);
            }
            try {
                listener.requestSent(event);
            } catch (Exception ex) {
                LOG.log(Level.WARNING, UNHANDLED, ex);
            }
        }
    }
389456
public void destroy( HttpServletRequest request )
    {
        StorageHandler sh = Handlers.get( getServletContext() ).getStorageHandler();
        HttpServletRequest unwrappedRequest = PageFlowUtils.unwrapMultipart( request );
        RequestContext rc = new RequestContext( unwrappedRequest, null );
        String attrName = ScopedServletUtils.getScopedSessionAttrName( JPF_STACK_ATTR, unwrappedRequest );
        
        sh.removeAttribute( rc, attrName );
    }
912192
protected void doRequest (HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException
    {
        InvocationContext context = null;
        try {
            context =  new InvocationContext(request, response);
            setContentType(request, response);

            Template template = handleRequest(request, response, context);
            if (template != null) {
                mergeTemplate(template, context);
            }

        } catch (Exception e) {
            log.warning("doRequest failed", "uri", request.getRequestURI(), e);
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
        }
    }
1153043
@Override
  public Answer processRequest(Request request) {
    if (logger.isInfoEnabled()) {
      logger.info("Diameter Stack Mux :: processRequest :: Command-Code [" + request.getCommandCode() + "]");
    }

    DiameterListener listener = findListener(request);

    if (listener != null) {
      return listener.processRequest(request);
    }
    else {
      try {
        Answer answer = request.createAnswer(ResultCode.APPLICATION_UNSUPPORTED);
        //this.stack.getSessionFactory().getNewRawSession().send(answer);
        return answer;
      }
      catch (Exception e) {
        logger.error("Failed to create APPLICATION UNSUPPORTED answer.", e);
      }
    }
    return null;
  }
1174881
@Override
	public void serviceRequest(final Request request) {
		// Get expected step count
		UIContext uic = UIContextHolder.getCurrent();
		int expected = uic.getEnvironment().getStep();

		// Step should already be set on the session
		if (expected == 0) {
			throw new SystemException(
					"Step count should already be set on the session before content request.");
		}

		// Get step count on the request
		int got = StepCountUtil.getRequestStep(request);

		// Check tokens match (both must be provided)
		if (expected == got) {
			// Process Service Request
			getBackingComponent().serviceRequest(request);
		} else if (!StepCountUtil.isStepOnRequest(request) && StepCountUtil.isCachedContentRequest(request)) {  // cached content (no step on request)
			// Process Service Request
			getBackingComponent().serviceRequest(request);
		} else {  // Invalid token
			// Set an error code
			LOG.warn(
					"Wrong step detected for content request. Expected step [" + expected + "] but got step [" + got
					+ "].");
			handleError();
		}

	}
877872
@Override
	public void serviceRequest(final Request request) {

		// Get expected step count
		UIContext uic = UIContextHolder.getCurrent();
		int expected = uic.getEnvironment().getStep();

		// Get step count from the request
		int got = StepCountUtil.getRequestStep(request);

		// Match (first time, both are zero)
		// or no Step count and processing a GET
		if (expected == got || (!StepCountUtil.isStepOnRequest(request) && "GET".equals(request.
				getMethod()))) {
			// Process Service Request
			getBackingComponent().serviceRequest(request);
		} else { // Invalid step
			LOG.warn(
					"SERVER: Wrong step detected. Expected step " + expected + " but got step " + got);

			// Redirect to error page
			if (StepCountUtil.isErrorRedirect()) {
				String url = StepCountUtil.getErrorUrl();
				LOG.warn("User will be redirected to an error page. URL: " + url);
				try {
					getResponse().sendRedirect(url);
				} catch (IOException e) {
					LOG.warn("Error trying to redirect for wrong step indicator.");
				}

				// Make sure the render phase is not processed
				throw new ActionEscape();
			} else {  // Warp to the future
				// Call handle step error
				WComponent application = getUI();
				if (application instanceof WApplication) {
					LOG.warn("The handleStepError method will be called on WApplication.");
					((WApplication) application).handleStepError();
				}

				LOG.warn("The render phase will warp the user back to the future.");
			}
		}
	}
283583
private void handleTrackRequest(final Request request) {
		String trackRequested = request.getParameter(TRACK_INDEX_REQUEST_PARAM_KEY);
		int trackIndex = 0;

		try {
			trackIndex = Integer.parseInt(trackRequested);
		} catch (NumberFormatException e) {
			LOG.error("Failed to parse track index: " + trackIndex);
		}

		Track[] tracks = getTracks();

		if (tracks != null && trackIndex >= 0 && trackIndex < tracks.length) {
			ContentEscape escape = new ContentEscape(tracks[trackIndex]);
			escape.setCacheable(!Util.empty(getCacheKey()));
			throw escape;
		} else {
			LOG.warn("Client requested invalid track: " + trackIndex);
		}
	}
1112918
protected CompletableFuture<AppendResponse> handleAppend(final AppendRequest request) {
    CompletableFuture<AppendResponse> future = new CompletableFuture<>();

    // Check that the term of the given request matches the local term or update the term.
    if (!checkTerm(request, future)) {
      return future;
    }

    // Check that the previous index/term matches the local log's last entry.
    if (!checkPreviousEntry(request, future)) {
      return future;
    }

    // Append the entries to the log.
    appendEntries(request, future);
    return future;
  }
862951
private void handleShuffleState(final Request request) {

		String json = request.getParameter(SHUFFLE_REQUEST_KEY);
		if (Util.empty(json)) {
			return;
		}

		// New
		TreeItemIdNode newTree;
		try {
			newTree = TreeItemUtil.convertJsonToTree(json);
		} catch (Exception e) {
			LOG.warn("Could not parse JSON for shuffle tree items. " + e.getMessage());
			return;
		}

		// Current
		TreeItemIdNode currentTree = getCustomTree();

		boolean changed = !TreeItemUtil.isTreeSame(newTree, currentTree);

		if (changed) {
			setCustomTree(newTree);
			// Run the shuffle action (if set)
			final Action action = getShuffleAction();
			if (action != null) {
				final ActionEvent event = new ActionEvent(this, "shuffle");
				Runnable later = new Runnable() {
					@Override
					public void run() {
						action.execute(event);
					}
				};
				invokeLater(later);
			}
		}
	}
992893
@Override
	protected void preparePaintComponent(final Request request) {
		super.preparePaintComponent(request);
		WComponent content = getContent();

		if (content != null) {
			switch (getMode()) {
				case EAGER: {
					// Will always be visible
					content.setVisible(true);
					AjaxHelper.registerContainer(getId(), getId() + "-content", content.getId());
					break;
				}
				case LAZY: {
					content.setVisible(isOpen());
					if (!isOpen()) {
						AjaxHelper.registerContainer(getId(), getId() + "-content", content.getId());
					}

					break;
				}
				case DYNAMIC: {
					content.setVisible(isOpen());
					AjaxHelper.registerContainer(getId(), getId() + "-content", content.getId());
					break;
				}
				case SERVER: {
					content.setVisible(isOpen());
					break;
				}
				case CLIENT: {
					// Will always be visible
					content.setVisible(true);
					break;
				}

				default:
					// do nothing.
					break;
			}
		}
	}
1184916
public void processRequest(RequestEvent request) {
    Request req_msg = request.getRequest();
    ToHeader to = (ToHeader) req_msg.getHeader(ToHeader.NAME);
    SipContact my_contact_info = new SipContact();

    synchronized (contactLock) {
      my_contact_info.setContactHeader((ContactHeader) (contactInfo.getContactHeader().clone()));
    }

    // Is it for me? Check: Request-URI = my contact address (I may not be
    // the original 'To' party, also there may be multiple devices for one
    // "me" address of record)
    // If no match, check 'To' = me
    // (so that local messaging without proxy still works) - but ONLY IF
    // setLoopback() has been called

    LOG.trace("request received !");
    LOG.trace("     me ('To' check) = {}", me);
    LOG.trace("     my local contact info ('Request URI' check) = {}", my_contact_info.getURI());
    LOG.trace("     {}" , req_msg.toString());

    if (req_msg.getMethod().equalsIgnoreCase(SipRequest.REGISTER)) {
      if (!isPassThroughRegisterRequests()) {
        if (!isSupportRegisterRequests()) {
          return;
        } else {
          ExpiresHeader expires = req_msg.getExpires();
          if (expires.getExpires() == 0) {
            try {
              Response response = getParent().getMessageFactory().createResponse(Response.OK, request.getRequest());
              sendReply(request, response);
              return;
            } catch (Exception e) {
              LOG.error("Exception while trying to respond to REGISTER with Expires header 0 request");
            }
          }
        }
      }
    } else if (!acceptTrafficOnEphemeralPorts) {
      //Check if destination match
      if (destMatch((SipURI) my_contact_info.getContactHeader().getAddress().getURI(),
              (SipURI) req_msg.getRequestURI()) == false) {
        if (!loopback) {
          LOG.trace("     skipping 'To' check, we're not loopback (see setLoopback())");
          return;
        }

        // check 'To' for a match
        if (to.getAddress().getURI().toString().equals(me) == false) {
          return;
        }
      }
    }

    if (req_msg.getMethod().equalsIgnoreCase(Request.OPTIONS)) {
      int responseCode = Response.OK;
      if (!isAutoResponseOptionsRequests()) {
        if (errorRespondToOptions != -1 ) {
          responseCode = errorRespondToOptions;
        } else {
          return;
        }
      }
      try {
        Response response = getParent().getMessageFactory().createResponse(responseCode, request.getRequest());
        sendReply(request, response);
        lastReceivedOptionsRequest = req_msg;
      } catch (Exception e) {
        LOG.error("Exception while trying to respond to OPTIONS request");
      }
    }

    // check for listener handling
    synchronized (requestListeners) {
      List<RequestListener> listeners = requestListeners.get(req_msg.getMethod());
      if (listeners != null) {
        Iterator<RequestListener> i = listeners.iterator();
        while (i.hasNext()) {
          RequestListener listener = (RequestListener) i.next();
          listener.processEvent(request);
        }
      }
    }

    synchronized (reqBlock) {
      if (rcvRequests == false) {
        LOG.trace("not interested in blocking requests");
        return;
      }

      reqEvents.addLast(request);

      LOG.trace("notifying block object");
      reqBlock.notifyEvent();
    }
  }
79621
protected void handleTriggerOpenAction(final Request request) {
		// Run the action (if set)
		final Action action = getTriggerOpenAction();
		if (action != null) {
			final ActionEvent event = new ActionEvent(this, OPEN_DIALOG_ACTION);
			Runnable later = new Runnable() {
				@Override
				public void run() {
					action.execute(event);
				}
			};
			invokeLater(later);
		}
	}
670254
@Override
	public void handleRequest(final Request request) {
		super.handleRequest(request);

		WComponent visibleDialog = getVisible();

		if (visibleDialog != null) {
			visibleDialog.serviceRequest(request);
		}
	}
511158
public void setRequest(ServletRequest request) {
        if (request != null) {
            if (logger.isDebugEnabled()) {
                logger.debug(String.format("set request: %s", request));
            }
            this.threadLocalRequests.set((HttpServletRequest) request);
        } else {
            //if null, remove from threadLocalRequests
            // @see WindowTask#run 's finally
            if (logger.isDebugEnabled()) {
                HttpServletRequest tmpRequest = this.threadLocalRequests.get();
                logger.debug(String.format("remove request: %s", tmpRequest));
            }
            this.threadLocalRequests.remove();
        }
    }
10773
static void preHandleMultipartRequest(HttpServletRequest request)
        throws ServletException
    {
        MultipartRequestHandler multipartHandler = getCachedMultipartHandler(request);
        
        if (multipartHandler == null)
        {
            multipartHandler = getMultipartHandler(request);
            
            if (multipartHandler != null)
            {
                //
                // Run the request through the handler, and cache the handler in the outer request.
                //
                multipartHandler.handleRequest(request);
                HttpServletRequest outerRequest = ScopedServletUtils.getOuterRequest(request);
                outerRequest.setAttribute(PREHANDLED_MULTIPART_REQUEST_ATTR, multipartHandler);
            }
        }
    }
554080
public void handleRequest(String request) {
        if (messageListener != null) {
            log.debug("Received Http request");
            messageListener.onInboundMessage(new RawMessage(request), null);
        } else {
            if (log.isDebugEnabled()) {
                log.debug("Received Http request:" + NEWLINE + request);
            }
        }
    }