Monday, May 23, 2016

Integrating Play Framework & Hippo CMS

Some people ask if I advice using Hippo CMS, I work at Hippo so usually I say I do... but Hippo CMS is a content centric CMS which can be used for enterprise purposes where it maintains a lot content, if I say a lot content I mean minimum 100 documents. Given this situations I though what if you could combine the simplicity of play framework with the core strength and stability of Hippo CMS?

PlayHippo[1] is the attempt integrating Hippo Content Beans into PlayFramework, which let's you use your HippoBeans and Queries in Play Controllers.

Add the following module dependency in your build.sbt:

resolvers += (
  "Play Hippo Repository" at "http://jbloemendal.github.io/play-hippo/releases/"
)

libraryDependencies ++= Seq(
  "org.onehippo" % "playhippo_2.11" % "1.1",
  ...
)

I have to say the RMI connector is not the most efficient way of connecting to Hippo CMS, you need to active RMI support[2].

Skipping an entire project setup from scratch, checkout the hippo demo project gogreen [3], which ships a project which you can use right from the start, you don't have to do anything. If you want to remove features which you can't use comment out the HST site deployable and channel manager dependencies:

cms/pom.xml
<!--dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-addon-channel-manager-frontend</artifactId>
</dependency-->
<!--dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-addon-channel-manager-repository</artifactId>
</dependency-->
 pom.xml 
<!--deployable>
<location>${project.basedir}/site/target/site.war</location>
<type>war</type>
<properties>
<context>/site</context>
</properties>
</deployable-->
 
Activate RMI connections by adding these lines to your cms/src/main/webapp/WEB-INF/web.xml file:
<context-param>
  <description>The address of the repository</description>
  <param-name>repository-address</param-name>
  <param-value>rmi://localhost:1099/hipporepository</param-value>
</context-param>
<context-param>
  <description>The address of the repository</description>
  <param-name>start-remote-server</param-name>
  <param-value>true</param-value>
</context-param>

Build and start hippo gogreen

mvn clean verify
mvn -P cargo.run

PlayHippo [1] contains an example play project, using the PlayHippoTool Service[4]. Clone or download PlayHippo, use the activator and run the project.

./activator
run 

Now you should be able to access hippo content from your play project, for example view a HippoFacetNavigation http://localhost:9000/content/documents/gogreen/newsfacets/, add your own hippo document beans [5], create some hst queries.

This article should provide a starting point and ideas which you can integrate in your own project. To get it going just add the PlayHippo dependency like described. In a production usecase ensure you configure your own credentials.

conf/application.conf
hippo.rmi.uri = "rmi://localhost:1099/hipporepository"
hippo.rmi.user = "admin"
hippo.rmi.password = "admin"


[1] https://github.com/jbloemendal/play-hippo
[2] http://www.onehippo.org/library/concepts/content-repository/repository-deployment-settings.html
[3] http://www.onehippo.org/binaries/content/assets/connect/trails/developer-trail/hippo-10.2/gogreen-iteration-2-3.2.0.zip
[4] https://github.com/jbloemendal/play-hippo/blob/master/app/controllers/HippoController.java
[5] https://github.com/jbloemendal/play-hippo/blob/master/app/model/HippoGoGreenNewsDocument.java

No comments:

Post a Comment