jackrabbit-oak-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1300979 - /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
Date Thu, 15 Mar 2012 13:47:55 GMT
Author: mduerig
Date: Thu Mar 15 13:47:55 2012
New Revision: 1300979

URL: http://svn.apache.org/viewvc?rev=1300979&view=rev
Log:
OAK-5: JCR bindings for Oak
fix: RepositoryTest#getWorkspaceNames

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java?rev=1300979&r1=1300978&r2=1300979&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
Thu Mar 15 13:47:55 2012
@@ -18,6 +18,10 @@ package org.apache.jackrabbit.oak.jcr;
 
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.oak.jcr.SessionImpl.Context;
+import org.apache.jackrabbit.oak.jcr.json.FullJsonParser;
+import org.apache.jackrabbit.oak.jcr.json.JsonValue;
+import org.apache.jackrabbit.oak.jcr.json.JsonValue.JsonObject;
+import org.apache.jackrabbit.oak.jcr.json.UnescapingJsonTokenizer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.ContentHandler;
@@ -45,6 +49,9 @@ import javax.jcr.version.VersionExceptio
 import javax.jcr.version.VersionManager;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map.Entry;
 
 /**
  * <code>WorkspaceImpl</code>...
@@ -166,8 +173,19 @@ public class WorkspaceImpl implements Wo
     public String[] getAccessibleWorkspaceNames() throws RepositoryException {
         getOakSession().checkIsAlive();
 
-        // TODO
-        return new String[0];
+        MicroKernel microKernel = sessionContext.getMicrokernel();
+        String revision = sessionContext.getRevision();
+        String json = microKernel.getNodes("/", revision, 0, 0, -1, null);
+        JsonObject jsonObject = FullJsonParser.parseObject(new UnescapingJsonTokenizer(json));
+
+        List<String> workspaces = new ArrayList<String>();
+        for (Entry<String, JsonValue> entry : jsonObject.value().entrySet()) {
+            if (entry.getValue().isObject()) {
+                workspaces.add(entry.getKey());
+            }
+        }
+
+        return workspaces.toArray(new String[workspaces.size()]);
     }
 
     @Override



Mime
View raw message