Search in sources :

Example 1 with HstRequestContext

use of org.hippoecm.hst.core.request.HstRequestContext in project hippo by NHS-digital-website.

the class HippoBeanHelper method getTaxonomyName.

public static String getTaxonomyName() throws HstComponentException {
    String taxonomyName;
    try {
        HstRequestContext ctx = RequestContextProvider.get();
        taxonomyName = ctx.getSession().getNode("/hippo:namespaces/publicationsystem/publication/editor:templates/_default_/classifiable").getProperty("essentials-taxonomy-name").getString();
    } catch (RepositoryException repositoryException) {
        throw new HstComponentException("Exception occurred during fetching taxonomy file name.", repositoryException);
    }
    return taxonomyName;
}
Also used : RepositoryException(javax.jcr.RepositoryException) HstComponentException(org.hippoecm.hst.core.component.HstComponentException) HstRequestContext(org.hippoecm.hst.core.request.HstRequestContext)

Example 2 with HstRequestContext

use of org.hippoecm.hst.core.request.HstRequestContext in project hippo by NHS-digital-website.

the class CiHubComponent method doBeforeRender.

@Override
public void doBeforeRender(final HstRequest request, final HstResponse response) throws HstComponentException {
    super.doBeforeRender(request, response);
    final HstRequestContext ctx = request.getRequestContext();
    request.setAttribute("document", ctx.getContentBean());
}
Also used : HstRequestContext(org.hippoecm.hst.core.request.HstRequestContext)

Example 3 with HstRequestContext

use of org.hippoecm.hst.core.request.HstRequestContext in project hippo by NHS-digital-website.

the class GraphProviderImpl method getHttpRequest.

private HttpEntity<String> getHttpRequest(final MediaType acceptMediaType) {
    final HttpHeaders headers = new HttpHeaders();
    final HstRequestContext context = RequestContextProvider.get();
    headers.setAccept(Collections.singletonList(acceptMediaType));
    headers.setBearerAuth((String) context.getAttribute(Constants.ACCESS_TOKEN_PROPERTY_NAME));
    return new HttpEntity<>(headers);
}
Also used : HstRequestContext(org.hippoecm.hst.core.request.HstRequestContext)

Example 4 with HstRequestContext

use of org.hippoecm.hst.core.request.HstRequestContext in project hippo by NHS-digital-website.

the class Task method getRelatedDocuments.

private <T extends HippoBean> List<T> getRelatedDocuments(String property, Class<T> beanClass) throws HstComponentException, QueryException {
    final HstRequestContext context = RequestContextProvider.get();
    HstQuery query = ContentBeanUtils.createIncomingBeansQuery(this.getCanonicalBean(), context.getSiteContentBaseBean(), property, beanClass, false);
    return toList(query.execute().getHippoBeans());
}
Also used : HstQuery(org.hippoecm.hst.content.beans.query.HstQuery) HstRequestContext(org.hippoecm.hst.core.request.HstRequestContext)

Example 5 with HstRequestContext

use of org.hippoecm.hst.core.request.HstRequestContext in project hippo by NHS-digital-website.

the class MasterComponent method doBeforeRender.

@Override
public void doBeforeRender(HstRequest request, HstResponse response) {
    super.doBeforeRender(request, response);
    final HstRequestContext context = request.getRequestContext();
    final HippoBean document = context.getContentBean();
    if (document != null) {
        request.setAttribute("document", document);
    }
}
Also used : HippoBean(org.hippoecm.hst.content.beans.standard.HippoBean) HstRequestContext(org.hippoecm.hst.core.request.HstRequestContext)

Aggregations

HstRequestContext (org.hippoecm.hst.core.request.HstRequestContext)42 HstQuery (org.hippoecm.hst.content.beans.query.HstQuery)17 QueryException (org.hippoecm.hst.content.beans.query.exceptions.QueryException)11 HstQueryResult (org.hippoecm.hst.content.beans.query.HstQueryResult)8 HippoBean (org.hippoecm.hst.content.beans.standard.HippoBean)8 RepositoryException (javax.jcr.RepositoryException)6 Query (javax.jcr.query.Query)5 QueryManager (javax.jcr.query.QueryManager)5 QueryResult (javax.jcr.query.QueryResult)5 HippoBeanIterator (org.hippoecm.hst.content.beans.standard.HippoBeanIterator)5 Node (javax.jcr.Node)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 NodeIterator (javax.jcr.NodeIterator)3 HstComponentException (org.hippoecm.hst.core.component.HstComponentException)3 ValueList (org.onehippo.forge.selection.hst.contentbean.ValueList)3 Collectors (java.util.stream.Collectors)2 IteratorUtils.toList (org.apache.commons.collections.IteratorUtils.toList)2 ObjectBeanManagerException (org.hippoecm.hst.content.beans.ObjectBeanManagerException)2 ObjectConverter (org.hippoecm.hst.content.beans.manager.ObjectConverter)2 Constraint (org.hippoecm.hst.content.beans.query.builder.Constraint)2