Install the GREB (Generic Resource Entity Builder) API Add-on
Status
Prerequisites
To be able to use the GREB (Generic Resource Entity Builder) API add-on, your implementation project must be set up as a Bloomreach Experience Manager project.
Instructions
Add Maven Dependency
In the main pom.xml of your project, add a new property in the properties section. For the correct version number for your project, check the Release Notes page.
<hippo-addon-generic-resource-entity-builder.version>version-number</hippo-addon-generic-resource-entity-builder.version>
In the site module of your project, add the following dependency in the pom.xml:
<dependency> <groupId>com.onehippo.cms7</groupId> <artifactId>hippo-addon-generic-resource-entity-builder</artifactId> <version>${hippo-addon-generic-resource-entity-builder.version}</version> </dependency>
Configure Delivery Tier Mount
Add an API mount, with hst:namedpipeline = GenericResourceEntitySitePipeline, like the following example (expressed in YAML format).
/hst:hst/hst:hosts/dev-localhost/localhost/hst:root/grebapi: jcr:primaryType: hst:mount hst:alias: grebapi hst:namedpipeline: GenericResourceEntitySitePipeline hst:nochannelinfo: true
After rebuilding the project and restarting the server, you will be able to use the GREB (Generic Resource Entity Builder) API right way.
Enabling Relevance in GREB Pipeline
By default, the Pipeline of GREB API is not configured with Relevance module (i.e, TargetingUpdateValve). If you have already installed Relevance module in your project, you can also enable Relevance in GREP API Pipeline.
To configure Relevance in the Pipeline of GREP API, add a Spring bean assembly XML file (e.g, greb-targeting.xml) in site/src/main/resources/META-INF/hst-assembly/overrides/addon/com/onehippo/cms7/genericresource/entitybuilder/ folder like the following:
<?xml version="1.0" encoding="UTF-8"?> <!-- greb-targeting.xml --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> <bean class="org.hippoecm.hst.site.container.TypeDeterminedMethodInvokingFactoryBean"> <constructor-arg value="java.lang.Void" /> <property name="targetObject"> <bean class="org.hippoecm.hst.site.container.TypeDeterminedMethodInvokingFactoryBean"> <constructor-arg value="org.hippoecm.hst.core.container.Pipeline" /> <property name="targetObject" ref="org.hippoecm.hst.core.container.Pipelines" /> <property name="targetMethod" value="getPipeline" /> <property name="arguments"> <list> <value>GenericResourceEntitySitePipeline</value> </list> </property> </bean> </property> <property name="targetMethod" value="addProcessingValve" /> <property name="arguments"> <list> <bean class="com.onehippo.cms7.targeting.hst.container.TargetingUpdateValve"> <property name="valveName" value="targetingUpdateValve" /> <property name="afterValves" value="contextResolvingValve, localizationValve" /> <property name="beforeValves" value="actionValve, resourceServingValve" /> </bean> </list> </property> </bean> </beans>
CORS Support
If you want to add custom CORS related HTTP headers, you can add a Spring bean assembly XML file (e.g, greb-cors.xml) in site/src/main/resources/META-INF/hst-assembly/overrides/addon/com/onehippo/cms7/genericresource/entitybuilder/ folder like the following:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> <bean id="genericResourceEntityCustomResponseHeadersValveSettableHeaders" class="org.springframework.beans.factory.config.ListFactoryBean"> <property name="sourceList"> <list> <bean class="org.hippoecm.hst.util.DefaultKeyValue"> <constructor-arg value="Access-Control-Allow-Origin" /> <constructor-arg value="*" /> </bean> </list> </property> </bean> </beans>