jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r896857 - in /jackrabbit/trunk: ./ jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/ jackrabbit-jcr2dav/ jackrabbit-jcr2dav/src/ jackrabbit-jcr2dav/src/main/ jackrabbit-jcr2dav/src/main/java/ jackrabbit-jcr2dav/src/main/ja...
Date Thu, 07 Jan 2010 12:13:41 GMT
Author: jukka
Date: Thu Jan  7 12:12:00 2010
New Revision: 896857

URL: http://svn.apache.org/viewvc?rev=896857&view=rev
Log:
JCR-2451: Implement RepositoryFactory in jcr2dav

Added:
    jackrabbit/trunk/jackrabbit-jcr2dav/
    jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml   (with props)
    jackrabbit/trunk/jackrabbit-jcr2dav/src/
    jackrabbit/trunk/jackrabbit-jcr2dav/src/main/
    jackrabbit/trunk/jackrabbit-jcr2dav/src/main/java/
    jackrabbit/trunk/jackrabbit-jcr2dav/src/main/java/org/
    jackrabbit/trunk/jackrabbit-jcr2dav/src/main/java/org/apache/
    jackrabbit/trunk/jackrabbit-jcr2dav/src/main/java/org/apache/jackrabbit/
    jackrabbit/trunk/jackrabbit-jcr2dav/src/main/java/org/apache/jackrabbit/jcr2dav/
    jackrabbit/trunk/jackrabbit-jcr2dav/src/main/java/org/apache/jackrabbit/jcr2dav/Jcr2davRepositoryFactory.java
  (with props)
    jackrabbit/trunk/jackrabbit-jcr2dav/src/main/resources/
    jackrabbit/trunk/jackrabbit-jcr2dav/src/main/resources/META-INF/
    jackrabbit/trunk/jackrabbit-jcr2dav/src/main/resources/META-INF/services/
    jackrabbit/trunk/jackrabbit-jcr2dav/src/main/resources/META-INF/services/javax.jcr.RepositoryFactory
Modified:
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/GenericRepositoryFactory.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/Jcr2spiRepositoryFactory.java
    jackrabbit/trunk/pom.xml

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/GenericRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/GenericRepositoryFactory.java?rev=896857&r1=896856&r2=896857&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/GenericRepositoryFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/GenericRepositoryFactory.java
Thu Jan  7 12:12:00 2010
@@ -124,20 +124,11 @@
                 }
                 parameters.put("org.apache.jackrabbit.repository.home", home);
                 parameters.put("org.apache.jackrabbit.repository.conf", conf);
-            } else if ("http".equalsIgnoreCase(scheme)
-                    || "https".equalsIgnoreCase(scheme)){
-                parameters.put(
-                        "org.apache.jackrabbit.spi.RepositoryServiceFactory",
-                        "org.apache.jackrabbit.spi2davex.Spi2davexRepositoryServiceFactory");
-                parameters.put(
-                        "org.apache.jackrabbit.spi2davex.uri", parameter);
             } else {
-                throw new RepositoryException(
-                        "Unsupported repository URI: " + parameter);
+                return null;
             }
         } catch (URISyntaxException e) {
-            throw new RepositoryException(
-                    "Invalid repository URI: " + parameter, e);
+            return null;
         }
 
         return JcrUtils.getRepository(parameters);

Added: jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml?rev=896857&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml (added)
+++ jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml Thu Jan  7 12:12:00 2010
@@ -0,0 +1,52 @@
+<?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>
+
+<!-- ====================================================================== -->
+<!-- P R O J E C T  D E S C R I P T I O N                                   -->
+<!-- ====================================================================== -->
+  <parent>
+    <groupId>org.apache.jackrabbit</groupId>
+    <artifactId>jackrabbit-parent</artifactId>
+    <version>2.1-SNAPSHOT</version>
+    <relativePath>../jackrabbit-parent/pom.xml</relativePath>
+  </parent>
+  <artifactId>jackrabbit-jcr2dav</artifactId>
+  <name>Jackrabbit JCR to WebDAV</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>javax.jcr</groupId>
+      <artifactId>jcr</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-jcr2spi</artifactId>
+      <version>2.1-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-spi2dav</artifactId>
+      <version>2.1-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+
+</project>

Propchange: jackrabbit/trunk/jackrabbit-jcr2dav/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-jcr2dav/src/main/java/org/apache/jackrabbit/jcr2dav/Jcr2davRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2dav/src/main/java/org/apache/jackrabbit/jcr2dav/Jcr2davRepositoryFactory.java?rev=896857&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2dav/src/main/java/org/apache/jackrabbit/jcr2dav/Jcr2davRepositoryFactory.java
(added)
+++ jackrabbit/trunk/jackrabbit-jcr2dav/src/main/java/org/apache/jackrabbit/jcr2dav/Jcr2davRepositoryFactory.java
Thu Jan  7 12:12:00 2010
@@ -0,0 +1,111 @@
+/*
+ * 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.jcr2dav;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+
+import org.apache.jackrabbit.commons.GenericRepositoryFactory;
+import org.apache.jackrabbit.jcr2spi.RepositoryImpl;
+import org.apache.jackrabbit.jcr2spi.Jcr2spiRepositoryFactory;
+import org.apache.jackrabbit.spi.RepositoryServiceFactory;
+import org.apache.jackrabbit.spi2dav.Spi2davRepositoryServiceFactory;
+import org.apache.jackrabbit.spi2davex.Spi2davexRepositoryServiceFactory;
+
+/**
+ * Repository factory for JCR to WebDAV connections. This factory supports
+ * three main configuration parameters:
+ * <dl>
+ *   <dt>{@link GenericRepositoryFactory#URI org.apache.jackrabbit.repository.uri}</dt>
+ *   <dd>
+ *     If this parameter contains a valid http or https URI, then an spi2davex
+ *     connection to that URI is returned.
+ *   </dd>
+ *   <dt>{@link Spi2davRepositoryServiceFactory#PARAM_REPOSITORY_URI org.apache.jackrabbit.spi2dav.uri}</dt>
+ *   <dd>
+ *     If this parameter is specified, then an spi2dav connection
+ *     to that URI is returned.
+ *   </dd>
+ *   <dt>{@link Spi2davexRepositoryServiceFactory#PARAM_REPOSITORY_URI org.apache.jackrabbit.spi2davex.uri}</dt>
+ *   <dd>
+ *     If this parameter is specified, then an spi2davex connection
+ *     to that URI is returned.
+ *   </dd>
+ * </dl>
+ *
+ * @since Apache Jackrabbit 2.0
+ */
+@SuppressWarnings("unchecked")
+public class Jcr2davRepositoryFactory implements RepositoryFactory {
+
+    private static final String DAV_URI =
+        Spi2davRepositoryServiceFactory.PARAM_REPOSITORY_URI;
+
+    private static final String DAVEX_URI =
+        Spi2davexRepositoryServiceFactory.PARAM_REPOSITORY_URI;
+
+    private static final String GENERIC_URI =
+        GenericRepositoryFactory.URI;
+
+    public Repository getRepository(Map parameters) throws RepositoryException {
+        if (parameters == null) {
+            return null;
+        } else if (parameters.containsKey(DAV_URI)) {
+            return getRepository(
+                    new Spi2davRepositoryServiceFactory(), parameters);
+        } else if (parameters.containsKey(DAVEX_URI)) {
+            return getRepository(
+                    new Spi2davexRepositoryServiceFactory(), parameters);
+        } else if (parameters.containsKey(GENERIC_URI)) {
+            Map copy = new HashMap(parameters);
+            Object parameter = copy.remove(GENERIC_URI);
+            try {
+                URI uri = new URI(parameter.toString().trim());
+                String scheme = uri.getScheme();
+                // TODO: Check whether this is a valid dav or davex URI
+                // TODO: Support tags like <link rel="jackrabbit-spi2dav" ...>
+                if ("http".equalsIgnoreCase(scheme)
+                        || "https".equalsIgnoreCase(scheme)) {
+                    copy.put(DAVEX_URI, parameter);
+                    return getRepository(
+                            new Spi2davexRepositoryServiceFactory(), copy);
+                } else {
+                    return null;
+                }
+            } catch (URISyntaxException e) {
+                return null;
+            }
+        } else {
+            return null;
+        }
+    }
+
+    private Repository getRepository(
+            RepositoryServiceFactory factory, Map parameters)
+            throws RepositoryException {
+        return RepositoryImpl.create(
+                new Jcr2spiRepositoryFactory.RepositoryConfigImpl(
+                        factory, parameters));
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit-jcr2dav/src/main/java/org/apache/jackrabbit/jcr2dav/Jcr2davRepositoryFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-jcr2dav/src/main/resources/META-INF/services/javax.jcr.RepositoryFactory
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2dav/src/main/resources/META-INF/services/javax.jcr.RepositoryFactory?rev=896857&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2dav/src/main/resources/META-INF/services/javax.jcr.RepositoryFactory
(added)
+++ jackrabbit/trunk/jackrabbit-jcr2dav/src/main/resources/META-INF/services/javax.jcr.RepositoryFactory
Thu Jan  7 12:12:00 2010
@@ -0,0 +1,16 @@
+#  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.
+
+org.apache.jackrabbit.jcr2dav.Jcr2davRepositoryFactory

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/Jcr2spiRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/Jcr2spiRepositoryFactory.java?rev=896857&r1=896856&r2=896857&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/Jcr2spiRepositoryFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/Jcr2spiRepositoryFactory.java
Thu Jan  7 12:12:00 2010
@@ -221,7 +221,7 @@
         }
     }
 
-    private static class RepositoryConfigImpl implements RepositoryConfig {
+    public static class RepositoryConfigImpl implements RepositoryConfig {
         private final RepositoryServiceFactory serviceFactory;
         private final CacheBehaviour cacheBehaviour;
         private final int itemCacheSize;

Modified: jackrabbit/trunk/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/pom.xml?rev=896857&r1=896856&r2=896857&view=diff
==============================================================================
--- jackrabbit/trunk/pom.xml (original)
+++ jackrabbit/trunk/pom.xml Thu Jan  7 12:12:00 2010
@@ -50,6 +50,7 @@
     <module>jackrabbit-jcr2spi</module>
     <module>jackrabbit-spi2jcr</module>
     <module>jackrabbit-spi2dav</module>
+    <module>jackrabbit-jcr2dav</module>
     <module>jackrabbit-jcr-client</module>
     <module>jackrabbit-standalone</module>
   </modules>



Mime
View raw message