Gets the TemplatedURLFormatter instance from a ServletRequest attribute.

@param servletRequest the current ServletRequest.
@return the TemplatedURLFormatter instance from the ServletRequest.
977242
public static TemplatedURLFormatter getTemplatedURLFormatter(ServletRequest servletRequest)
    {
        assert servletRequest != null : "The ServletRequest cannot be null.";

        if (servletRequest == null) {
            throw new IllegalArgumentException("The ServletRequest cannot be null.");
        }

        return (TemplatedURLFormatter) servletRequest.getAttribute(TEMPLATED_URL_FORMATTER_ATTR);
    }
230847
public static String getUriTemplateString(ImmutableFunctionalTerm uriFunction) {
        ValueConstant term = (ValueConstant) uriFunction.getTerm(0);
        final String template = term.getValue();
        ImmutableList<? extends ImmutableTerm> otherSubTerms = uriFunction.getTerms()
                .subList(1, uriFunction.getTerms().size());

        List<String> splitParts = Splitter.on(PLACE_HOLDER).splitToList(template);

        StringBuilder templateWithVars = new StringBuilder();

        int numVars = otherSubTerms.size();
        int numParts = splitParts.size();

        if (numParts != numVars + 1 && numParts != numVars) {
            throw new IllegalArgumentException("the number of place holders should be equal to the number of other terms.");
        }

        for (int i = 0; i < numVars; i++) {
            templateWithVars.append(splitParts.get(i))
                    .append("{")
                    .append(otherSubTerms.get(i))
                    .append("}");
        }

        if (numParts == numVars + 1) {
            templateWithVars.append(splitParts.get(numVars));
        }

        return templateWithVars.toString();
    }
719776
public static RegexPathTemplate create(String urlTemplate) {
        StringBuffer baseUrl = new StringBuffer();
        Map<String, PathTemplate> templates = new HashMap<String, PathTemplate>();
        CurlyBraceTokenizer t = new CurlyBraceTokenizer(urlTemplate);
        while (t.hasNext()) {
            String tok = t.next();
            if (CurlyBraceTokenizer.insideBraces(tok)) {
                tok = CurlyBraceTokenizer.stripBraces(tok);

                int index = tok.indexOf(':'); // first index of : as it can't appears in the name
                String name;
                Pattern validationPattern;
                if(index > -1) {
                    name = tok.substring(0, index);
                    validationPattern = Pattern.compile("^" + tok.substring(index + 1) + "$");
                }else{
                    name = tok;
                    validationPattern = DEFAULT_VALIDATION_PATTERN;
                }
                Validate.isTrue(TEMPLATE_NAME_PATTERN.matcher(name).matches(), "Template name '%s' doesn't match the expected format: %s", name, TEMPLATE_NAME_PATTERN);
                Validate.isFalse(templates.containsKey(name), "Template name '%s' is already defined!", name);
                templates.put(name, new PathTemplate(name, validationPattern));
                baseUrl.append("{").append(name).append("}");
            } else {
                baseUrl.append(tok);
            }
        }
        String url = baseUrl.toString();
        isTrue(!Urls.hasQueryString(url), "Given url contains a query string: %s", url);
        return new RegexPathTemplate(url, templates);
    }
913109
@Override
    public long getLastModified(HttpServletRequest request) {
        String path;
        int idx;
        long result;

        result = -1;
        try {
            path = request.getPathInfo();
            if (path != null && path.startsWith("/get/")) {
                lazyInit(request);
                path = path.substring(5);
                idx = path.indexOf('/');
                if (idx != -1) {
                    path = path.substring(idx + 1);
                    result = engine.getLastModified(path);
                }
            }
        } catch (IOException e) {
            error(request, "getLastModified", e);
            // fall-through
        } catch (RuntimeException | Error e) {
            error(request, "getLastModified", e);
            throw e;
        }
        LOG.debug("getLastModified(" + request.getPathInfo() + ") -> " + result);
        return result;
    }
1101748
private ThymeLeafTemplateImplementation getTemplateByURL(URL url) {
        Collection<ThymeLeafTemplateImplementation> list = registrations.keySet();
        for (ThymeLeafTemplateImplementation template : list) {
            if (template.getURL().sameFile(url)) {
                return template;
            }
        }
        return null;
    }
832071
public static String getDomain(HttpServletRequest request) {

		if (request == null) {
			return null;
		}

		return UrlUtils.resolveDomain(request.getServerName());
	}
770372
static String getConsumedContentType(HttpServletRequest request) {
        String mimeType = firstNotNull(request.getParameter("format"), request
                .getContentType());

        return ((mimeType != null) ? mimeType.replace("application/xml",
                BaseRestResource.XML) : null);
    }
1288267
@SuppressWarnings("unchecked")
    protected Map<IPortletWindowId, IPortletRenderExecutionWorker> getPortletHeaderRenderingMap(
            HttpServletRequest request) {
        synchronized (PortalWebUtils.getRequestAttributeMutex(request)) {
            Map<IPortletWindowId, IPortletRenderExecutionWorker> portletRenderingMap =
                    (Map<IPortletWindowId, IPortletRenderExecutionWorker>)
                            request.getAttribute(PORTLET_HEADER_RENDERING_MAP);
            if (portletRenderingMap == null) {
                portletRenderingMap =
                        new ConcurrentHashMap<IPortletWindowId, IPortletRenderExecutionWorker>();
                request.setAttribute(PORTLET_HEADER_RENDERING_MAP, portletRenderingMap);
            }
            return portletRenderingMap;
        }
    }
9402
public static String getDomainFromURL(String strURL, String strContextPathAtEnd, boolean includePortNumber)
    {
        String strDomain = strURL;
        
        if (strDomain.indexOf(':') < 8)
            strDomain = strDomain.substring(strDomain.indexOf(':') + 1);  // Get rid of protocol
        if (strDomain.indexOf("//") == 0)
            strDomain = strDomain.substring(2);  // Get rid of '//'
        if (strDomain.indexOf('?') != -1)
            strDomain = strDomain.substring(0, strDomain.indexOf('?'));   // Get rid of params
        int iEndDomain = strDomain.indexOf('/');
        if (iEndDomain == -1)
            iEndDomain = strDomain.length();
        if (strDomain.lastIndexOf(Constants.DEFAULT_SERVLET) >= iEndDomain)
            strDomain = strDomain.substring(0, strDomain.lastIndexOf(Constants.DEFAULT_SERVLET) - 1);   // Strip servlet name
        if ((strDomain.indexOf(':') != -1) && (includePortNumber == false))
            strDomain = strDomain.substring(0, strDomain.indexOf(':'));  // Get rid of port number
        else
            strDomain = strDomain.substring(0, iEndDomain);
        
        if (strContextPathAtEnd != null)
        {
            int iStartIndex = strURL.indexOf(strDomain);
            int iContextIndex = strURL.indexOf(strContextPathAtEnd, iStartIndex + strDomain.length());
            if (iContextIndex != -1)
            {   // Always
                iContextIndex = iContextIndex + strContextPathAtEnd.length();
                strDomain = strURL.substring(iStartIndex, iContextIndex);
                if (!strDomain.endsWith(System.getProperty("file.separator")))
                    strDomain = strDomain + System.getProperty("file.separator");
            }
        }
        return strDomain;
    }
180381
public int doStartTag()
            throws JspException {

        Tag parent = getParent();
        if (parent != null) {
            String s = Bundle.getString("TempExcp_ContainedTemplate");
            registerTagError(s,null);
            reportErrors();
            _fatalError = true;
            return SKIP_BODY;
        }

        ServletRequest req = pageContext.getRequest();
        _savedContext = (TemplateContext) req.getAttribute(TEMPLATE_SECTIONS);
        TemplateContext ctxt = new TemplateContext();
        req.setAttribute(TEMPLATE_SECTIONS,ctxt);

        return EVAL_BODY_INCLUDE;
    }
1368932
public static HttpServletRequest getRequest(JspContext jspContext) {
        PageContext pageContext = getPageContext(jspContext);
        return (HttpServletRequest)pageContext.getRequest();
    }
278613
public static final AAFCon<?> obtain(Object servletRequest) {
		if(servletRequest instanceof CadiWrap) {
			Lur lur = ((CadiWrap)servletRequest).getLur();
			if(lur != null) {
				if(lur instanceof EpiLur) {
					AbsAAFLur<?> aal = (AbsAAFLur<?>) ((EpiLur)lur).subLur(AbsAAFLur.class);
					if(aal!=null) {
						return aal.aaf;
					}
				} else {
					if(lur instanceof AbsAAFLur) {
						return ((AbsAAFLur<?>)lur).aaf;
					}
				}
			}
		}
		return null;
	}
488716
public static Map<String, Object> getAttributeMap(ServletRequest req) {

        if (req instanceof CmsFlexRequest) {
            return ((CmsFlexRequest)req).getAttributeMap();
        }
        Map<String, Object> attrs = new HashMap<String, Object>();
        Enumeration<String> atrrEnum = CmsCollectionsGenericWrapper.enumeration(req.getAttributeNames());
        while (atrrEnum.hasMoreElements()) {
            String key = atrrEnum.nextElement();
            Object value = req.getAttribute(key);
            attrs.put(key, value);
        }
        return attrs;
    }
696352
public static Map<String, String> getParamMap(ServletRequest request) {
		Map<String, String> params = new HashMap<String, String>();
		for (Map.Entry<String, String[]> entry : getParams(request).entrySet()) {
			params.put(entry.getKey(), ArrayUtil.join(entry.getValue(), StrUtil.COMMA));
		}
		return params;
	}
1146645
public GetDomainCacheTTLResponse getDomainCacheTTL(GetDomainCacheTTLRequest request) {
        checkNotNull(request, "The parameter request should NOT be null.");
        InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, DOMAIN, request.getDomain(), "config");
        internalRequest.addParameter("cacheTTL","");
        return invokeHttpClient(internalRequest, GetDomainCacheTTLResponse.class);
    }
459260
public CmsTemplateContext getTemplateContext(
        String providerName,
        CmsObject cms,
        HttpServletRequest request,
        CmsResource resource) {

        I_CmsTemplateContextProvider provider = getTemplateContextProvider(providerName);
        if (provider == null) {
            return null;
        }
        String cookieName = provider.getOverrideCookieName();
        String forcedValue = null;
        if (request != null) {
            String paramTemplateContext = request.getParameter(CmsGwtConstants.PARAM_TEMPLATE_CONTEXT);
            if (!CmsStringUtil.isEmptyOrWhitespaceOnly(paramTemplateContext)) {
                forcedValue = paramTemplateContext;
            } else if (cookieName != null) {
                forcedValue = CmsRequestUtil.getCookieValue(request.getCookies(), cookieName);
            }
        }
        if (forcedValue != null) {
            Map<String, CmsTemplateContext> contextMap = provider.getAllContexts();
            if (contextMap.containsKey(forcedValue)) {
                CmsTemplateContext contextBean = contextMap.get(forcedValue);
                return new CmsTemplateContext(
                    contextBean.getKey(),
                    contextBean.getTemplatePath(),
                    contextBean.getMessageContainer(),
                    contextBean.getProvider(),
                    contextBean.getClientVariants().values(),
                    true);

            }
        }
        return provider.getTemplateContext(cms, request, resource);
    }
469603
@SuppressWarnings("unchecked")
	static public Map<String, Object> getParameters(ServletRequest request){
    	Map<String, Object> params = (Map<String, Object>) request.getAttribute(TEMPLATE_PARAMETER_MAP);
    	if (params == null){							// no need to check thread-safe?
    		params = new HashMap<String, Object>();
    		request.setAttribute(TEMPLATE_PARAMETER_MAP, params);
    	}
    	return params;
    }