Fork me on GitHub

Installing GREB API

Add Dependencies

Make sure you have the forge Maven2 repository reference and dependency definition in the root pom.xml of your project.

    <repositories>

      <!-- SNIP -->

      <repository>
        <id>hippo-maven2-forge</id>
        <name>Hippo Maven 2 Forge repository</name>
        <url>http://maven.onehippo.com/maven2-forge/</url>
        <snapshots />
      </repository>

      <!-- SNIP -->

    </repositories>
    

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.

    <greb-api.version>version-number</greb-api.version>
          

Add the following dependency in the site/components/pom.xml:

    <dependency>
      <groupId>org.onehippo.forge.greb-api</groupId>
      <artifactId>greb-api</artifactId>
      <version>${greb-api.version}</version>
    </dependency>
          
Note: Since v2.0.1, the maven coordinates have been changed from com.onehippo.cms7:hippo-addon-generic-resource-entity-builder to org.onehippo.forge.greb-api:greb-api.

Now, you're ready to use the plugin!

Configure Delivery Tier Mount

Add an API mount, with hst:namedpipeline = GenericResourceEntitySitePipeline, like the following example (expressed in YAML format).

/hst:myproject/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/components/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.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"
              init-method="initialize" destroy-method="destroy">
          <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 response headers or other security HTTP response headers on the GREB API mount, see the following pages: