/** * Get the site content base bean, which is the root document bean whithin * preview or live context. */ protected HippoBean getSiteContentBaseBean(HstRequest request) { return request.getRequestContext().getSiteContentBaseBean(); }
@Nullable @Override public HippoBean getSiteScope() { final HstRequestContext context = request.getRequestContext(); return context.getSiteContentBaseBean(); } }
/** * @deprecated since 7.9.0. Use {@link org.hippoecm.hst.core.request.HstRequestContext#getSiteContentBaseBean()} instead */ @Deprecated public HippoBean getSiteContentBaseBean(HstRequest request) { return request.getRequestContext().getSiteContentBaseBean(); }
public <T extends HippoBean> T getHippoBeanForPath(final String documentPath, Class<T> beanMappingClass) { if (!Strings.isNullOrEmpty(documentPath)) { final HstRequestContext context = RequestContextProvider.get(); final HippoBean root = context.getSiteContentBaseBean(); return root.getBean(documentPath, beanMappingClass); } return null; }
/** * Find HippoBean for given path. If path is null or empty, site root bean will be returned. * * @param path document (or folder) path relative to site-root. * @return bean identified by path. Site root bean if path empty or no corresponding bean. */ public HippoBean doGetScopeBean(final String path) { final HstRequestContext context = RequestContextProvider.get(); final HippoBean siteBean = context.getSiteContentBaseBean(); if (!Strings.isNullOrEmpty(path)) { final String myPath = PathUtils.normalizePath(path); log.debug("Looking for bean {}", myPath); HippoBean scope = siteBean.getBean(myPath); if (scope != null) { return scope; } log.warn("Bean was null for selected path: {}", myPath); } return siteBean; }
/** * Find HippoBean for given path. If path is null or empty, site root bean will be returned * * @param path document (or folder) path relative to site-root * @return bean identified by path. Site root bean if path empty or no corresponding bean. * @deprecated use the non-static {@code doGetScopeBean()} instead. */ public static HippoBean getScopeBean(final String path) { final HstRequestContext context = RequestContextProvider.get(); final HippoBean siteBean = context.getSiteContentBaseBean(); if (!Strings.isNullOrEmpty(path)) { final String myPath = PathUtils.normalizePath(path); log.debug("Looking for bean {}", myPath); HippoBean scope = siteBean.getBean(myPath); if (scope != null) { return scope; } log.warn("Bean was null for selected path: {}", myPath); } return siteBean; }
/** * Sets content bean onto request. If no bean is found, *no* 404 response will be set. * NOTE: Only bean defined through component interface is used unlike within * {@code setContentBean()} method * * @param documentPath document (content) path * @param request HstRequest * @param response HstResponse * @see #setContentBean(String, org.hippoecm.hst.core.component.HstRequest, org.hippoecm.hst.core.component.HstResponse) */ public void setContentBeanForPath(final String documentPath, HstRequest request, final HstResponse response) { final HstRequestContext context = request.getRequestContext(); if (!Strings.isNullOrEmpty(documentPath)) { final HippoBean root = context.getSiteContentBaseBean(); request.setModel(REQUEST_ATTR_DOCUMENT, root.getBean(documentPath)); } }
/** * Get content bean based on path e.g. {@code "/foo/bar/"} * * @param path content path * @return null if nothing found */ public static HippoBean getBean(final String path) { final HstRequestContext context = RequestContextProvider.get(); final HippoBean currentBean = context.getContentBean(); if (path == null) { return currentBean; } if (path.startsWith("/")) { return context.getSiteContentBaseBean().getBean(path.substring(1)); } if (currentBean != null) { return currentBean.getBean(path); } return null; }
protected HippoFacetNavigationBean getFacetNavigationBean(final HstRequestContext context, String path, String query) { if (Strings.isNullOrEmpty(path)) { log.warn("Facetpath was empty {}", path); return null; } ResolvedSiteMapItem resolvedSiteMapItem = context.getResolvedSiteMapItem(); String resolvedContentPath = PathUtils.normalizePath(resolvedSiteMapItem.getRelativeContentPath()); String parsedQuery = cleanupSearchQuery(query); HippoFacetNavigationBean facNavBean; if (!StringUtils.isBlank(resolvedContentPath) && !resolvedContentPath.startsWith("/") && context.getSiteContentBaseBean().getBean(resolvedContentPath, HippoFacetNavigationBean.class) != null) { facNavBean = ContentBeanUtils.getFacetNavigationBean(resolvedContentPath, parsedQuery); } else { facNavBean = ContentBeanUtils.getFacetNavigationBean(path, parsedQuery); } return facNavBean; } }
/** * Sets content bean onto request. If no bean is found, *no* 404 response will be set. * NOTE: we first check if document is set through component interface, * otherwise we try o fetch mapped (sitemap) bean * * @param documentPath document (content) path * @param request HstRequest * @param response HstResponse * @see #pageNotFound(org.hippoecm.hst.core.component.HstResponse) */ public void setContentBean(final String documentPath, HstRequest request, final HstResponse response) { final HstRequestContext context = request.getRequestContext(); HippoBean bean; if (!Strings.isNullOrEmpty(documentPath)) { final HippoBean root = context.getSiteContentBaseBean(); bean = root.getBean(documentPath); } else { bean = context.getContentBean(); } request.setModel(REQUEST_ATTR_DOCUMENT, bean); }
/** * Helper function for retrieving a value list by identifier, using the current context's locale. * * @param identifier of the (set of) value lists * @param context current request context * @return requested value list, or null if none was found */ public static ValueList getValueListByIdentifier(final String identifier, final HstRequestContext context) { final ValueListManager valueListManager = HstServices.getComponentManager().getComponent(ValueListManager.class.getName()); final HippoBean baseBean = context.getSiteContentBaseBean(); final Locale locale = LocaleUtils.toLocale(context.getResolvedMount().getMount().getLocale()); return valueListManager.getValueList(baseBean, identifier, locale); } }
final HippoBean bean = context.getSiteContentBaseBean().getBean(pageNotFoundPath, HippoBean.class); response.setStatus(HttpServletResponse.SC_NOT_FOUND); if (bean != null) {