Reduce CMS size
authorMathieu Baudier <mbaudier@argeo.org>
Sat, 17 Jan 2015 19:02:47 +0000 (19:02 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sat, 17 Jan 2015 19:02:47 +0000 (19:02 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@7684 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

29 files changed:
dep/org.argeo.dep.cms/pom.xml
dep/org.argeo.security.dep.node/pom.xml
org.argeo.cms/bnd.bnd
org.argeo.security.core/src/org/argeo/security/jcr/rememberme/JcrPersistentTokenRepository.java [deleted file]
org.argeo.server.jackrabbit/bnd.bnd
org.argeo.server.jackrabbit/pom.xml
org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/AbstractJackrabbitHandlerMapping.java [deleted file]
org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/ExtendedDispatcherServlet.java [deleted file]
org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/IOHandlerWrapper.java [deleted file]
org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/IOManagerBean.java [deleted file]
org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/JcrRemotingHandlerMapping.java [deleted file]
org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/JcrRemotingServlet.java [deleted file]
org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/OpenInViewSessionProvider.java [deleted file]
org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/ScopedSessionProvider.java [deleted file]
org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/SimpleSessionProvider.java [deleted file]
org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/SimpleWebdavHandlerMapping.java [deleted file]
org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/SimpleWebdavServlet.java [deleted file]
org.argeo.server.jcr.mvc/bnd.bnd
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/AbstractJackrabbitHandlerMapping.java [new file with mode: 0644]
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/ExtendedDispatcherServlet.java [new file with mode: 0644]
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/IOHandlerWrapper.java [new file with mode: 0644]
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/IOManagerBean.java [new file with mode: 0644]
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/JcrRemotingHandlerMapping.java [new file with mode: 0644]
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/JcrRemotingServlet.java [new file with mode: 0644]
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/OpenInViewSessionProvider.java [new file with mode: 0644]
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/ScopedSessionProvider.java [new file with mode: 0644]
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/SimpleSessionProvider.java [new file with mode: 0644]
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/SimpleWebdavHandlerMapping.java [new file with mode: 0644]
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/SimpleWebdavServlet.java [new file with mode: 0644]

index f69418c5aacc54ea4f0e7e103a307d3a4a22e7f2..28ccd858f7c30b7698d40b3d29dbee91ab487d7c 100644 (file)
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<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">
+<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.argeo.commons</groupId>
                        <version>2.1.13-SNAPSHOT</version>
                </dependency>
 
-               <!-- Minimal web target platform -->
+               <!-- Complete target platform -->
                <dependency>
                        <groupId>org.argeo.commons</groupId>
                        <artifactId>org.argeo.security.dep.node</artifactId>
                        <type>pom</type>
                        <version>2.1.13-SNAPSHOT</version>
+               </dependency>
+
+               <!-- Third parties -->
+               <dependency>
+                       <groupId>org.argeo.tp</groupId>
+                       <artifactId>argeo-tp</artifactId>
+                       <version>${version.argeo-distribution}</version>
                        <exclusions>
+                               <!-- Equinox -->
+                               <exclusion>
+                                       <groupId>org.argeo.tp.rap</groupId>
+                                       <artifactId>org.eclipse.equinox.security</artifactId>
+                               </exclusion>
+                               <!-- Databinding -->
+                               <exclusion>
+                                       <groupId>org.argeo.tp.rap.platform</groupId>
+                                       <artifactId>com.ibm.icu.base</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>org.argeo.tp.rap.platform</groupId>
+                                       <artifactId>org.eclipse.rap.jface.databinding</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>org.argeo.tp.rap.platform</groupId>
+                                       <artifactId>org.eclipse.core.databinding</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>org.argeo.tp.rap.platform</groupId>
+                                       <artifactId>org.eclipse.core.databinding.observable</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>org.argeo.tp.rap.platform</groupId>
+                                       <artifactId>org.eclipse.core.databinding.property</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>org.argeo.tp.rap.platform</groupId>
+                                       <artifactId>org.eclipse.core.databinding.beans</artifactId>
+                               </exclusion>
+
                                <!-- Workbench -->
+                               <exclusion>
+                                       <groupId>org.argeo.tp.rap.platform</groupId>
+                                       <artifactId>javax.xml</artifactId>
+                               </exclusion>
                                <exclusion>
                                        <groupId>org.argeo.tp.rap.platform</groupId>
                                        <artifactId>org.eclipse.rap.ui.workbench</artifactId>
                                        <groupId>org.argeo.tp.rap.platform</groupId>
                                        <artifactId>org.eclipse.help</artifactId>
                                </exclusion>
+
+                               <!-- Spring -->
+                               <exclusion>
+                                       <groupId>org.argeo.tp.spring</groupId>
+                                       <artifactId>org.springframework.jdbc</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>org.argeo.tp.spring</groupId>
+                                       <artifactId>org.springframework.web</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>org.argeo.tp.spring</groupId>
+                                       <artifactId>org.springframework.web.servlet</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>org.argeo.tp.spring</groupId>
+                                       <artifactId>org.springframework.ldap</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>org.argeo.tp.spring</groupId>
+                                       <artifactId>org.springframework.aspects</artifactId>
+                               </exclusion>
+
+                               <!-- Spring Security -->
+                               <exclusion>
+                                       <groupId>org.argeo.tp.spring.security</groupId>
+                                       <artifactId>org.springframework.security.aspects</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>org.argeo.tp.spring.security</groupId>
+                                       <artifactId>org.springframework.security.ldap</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>org.argeo.tp.spring.security</groupId>
+                                       <artifactId>org.springframework.security.web</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>org.argeo.tp.spring.security</groupId>
+                                       <artifactId>org.springframework.security.config</artifactId>
+                               </exclusion>
+
+                               <!-- Apache -->
+                               <exclusion>
+                                       <groupId>org.argeo.tp.apache</groupId>
+                                       <artifactId>org.apache.tika.parser</artifactId>
+                               </exclusion>
+                               <!-- <exclusion> -->
+                               <!-- <groupId>org.argeo.tp.apache.commons</groupId> -->
+                               <!-- <artifactId>org.apache.commons.vfs</artifactId> -->
+                               <!-- </exclusion> -->
+
+                               <!-- Bouncycastle -->
+                               <!-- <exclusion> -->
+                               <!-- <groupId>org.argeo.tp.bouncycastle</groupId> -->
+                               <!-- <artifactId>bcpkix</artifactId> -->
+                               <!-- </exclusion> -->
+                               <!-- <exclusion> -->
+                               <!-- <groupId>org.argeo.tp.bouncycastle</groupId> -->
+                               <!-- <artifactId>bcmail</artifactId> -->
+                               <!-- </exclusion> -->
+
+                               <!-- Misc -->
+                               <!-- <exclusion> -->
+                               <!-- <groupId>org.argeo.tp</groupId> -->
+                               <!-- <artifactId>org.junit</artifactId> -->
+                               <!-- </exclusion> -->
+                               <exclusion>
+                                       <groupId>org.argeo.tp</groupId>
+                                       <artifactId>org.joda.time</artifactId>
+                               </exclusion>
+                               <!-- <exclusion> -->
+                               <!-- <groupId>org.argeo.tp.javax</groupId> -->
+                               <!-- <artifactId>javax.mail</artifactId> -->
+                               <!-- </exclusion> -->
+                               <exclusion>
+                                       <groupId>org.argeo.tp</groupId>
+                                       <artifactId>org.objectweb.asm</artifactId>
+                               </exclusion>
+                               <!-- <exclusion> -->
+                               <!-- <groupId>org.argeo.tp</groupId> -->
+                               <!-- <artifactId>com.jcraft.jsch</artifactId> -->
+                               <!-- </exclusion> -->
+
+                               <!-- Require org.springframework.core repackaging -->
+                               <!-- <exclusion> -->
+                               <!-- <groupId>org.argeo.tp</groupId> -->
+                               <!-- <artifactId>org.aspectj.weaver</artifactId> -->
+                               <!-- </exclusion> -->
+                               <!-- <exclusion> -->
+                               <!-- <groupId>org.argeo.tp.apache.ant</groupId> -->
+                               <!-- <artifactId>org.apache.ant</artifactId> -->
+                               <!-- </exclusion> -->
+                               <!-- <exclusion> -->
+                               <!-- <groupId>org.argeo.tp.apache.ant</groupId> -->
+                               <!-- <artifactId>org.apache.ant.launch</artifactId> -->
+                               <!-- </exclusion> -->
                        </exclusions>
                </dependency>
+
        </dependencies>
+       <profiles>
+               <profile>
+                       <id>check-osgi</id>
+                       <build>
+                               <plugins>
+                                       <plugin>
+                                               <groupId>org.argeo.maven.plugins</groupId>
+                                               <artifactId>maven-argeo-osgi-plugin</artifactId>
+                                               <executions>
+                                                       <execution>
+                                                               <id>check-osgi</id>
+                                                               <phase>test</phase>
+                                                               <goals>
+                                                                       <goal>equinox</goal>
+                                                               </goals>
+                                                               <configuration>
+                                                                       <onlyCheck>true</onlyCheck>
+                                                               </configuration>
+                                                       </execution>
+                                               </executions>
+                                       </plugin>
+                               </plugins>
+                       </build>
+               </profile>
+       </profiles>
 </project>
\ No newline at end of file
index 559ca8c8d8613e3f92fc80048152eff2413be2ab..27efb4fa1f72ae746fa060aa0a763ed8a9ae0ab1 100644 (file)
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<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">
+<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.argeo.commons</groupId>
                        <artifactId>org.argeo.security.dao.jackrabbit</artifactId>
                        <version>2.1.13-SNAPSHOT</version>
                </dependency>
-
-               <!-- Security (Standalone) -->
-               <!--  <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.security.dao.os</artifactId>
-                       <version>2.1.12-SNAPSHOT</version>
-               </dependency>
- -->
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.server.jcr.mvc</artifactId>
-                       <version>2.1.13-SNAPSHOT</version>
-               </dependency>
        </dependencies>
        <profiles>
                <profile>
index 149e66fde3d6dd090a1887661c25f5919c3ed963..48343c42d87bffe3e87e658984b90daafa78c14b 100644 (file)
@@ -6,6 +6,5 @@ Import-Package: org.springframework.core,\
                                javax.jcr.security,\
                                org.eclipse.swt.widgets;version="0.0.0",\
                                org.eclipse.rap.*;resolution:=optional,\
+                               org.argeo.jackrabbit.*;resolution:=optional,\
                                *
-# Useless
-#Private-Package: org.argeo.cms.internal.*
\ No newline at end of file
diff --git a/org.argeo.security.core/src/org/argeo/security/jcr/rememberme/JcrPersistentTokenRepository.java b/org.argeo.security.core/src/org/argeo/security/jcr/rememberme/JcrPersistentTokenRepository.java
deleted file mode 100644 (file)
index a573b6a..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed 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.argeo.security.jcr.rememberme;
-
-import java.util.Date;
-
-import org.springframework.security.web.authentication.rememberme.PersistentRememberMeToken;
-import org.springframework.security.web.authentication.rememberme.PersistentTokenRepository;
-
-public class JcrPersistentTokenRepository implements PersistentTokenRepository {
-
-       public void createNewToken(PersistentRememberMeToken token) {
-               // TODO Auto-generated method stub
-
-       }
-
-       public void updateToken(String series, String tokenValue, Date lastUsed) {
-               // TODO Auto-generated method stub
-
-       }
-
-       public PersistentRememberMeToken getTokenForSeries(String seriesId) {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       public void removeUserTokens(String username) {
-               // TODO Auto-generated method stub
-
-       }
-
-}
index df9b79b1bbf8578a5aa4c67f9505c5478f237b65..785086f75d8c0ec8ed0fc3a2ca28b42f8f9e4dc7 100644 (file)
@@ -1,6 +1,5 @@
 Import-Package: javax.servlet,\
 org.apache.jackrabbit.webdav.server,\
-org.springframework.web.context,\
 org.osgi.framework;version="0.0.0",\
 org.xml.sax;version="0.0.0",\
 org.apache.jackrabbit.webdav.jcr,\
index 3ba4cc80bb5decd1933b296948424a242d03d64b..c42cc6c00b952195205c17306a429e308c964e98 100644 (file)
                </dependency>
                <dependency>
                        <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.server.jcr.mvc</artifactId>
+                       <artifactId>org.argeo.server.jcr</artifactId>
                        <version>2.1.13-SNAPSHOT</version>
                </dependency>
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.commons</groupId> -->
+<!--                   <artifactId>org.argeo.server.jcr.mvc</artifactId> -->
+<!--                   <version>2.1.13-SNAPSHOT</version> -->
+<!--                   <scope>compile</scope> -->
+<!--           </dependency> -->
 
                <!-- Jackrabbit -->
 <!--           <dependency> -->
diff --git a/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/AbstractJackrabbitHandlerMapping.java b/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/AbstractJackrabbitHandlerMapping.java
deleted file mode 100644 (file)
index 99bfab4..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed 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.argeo.jackrabbit.remote;
-
-import org.apache.jackrabbit.server.SessionProvider;
-import org.argeo.jcr.mvc.MultipleRepositoryHandlerMapping;
-
-/** Base class for Jackrabbit handler mappings. */
-public abstract class AbstractJackrabbitHandlerMapping extends
-               MultipleRepositoryHandlerMapping {
-       private SessionProvider sessionProvider;
-
-       protected SessionProvider getSessionProvider() {
-               return sessionProvider;
-       }
-
-       public void setSessionProvider(SessionProvider sessionProvider) {
-               this.sessionProvider = sessionProvider;
-       }
-
-}
diff --git a/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/ExtendedDispatcherServlet.java b/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/ExtendedDispatcherServlet.java
deleted file mode 100644 (file)
index 14b6e99..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed 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.argeo.jackrabbit.remote;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.ArgeoException;
-import org.springframework.web.servlet.DispatcherServlet;
-
-/**
- * Overrides Spring {@link DispatcherServlet}, see
- * http://forum.springsource.org/showthread.php?t=53472.
- */
-public class ExtendedDispatcherServlet extends DispatcherServlet {
-       private static final long serialVersionUID = -5584673209855752009L;
-
-       private final static Log log = LogFactory
-                       .getLog(ExtendedDispatcherServlet.class);
-
-       protected void service(HttpServletRequest request,
-                       HttpServletResponse response) throws ServletException,
-                       java.io.IOException {
-               try {
-                       if (log.isTraceEnabled()) {
-                               log.trace("SessionID    = " + request.getSession().getId());
-                               log.trace(" ContextPath = " + request.getContextPath());
-                               log.trace(" ServletPath = " + request.getServletPath());
-                               log.trace(" PathInfo    = " + request.getPathInfo());
-                               log.trace(" Method      = " + request.getMethod());
-                               log.trace(" User-Agent  = " + request.getHeader("User-Agent"));
-                       }
-                       doService(request, response);
-               } catch (Exception e) {
-                       throw new ArgeoException("Cannot process request", e);
-               }
-       }
-
-}
diff --git a/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/IOHandlerWrapper.java b/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/IOHandlerWrapper.java
deleted file mode 100644 (file)
index daf2ecb..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed 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.argeo.jackrabbit.remote;
-
-import java.io.IOException;
-
-import org.apache.jackrabbit.server.io.ExportContext;
-import org.apache.jackrabbit.server.io.IOHandler;
-import org.apache.jackrabbit.server.io.IOManager;
-import org.apache.jackrabbit.server.io.ImportContext;
-import org.apache.jackrabbit.webdav.DavResource;
-import org.argeo.ArgeoException;
-
-/** Wraps an IOHandler so that it can be injected a posteriori */
-public class IOHandlerWrapper implements IOHandler {
-       private IOManager ioManager = null;
-       private IOHandler ioHandler = null;
-
-       public void setIOHandler(IOHandler ioHandler) {
-               if ((this.ioHandler != null) && (ioHandler != null))
-                       throw new ArgeoException(
-                                       "There is already an IO Handler registered");
-               this.ioHandler = ioHandler;
-               if (ioManager != null && this.ioHandler != null)
-                       ioHandler.setIOManager(ioManager);
-       }
-
-       public IOHandler getIOHandler() {
-               return ioHandler;
-       }
-
-       public IOManager getIOManager() {
-               return ioManager;
-       }
-
-       public void setIOManager(IOManager ioManager) {
-               this.ioManager = ioManager;
-               if (ioHandler != null)
-                       ioHandler.setIOManager(ioManager);
-       }
-
-       public String getName() {
-               if (ioHandler != null)
-                       return ioHandler.getName();
-               else
-                       return "Empty IOHandler Wrapper";
-       }
-
-       public boolean canImport(ImportContext context, boolean isCollection) {
-               if (ioHandler != null)
-                       return ioHandler.canImport(context, isCollection);
-               return false;
-       }
-
-       public boolean canImport(ImportContext context, DavResource resource) {
-               if (ioHandler != null)
-                       return ioHandler.canImport(context, resource);
-               return false;
-       }
-
-       public boolean importContent(ImportContext context, boolean isCollection)
-                       throws IOException {
-               if (ioHandler != null)
-                       ioHandler.importContent(context, isCollection);
-               return false;
-       }
-
-       public boolean importContent(ImportContext context, DavResource resource)
-                       throws IOException {
-               if (ioHandler != null)
-                       ioHandler.importContent(context, resource);
-               return false;
-       }
-
-       public boolean canExport(ExportContext context, boolean isCollection) {
-               if (ioHandler != null)
-                       ioHandler.canExport(context, isCollection);
-               return false;
-       }
-
-       public boolean canExport(ExportContext context, DavResource resource) {
-               if (ioHandler != null)
-                       ioHandler.canExport(context, resource);
-               return false;
-       }
-
-       public boolean exportContent(ExportContext context, boolean isCollection)
-                       throws IOException {
-               if (ioHandler != null)
-                       ioHandler.exportContent(context, isCollection);
-               return false;
-       }
-
-       public boolean exportContent(ExportContext context, DavResource resource)
-                       throws IOException {
-               if (ioHandler != null)
-                       ioHandler.exportContent(context, resource);
-               return false;
-       }
-
-}
diff --git a/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/IOManagerBean.java b/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/IOManagerBean.java
deleted file mode 100644 (file)
index 82a7673..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed 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.argeo.jackrabbit.remote;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.jackrabbit.server.io.ExportContext;
-import org.apache.jackrabbit.server.io.IOHandler;
-import org.apache.jackrabbit.server.io.IOManager;
-import org.apache.jackrabbit.server.io.ImportContext;
-import org.apache.jackrabbit.webdav.DavResource;
-import org.apache.tika.detect.Detector;
-
-/** {@link IOManager} that can easily be configured as a bean. */
-public class IOManagerBean implements IOManager {
-       private Detector detector = null;
-       private List<IOHandler> ioHandlers = new ArrayList<IOHandler>();
-
-       public boolean importContent(ImportContext context, boolean isCollection)
-                       throws IOException {
-               // TODO Auto-generated method stub
-               return false;
-       }
-
-       public boolean importContent(ImportContext context, DavResource resource)
-                       throws IOException {
-               // TODO Auto-generated method stub
-               return false;
-       }
-
-       public boolean exportContent(ExportContext context, boolean isCollection)
-                       throws IOException {
-               // TODO Auto-generated method stub
-               return false;
-       }
-
-       public boolean exportContent(ExportContext context, DavResource resource)
-                       throws IOException {
-               // TODO Auto-generated method stub
-               return false;
-       }
-
-       public synchronized void addIOHandler(IOHandler ioHandler) {
-               ioHandlers.add(ioHandler);
-       }
-
-       public synchronized IOHandler[] getIOHandlers() {
-               return ioHandlers.toArray(new IOHandler[ioHandlers.size()]);
-       }
-
-       public Detector getDetector() {
-               return detector;
-       }
-
-       public void setDetector(Detector detector) {
-               this.detector = detector;
-       }
-
-       public synchronized List<IOHandler> getIoHandlers() {
-               return ioHandlers;
-       }
-
-       public synchronized void setIoHandlers(List<IOHandler> ioHandlers) {
-               this.ioHandlers = ioHandlers;
-       }
-
-}
diff --git a/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/JcrRemotingHandlerMapping.java b/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/JcrRemotingHandlerMapping.java
deleted file mode 100644 (file)
index caea5fc..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed 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.argeo.jackrabbit.remote;
-
-import java.util.Properties;
-
-import javax.jcr.Repository;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-
-public class JcrRemotingHandlerMapping extends AbstractJackrabbitHandlerMapping {
-
-       protected HttpServlet createServlet(Repository repository, String pathPrefix)
-                       throws ServletException {
-               JcrRemotingServlet servlet = new JcrRemotingServlet(repository,
-                               getSessionProvider());
-               Properties initParameters = new Properties();
-               initParameters.setProperty(
-                               JcrRemotingServlet.INIT_PARAM_RESOURCE_PATH_PREFIX, pathPrefix);
-               servlet.init(new DelegatingServletConfig(pathPrefix.replace('/', '_'),
-                               initParameters));
-               return servlet;
-       }
-}
diff --git a/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/JcrRemotingServlet.java b/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/JcrRemotingServlet.java
deleted file mode 100644 (file)
index b3f0797..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed 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.argeo.jackrabbit.remote;
-
-import javax.jcr.Repository;
-
-import org.apache.jackrabbit.server.SessionProvider;
-
-public class JcrRemotingServlet extends
-               org.apache.jackrabbit.server.remoting.davex.JcrRemotingServlet {
-
-       private static final long serialVersionUID = 3131835511468341309L;
-
-       private final Repository repository;
-       private final SessionProvider sessionProvider;
-
-       public JcrRemotingServlet(Repository repository,
-                       SessionProvider sessionProvider) {
-               this.repository = repository;
-               this.sessionProvider = sessionProvider;
-       }
-
-       @Override
-       protected Repository getRepository() {
-               return repository;
-       }
-
-       @Override
-       protected SessionProvider getSessionProvider() {
-               return sessionProvider;
-       }
-
-}
diff --git a/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/OpenInViewSessionProvider.java b/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/OpenInViewSessionProvider.java
deleted file mode 100644 (file)
index b4d1d60..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed 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.argeo.jackrabbit.remote;
-
-import java.io.Serializable;
-
-import javax.jcr.LoginException;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jackrabbit.server.SessionProvider;
-import org.argeo.jcr.JcrUtils;
-
-/**
- * Implements an open session in view patter: a new JCR session is created for
- * each request
- */
-public class OpenInViewSessionProvider implements SessionProvider, Serializable {
-       private static final long serialVersionUID = 2270957712453841368L;
-
-       private final static Log log = LogFactory
-                       .getLog(OpenInViewSessionProvider.class);
-
-       public Session getSession(HttpServletRequest request, Repository rep,
-                       String workspace) throws LoginException, ServletException,
-                       RepositoryException {
-               return login(request, rep, workspace);
-       }
-
-       protected Session login(HttpServletRequest request, Repository repository,
-                       String workspace) throws RepositoryException {
-               if (log.isTraceEnabled())
-                       log.trace("Login to workspace "
-                                       + (workspace == null ? "<default>" : workspace)
-                                       + " in web session " + request.getSession().getId());
-               return repository.login(workspace);
-       }
-
-       public void releaseSession(Session session) {
-               JcrUtils.logoutQuietly(session);
-               if (log.isTraceEnabled())
-                       log.trace("Logged out remote JCR session " + session);
-       }
-
-       public void init() {
-       }
-
-       public void destroy() {
-       }
-
-}
diff --git a/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/ScopedSessionProvider.java b/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/ScopedSessionProvider.java
deleted file mode 100644 (file)
index 931f697..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed 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.argeo.jackrabbit.remote;
-
-import java.io.Serializable;
-
-import javax.jcr.LoginException;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jackrabbit.server.SessionProvider;
-import org.argeo.ArgeoException;
-import org.argeo.jcr.ArgeoJcrConstants;
-import org.argeo.jcr.JcrUtils;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
-
-/**
- * Session provider assuming a single workspace and a short life cycle,
- * typically a Spring bean of scope (web) 'session'.
- */
-public class ScopedSessionProvider implements SessionProvider, Serializable {
-       private static final long serialVersionUID = 6589775984177317058L;
-       private static final Log log = LogFactory
-                       .getLog(ScopedSessionProvider.class);
-       private transient HttpSession httpSession = null;
-       private transient Session jcrSession = null;
-
-       private transient String currentRepositoryName = null;
-       private transient String currentWorkspaceName = null;
-       private transient String currentJcrUser = null;
-
-       // private transient String anonymousUserId = "anonymous";
-
-       public Session getSession(HttpServletRequest request, Repository rep,
-                       String workspace) throws LoginException, ServletException,
-                       RepositoryException {
-
-               Authentication authentication = SecurityContextHolder.getContext()
-                               .getAuthentication();
-               if (authentication == null)
-                       throw new ArgeoException(
-                                       "Request not authenticated by Spring Security");
-               String springUser = authentication.getName();
-
-               // HTTP
-               String requestJcrRepository = (String) request
-                               .getAttribute(ArgeoJcrConstants.JCR_REPOSITORY_ALIAS);
-
-               // HTTP session
-               if (httpSession != null
-                               && !httpSession.getId().equals(request.getSession().getId()))
-                       throw new ArgeoException(
-                                       "Only session scope is supported in this mode");
-               if (httpSession == null)
-                       httpSession = request.getSession();
-
-               // Initializes current values
-               if (currentRepositoryName == null)
-                       currentRepositoryName = requestJcrRepository;
-               if (currentWorkspaceName == null)
-                       currentWorkspaceName = workspace;
-               if (currentJcrUser == null)
-                       currentJcrUser = springUser;
-
-               // logout if there was a change in session coordinates
-               if (jcrSession != null)
-                       if (!currentRepositoryName.equals(requestJcrRepository)) {
-                               if (log.isDebugEnabled())
-                                       log.debug(getHttpSessionId() + " Changed from repository '"
-                                                       + currentRepositoryName + "' to '"
-                                                       + requestJcrRepository
-                                                       + "', logging out cached JCR session.");
-                               logout();
-                       } else if (!currentWorkspaceName.equals(workspace)) {
-                               if (log.isDebugEnabled())
-                                       log.debug(getHttpSessionId() + " Changed from workspace '"
-                                                       + currentWorkspaceName + "' to '" + workspace
-                                                       + "', logging out cached JCR session.");
-                               logout();
-                       } else if (!currentJcrUser.equals(springUser)) {
-                               if (log.isDebugEnabled())
-                                       log.debug(getHttpSessionId() + " Changed from user '"
-                                                       + currentJcrUser + "' to '" + springUser
-                                                       + "', logging out cached JCR session.");
-                               logout();
-                       }
-
-               // login if needed
-               if (jcrSession == null)
-                       try {
-                               Session session = login(rep, workspace);
-                               if (!session.getUserID().equals(springUser)) {
-                                       JcrUtils.logoutQuietly(session);
-                                       throw new ArgeoException("Spring Security user '"
-                                                       + springUser + "' not in line with JCR user '"
-                                                       + session.getUserID() + "'");
-                               }
-                               currentRepositoryName = requestJcrRepository;
-                               // do not use workspace variable which may be null
-                               currentWorkspaceName = session.getWorkspace().getName();
-                               currentJcrUser = session.getUserID();
-
-                               jcrSession = session;
-                               return jcrSession;
-                       } catch (RepositoryException e) {
-                               throw new ArgeoException("Cannot open session to workspace "
-                                               + workspace, e);
-                       }
-
-               // returns cached session
-               return jcrSession;
-       }
-
-       protected Session login(Repository repository, String workspace)
-                       throws RepositoryException {
-               Session session = repository.login(workspace);
-               if (log.isDebugEnabled())
-                       log.debug(getHttpSessionId() + " User '" + session.getUserID()
-                                       + "' logged in workspace '"
-                                       + session.getWorkspace().getName() + "' of repository '"
-                                       + currentRepositoryName + "'");
-               return session;
-       }
-
-       public void releaseSession(Session session) {
-               if (log.isTraceEnabled())
-                       log.trace(getHttpSessionId() + " Releasing JCR session " + session);
-       }
-
-       protected void logout() {
-               JcrUtils.logoutQuietly(jcrSession);
-               jcrSession = null;
-       }
-
-       protected final String getHttpSessionId() {
-               return httpSession != null ? httpSession.getId() : "<null>";
-       }
-
-       public void init() {
-       }
-
-       public void destroy() {
-               logout();
-               if (getHttpSessionId() != null)
-                       if (log.isDebugEnabled())
-                               log.debug(getHttpSessionId()
-                                               + " Cleaned up provider for web session ");
-               httpSession = null;
-       }
-
-}
diff --git a/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/SimpleSessionProvider.java b/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/SimpleSessionProvider.java
deleted file mode 100644 (file)
index 1d438d5..0000000
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed 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.argeo.jackrabbit.remote;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.LoginException;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.Value;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jackrabbit.api.JackrabbitSession;
-import org.apache.jackrabbit.api.security.user.Group;
-import org.apache.jackrabbit.api.security.user.User;
-import org.apache.jackrabbit.api.security.user.UserManager;
-import org.apache.jackrabbit.server.SessionProvider;
-import org.argeo.ArgeoException;
-import org.argeo.jcr.ArgeoNames;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.jcr.UserJcrUtils;
-
-/**
- * Implements an open session in view patter: a new JCR session is created for
- * each request
- * 
- * @deprecated use {@link ScopedSessionProvider} or
- *             {@link OpenInViewSessionProvider}
- */
-@Deprecated
-public class SimpleSessionProvider implements SessionProvider, Serializable {
-       private static final long serialVersionUID = 2270957712453841368L;
-
-       private final static Log log = LogFactory
-                       .getLog(SimpleSessionProvider.class);
-
-       private transient Map<String, Session> sessions;
-
-       private Boolean openSessionInView = true;
-
-       private String defaultWorkspace = "default";
-
-       private String webSessionId = null;
-
-       public Session getSession(HttpServletRequest request, Repository rep,
-                       String workspace) throws LoginException, ServletException,
-                       RepositoryException {
-
-               if (openSessionInView) {
-                       JackrabbitSession session = (JackrabbitSession) login(request, rep,
-                                       workspace);
-                       if (session.getWorkspace().getName().equals(defaultWorkspace))
-                               writeRemoteRoles(session);
-                       return session;
-               } else {
-                       if (webSessionId != null
-                                       && !webSessionId.equals(request.getSession().getId()))
-                               throw new ArgeoException(
-                                               "Only session scope is supported in this mode");
-                       webSessionId = request.getSession().getId();
-
-                       // since sessions is transient it can't be restored from the session
-                       if (sessions == null)
-                               sessions = Collections
-                                               .synchronizedMap(new HashMap<String, Session>());
-
-                       if (!sessions.containsKey(workspace)) {
-                               try {
-                                       // JackrabbitSession session = (JackrabbitSession)
-                                       // rep.login(
-                                       // null, workspace);
-                                       JackrabbitSession session = (JackrabbitSession) login(
-                                                       request, rep, workspace);
-                                       if (session.getWorkspace().getName()
-                                                       .equals(defaultWorkspace))
-                                               writeRemoteRoles(session);
-                                       if (log.isTraceEnabled())
-                                               log.trace("User " + session.getUserID()
-                                                               + " logged into " + request.getServletPath());
-                                       sessions.put(workspace, session);
-                                       return session;
-                               } catch (Exception e) {
-                                       throw new ArgeoException("Cannot open session", e);
-                               }
-                       } else {
-                               Session session = sessions.get(workspace);
-                               if (!session.isLive()) {
-                                       sessions.remove(workspace);
-                                       session = login(request, rep, workspace);
-                                       sessions.put(workspace, session);
-                               }
-                               return session;
-                       }
-               }
-       }
-
-       protected Session login(HttpServletRequest request, Repository repository,
-                       String workspace) throws RepositoryException {
-               if (log.isDebugEnabled())
-                       log.debug("Login to workspace "
-                                       + (workspace == null ? "<default>" : workspace)
-                                       + " in web session " + request.getSession().getId());
-               return repository.login(workspace);
-       }
-
-       protected void writeRemoteRoles(JackrabbitSession session)
-                       throws RepositoryException {
-               // FIXME better deal w/ non node repo
-
-               // retrieve roles
-               String userId = session.getUserID();
-               UserManager userManager = session.getUserManager();
-               User user = (User) userManager.getAuthorizable(userId);
-               if (user == null) {
-                       // anonymous
-                       return;
-               }
-               List<String> userGroupIds = new ArrayList<String>();
-               if (user != null)
-                       for (Iterator<Group> it = user.memberOf(); it.hasNext();)
-                               userGroupIds.add(it.next().getID());
-
-               // write roles if needed
-               Node userHome = UserJcrUtils.getUserHome(session);
-               boolean writeRoles = false;
-               if (userHome.hasProperty(ArgeoNames.ARGEO_REMOTE_ROLES)) {
-                       Value[] roles = userHome.getProperty(ArgeoNames.ARGEO_REMOTE_ROLES)
-                                       .getValues();
-                       if (roles.length != userGroupIds.size())
-                               writeRoles = true;
-                       else
-                               for (int i = 0; i < roles.length; i++)
-                                       if (!roles[i].getString().equals(userGroupIds.get(i)))
-                                               writeRoles = true;
-               } else
-                       writeRoles = true;
-
-               if (writeRoles) {
-                       session.getWorkspace().getVersionManager()
-                                       .checkout(userHome.getPath());
-                       String[] roleIds = userGroupIds.toArray(new String[userGroupIds
-                                       .size()]);
-                       userHome.setProperty(ArgeoNames.ARGEO_REMOTE_ROLES, roleIds);
-                       JcrUtils.updateLastModified(userHome);
-                       session.save();
-                       session.getWorkspace().getVersionManager()
-                                       .checkin(userHome.getPath());
-               }
-
-       }
-
-       public void releaseSession(Session session) {
-               if (log.isTraceEnabled())
-                       log.trace("Releasing JCR session " + session);
-               if (openSessionInView) {
-                       JcrUtils.logoutQuietly(session);
-                       if (log.isDebugEnabled())
-                               log.debug("Logged out remote JCR session " + session);
-               }
-       }
-
-       public void init() {
-               if (log.isDebugEnabled())
-                       log.debug("Init session provider for web session " + webSessionId);
-       }
-
-       public void destroy() {
-               if (log.isDebugEnabled())
-                       log.debug("Destroy session provider for web session "
-                                       + webSessionId);
-
-               if (sessions != null)
-                       for (String workspace : sessions.keySet()) {
-                               Session session = sessions.get(workspace);
-                               JcrUtils.logoutQuietly(session);
-                       }
-       }
-
-       /**
-        * If set to true a new session will be created each time (the default),
-        * otherwise a single session is cached by workspace and the object should
-        * be of scope session (not supported)
-        */
-       public void setOpenSessionInView(Boolean openSessionInView) {
-               this.openSessionInView = openSessionInView;
-       }
-
-       public void setSecurityWorkspace(String securityWorkspace) {
-               this.defaultWorkspace = securityWorkspace;
-       }
-
-}
diff --git a/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/SimpleWebdavHandlerMapping.java b/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/SimpleWebdavHandlerMapping.java
deleted file mode 100644 (file)
index bd8d804..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed 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.argeo.jackrabbit.remote;
-
-import java.util.Properties;
-
-import javax.jcr.Repository;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-
-/** Handler mapping for WebDav */
-public class SimpleWebdavHandlerMapping extends
-               AbstractJackrabbitHandlerMapping {
-       private String configuration;
-
-       protected HttpServlet createServlet(Repository repository, String pathPrefix)
-                       throws ServletException {
-
-               SimpleWebdavServlet servlet = new SimpleWebdavServlet(repository,
-                               getSessionProvider());
-               Properties initParameters = new Properties();
-               initParameters.setProperty(
-                               SimpleWebdavServlet.INIT_PARAM_RESOURCE_CONFIG, configuration);
-               initParameters
-                               .setProperty(
-                                               SimpleWebdavServlet.INIT_PARAM_RESOURCE_PATH_PREFIX,
-                                               pathPrefix);
-               servlet.init(new DelegatingServletConfig(pathPrefix.replace('/', '_'),
-                               initParameters));
-               return servlet;
-       }
-
-       public void setConfiguration(String configuration) {
-               this.configuration = configuration;
-       }
-}
diff --git a/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/SimpleWebdavServlet.java b/org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/SimpleWebdavServlet.java
deleted file mode 100644 (file)
index f1ca0a9..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed 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.argeo.jackrabbit.remote;
-
-import java.io.IOException;
-
-import javax.jcr.Repository;
-import javax.servlet.ServletException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jackrabbit.server.SessionProvider;
-import org.apache.jackrabbit.webdav.DavException;
-import org.apache.jackrabbit.webdav.DavResource;
-import org.apache.jackrabbit.webdav.WebdavRequest;
-import org.apache.jackrabbit.webdav.WebdavResponse;
-
-/** WebDav servlet whose repository is injected */
-public class SimpleWebdavServlet extends
-               org.apache.jackrabbit.webdav.simple.SimpleWebdavServlet {
-       private static final long serialVersionUID = -369787931175177080L;
-
-       private final static Log log = LogFactory.getLog(SimpleWebdavServlet.class);
-
-       private final Repository repository;
-
-       public SimpleWebdavServlet(Repository repository,
-                       SessionProvider sessionProvider) {
-               this.repository = repository;
-               setSessionProvider(sessionProvider);
-       }
-
-       public Repository getRepository() {
-               return repository;
-       }
-
-       @Override
-       protected boolean execute(WebdavRequest request, WebdavResponse response,
-                       int method, DavResource resource) throws ServletException,
-                       IOException, DavException {
-               if (log.isTraceEnabled())
-                       log.trace(request.getMethod() + "\t" + request.getPathInfo());
-               boolean res = super.execute(request, response, method, resource);
-               return res;
-       }
-
-}
index b26c2e3ce20c6a6f6748af7aa7b5d91bda2b2774..ce63cf68af3bc1f47136c664829f056beb831dee 100644 (file)
@@ -4,4 +4,6 @@ javax.xml.transform.*;version="0.0.0",\
 javax.xml.parsers.*;version="0.0.0",\
 org.w3c.dom.*;version="0.0.0",\
 org.xml.sax.*;version="0.0.0",\
+org.apache.jackrabbit.server.remoting.davex,\
+org.apache.jackrabbit.webdav.server,\
 *
diff --git a/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/AbstractJackrabbitHandlerMapping.java b/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/AbstractJackrabbitHandlerMapping.java
new file mode 100644 (file)
index 0000000..99bfab4
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed 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.argeo.jackrabbit.remote;
+
+import org.apache.jackrabbit.server.SessionProvider;
+import org.argeo.jcr.mvc.MultipleRepositoryHandlerMapping;
+
+/** Base class for Jackrabbit handler mappings. */
+public abstract class AbstractJackrabbitHandlerMapping extends
+               MultipleRepositoryHandlerMapping {
+       private SessionProvider sessionProvider;
+
+       protected SessionProvider getSessionProvider() {
+               return sessionProvider;
+       }
+
+       public void setSessionProvider(SessionProvider sessionProvider) {
+               this.sessionProvider = sessionProvider;
+       }
+
+}
diff --git a/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/ExtendedDispatcherServlet.java b/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/ExtendedDispatcherServlet.java
new file mode 100644 (file)
index 0000000..14b6e99
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed 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.argeo.jackrabbit.remote;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.ArgeoException;
+import org.springframework.web.servlet.DispatcherServlet;
+
+/**
+ * Overrides Spring {@link DispatcherServlet}, see
+ * http://forum.springsource.org/showthread.php?t=53472.
+ */
+public class ExtendedDispatcherServlet extends DispatcherServlet {
+       private static final long serialVersionUID = -5584673209855752009L;
+
+       private final static Log log = LogFactory
+                       .getLog(ExtendedDispatcherServlet.class);
+
+       protected void service(HttpServletRequest request,
+                       HttpServletResponse response) throws ServletException,
+                       java.io.IOException {
+               try {
+                       if (log.isTraceEnabled()) {
+                               log.trace("SessionID    = " + request.getSession().getId());
+                               log.trace(" ContextPath = " + request.getContextPath());
+                               log.trace(" ServletPath = " + request.getServletPath());
+                               log.trace(" PathInfo    = " + request.getPathInfo());
+                               log.trace(" Method      = " + request.getMethod());
+                               log.trace(" User-Agent  = " + request.getHeader("User-Agent"));
+                       }
+                       doService(request, response);
+               } catch (Exception e) {
+                       throw new ArgeoException("Cannot process request", e);
+               }
+       }
+
+}
diff --git a/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/IOHandlerWrapper.java b/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/IOHandlerWrapper.java
new file mode 100644 (file)
index 0000000..daf2ecb
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed 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.argeo.jackrabbit.remote;
+
+import java.io.IOException;
+
+import org.apache.jackrabbit.server.io.ExportContext;
+import org.apache.jackrabbit.server.io.IOHandler;
+import org.apache.jackrabbit.server.io.IOManager;
+import org.apache.jackrabbit.server.io.ImportContext;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.argeo.ArgeoException;
+
+/** Wraps an IOHandler so that it can be injected a posteriori */
+public class IOHandlerWrapper implements IOHandler {
+       private IOManager ioManager = null;
+       private IOHandler ioHandler = null;
+
+       public void setIOHandler(IOHandler ioHandler) {
+               if ((this.ioHandler != null) && (ioHandler != null))
+                       throw new ArgeoException(
+                                       "There is already an IO Handler registered");
+               this.ioHandler = ioHandler;
+               if (ioManager != null && this.ioHandler != null)
+                       ioHandler.setIOManager(ioManager);
+       }
+
+       public IOHandler getIOHandler() {
+               return ioHandler;
+       }
+
+       public IOManager getIOManager() {
+               return ioManager;
+       }
+
+       public void setIOManager(IOManager ioManager) {
+               this.ioManager = ioManager;
+               if (ioHandler != null)
+                       ioHandler.setIOManager(ioManager);
+       }
+
+       public String getName() {
+               if (ioHandler != null)
+                       return ioHandler.getName();
+               else
+                       return "Empty IOHandler Wrapper";
+       }
+
+       public boolean canImport(ImportContext context, boolean isCollection) {
+               if (ioHandler != null)
+                       return ioHandler.canImport(context, isCollection);
+               return false;
+       }
+
+       public boolean canImport(ImportContext context, DavResource resource) {
+               if (ioHandler != null)
+                       return ioHandler.canImport(context, resource);
+               return false;
+       }
+
+       public boolean importContent(ImportContext context, boolean isCollection)
+                       throws IOException {
+               if (ioHandler != null)
+                       ioHandler.importContent(context, isCollection);
+               return false;
+       }
+
+       public boolean importContent(ImportContext context, DavResource resource)
+                       throws IOException {
+               if (ioHandler != null)
+                       ioHandler.importContent(context, resource);
+               return false;
+       }
+
+       public boolean canExport(ExportContext context, boolean isCollection) {
+               if (ioHandler != null)
+                       ioHandler.canExport(context, isCollection);
+               return false;
+       }
+
+       public boolean canExport(ExportContext context, DavResource resource) {
+               if (ioHandler != null)
+                       ioHandler.canExport(context, resource);
+               return false;
+       }
+
+       public boolean exportContent(ExportContext context, boolean isCollection)
+                       throws IOException {
+               if (ioHandler != null)
+                       ioHandler.exportContent(context, isCollection);
+               return false;
+       }
+
+       public boolean exportContent(ExportContext context, DavResource resource)
+                       throws IOException {
+               if (ioHandler != null)
+                       ioHandler.exportContent(context, resource);
+               return false;
+       }
+
+}
diff --git a/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/IOManagerBean.java b/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/IOManagerBean.java
new file mode 100644 (file)
index 0000000..82a7673
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed 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.argeo.jackrabbit.remote;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.jackrabbit.server.io.ExportContext;
+import org.apache.jackrabbit.server.io.IOHandler;
+import org.apache.jackrabbit.server.io.IOManager;
+import org.apache.jackrabbit.server.io.ImportContext;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.tika.detect.Detector;
+
+/** {@link IOManager} that can easily be configured as a bean. */
+public class IOManagerBean implements IOManager {
+       private Detector detector = null;
+       private List<IOHandler> ioHandlers = new ArrayList<IOHandler>();
+
+       public boolean importContent(ImportContext context, boolean isCollection)
+                       throws IOException {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       public boolean importContent(ImportContext context, DavResource resource)
+                       throws IOException {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       public boolean exportContent(ExportContext context, boolean isCollection)
+                       throws IOException {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       public boolean exportContent(ExportContext context, DavResource resource)
+                       throws IOException {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       public synchronized void addIOHandler(IOHandler ioHandler) {
+               ioHandlers.add(ioHandler);
+       }
+
+       public synchronized IOHandler[] getIOHandlers() {
+               return ioHandlers.toArray(new IOHandler[ioHandlers.size()]);
+       }
+
+       public Detector getDetector() {
+               return detector;
+       }
+
+       public void setDetector(Detector detector) {
+               this.detector = detector;
+       }
+
+       public synchronized List<IOHandler> getIoHandlers() {
+               return ioHandlers;
+       }
+
+       public synchronized void setIoHandlers(List<IOHandler> ioHandlers) {
+               this.ioHandlers = ioHandlers;
+       }
+
+}
diff --git a/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/JcrRemotingHandlerMapping.java b/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/JcrRemotingHandlerMapping.java
new file mode 100644 (file)
index 0000000..caea5fc
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed 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.argeo.jackrabbit.remote;
+
+import java.util.Properties;
+
+import javax.jcr.Repository;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+
+public class JcrRemotingHandlerMapping extends AbstractJackrabbitHandlerMapping {
+
+       protected HttpServlet createServlet(Repository repository, String pathPrefix)
+                       throws ServletException {
+               JcrRemotingServlet servlet = new JcrRemotingServlet(repository,
+                               getSessionProvider());
+               Properties initParameters = new Properties();
+               initParameters.setProperty(
+                               JcrRemotingServlet.INIT_PARAM_RESOURCE_PATH_PREFIX, pathPrefix);
+               servlet.init(new DelegatingServletConfig(pathPrefix.replace('/', '_'),
+                               initParameters));
+               return servlet;
+       }
+}
diff --git a/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/JcrRemotingServlet.java b/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/JcrRemotingServlet.java
new file mode 100644 (file)
index 0000000..b3f0797
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed 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.argeo.jackrabbit.remote;
+
+import javax.jcr.Repository;
+
+import org.apache.jackrabbit.server.SessionProvider;
+
+public class JcrRemotingServlet extends
+               org.apache.jackrabbit.server.remoting.davex.JcrRemotingServlet {
+
+       private static final long serialVersionUID = 3131835511468341309L;
+
+       private final Repository repository;
+       private final SessionProvider sessionProvider;
+
+       public JcrRemotingServlet(Repository repository,
+                       SessionProvider sessionProvider) {
+               this.repository = repository;
+               this.sessionProvider = sessionProvider;
+       }
+
+       @Override
+       protected Repository getRepository() {
+               return repository;
+       }
+
+       @Override
+       protected SessionProvider getSessionProvider() {
+               return sessionProvider;
+       }
+
+}
diff --git a/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/OpenInViewSessionProvider.java b/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/OpenInViewSessionProvider.java
new file mode 100644 (file)
index 0000000..b4d1d60
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed 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.argeo.jackrabbit.remote;
+
+import java.io.Serializable;
+
+import javax.jcr.LoginException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.server.SessionProvider;
+import org.argeo.jcr.JcrUtils;
+
+/**
+ * Implements an open session in view patter: a new JCR session is created for
+ * each request
+ */
+public class OpenInViewSessionProvider implements SessionProvider, Serializable {
+       private static final long serialVersionUID = 2270957712453841368L;
+
+       private final static Log log = LogFactory
+                       .getLog(OpenInViewSessionProvider.class);
+
+       public Session getSession(HttpServletRequest request, Repository rep,
+                       String workspace) throws LoginException, ServletException,
+                       RepositoryException {
+               return login(request, rep, workspace);
+       }
+
+       protected Session login(HttpServletRequest request, Repository repository,
+                       String workspace) throws RepositoryException {
+               if (log.isTraceEnabled())
+                       log.trace("Login to workspace "
+                                       + (workspace == null ? "<default>" : workspace)
+                                       + " in web session " + request.getSession().getId());
+               return repository.login(workspace);
+       }
+
+       public void releaseSession(Session session) {
+               JcrUtils.logoutQuietly(session);
+               if (log.isTraceEnabled())
+                       log.trace("Logged out remote JCR session " + session);
+       }
+
+       public void init() {
+       }
+
+       public void destroy() {
+       }
+
+}
diff --git a/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/ScopedSessionProvider.java b/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/ScopedSessionProvider.java
new file mode 100644 (file)
index 0000000..931f697
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed 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.argeo.jackrabbit.remote;
+
+import java.io.Serializable;
+
+import javax.jcr.LoginException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.server.SessionProvider;
+import org.argeo.ArgeoException;
+import org.argeo.jcr.ArgeoJcrConstants;
+import org.argeo.jcr.JcrUtils;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+
+/**
+ * Session provider assuming a single workspace and a short life cycle,
+ * typically a Spring bean of scope (web) 'session'.
+ */
+public class ScopedSessionProvider implements SessionProvider, Serializable {
+       private static final long serialVersionUID = 6589775984177317058L;
+       private static final Log log = LogFactory
+                       .getLog(ScopedSessionProvider.class);
+       private transient HttpSession httpSession = null;
+       private transient Session jcrSession = null;
+
+       private transient String currentRepositoryName = null;
+       private transient String currentWorkspaceName = null;
+       private transient String currentJcrUser = null;
+
+       // private transient String anonymousUserId = "anonymous";
+
+       public Session getSession(HttpServletRequest request, Repository rep,
+                       String workspace) throws LoginException, ServletException,
+                       RepositoryException {
+
+               Authentication authentication = SecurityContextHolder.getContext()
+                               .getAuthentication();
+               if (authentication == null)
+                       throw new ArgeoException(
+                                       "Request not authenticated by Spring Security");
+               String springUser = authentication.getName();
+
+               // HTTP
+               String requestJcrRepository = (String) request
+                               .getAttribute(ArgeoJcrConstants.JCR_REPOSITORY_ALIAS);
+
+               // HTTP session
+               if (httpSession != null
+                               && !httpSession.getId().equals(request.getSession().getId()))
+                       throw new ArgeoException(
+                                       "Only session scope is supported in this mode");
+               if (httpSession == null)
+                       httpSession = request.getSession();
+
+               // Initializes current values
+               if (currentRepositoryName == null)
+                       currentRepositoryName = requestJcrRepository;
+               if (currentWorkspaceName == null)
+                       currentWorkspaceName = workspace;
+               if (currentJcrUser == null)
+                       currentJcrUser = springUser;
+
+               // logout if there was a change in session coordinates
+               if (jcrSession != null)
+                       if (!currentRepositoryName.equals(requestJcrRepository)) {
+                               if (log.isDebugEnabled())
+                                       log.debug(getHttpSessionId() + " Changed from repository '"
+                                                       + currentRepositoryName + "' to '"
+                                                       + requestJcrRepository
+                                                       + "', logging out cached JCR session.");
+                               logout();
+                       } else if (!currentWorkspaceName.equals(workspace)) {
+                               if (log.isDebugEnabled())
+                                       log.debug(getHttpSessionId() + " Changed from workspace '"
+                                                       + currentWorkspaceName + "' to '" + workspace
+                                                       + "', logging out cached JCR session.");
+                               logout();
+                       } else if (!currentJcrUser.equals(springUser)) {
+                               if (log.isDebugEnabled())
+                                       log.debug(getHttpSessionId() + " Changed from user '"
+                                                       + currentJcrUser + "' to '" + springUser
+                                                       + "', logging out cached JCR session.");
+                               logout();
+                       }
+
+               // login if needed
+               if (jcrSession == null)
+                       try {
+                               Session session = login(rep, workspace);
+                               if (!session.getUserID().equals(springUser)) {
+                                       JcrUtils.logoutQuietly(session);
+                                       throw new ArgeoException("Spring Security user '"
+                                                       + springUser + "' not in line with JCR user '"
+                                                       + session.getUserID() + "'");
+                               }
+                               currentRepositoryName = requestJcrRepository;
+                               // do not use workspace variable which may be null
+                               currentWorkspaceName = session.getWorkspace().getName();
+                               currentJcrUser = session.getUserID();
+
+                               jcrSession = session;
+                               return jcrSession;
+                       } catch (RepositoryException e) {
+                               throw new ArgeoException("Cannot open session to workspace "
+                                               + workspace, e);
+                       }
+
+               // returns cached session
+               return jcrSession;
+       }
+
+       protected Session login(Repository repository, String workspace)
+                       throws RepositoryException {
+               Session session = repository.login(workspace);
+               if (log.isDebugEnabled())
+                       log.debug(getHttpSessionId() + " User '" + session.getUserID()
+                                       + "' logged in workspace '"
+                                       + session.getWorkspace().getName() + "' of repository '"
+                                       + currentRepositoryName + "'");
+               return session;
+       }
+
+       public void releaseSession(Session session) {
+               if (log.isTraceEnabled())
+                       log.trace(getHttpSessionId() + " Releasing JCR session " + session);
+       }
+
+       protected void logout() {
+               JcrUtils.logoutQuietly(jcrSession);
+               jcrSession = null;
+       }
+
+       protected final String getHttpSessionId() {
+               return httpSession != null ? httpSession.getId() : "<null>";
+       }
+
+       public void init() {
+       }
+
+       public void destroy() {
+               logout();
+               if (getHttpSessionId() != null)
+                       if (log.isDebugEnabled())
+                               log.debug(getHttpSessionId()
+                                               + " Cleaned up provider for web session ");
+               httpSession = null;
+       }
+
+}
diff --git a/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/SimpleSessionProvider.java b/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/SimpleSessionProvider.java
new file mode 100644 (file)
index 0000000..1d438d5
--- /dev/null
@@ -0,0 +1,216 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed 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.argeo.jackrabbit.remote;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.LoginException;
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Value;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.api.JackrabbitSession;
+import org.apache.jackrabbit.api.security.user.Group;
+import org.apache.jackrabbit.api.security.user.User;
+import org.apache.jackrabbit.api.security.user.UserManager;
+import org.apache.jackrabbit.server.SessionProvider;
+import org.argeo.ArgeoException;
+import org.argeo.jcr.ArgeoNames;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.jcr.UserJcrUtils;
+
+/**
+ * Implements an open session in view patter: a new JCR session is created for
+ * each request
+ * 
+ * @deprecated use {@link ScopedSessionProvider} or
+ *             {@link OpenInViewSessionProvider}
+ */
+@Deprecated
+public class SimpleSessionProvider implements SessionProvider, Serializable {
+       private static final long serialVersionUID = 2270957712453841368L;
+
+       private final static Log log = LogFactory
+                       .getLog(SimpleSessionProvider.class);
+
+       private transient Map<String, Session> sessions;
+
+       private Boolean openSessionInView = true;
+
+       private String defaultWorkspace = "default";
+
+       private String webSessionId = null;
+
+       public Session getSession(HttpServletRequest request, Repository rep,
+                       String workspace) throws LoginException, ServletException,
+                       RepositoryException {
+
+               if (openSessionInView) {
+                       JackrabbitSession session = (JackrabbitSession) login(request, rep,
+                                       workspace);
+                       if (session.getWorkspace().getName().equals(defaultWorkspace))
+                               writeRemoteRoles(session);
+                       return session;
+               } else {
+                       if (webSessionId != null
+                                       && !webSessionId.equals(request.getSession().getId()))
+                               throw new ArgeoException(
+                                               "Only session scope is supported in this mode");
+                       webSessionId = request.getSession().getId();
+
+                       // since sessions is transient it can't be restored from the session
+                       if (sessions == null)
+                               sessions = Collections
+                                               .synchronizedMap(new HashMap<String, Session>());
+
+                       if (!sessions.containsKey(workspace)) {
+                               try {
+                                       // JackrabbitSession session = (JackrabbitSession)
+                                       // rep.login(
+                                       // null, workspace);
+                                       JackrabbitSession session = (JackrabbitSession) login(
+                                                       request, rep, workspace);
+                                       if (session.getWorkspace().getName()
+                                                       .equals(defaultWorkspace))
+                                               writeRemoteRoles(session);
+                                       if (log.isTraceEnabled())
+                                               log.trace("User " + session.getUserID()
+                                                               + " logged into " + request.getServletPath());
+                                       sessions.put(workspace, session);
+                                       return session;
+                               } catch (Exception e) {
+                                       throw new ArgeoException("Cannot open session", e);
+                               }
+                       } else {
+                               Session session = sessions.get(workspace);
+                               if (!session.isLive()) {
+                                       sessions.remove(workspace);
+                                       session = login(request, rep, workspace);
+                                       sessions.put(workspace, session);
+                               }
+                               return session;
+                       }
+               }
+       }
+
+       protected Session login(HttpServletRequest request, Repository repository,
+                       String workspace) throws RepositoryException {
+               if (log.isDebugEnabled())
+                       log.debug("Login to workspace "
+                                       + (workspace == null ? "<default>" : workspace)
+                                       + " in web session " + request.getSession().getId());
+               return repository.login(workspace);
+       }
+
+       protected void writeRemoteRoles(JackrabbitSession session)
+                       throws RepositoryException {
+               // FIXME better deal w/ non node repo
+
+               // retrieve roles
+               String userId = session.getUserID();
+               UserManager userManager = session.getUserManager();
+               User user = (User) userManager.getAuthorizable(userId);
+               if (user == null) {
+                       // anonymous
+                       return;
+               }
+               List<String> userGroupIds = new ArrayList<String>();
+               if (user != null)
+                       for (Iterator<Group> it = user.memberOf(); it.hasNext();)
+                               userGroupIds.add(it.next().getID());
+
+               // write roles if needed
+               Node userHome = UserJcrUtils.getUserHome(session);
+               boolean writeRoles = false;
+               if (userHome.hasProperty(ArgeoNames.ARGEO_REMOTE_ROLES)) {
+                       Value[] roles = userHome.getProperty(ArgeoNames.ARGEO_REMOTE_ROLES)
+                                       .getValues();
+                       if (roles.length != userGroupIds.size())
+                               writeRoles = true;
+                       else
+                               for (int i = 0; i < roles.length; i++)
+                                       if (!roles[i].getString().equals(userGroupIds.get(i)))
+                                               writeRoles = true;
+               } else
+                       writeRoles = true;
+
+               if (writeRoles) {
+                       session.getWorkspace().getVersionManager()
+                                       .checkout(userHome.getPath());
+                       String[] roleIds = userGroupIds.toArray(new String[userGroupIds
+                                       .size()]);
+                       userHome.setProperty(ArgeoNames.ARGEO_REMOTE_ROLES, roleIds);
+                       JcrUtils.updateLastModified(userHome);
+                       session.save();
+                       session.getWorkspace().getVersionManager()
+                                       .checkin(userHome.getPath());
+               }
+
+       }
+
+       public void releaseSession(Session session) {
+               if (log.isTraceEnabled())
+                       log.trace("Releasing JCR session " + session);
+               if (openSessionInView) {
+                       JcrUtils.logoutQuietly(session);
+                       if (log.isDebugEnabled())
+                               log.debug("Logged out remote JCR session " + session);
+               }
+       }
+
+       public void init() {
+               if (log.isDebugEnabled())
+                       log.debug("Init session provider for web session " + webSessionId);
+       }
+
+       public void destroy() {
+               if (log.isDebugEnabled())
+                       log.debug("Destroy session provider for web session "
+                                       + webSessionId);
+
+               if (sessions != null)
+                       for (String workspace : sessions.keySet()) {
+                               Session session = sessions.get(workspace);
+                               JcrUtils.logoutQuietly(session);
+                       }
+       }
+
+       /**
+        * If set to true a new session will be created each time (the default),
+        * otherwise a single session is cached by workspace and the object should
+        * be of scope session (not supported)
+        */
+       public void setOpenSessionInView(Boolean openSessionInView) {
+               this.openSessionInView = openSessionInView;
+       }
+
+       public void setSecurityWorkspace(String securityWorkspace) {
+               this.defaultWorkspace = securityWorkspace;
+       }
+
+}
diff --git a/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/SimpleWebdavHandlerMapping.java b/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/SimpleWebdavHandlerMapping.java
new file mode 100644 (file)
index 0000000..bd8d804
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed 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.argeo.jackrabbit.remote;
+
+import java.util.Properties;
+
+import javax.jcr.Repository;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+
+/** Handler mapping for WebDav */
+public class SimpleWebdavHandlerMapping extends
+               AbstractJackrabbitHandlerMapping {
+       private String configuration;
+
+       protected HttpServlet createServlet(Repository repository, String pathPrefix)
+                       throws ServletException {
+
+               SimpleWebdavServlet servlet = new SimpleWebdavServlet(repository,
+                               getSessionProvider());
+               Properties initParameters = new Properties();
+               initParameters.setProperty(
+                               SimpleWebdavServlet.INIT_PARAM_RESOURCE_CONFIG, configuration);
+               initParameters
+                               .setProperty(
+                                               SimpleWebdavServlet.INIT_PARAM_RESOURCE_PATH_PREFIX,
+                                               pathPrefix);
+               servlet.init(new DelegatingServletConfig(pathPrefix.replace('/', '_'),
+                               initParameters));
+               return servlet;
+       }
+
+       public void setConfiguration(String configuration) {
+               this.configuration = configuration;
+       }
+}
diff --git a/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/SimpleWebdavServlet.java b/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/SimpleWebdavServlet.java
new file mode 100644 (file)
index 0000000..f1ca0a9
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed 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.argeo.jackrabbit.remote;
+
+import java.io.IOException;
+
+import javax.jcr.Repository;
+import javax.servlet.ServletException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.server.SessionProvider;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.WebdavRequest;
+import org.apache.jackrabbit.webdav.WebdavResponse;
+
+/** WebDav servlet whose repository is injected */
+public class SimpleWebdavServlet extends
+               org.apache.jackrabbit.webdav.simple.SimpleWebdavServlet {
+       private static final long serialVersionUID = -369787931175177080L;
+
+       private final static Log log = LogFactory.getLog(SimpleWebdavServlet.class);
+
+       private final Repository repository;
+
+       public SimpleWebdavServlet(Repository repository,
+                       SessionProvider sessionProvider) {
+               this.repository = repository;
+               setSessionProvider(sessionProvider);
+       }
+
+       public Repository getRepository() {
+               return repository;
+       }
+
+       @Override
+       protected boolean execute(WebdavRequest request, WebdavResponse response,
+                       int method, DavResource resource) throws ServletException,
+                       IOException, DavException {
+               if (log.isTraceEnabled())
+                       log.trace(request.getMethod() + "\t" + request.getPathInfo());
+               boolean res = super.execute(request, response, method, resource);
+               return res;
+       }
+
+}