Commit 04f7afd9 authored by Peter Harrison's avatar Peter Harrison

Changing to Jackrabbit Oak and MamboDB.

parent 933e2b8d
......@@ -185,6 +185,7 @@
<version>2.0</version>
</dependency>
<!--
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr-commons</artifactId>
......@@ -196,12 +197,25 @@
<artifactId>jackrabbit-jcr-commons</artifactId>
<version>2.4.1</version>
</dependency>
-->
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>oak-jcr</artifactId>
<version>1.2.6</version>
</dependency>
<dependency>
<groupId>org.apache</groupId>
<artifactId>jackrabbit-ocm</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.12.5</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
......
......@@ -21,6 +21,8 @@
package nz.net.orcon.kanban.automation;
import java.net.UnknownHostException;
import javax.annotation.PreDestroy;
import nz.net.orcon.kanban.tools.OcmMapperFactory;
......@@ -48,7 +50,7 @@ public class JcrObserver {
ObjectContentManager ocm;
public void start() throws UnsupportedRepositoryOperationException, LoginException, RepositoryException, ClassNotFoundException{
public void start() throws UnsupportedRepositoryOperationException, LoginException, RepositoryException, ClassNotFoundException, UnknownHostException{
this.ocm = ocmFactory.getOcm();
ObservationManager observationManager = ocm.getSession().getWorkspace().getObservationManager();
final String[] types = { "nt:unstructured" };
......
......@@ -21,6 +21,7 @@
package nz.net.orcon.kanban.controllers;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
......@@ -153,7 +154,7 @@ public class NotificationController {
}
@RequestMapping(value = "/{notificationType}", method=RequestMethod.GET)
public @ResponseBody NotificationTypeMapping getNotificationTypeMapping(@PathVariable String notificationType) throws LoginException, RepositoryException, ClassNotFoundException{
public @ResponseBody NotificationTypeMapping getNotificationTypeMapping(@PathVariable String notificationType) throws LoginException, RepositoryException, ClassNotFoundException, UnknownHostException{
ObjectContentManager ocm = ocmFactory.getOcm();
NotificationTypeMapping notificationTypeMapping = null;
try{
......
......@@ -21,6 +21,7 @@
package nz.net.orcon.kanban.tools;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
......@@ -34,25 +35,32 @@ import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import org.apache.jackrabbit.oak.jcr.Jcr;
import org.apache.jackrabbit.oak.plugins.document.DocumentMK;
import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore;
import org.apache.jackrabbit.oak.Oak;
import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
import org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerImpl;
import org.apache.jackrabbit.ocm.mapper.Mapper;
import org.apache.jackrabbit.ocm.mapper.impl.annotation.AnnotationMapperImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Autowired;
import com.mongodb.DB;
import com.mongodb.MongoClient;
public class OcmMapperFactory {
private static final Logger logger = LoggerFactory.getLogger(OcmMapperFactory.class);
@Autowired
private Repository repository;
private String domainPackage;
private List<String> classList;
private List<String> mainNodes;
private String host;
private String user;
private String password;
......@@ -69,8 +77,21 @@ public class OcmMapperFactory {
this.mapper = new AnnotationMapperImpl(classes);
}
public ObjectContentManager getOcm() throws LoginException, RepositoryException, ClassNotFoundException {
public ObjectContentManager getOcm() throws LoginException, RepositoryException, ClassNotFoundException, UnknownHostException {
if(this.repository==null){
logger.info("Creating Repository");
// MEMORY REPO
// repository = new Jcr(new Oak()).createRepository();
DB db = new MongoClient(host, 27017).getDB("gravity");
DocumentNodeStore ns = new DocumentMK.Builder().
setMongoDB(db).getNodeStore();
this.repository = new Jcr(new Oak(ns)).createRepository();
}
if(this.mapper==null){
logger.info("Generating Mapper");
generateMapper();
}
......@@ -167,4 +188,12 @@ public class OcmMapperFactory {
return mainNodes;
}
public String getHost() {
return host;
}
public void setUrl(String host) {
this.host = host;
}
}
......@@ -10,9 +10,11 @@
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
<!--
<bean id="repository" class="org.apache.jackrabbit.commons.JcrUtils" factory-method="getRepository">
<constructor-arg value="${repository.url}"/>
</bean>
-->
<bean id="ocmFactory" class="nz.net.orcon.kanban.tools.OcmMapperFactory">
<property name="user" value="admin"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment