Returns the error bootstrap page HTML.<p>

@param cms the cms context
@param throwable the throwable
@param request the current request

@return the error bootstrap page HTML
179508
public static String getBootstrapPage(CmsObject cms, Throwable throwable, HttpServletRequest request) {

        try {
            setErrorAttributes(cms, throwable, request);

            byte[] pageBytes = CmsFileUtil.readFully(
                Thread.currentThread().getContextClassLoader().getResourceAsStream(
                    "org/opencms/ui/error/error-page.html"));
            String page = new String(pageBytes, "UTF-8");
            CmsMacroResolver resolver = new CmsMacroResolver();
            String context = OpenCms.getSystemInfo().getContextPath();
            String vaadinDir = CmsStringUtil.joinPaths(context, "VAADIN/");
            String vaadinVersion = Version.getFullVersion();
            String vaadinServlet = CmsStringUtil.joinPaths(context, "workplace/", ERROR_PAGE_PATH_FRAQUMENT);
            String vaadinBootstrap = CmsStringUtil.joinPaths(context, "VAADIN/vaadinBootstrap.js");

            resolver.addMacro("loadingHtml", CmsVaadinConstants.LOADING_INDICATOR_HTML);
            resolver.addMacro("vaadinDir", vaadinDir);
            resolver.addMacro("vaadinVersion", vaadinVersion);
            resolver.addMacro("vaadinServlet", vaadinServlet);
            resolver.addMacro("vaadinBootstrap", vaadinBootstrap);
            resolver.addMacro("title", "Error page");

            page = resolver.resolveMacros(page);
            return page;
        } catch (Exception e) {
            LOG.error("Failed to display error page.", e);
            return "<!--Error-->";
        }
    }
839654
public static void addError(final HttpServletRequest request, final String message) {
		StringBuilder sb = (StringBuilder) request.getAttribute(ERROR_KEY);
		if (sb == null) {
			sb = new StringBuilder();
			request.setAttribute(ERROR_KEY, sb);
		}
		sb.append(message);
	}
631002
protected Mono<ServerResponse> renderErrorView(ServerRequest request) {
		boolean includeStackTrace = isIncludeStackTrace(request, MediaType.TEXT_HTML);
		Map<String, Object> error = getErrorAttributes(request, includeStackTrace);
		HttpStatus errorStatus = getHttpStatus(error);
		ServerResponse.BodyBuilder responseBody = ServerResponse.status(errorStatus)
				.contentType(MediaType.TEXT_HTML);
		return Flux
				.just("error/" + errorStatus.value(),
						"error/" + SERIES_VIEWS.get(errorStatus.series()), "error/error")
				.flatMap((viewName) -> renderErrorView(viewName, responseBody, error))
				.switchIfEmpty(this.errorProperties.getWhitelabel().isEnabled()
						? renderDefaultErrorView(responseBody, error)
						: Mono.error(getError(request)))
				.next();
	}
544912
@Override
    public int doEndTag() throws JspException {

        ServletRequest req = pageContext.getRequest();

        // This will always be true if the page is called through OpenCms
        if (CmsFlexController.isCmsRequest(req)) {
            try {
                // Get link-string from the body and reset body
                String link = getBodyContent().getString();
                getBodyContent().clear();
                // Calculate the link substitution
                String newlink = linkTagAction(link, req, getBaseUri(), getDetailPage(), m_locale);
                // Write the result back to the page
                getBodyContent().print(newlink);
                getBodyContent().writeOut(pageContext.getOut());

            } catch (Exception ex) {
                if (LOG.isErrorEnabled()) {
                    LOG.error(Messages.get().getBundle().key(Messages.ERR_PROCESS_TAG_1, "link"), ex);
                }
                throw new JspException(ex);
            }
        }
        return EVAL_PAGE;
    }
1275487
public static Optional<ModelAndView> hasDelegationRequestFailed(final HttpServletRequest request, final int status) {
        val params = request.getParameterMap();
        if (Stream.of("error", "error_code", "error_description", "error_message").anyMatch(params::containsKey)) {
            val model = new HashMap<String, Object>();
            if (params.containsKey("error_code")) {
                model.put("code", StringEscapeUtils.escapeHtml4(request.getParameter("error_code")));
            } else {
                model.put("code", status);
            }
            model.put("error", StringEscapeUtils.escapeHtml4(request.getParameter("error")));
            model.put("reason", StringEscapeUtils.escapeHtml4(request.getParameter("error_reason")));
            if (params.containsKey("error_description")) {
                model.put("description", StringEscapeUtils.escapeHtml4(request.getParameter("error_description")));
            } else if (params.containsKey("error_message")) {
                model.put("description", StringEscapeUtils.escapeHtml4(request.getParameter("error_message")));
            }
            model.put(CasProtocolConstants.PARAMETER_SERVICE, request.getAttribute(CasProtocolConstants.PARAMETER_SERVICE));
            model.put("client", StringEscapeUtils.escapeHtml4(request.getParameter("client_name")));
            LOGGER.debug("Delegation request has failed. Details are [{}]", model);
            return Optional.of(new ModelAndView("casPac4jStopWebflow", model));
        }
        return Optional.empty();
    }
234672
public static CmsGallerySearchBean getSearch(HttpServletRequest request, CmsGalleryDataBean config) {

        CmsGalleryService srv = new CmsGalleryService();
        srv.setCms(CmsFlexController.getCmsObject(request));
        srv.setRequest(request);
        CmsGallerySearchBean result = null;
        try {
            result = srv.getSearch(config);
        } finally {
            srv.clearThreadStorage();
        }
        return result;
    }
1106829
protected String renderErrorPageToHTML(final WComponent errorPage) {

		// Check if using the default error page
		boolean defaultErrorPage = errorPage instanceof FatalErrorPage;

		String html = null;

		// If not default implementation of error page, Transform error page to HTML
		if (!defaultErrorPage) {
			// Set UIC and Environment (Needed for Theme Paths)
			UIContext uic = new UIContextImpl();
			uic.setEnvironment(createEnvironment());
			UIContextHolder.pushContext(uic);
			try {
				html = WebUtilities.renderWithTransformToHTML(errorPage);
			} catch (Exception e) {
				LOG.warn("Could not transform error page.", e);
			} finally {
				UIContextHolder.popContext();
			}
		}

		// Not transformed. So just render.
		if (html == null) {
			UIContextHolder.pushContext(new UIContextImpl());
			try {
				html = WebUtilities.render(errorPage);
			} catch (Exception e) {
				LOG.warn("Could not render error page.", e);
				html = "System error occurred but could not render error page.";
			} finally {
				UIContextHolder.popContext();
			}
		}

		return html;
	}
855830
protected CmsObject registerSession(HttpServletRequest request, CmsObject cms) throws CmsException {

        if (!cms.getRequestContext().getCurrentUser().isGuestUser()) {
            // make sure we have a new session after login for security reasons
            HttpSession session = request.getSession(false);
            if (session != null) {
                session.invalidate();
            }
            session = request.getSession(true);
        }

        // update the request context
        cms = OpenCmsCore.getInstance().updateContext(request, cms);

        CmsUser user = cms.getRequestContext().getCurrentUser();
        if (!user.isGuestUser() && !OpenCms.getDefaultUsers().isUserExport(user.getName())) {
            // create the session info object, only for 'real' users
            CmsSessionInfo sessionInfo = new CmsSessionInfo(
                cms.getRequestContext(),
                new CmsUUID(),
                request.getSession().getMaxInactiveInterval());
            // register the updated cms object in the session manager
            OpenCmsCore.getInstance().getSessionManager().addSessionInfo(sessionInfo);
        }
        // return the updated cms object
        return cms;
    }
1164310
@Override
    public int doEndTag() throws JspException {

        ServletRequest req = pageContext.getRequest();
        A_CmsConfiguredHtmlParser parser;
        if (m_allowInlineEdit && CmsJspTagEditable.isEditableRequest(req)) {
            // during inline editing the content should not be parsed
            try {
                getBodyContent().writeOut(pageContext.getOut());
                release();
            } catch (Exception ex) {
                release();
                if (LOG.isErrorEnabled()) {
                    LOG.error(Messages.get().getBundle().key(Messages.ERR_PROCESS_TAG_1, TAG_NAME), ex);
                }
                // this is severe
                throw new JspException(ex);
            }
        } else {
            // This will always be true if the page is called through OpenCms
            if (CmsFlexController.isCmsRequest(req)) {
                String content = "";
                try {
                    if (CmsStringUtil.isEmpty(m_configuredParserClassname)) {
                        if (LOG.isErrorEnabled()) {
                            LOG.error(
                                Messages.get().getBundle().key(
                                    Messages.GUI_ERR_TAG_ATTRIBUTE_MISSING_2,
                                    new Object[] {TAG_NAME, ATT_VISITOR_CLASS}));
                        }

                    }
                    // wrong attribute visitorClass -> content will remain empty, but no exception is
                    // thrown
                    try {
                        // load
                        Class<?> cl = Class.forName(m_configuredParserClassname);
                        // Instantiate
                        Object instance = cl.newInstance();
                        // cast
                        parser = (A_CmsConfiguredHtmlParser)instance;
                        parser.setParam(m_param);
                        // cms object:
                        CmsFlexController controller = CmsFlexController.getController(req);
                        CmsObject cms = controller.getCmsObject();
                        parser.setCmsObject(cms);
                        content = parseTagAction(getBodyContent().getString(), pageContext, parser);

                    } catch (Exception e) {
                        if (LOG.isErrorEnabled()) {
                            LOG.error(
                                Messages.get().getBundle().key(
                                    Messages.GUI_ERR_TAG_ATTRIBUTE_INVALID_3,
                                    new Object[] {
                                        TAG_NAME,
                                        ATT_VISITOR_CLASS,
                                        A_CmsConfiguredHtmlParser.class.getName()}),
                                e);
                        }
                        e.printStackTrace(System.err);
                    }

                } finally {
                    try {
                        getBodyContent().clear();
                        getBodyContent().print(content);
                        getBodyContent().writeOut(pageContext.getOut());
                        release();

                    } catch (Exception ex) {
                        release();
                        if (LOG.isErrorEnabled()) {
                            LOG.error(Messages.get().getBundle().key(Messages.ERR_PROCESS_TAG_1, TAG_NAME), ex);
                        }
                        // this is severe
                        throw new JspException(ex);
                    }

                }

            }
        }
        return EVAL_PAGE;
    }
55517
def page_not_found(request, template_name='404.html'):
    
    response = render_in_page(request, template_name)

    if response:
        return response

    template = Template(
        '<h1>Not Found</h1>'
        '<p>The requested URL {{ request_path }} was not found on this server.</p>')
    body = template.render(RequestContext(
        request, {'request_path': request.path}))
    return http.HttpResponseNotFound(body, content_type=CONTENT_TYPE)
323423
private ModelAndView generateErrorView(final String code, final Object[] args, final HttpServletRequest request, final WebApplicationService service) {
        val modelAndView = serviceValidateConfigurationContext.getValidationViewFactory().getModelAndView(request, false, service, getClass());
        val convertedDescription = this.applicationContext.getMessage(code, args, code, request.getLocale());
        modelAndView.addObject(CasViewConstants.MODEL_ATTRIBUTE_NAME_ERROR_CODE, StringEscapeUtils.escapeHtml4(code));
        modelAndView.addObject(CasViewConstants.MODEL_ATTRIBUTE_NAME_ERROR_DESCRIPTION, StringEscapeUtils.escapeHtml4(convertedDescription));
        return modelAndView;
    }
691799
public static String generateLoginHtmlFragment(CmsObject cms, VaadinRequest request) throws IOException {

        LoginParameters parameters = CmsLoginHelper.getLoginParameters(cms, (HttpServletRequest)request, true);
        request.getWrappedSession().setAttribute(CmsLoginUI.INIT_DATA_SESSION_ATTR, parameters);
        byte[] pageBytes;

        pageBytes = CmsFileUtil.readFully(
            Thread.currentThread().getContextClassLoader().getResourceAsStream(
                "org/opencms/ui/login/login-fragment.html"));

        String html = new String(pageBytes, "UTF-8");
        String autocomplete = ((parameters.getPcType() == null)
            || parameters.getPcType().equals(CmsLoginHelper.PCTYPE_PRIVATE)) ? "on" : "off";
        CmsMacroResolver resolver = new CmsMacroResolver();
        resolver.addMacro("autocompplete", autocomplete);
        if ((parameters.getPcType() == null) || parameters.getPcType().equals(CmsLoginHelper.PCTYPE_PRIVATE)) {
            resolver.addMacro(
                "hiddenPasswordField",
                "      <input type=\"password\" id=\"hidden-password\" name=\"ocPword\" autocomplete=\"%(autocomplete)\" >");
        }
        if (parameters.getUsername() != null) {
            resolver.addMacro("predefUser", "value=\"" + CmsEncoder.escapeXml(parameters.getUsername()) + "\"");
        }
        html = resolver.resolveMacros(html);
        return html;
    }
669934
public void includeErrorpage(CmsWorkplace wp, Throwable t) throws JspException {

        CmsLog.getLog(wp).error(Messages.get().getBundle().key(Messages.ERR_WORKPLACE_DIALOG_0), t);
        getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, wp);
        getJsp().getRequest().setAttribute(ATTRIBUTE_THROWABLE, t);
        getJsp().include(FILE_DIALOG_SCREEN_ERRORPAGE);
    }
828842
def server_error(request, template_name='500.html'):
    

    response = render_in_page(request, template_name)

    if response:
        return response

    try:
        template = loader.get_template(template_name)
    except TemplateDoesNotExist:
        return http.HttpResponseServerError('<h1>Server Error (500)</h1>', content_type='text/html')
    return http.HttpResponseServerError(template.render(Context({})))
343842
@Override
    public ContentPattern<?> forRequest(Request request) {
        final String mimeType = request.getHeaders().getContentTypeHeader().mimeTypePart();
        if (mimeType != null) {
            if (mimeType.contains("json")) {
                return new EqualToJsonPattern(request.getBodyAsString(), ignoreArrayOrder, ignoreExtraElements);
            } else if (mimeType.contains("xml")) {
                return new EqualToXmlPattern(request.getBodyAsString());
            } else if (mimeType.equals("multipart/form-data")) {
                // TODO: Need to add a matcher that can handle multipart data properly. For now, just always match
                return new AnythingPattern();
            } else if (!determineIsTextFromMimeType(mimeType)) {
                return new BinaryEqualToPattern(request.getBody());
            }
        }

        return new EqualToPattern(request.getBodyAsString(), caseInsensitive);
    }
690099
public static CmsCntPageData prefetch(HttpServletRequest request) throws CmsRpcException {

        CmsContainerpageService srv = new CmsContainerpageService();
        srv.setCms(CmsFlexController.getCmsObject(request));
        srv.setRequest(request);
        CmsCntPageData result = null;
        try {
            result = srv.prefetch();
        } finally {
            srv.clearThreadStorage();
        }
        return result;
    }
911902
public void init(CmsObject cms) {

        m_cms = cms;
        m_result = null;
        m_lastException = null;
        m_pageCount = 0;
        m_nextUrl = null;
        m_prevUrl = null;
    }