public HttpServletRequest getServletRequest() { return requestContext.getServletRequest(); }
public String getRenderingMountId() { final String renderingMountId = (String) getRequestContext().getServletRequest().getSession(true).getAttribute(CMS_REQUEST_RENDERING_MOUNT_ID); if (renderingMountId == null) { throw new IllegalStateException("Could not find rendering mount id on request session."); } return renderingMountId; }
@Override public String toString() { return "ChannelEvent{" + "channelEventType=" + channelEventType + ", userIds=" + userIds + ", editingMount=" + editingMount + ", editingPreviewSite=" + editingPreviewSite + ", request=" + requestContext.getServletRequest() + ", exception=" + getException() + '}'; } }
public boolean isRenderingMountSet() { return getRequestContext().getServletRequest().getSession(true).getAttribute(CMS_REQUEST_RENDERING_MOUNT_ID) != null; }
private static String getCurrentCmsUser() { return (String)RequestContextProvider.get().getServletRequest().getAttribute(CMS_REQUEST_USER_ID_ATTR); }
private String getEncoding(final HstRequestContext requestContext) { return HstRequestUtils.getURIEncoding(requestContext.getServletRequest()); }
public void removeRenderingMountId() { getRequestContext().getServletRequest().getSession(true).removeAttribute(CMS_REQUEST_RENDERING_MOUNT_ID); }
@Override public void writeContent(final HttpServletResponse response) throws IOException { if (esiPageRenderer == null) { log.warn("ESIHstPageInfo misses esiPageRenderer and thus cannot render ESI includes."); super.writeContent(response); return; } HstRequestContext requestContext = RequestContextProvider.get(); Writer writer = new BufferedWriter(response.getWriter()); esiPageRenderer.render(writer, requestContext.getServletRequest(), this); writer.flush(); }
public static boolean isUserInRole(final HstSiteMenuItemConfiguration hstSiteMenuItemConfiguration, final HstRequestContext hstRequestContext) { for (String role : hstSiteMenuItemConfiguration.getRoles()) { if (hstRequestContext.getServletRequest().isUserInRole(role)) { log.debug("Found HstSiteMenuItemConfiguration '{}' to be in role '{}'", hstSiteMenuItemConfiguration.getName(), role); return true; } } log.debug("No matching role found for HstSiteMenuItemConfiguration '{}'", hstSiteMenuItemConfiguration.getName()); return false; } }
public Serializable create(final HstRequestContext requestContext) { HttpServletRequest request = requestContext.getServletRequest(); StringBuilder requestInfo = new StringBuilder(256); final char delim = '\uFFFF'; Optional<String> antiCacheValue = webFilesAntiCacheValue; if (antiCacheValue == null) { antiCacheValue = populateAntiCacheValue(requestContext); } if (antiCacheValue.isPresent()) { requestInfo.append(antiCacheValue.get()).append(delim); } // Implementers should differentiate between GET and HEAD requests otherwise blank pages // can result. requestInfo.append(request.getMethod()).append(delim); requestInfo.append(HstRequestUtils.getFarthestRequestScheme(request)).append(delim); requestInfo.append(HstRequestUtils.getFarthestRequestHost(request)).append(delim); requestInfo.append(request.getRequestURI()).append(delim); requestInfo.append(StringUtils.defaultString(request.getQueryString())).append(delim); // AFter an internal HST FORWARD, all the above parts are the same because same http request, // but the base URL pathInfo has been changed. Hence, we need to account for pathInfo // to make sure that in a FORWARDED request we do not get the same cached entry requestInfo.append(requestContext.getBaseURL().getPathInfo()).append(delim); return requestInfo.toString(); }
public static Session getPreviewCmsQuerySession(HstRequestContext requestContext, String sessionIdentifier) throws HstComponentException { try { SessionSecurityDelegation sessionSecurityDelegation = HstServices.getComponentManager().getComponent(SessionSecurityDelegation.class.getName()); if (!sessionSecurityDelegation.sessionSecurityDelegationEnabled()) { log.debug("Security Delegation was expected to be enabled for cms request with non proxied session but it was not enabled. " + "Return session from request context instead of new security delegated one"); return requestContext.getSession(true); } Credentials cmsUserCred = (Credentials) requestContext.getServletRequest().getAttribute(ContainerConstants.CMS_REQUEST_REPO_CREDS_ATTR); if (cmsUserCred == null) { throw new IllegalStateException("HttpServletRequest should contain cms user credentials attribute for cms requests"); } // create a security delegated session that is automatically cleaned up at the end of the request return sessionSecurityDelegation.getOrCreatePreviewSecurityDelegate(cmsUserCred, sessionIdentifier); } catch (RepositoryException e) { throw new HstComponentException(e); } }
protected void includeLocalDispatchURL(Writer writer, URI uri, HstContainerURL localContainerURL) throws IOException { HstRequestContext requestContext = RequestContextProvider.get(); try { RequestDispatcher disp = getRequestDispatcherForLocalURL(uri, localContainerURL); ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); ContentBufferingResponseWrapper responseWrapper = new ContentBufferingResponseWrapper(requestContext.getServletResponse(), baos); disp.include(requestContext.getServletRequest(), responseWrapper); responseWrapper.flush(); String charset = responseWrapper.getCharacterEncoding(); if (StringUtils.isEmpty(charset)) { Map<String, String> params = MimeUtil.getHeaderParams(responseWrapper.getContentType()); charset = StringUtils.defaultIfEmpty(params.get("charset"), "UTF-8"); } String contentBody = baos.toString(charset); writer.write(contentBody); } catch (ServletException e) { if (log.isDebugEnabled()) { log.warn("Failed to include dispatcher for ESI Include Tag: '{}'.", uri, e); } else { log.warn("Failed to include dispatcher for ESI Include Tag: '{}'. {}", uri, e); } } }
continue; String requestContextPath = RequestContextProvider.get().getServletRequest().getContextPath(); if (mount.getContextPath() == null || !mount.getContextPath().equals(requestContextPath)) { log.debug("Skipping mount '{}' because it can only be rendered for webapp '{}' and not for webapp '{}'",
public HstSiteMenusImpl(HstRequestContext hstRequestContext) { if (hstRequestContext.getResolvedSiteMapItem() == null) { log.info("'{}' does not resolve to a siteMap item hence no siteMenus can be provided", hstRequestContext.getServletRequest()); return; } // find currently selected hstSiteMenuItemConfiguration's HstSiteMapItem selectedSiteMapItem = hstRequestContext.getResolvedSiteMapItem().getHstSiteMapItem(); HstSiteMenusConfiguration siteMenusConfiguration = selectedSiteMapItem.getHstSiteMap().getSite().getSiteMenusConfiguration(); if(siteMenusConfiguration != null) { for(HstSiteMenuConfiguration siteMenuConfiguration : siteMenusConfiguration.getSiteMenuConfigurations().values()) { HstSiteMenuImpl siteMenu = new HstSiteMenuImpl(this, siteMenuConfiguration, hstRequestContext); siteMenus.put(siteMenu.getName(), siteMenu); } } }
final String encoding = HstRequestUtils.getURIEncoding(requestContext.getServletRequest()); if (containsInvalidChars(info, encoding)) { String msg = String.format("Invalid pathInfo '%s' because contains invalid (encoded) chars like " +
" waste you are not aware of. If it is on purpose, for example because the component does only some" + " processing that does not involve direct response contribution, you can mark the component with '{} = true'.", RequestContextProvider.get().getServletRequest(), childWindow.getComponent().getComponentConfiguration().getCanonicalPath(), getRenderer(childWindow, childResponseImpl), COMPONENT_PROPERTY_SUPPRESS_WASTE_MESSAGE); } else { " If it is on purpose, for example because the component does only some" + " processing that does not involve direct response contribution, you can mark the component with '{} = true'.", RequestContextProvider.get().getServletRequest(), childWindow.getComponent().getComponentConfiguration().getCanonicalPath(), getRenderer(childWindow, childResponseImpl), COMPONENT_PROPERTY_SUPPRESS_WASTE_MESSAGE);
@Override public void invoke(ValveContext context) throws ContainerException { HstRequestContext requestContext = context.getRequestContext(); if (!isRequestCacheable(context)) { context.invokeNext(); return; } try { appendRequestInfoToCacheKey(context); HstPageInfo pageInfo = getPageInfoFromCacheOrBuild(context); if (pageInfo == null) { throw new ContainerException("PageInfo null. "); } requestContext.getServletRequest().setAttribute(PageInfoRenderingValve.PAGE_INFO, pageInfo); } catch (HstCacheException e) { throw new ContainerException("Cache exception : ", e); } catch (Exception e) { throw new ContainerException(e); } }
requestContext.getServletRequest().getParameter(MAX_CONTENT_REFERENCE_LEVEL_PARAM_NAME), defaultMaxContentReferenceLevel); final JsonNode contentNode = serializeContentMap(aggregatedPageModel.getContentMap(), maxRefLevel);
@Override public Response call() throws Exception { final AbstractTreePickerRepresentation representation; if (StringUtils.isEmpty(siteMapItemRefIdOrPath)) { representation = representRequestContentNode(getPageComposerContextService()); } else { // find first the mount for current request HttpSession session = getPageComposerContextService().getRequestContext().getServletRequest().getSession(); String renderingHost = (String)session.getAttribute(ContainerConstants.RENDERING_HOST); final VirtualHost virtualHost = getPageComposerContextService().getRequestContext().getResolvedMount().getMount().getVirtualHost(); final Mount editingMount = getPageComposerContextService().getEditingMount(); final ResolvedMount resolvedMount = virtualHost.getVirtualHosts().matchMount(renderingHost, null, editingMount.getMountPath()); representation = representExpandedParentTree(getPageComposerContextService(),resolvedMount, siteMapItemRefIdOrPath); } return ok("Folder loaded successfully", representation); } });
HttpServletRequest request = requestContext.getServletRequest();