You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by dp...@apache.org on 2009/01/23 17:46:41 UTC

svn commit: r737085 - in /jackrabbit/sandbox/jcr-cmis/cmis2jcr: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/jackrabbit/ src/main/java/org/apache/jackrabbit/cmis/ src/main/java/org/apache/jackra...

Author: dpfister
Date: Fri Jan 23 08:46:41 2009
New Revision: 737085

URL: http://svn.apache.org/viewvc?rev=737085&view=rev
Log:
JCRCMIS - Generic CMIS to JCR mapper

Added:
    jackrabbit/sandbox/jcr-cmis/cmis2jcr/
    jackrabbit/sandbox/jcr-cmis/cmis2jcr/pom.xml   (with props)
    jackrabbit/sandbox/jcr-cmis/cmis2jcr/readme.txt   (with props)
    jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/
    jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/
    jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/
    jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/
    jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/
    jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/
    jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/
    jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/
    jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCREntry.java   (with props)
    jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCREntryIterator.java   (with props)
    jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCRRepository.java   (with props)

Added: jackrabbit/sandbox/jcr-cmis/cmis2jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcr-cmis/cmis2jcr/pom.xml?rev=737085&view=auto
==============================================================================
--- jackrabbit/sandbox/jcr-cmis/cmis2jcr/pom.xml (added)
+++ jackrabbit/sandbox/jcr-cmis/cmis2jcr/pom.xml Fri Jan 23 08:46:41 2009
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements. See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version
+    2.0 (the "License"); you may not use this file except in compliance
+    with the License. You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+    applicable law or agreed to in writing, software distributed under the
+    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+    CONDITIONS OF ANY KIND, either express or implied. See the License for
+    the specific language governing permissions and limitations under the
+    License.
+-->
+
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.jackrabbit</groupId>
+        <artifactId>jcr-cmis-parent</artifactId>
+        <version>1.6-SNAPSHOT</version>
+    </parent>
+    <artifactId>jcr-cmis-cmis2jcr</artifactId>
+    <version>1.6-SNAPSHOT</version>
+    <name>Jackrabbit CMIS to JCR wrapper</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>javax.jcr</groupId>
+      <artifactId>jcr</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jcr-cmis-api</artifactId>
+      <version>1.6-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+
+</project>

Propchange: jackrabbit/sandbox/jcr-cmis/cmis2jcr/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/sandbox/jcr-cmis/cmis2jcr/readme.txt
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcr-cmis/cmis2jcr/readme.txt?rev=737085&view=auto
==============================================================================
--- jackrabbit/sandbox/jcr-cmis/cmis2jcr/readme.txt (added)
+++ jackrabbit/sandbox/jcr-cmis/cmis2jcr/readme.txt Fri Jan 23 08:46:41 2009
@@ -0,0 +1 @@
+This directory contains a generic CMIS to JCR bridge.

Propchange: jackrabbit/sandbox/jcr-cmis/cmis2jcr/readme.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCREntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCREntry.java?rev=737085&view=auto
==============================================================================
--- jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCREntry.java (added)
+++ jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCREntry.java Fri Jan 23 08:46:41 2009
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.cmis.jcr;
+
+import java.util.Calendar;
+import java.util.Iterator;
+
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.RepositoryException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.jackrabbit.cmis.Entry;
+
+public class JCREntry implements Entry {
+
+    private static Logger log = LoggerFactory.getLogger(JCREntry.class);
+
+    private javax.jcr.Node node;
+
+    public JCREntry(javax.jcr.Node node) {
+        this.node = node;
+    }
+
+    public String getId() {
+        return getObjectId();
+    }
+
+    public String getChangeToken() {
+        return null;
+    }
+
+    public String getCreatedBy() {
+        try {
+            return node.getSession().getUserID();
+        } catch (RepositoryException e) {
+            log.warn("Unable to retrieve user ID", e);
+            return null;
+        }
+    }
+
+    public Calendar getCreationDate() {
+        return Calendar.getInstance();
+    }
+
+    public String getLastModifiedBy() {
+        try {
+            return node.getSession().getUserID();
+        } catch (RepositoryException e) {
+            log.warn("Unable to retrieve user ID", e);
+            return null;
+        }
+    }
+
+    public Calendar getLastModificationDate() {
+        return Calendar.getInstance();
+    }
+
+    public String getName() {
+        try {
+            return node.getName();
+        } catch (RepositoryException e) {
+            log.warn("Unable to retrieve item name", e);
+            return null;
+        }
+    }
+
+    public String getObjectId() {
+        try {
+            String id = node.getPath();
+            if (id.startsWith("/")) {
+                id = id.substring(1);
+            }
+            return id;
+        } catch (RepositoryException e) {
+            log.warn("Unable to retrieve item path", e);
+            return null;
+        }
+    }
+
+    public String getObjectTypeId() {
+        try {
+            return node.getPrimaryNodeType().getName();
+        } catch (RepositoryException e) {
+            log.warn("Unable to retrieve primary node type", e);
+            return null;
+        }
+    }
+
+    public String getParentId() {
+        try {
+            return node.getParent().getPath();
+        } catch (ItemNotFoundException e) {
+            /* this is the root node */
+            return "";
+        } catch (RepositoryException e) {
+            log.warn("Unable to retrieve parent path", e);
+            return null;
+        }
+    }
+
+    public Iterable<Entry> getChildren() {
+        final javax.jcr.Node node = this.node;
+
+        return new Iterable<Entry>() {
+            public Iterator<Entry> iterator() {
+                try {
+                    return new JCREntryIterator(node.getNodes());
+                } catch (RepositoryException e) {
+                    log.warn("Unable to retrieve children", e);
+                    return null;
+                }
+            }
+        };
+    }
+
+    public Iterable<Entry> getDescendants() {
+	// TODO: retrieve all descendants, not just the direct ones
+        return getChildren();
+    }
+}

Propchange: jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCREntry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCREntry.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCREntryIterator.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCREntryIterator.java?rev=737085&view=auto
==============================================================================
--- jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCREntryIterator.java (added)
+++ jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCREntryIterator.java Fri Jan 23 08:46:41 2009
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.cmis.jcr;
+
+import java.util.Iterator;
+
+import org.apache.jackrabbit.cmis.Entry;
+
+public class JCREntryIterator implements Iterator<Entry> {
+
+    javax.jcr.NodeIterator nodeiter;
+
+    public JCREntryIterator(javax.jcr.NodeIterator nodeiter) {
+        this.nodeiter = nodeiter;
+    }
+
+    public boolean hasNext() {
+        return nodeiter.hasNext();
+    }
+
+    public Entry next() {
+        return new JCREntry(nodeiter.nextNode());
+    }
+
+    public void remove() {
+        throw new UnsupportedOperationException();
+    }
+}

Propchange: jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCREntryIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCREntryIterator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCRRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCRRepository.java?rev=737085&view=auto
==============================================================================
--- jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCRRepository.java (added)
+++ jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCRRepository.java Fri Jan 23 08:46:41 2009
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.cmis.jcr;
+
+import java.net.URI;
+
+import javax.jcr.RepositoryException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.jackrabbit.cmis.Capabilities;
+import org.apache.jackrabbit.cmis.Entry;
+import org.apache.jackrabbit.cmis.FullTextSupport;
+import org.apache.jackrabbit.cmis.JoinSupport;
+import org.apache.jackrabbit.cmis.QuerySupport;
+import org.apache.jackrabbit.cmis.Repository;
+
+public class JCRRepository implements Repository, Capabilities {
+
+    private static Logger log = LoggerFactory.getLogger(JCRRepository.class);
+    private javax.jcr.Repository repository;
+    private String workspace;
+
+    public JCRRepository(javax.jcr.Repository repository, String workspace) {
+        this.repository = repository;
+        this.workspace = workspace;
+    }
+
+    public Capabilities getCapabilities() {
+        return this;
+    }
+
+    public String getDescription() {
+        return repository.getDescriptor(javax.jcr.Repository.REP_NAME_DESC);
+    }
+
+    public String getId() {
+        return getName();
+    }
+
+    public String getName() {
+        return repository.getDescriptor(javax.jcr.Repository.REP_NAME_DESC);
+    }
+
+    public URI getURI() {
+        // TODO Return a URI
+        return null;
+    }
+
+    public String getProductName() {
+        return repository.getDescriptor(javax.jcr.Repository.REP_NAME_DESC);
+    }
+
+    public String getProductVersion() {
+        return repository.getDescriptor(javax.jcr.Repository.REP_VERSION_DESC);
+    }
+
+    public String getRootFolderId() {
+        return workspace;
+    }
+
+    public String getVendorName() {
+        return repository.getDescriptor(javax.jcr.Repository.REP_VENDOR_DESC);
+    }
+
+    public String getVersionsSupported() {
+        return "0.5";
+    }
+
+    public Entry getEntry(String id) {
+        try {
+            javax.jcr.Node node = repository.login(workspace).getRootNode();
+            if (!id.equals("")) {
+                node = node.getNode(id);
+            }
+            return new JCREntry(node);
+        } catch (RepositoryException e) {
+            log.warn("Unable to retrieve node " + id, e);
+            return null;
+        }
+    }
+
+    public boolean areAllVersionsSearchable() {
+        return false;
+    }
+
+    public FullTextSupport getFullTextSupport() {
+        return FullTextSupport.FULL_TEXT_AND_STRUCTURED;
+    }
+
+    public JoinSupport getJoinSupport() {
+        return JoinSupport.NO;
+    }
+
+    public QuerySupport getQuerySupport() {
+        return QuerySupport.BOTH;
+    }
+
+    public boolean hasMultifiling() {
+        return true;
+    }
+
+    public boolean hasUnfiling() {
+        return true;
+    }
+
+    public boolean hasVersionSpecificFiling() {
+        return false;
+    }
+
+    public boolean isPWCSearchable() {
+        return false;
+    }
+
+    public boolean isPWCUpdatable() {
+        return false;
+    }
+}

Propchange: jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCRRepository.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCRRepository.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url