Handle model and view.

@param request  the request
@param response the response
@return the model and view
@throws Exception the exception
170011
@GetMapping(path = CasProtocolConstants.ENDPOINT_PROXY_VALIDATE_V3)
    @Override
    protected ModelAndView handle(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
        return super.handleRequestInternal(request, response);
    }
581055
private static void renderException(final Map model, final HttpServletResponse response) {
        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
        model.put("status", HttpServletResponse.SC_BAD_REQUEST);
        render(model, response);
    }
522052
void doMethod(HttpServletRequest request, HttpServletResponse response, HttpMethod httpMethod) {

        // Locate a request handler:
        String requestPath = mapRequestPath(request);
        Route route = api.get(requestPath);

        try {

            if (route != null && route.requestHandlers.containsKey(httpMethod)) {
                handleRequest(request, response, route, httpMethod);
            } else {
                handleNotFound(request, response);
            }

        } catch (Throwable t) {

            // Chances are the exception we've actually caught is the reflection
            // one from Method.invoke(...)
            Throwable caught = t;
            if (InvocationTargetException.class.isAssignableFrom(t.getClass())) {
                caught = t.getCause();
            }

            RequestHandler requestHandler = (route == null ? null : route.requestHandlers.get(httpMethod));
            handleError(request, response, requestHandler, caught);
        }

    }
1093286
public void handleSsoPostProfileRequest(final HttpServletResponse response,
                                            final HttpServletRequest request,
                                            final BaseHttpServletRequestXMLMessageDecoder decoder) throws Exception {
        val authnRequest = getSamlProfileHandlerConfigurationContext().getSamlHttpRequestExtractor()
            .extract(request, decoder, AuthnRequest.class);
        initiateAuthenticationRequest(authnRequest, response, request);
    }
864784
@Override
  public Response handle() throws Exception {
    Object p = getRequest().getPayload().get("id");

    if (JSONObject.NULL.equals(p)) {
      getWebDriver().getContext().setCurrentFrame(null, null, null);
    } else {
      RemoteWebElement iframe;
      if (p instanceof String) {
        iframe = getIframe((String) p);
      } else if (p instanceof Integer) {
        iframe = getIframe((Integer) p);
      } else if (p instanceof JSONObject) {
        String id = ((JSONObject) p).getString("ELEMENT");
        iframe = getWebDriver().createElement(id);
      } else {
        throw new UnsupportedCommandException("not supported : frame selection by " + p.getClass());
      }

      RemoteWebElement document = iframe.getContentDocument();
      RemoteWebElement window = iframe.getContentWindow();
      getWebDriver().getContext().setCurrentFrame(iframe, document, window);
    }

    Response res = new Response();
    res.setSessionId(getSession().getSessionId());
    res.setStatus(0);
    res.setValue(new JSONObject());
    return res;
  }
1258384
@Override
    public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response,
                                         Object handler, Exception ex) {
        // don't reuse cached controller attribute 
        request.removeAttribute(GrailsApplicationAttributes.GRAILS_CONTROLLER_CLASS_AVAILABLE);        
        
        ex = findWrappedException(ex);

        filterStackTrace(ex);

        ModelAndView mv = super.resolveException(request, response, handler, ex);

        setStatus(request, response, mv, ex);

        logStackTrace(ex, request);

        UrlMappingsHolder urlMappings = lookupUrlMappings();
        if (urlMappings != null) {
            mv = resolveViewOrForward(ex, urlMappings, request, response, mv);
        }

        return mv;
    }
1259529
@Override
    public void handleRequest(HttpServletRequest request, HttpServletResponse response) {
        handleRequest(request, response, null, null, false);
    }
1318430
@RequestMapping(
            headers = {"org.apereo.portal.url.UrlType=ACTION"},
            method = RequestMethod.POST)
    public void actionRequest(HttpServletRequest request, HttpServletResponse response)
            throws IOException {

        final IPortalRequestInfo portalRequestInfo =
                this.urlSyntaxProvider.getPortalRequestInfo(request);
        final IPortletRequestInfo portletRequestInfo =
                portalRequestInfo.getTargetedPortletRequestInfo();

        final IPortalUrlBuilder actionRedirectUrl;
        if (portletRequestInfo != null) {
            final IPortletWindowId targetWindowId = portletRequestInfo.getPortletWindowId();
            actionRedirectUrl =
                    this.portalUrlProvider.getPortalUrlBuilderByPortletWindow(
                            request, targetWindowId, UrlType.RENDER);
        } else {
            final String targetedLayoutNodeId = portalRequestInfo.getTargetedLayoutNodeId();

            if (targetedLayoutNodeId != null) {
                actionRedirectUrl =
                        this.portalUrlProvider.getPortalUrlBuilderByLayoutNode(
                                request, targetedLayoutNodeId, UrlType.RENDER);
            } else {
                actionRedirectUrl = this.portalUrlProvider.getDefaultUrl(request);
            }
        }

        // Stuff the action-redirect URL builder into the request so other code can use it during
        // request processing
        this.portalUrlProvider.convertToPortalActionUrlBuilder(request, actionRedirectUrl);

        if (portletRequestInfo != null) {
            final IPortletWindowId targetWindowId = portletRequestInfo.getPortletWindowId();

            try {
                this.portletExecutionManager.doPortletAction(targetWindowId, request, response);
            } catch (RuntimeException e) {
                this.logger.error(
                        "Exception thrown while executing portlet action for: "
                                + portletRequestInfo,
                        e);

                // TODO this should be a constant right?
                actionRedirectUrl.setParameter("portletActionError", targetWindowId.toString());
            }
        }

        sendRedirect(actionRedirectUrl, response);
    }
1305111
public boolean preHandle(HttpServletRequest request,
                             HttpServletResponse response, Object handler) throws Exception {

        String queryString = request.getQueryString() == null ? "" : request.getQueryString();

        if (ConfigurationService.getInstance().isValid()
                || request.getServletPath().startsWith("/configuration")
                || request.getServletPath().startsWith("/resources")
                || queryString.contains("requestFromConfiguration=true")) {
            return true;
        } else {
            response.sendRedirect("configuration");
            return false;
        }
    }
1192485
public void doBrowse(HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException
    {
        if (!common.checkGet(request, response)) return;
        User user = common.getLoggedInUser(request);
        if (user == null) {
            common.pageSoftError(response, "Can't do /browse.  Nobody is logged in.");
            return;
        }

        DbxClientV2 dbxClient = requireDbxClient(request, response, user);
        if (dbxClient == null) return;

        String path = request.getParameter("path");
        if (path == null || path.length() == 0) {
            renderFolder(response, user, dbxClient, "");
        } else {
            String pathError = DbxPathV2.findError(path);
            if (pathError != null) {
                response.sendError(400, "Invalid path: " + jq(path) + ": " + pathError);
                return;
            }
            Metadata metadata;
            try {
                metadata = dbxClient.files()
                    .getMetadata(path);
            }
            catch (GetMetadataErrorException ex) {
                if (ex.errorValue.isPath()) {
                    LookupError le = ex.errorValue.getPathValue();
                    if (le.isNotFound()) {
                        response.sendError(400, "Path doesn't exist on Dropbox: " + jq(path));
                        return;
                    }
                }
                common.handleException(response, ex, "getMetadata(" + jq(path) + ")");
                return;
            }
            catch (DbxException ex) {
                common.handleDbxException(response, user, ex, "getMetadata(" + jq(path) + ")");
                return;
            }

            path = DbxPathV2.getParent(path) + "/" + metadata.getName();
            if (metadata instanceof FolderMetadata) {
                renderFolder(response, user, dbxClient, path);
            }
            else {
                renderFile(response, path, (FileMetadata) metadata);
            }
        }
    }
496284
@Override
    public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException {
        String stackTrace = getStackTrace(baseRequest);
        if (stackTrace != null) {
            response.getWriter().print(getStackTrace(baseRequest));
        } else {
            super.handle(target, baseRequest, request, response);
        }
    }
269731
protected void service(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		try {
			jawrController.handleRequest(request, response);
		} catch (Exception e) {
			if (logger.isDebugEnabled()) {
				logger.debug("Error in JawrSpringController", e);
			}
			throw new ServletException(e);
		}
	}
1363570
@Override
  public final void handle(final Map<String, Object> pReqVars,
    final IRequestData pRequestData) throws Exception {
    String processorName = pRequestData.getParameter("nmPrc");
    if (processorName == null) {
      //WHandlerAndJsp requires handle NULL request:
      return;
    }
    IProcessor proc = this.processorsFactory.lazyGet(pReqVars, processorName);
    proc.process(pReqVars, pRequestData);
  }
72514
public base_response loginchallengeresponse(String response) throws Exception
	{
		loginchallengeresponse logincr = new loginchallengeresponse(response);
		base_response result = logincr.perform_operation(this);
		if (result.errorcode == 0)
			this.sessionid = result.sessionid;
		return result;
	}
226206
public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		Debug.logVerbose("[JdonFramework]--> enter ModelViewAction process ", module);
		intContext(this.getServlet().getServletContext());

		ModelForm modelForm = FormBeanUtil.getModelForm(actionMapping, actionForm, request);

		if ((UtilValidate.isEmpty(modelForm.getAction())) || modelForm.getAction().equalsIgnoreCase(ModelForm.CREATE_STR)) {
			Debug.logVerbose("[JdonFramework]--> enter create process ", module);
			modelForm.setAction(ModelForm.CREATE_STR);
			createViewPage.doCreate(actionMapping, modelForm, request);

		} else if (modelForm.getAction().equalsIgnoreCase(ModelForm.EDIT_STR)) {

			Debug.logVerbose("[JdonFramework]--> enter " + ModelForm.EDIT_STR + " process ", module);
			Object model = editeViewPage.getModelForEdit(actionMapping, modelForm, request, this.servlet.getServletContext());
			if (model == null) // not found the model
				return errorsForward(modelForm.getAction(), actionMapping, request);

		} else if (modelForm.getAction().equalsIgnoreCase(ModelForm.VIEW_STR)) {

			Debug.logVerbose("[JdonFramework]--> enter " + ModelForm.VIEW_STR + " process ", module);
			Object model = editeViewPage.getModelForEdit(actionMapping, modelForm, request, this.servlet.getServletContext());
			if (model == null) // not found the model
				return errorsForward(modelForm.getAction(), actionMapping, request);

		} else {// other regard as create
			Debug.logVerbose("[JdonFramework]-->action value not supported, enter create process2 ", module);
			modelForm.setAction(ModelForm.CREATE_STR);
			createViewPage.doCreate(actionMapping, modelForm, request);
		}
		Debug.logVerbose("[JdonFramework]--> push the jsp that forward name is '" + modelForm.getAction() + "'", module);
		return actionMapping.findForward(modelForm.getAction());
	}
664031
public static ModelAndView produceErrorView(final Exception e) {
        return new ModelAndView(OAuth20Constants.ERROR_VIEW, CollectionUtils.wrap("rootCauseException", e));
    }
302980
protected void handleResponse(HttpRequest<?> request, MutableHttpResponse<?> response) {
        HttpHeaders headers = request.getHeaders();
        Optional<String> originHeader = headers.getOrigin();
        originHeader.ifPresent(requestOrigin -> {

            Optional<CorsOriginConfiguration> optionalConfig = getConfiguration(requestOrigin);

            if (optionalConfig.isPresent()) {
                CorsOriginConfiguration config = optionalConfig.get();

                if (CorsUtil.isPreflightRequest(request)) {
                    Optional<HttpMethod> result = headers.getFirst(ACCESS_CONTROL_REQUEST_METHOD, HttpMethod.class);
                    setAllowMethods(result.get(), response);
                    Argument<List> type = Argument.of(List.class, String.class);
                    Optional<List> allowedHeaders = headers.get(ACCESS_CONTROL_REQUEST_HEADERS, type);
                    allowedHeaders.ifPresent(val ->
                        setAllowHeaders(val, response)
                    );

                    setMaxAge(config.getMaxAge(), response);
                }

                setOrigin(requestOrigin, response);
                setVary(response);
                setExposeHeaders(config.getExposedHeaders(), response);
                setAllowCredentials(config, response);
            }
        });
    }