Search in sources :

Example 6 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)

Example 7 with HstComponentException

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

the class PublicationBase method getDatasets.

public List<Dataset> getDatasets() throws HstComponentException {
    assertPropertyPermitted(PropertyKeys.DATASETS);
    HstQueryResult hstQueryResult;
    try {
        hstQueryResult = HstQueryBuilder.create(getParentBean()).ofTypes(Dataset.class).build().execute();
    } catch (QueryException queryException) {
        log.error("Failed to find datasets for publication " + getCanonicalPath(), queryException);
        throw new HstComponentException("Failed to find datasets for publication " + getCanonicalPath(), queryException);
    }
    ArrayList<Dataset> hippoBeans = Lists.newArrayList((Iterator) hstQueryResult.getHippoBeans());
    hippoBeans.sort(DocumentTitleComparator.COMPARATOR);
    return hippoBeans;
}
Also used : QueryException(org.hippoecm.hst.content.beans.query.exceptions.QueryException) HstComponentException(org.hippoecm.hst.core.component.HstComponentException) HstQueryResult(org.hippoecm.hst.content.beans.query.HstQueryResult)

Example 8 with HstComponentException

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

the class DatasetComponent method doBeforeRender.

@Override
public void doBeforeRender(final HstRequest request, final HstResponse response) throws HstComponentException {
    super.doBeforeRender(request, response);
    final HstRequestContext ctx = request.getRequestContext();
    Dataset dataset = (Dataset) ctx.getContentBean();
    if (!dataset.isPubliclyAccessible()) {
        try {
            response.forward("/error/404");
        } catch (IOException ioException) {
            throw new HstComponentException("forward failed", ioException);
        }
        return;
    }
    request.setAttribute("dataset", dataset);
}
Also used : Dataset(uk.nhs.digital.ps.beans.Dataset) IOException(java.io.IOException) HstComponentException(org.hippoecm.hst.core.component.HstComponentException) HstRequestContext(org.hippoecm.hst.core.request.HstRequestContext)

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