Search in sources :

Example 1 with HstComponentException

use of org.hippoecm.hst.core.component.HstComponentException 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 HstComponentException

use of org.hippoecm.hst.core.component.HstComponentException in project hippo by NHS-digital-website.

the class CiBreadcrumbProvider method loadCiLandingBean.

/**
 * <p>
 * Query the repository to see if this document sits under one of the Clinical Indicator
 * folders, and if so load in the CiLanding bean (which is used to create the breadcrumb).
 * The CiLanding document has a property called urlNameOfContentFolder which links
 * the CiLanding page to the appropriate content folder
 * </p>
 */
private void loadCiLandingBean() {
    HstQueryBuilder queryBuilder = HstQueryBuilder.create(RequestContextProvider.get().getSiteContentBaseBean());
    final HstQueryResult hstQueryResult;
    Constraint[] constraints = Arrays.stream(currentDocumentBean.getPath().split("/")).map((pathSegment) -> constraint("publicationsystem:urlNameOfContentFolder").equalTo(pathSegment)).toArray(Constraint[]::new);
    final HstQuery query = queryBuilder.ofTypes(CiLanding.class).where(or(constraints)).build();
    try {
        hstQueryResult = query.execute();
    } catch (QueryException queryException) {
        throw new HstComponentException("Exception occurred during ci folder search.", queryException);
    }
    if (hstQueryResult.getHippoBeans().hasNext()) {
        isClinicalIndicator = true;
        ciLandingBean = (CiLanding) hstQueryResult.getHippoBeans().nextHippoBean();
    }
}
Also used : BreadcrumbItem(org.onehippo.forge.breadcrumb.om.BreadcrumbItem) java.util(java.util) HstRequestContext(org.hippoecm.hst.core.request.HstRequestContext) HstComponentException(org.hippoecm.hst.core.component.HstComponentException) HstRequest(org.hippoecm.hst.core.component.HstRequest) ConstraintBuilder.or(org.hippoecm.hst.content.beans.query.builder.ConstraintBuilder.or) HippoBean(org.hippoecm.hst.content.beans.standard.HippoBean) HstQuery(org.hippoecm.hst.content.beans.query.HstQuery) HippoFolder(org.hippoecm.hst.content.beans.standard.HippoFolder) Constraint(org.hippoecm.hst.content.beans.query.builder.Constraint) QueryException(org.hippoecm.hst.content.beans.query.exceptions.QueryException) uk.nhs.digital.ps.beans(uk.nhs.digital.ps.beans) RequestContextProvider(org.hippoecm.hst.container.RequestContextProvider) ConstraintBuilder.constraint(org.hippoecm.hst.content.beans.query.builder.ConstraintBuilder.constraint) HstQueryResult(org.hippoecm.hst.content.beans.query.HstQueryResult) HstQueryBuilder(org.hippoecm.hst.content.beans.query.builder.HstQueryBuilder) HstQuery(org.hippoecm.hst.content.beans.query.HstQuery) QueryException(org.hippoecm.hst.content.beans.query.exceptions.QueryException) HstQueryBuilder(org.hippoecm.hst.content.beans.query.builder.HstQueryBuilder) Constraint(org.hippoecm.hst.content.beans.query.builder.Constraint) HstComponentException(org.hippoecm.hst.core.component.HstComponentException) HstQueryResult(org.hippoecm.hst.content.beans.query.HstQueryResult)

Example 3 with HstComponentException

use of org.hippoecm.hst.core.component.HstComponentException in project hippo by NHS-digital-website.

the class IndicatorComponent method getIndicator.

private Indicator getIndicator(HstRequestContext ctx) throws HstComponentException {
    HippoBean content = ctx.getContentBean();
    if (content instanceof Indicator) {
        return (Indicator) content;
    }
    log.warn("Cannot find Indicator document for: {}", content.getPath());
    throw new HstComponentException("Cannot find Indicator document based on request content");
}
Also used : HippoBean(org.hippoecm.hst.content.beans.standard.HippoBean) HstComponentException(org.hippoecm.hst.core.component.HstComponentException) Indicator(uk.nhs.digital.nil.beans.Indicator)

Example 4 with HstComponentException

use of org.hippoecm.hst.core.component.HstComponentException in project hippo by NHS-digital-website.

the class PublicationComponent method getPublication.

private Publication getPublication(HstRequestContext ctx) throws HstComponentException {
    HippoBean content = ctx.getContentBean();
    if (content.getClass().equals(Publication.class)) {
        return (Publication) content;
    }
    if (content.getClass().equals(HippoFolder.class)) {
        return Publication.getPublicationInFolder((HippoFolder) content, Publication.class);
    }
    log.warn("Cannot find Publication document for: {}", content.getPath());
    throw new HstComponentException("Cannot find Publication document based on request content");
}
Also used : HippoBean(org.hippoecm.hst.content.beans.standard.HippoBean) Publication(uk.nhs.digital.ps.beans.Publication) HstComponentException(org.hippoecm.hst.core.component.HstComponentException)

Example 5 with HstComponentException

use of org.hippoecm.hst.core.component.HstComponentException in project hippo by NHS-digital-website.

the class FolderComponent method doBeforeRender.

@Override
public void doBeforeRender(final HstRequest request, final HstResponse response) throws HstComponentException {
    super.doBeforeRender(request, response);
    HippoFolder folder = (HippoFolder) request.getRequestContext().getContentBean();
    try {
        request.setAttribute("publications", findAllDocuments(folder));
    } catch (QueryException queryException) {
        throw new HstComponentException("Exception occurred during folder search.", queryException);
    }
}
Also used : QueryException(org.hippoecm.hst.content.beans.query.exceptions.QueryException) HippoFolder(org.hippoecm.hst.content.beans.standard.HippoFolder) HstComponentException(org.hippoecm.hst.core.component.HstComponentException)

Aggregations

HstComponentException (org.hippoecm.hst.core.component.HstComponentException)8 QueryException (org.hippoecm.hst.content.beans.query.exceptions.QueryException)4 HippoBean (org.hippoecm.hst.content.beans.standard.HippoBean)4 HstRequestContext (org.hippoecm.hst.core.request.HstRequestContext)4 java.util (java.util)2 RequestContextProvider (org.hippoecm.hst.container.RequestContextProvider)2 HstQueryResult (org.hippoecm.hst.content.beans.query.HstQueryResult)2 Constraint (org.hippoecm.hst.content.beans.query.builder.Constraint)2 ConstraintBuilder.constraint (org.hippoecm.hst.content.beans.query.builder.ConstraintBuilder.constraint)2 ConstraintBuilder.or (org.hippoecm.hst.content.beans.query.builder.ConstraintBuilder.or)2 HstQueryBuilder (org.hippoecm.hst.content.beans.query.builder.HstQueryBuilder)2 HippoFolder (org.hippoecm.hst.content.beans.standard.HippoFolder)2 HstRequest (org.hippoecm.hst.core.component.HstRequest)2 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 RepositoryException (javax.jcr.RepositoryException)1 IteratorUtils.toList (org.apache.commons.collections.IteratorUtils.toList)1