You are viewing a plain text version of this content. The canonical link for it is here.
Posted to lokahi-commits@incubator.apache.org by ns...@apache.org on 2007/06/18 15:23:04 UTC

svn commit: r548379 - in /incubator/lokahi/lokahi/branches/jackrabbit: conf/node.conf src/java/org/apache/lokahi/core/common/database/JackrabbitBroker.java src/java/org/apache/lokahi/core/common/database/LokahiRepository.java

Author: nstein
Date: Mon Jun 18 08:23:01 2007
New Revision: 548379

URL: http://svn.apache.org/viewvc?view=rev&rev=548379
Log:
added beginings of the jackrabbit backend.

Added:
    incubator/lokahi/lokahi/branches/jackrabbit/conf/node.conf
    incubator/lokahi/lokahi/branches/jackrabbit/src/java/org/apache/lokahi/core/common/database/JackrabbitBroker.java
    incubator/lokahi/lokahi/branches/jackrabbit/src/java/org/apache/lokahi/core/common/database/LokahiRepository.java

Added: incubator/lokahi/lokahi/branches/jackrabbit/conf/node.conf
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/branches/jackrabbit/conf/node.conf?view=auto&rev=548379
==============================================================================
--- incubator/lokahi/lokahi/branches/jackrabbit/conf/node.conf (added)
+++ incubator/lokahi/lokahi/branches/jackrabbit/conf/node.conf Mon Jun 18 08:23:01 2007
@@ -0,0 +1,29 @@
+<lokahi=...>
+
+[lokahi:entity] > nt:hierarchyNode, mix:versionable
+
+[lokahi:collection] > lokahi:entity, nt:folder
+
+[lokahi:template] > lokahi:collection
+ - foo (STRING)
+
+[lokahi:worker] > lokahi:entity
+
+[lokahi:pool] > lokahi:collection
+
+[lokahi:httpd-template] > lokahi:template
+ - apache-config (STRING)
+
+[lokahi:httpd-worker] > lokahi:worker
+ - worker-config (STRING)
+
+[lokahi:httpd-pool] > lokahi:pool
+
+[lokahi:httpd-vhost] > lokahi:entity
+
+[lokahi:server] > lokahi:entity
+
+[lokahi:user] > lokahi:entity
+ + * (lokahi:user-project-relationship)
+
+[lokahi:project] > lokahi:entity

Added: incubator/lokahi/lokahi/branches/jackrabbit/src/java/org/apache/lokahi/core/common/database/JackrabbitBroker.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/branches/jackrabbit/src/java/org/apache/lokahi/core/common/database/JackrabbitBroker.java?view=auto&rev=548379
==============================================================================
--- incubator/lokahi/lokahi/branches/jackrabbit/src/java/org/apache/lokahi/core/common/database/JackrabbitBroker.java (added)
+++ incubator/lokahi/lokahi/branches/jackrabbit/src/java/org/apache/lokahi/core/common/database/JackrabbitBroker.java Mon Jun 18 08:23:01 2007
@@ -0,0 +1,43 @@
+package org.apache.lokahi.core.common.database;
+import java.sql.SQLException;
+
+/**
+ * @author The Apache Incubated Lokahi project - http://incubator.apache.org/lokahi/
+ * @version $Id$
+ */
+public class JackrabbitBroker  {
+
+  /*
+  *
+/lokahi
+ /httpd
+   /template
+     /workerA
+     /workerB
+ /tomcat
+ /servers
+   /serverA
+   /serverB
+ /users
+   /userA
+   /userB
+ /projects
+   /projectA
+   /projectB
+
+  */
+
+  public int save(String statement, Object... params) throws SQLException {
+    return 0;
+  }
+
+  public boolean delete(String statement, Object... params) throws SQLException {
+    return false;
+  }
+
+  public void update(String statement, Object... params) throws SQLException {
+  }
+
+
+
+}

Added: incubator/lokahi/lokahi/branches/jackrabbit/src/java/org/apache/lokahi/core/common/database/LokahiRepository.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/branches/jackrabbit/src/java/org/apache/lokahi/core/common/database/LokahiRepository.java?view=auto&rev=548379
==============================================================================
--- incubator/lokahi/lokahi/branches/jackrabbit/src/java/org/apache/lokahi/core/common/database/LokahiRepository.java (added)
+++ incubator/lokahi/lokahi/branches/jackrabbit/src/java/org/apache/lokahi/core/common/database/LokahiRepository.java Mon Jun 18 08:23:01 2007
@@ -0,0 +1,72 @@
+package org.apache.lokahi.core.common.database;
+
+import org.apache.jackrabbit.core.TransientRepository;
+import org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader;
+import org.apache.jackrabbit.core.nodetype.compact.ParseException;
+import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;
+import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
+import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
+import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
+
+import javax.jcr.Repository;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Workspace;
+import java.io.IOException;
+import java.io.FileReader;
+import java.io.FileNotFoundException;
+import java.util.List;
+import java.util.Iterator;
+
+/**
+ * @author The Apache Incubated Lokahi project - http://incubator.apache.org/lokahi/
+ * @version $Id$
+ */
+public class LokahiRepository {
+Node root;
+
+ public LokahiRepository() throws IOException, RepositoryException {
+    Repository repository = new TransientRepository();
+    Session session = repository.login(new SimpleCredentials("username", "password".toCharArray())); //todo - make this a real repository rather than a simple test one.
+     Node   realRoot = session.getRootNode();
+   if (! realRoot.hasNodes()) {
+   root = realRoot.addNode("lokahi");
+     session.save();
+   } else {
+     root = realRoot.getNode("lokahi");
+   }
+   //still need to init the repository with the settings from the nodetype file.
+}
+
+     public static void RegisterCustomNodeTypes(Workspace ws, String cndFileName) throws InvalidNodeTypeDefException, RepositoryException, ParseException, FileNotFoundException {
+
+        // Read in the CND file
+        FileReader fileReader = new FileReader(cndFileName);
+
+        // Create a CompactNodeTypeDefReader
+        CompactNodeTypeDefReader cndReader = new CompactNodeTypeDefReader(fileReader, cndFileName);
+
+        // Get the List of NodeTypeDef objects
+        List ntdList = cndReader.getNodeTypeDefs();
+
+        // Get the NodeTypeManager from the Workspace.
+        // Note that it must be cast from the generic JCR NodeTypeManager to the
+        // Jackrabbit-specific implementation.
+        NodeTypeManagerImpl ntmgr =(NodeTypeManagerImpl)ws.getNodeTypeManager();
+
+        // Acquire the NodeTypeRegistry
+        NodeTypeRegistry ntreg = ntmgr.getNodeTypeRegistry();
+
+        // Loop through the prepared NodeTypeDefs
+        for (Iterator i = ntdList.iterator(); i.hasNext();) {
+
+            // Get the NodeTypeDef...
+            NodeTypeDef ntd = (NodeTypeDef)i.next();
+
+            // ...and register it
+            ntreg.registerNodeType(ntd);
+        }
+    }
+}