Remove JCR MVC
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 10 Feb 2015 08:55:58 +0000 (08:55 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 10 Feb 2015 08:55:58 +0000 (08:55 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@7771 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

18 files changed:
org.argeo.server.jcr.mvc/.classpath [deleted file]
org.argeo.server.jcr.mvc/.project [deleted file]
org.argeo.server.jcr.mvc/bnd.bnd [deleted file]
org.argeo.server.jcr.mvc/build.properties [deleted file]
org.argeo.server.jcr.mvc/pom.xml [deleted file]
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/AbstractJackrabbitHandlerMapping.java [deleted file]
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/ExtendedDispatcherServlet.java [deleted file]
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/IOHandlerWrapper.java [deleted file]
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/IOManagerBean.java [deleted file]
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/JcrRemotingHandlerMapping.java [deleted file]
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/JcrRemotingServlet.java [deleted file]
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/OpenInViewSessionProvider.java [deleted file]
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/ScopedSessionProvider.java [deleted file]
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/SimpleSessionProvider.java [deleted file]
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/SimpleWebdavHandlerMapping.java [deleted file]
org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/SimpleWebdavServlet.java [deleted file]
org.argeo.server.jcr.mvc/src/org/argeo/jcr/mvc/MultipleRepositoryHandlerMapping.java [deleted file]
org.argeo.server.jcr.mvc/src/org/argeo/jcr/mvc/ResourceProxyServlet.java [deleted file]

diff --git a/org.argeo.server.jcr.mvc/.classpath b/org.argeo.server.jcr.mvc/.classpath
deleted file mode 100644 (file)
index d2953a6..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="src" path="src" />
-       <classpathentry kind="con"
-               path="org.eclipse.pde.core.requiredPlugins" />
-       <classpathentry kind="con"
-               path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6" />
-       <classpathentry kind="output" path="bin" />
-</classpath>
diff --git a/org.argeo.server.jcr.mvc/.project b/org.argeo.server.jcr.mvc/.project
deleted file mode 100644 (file)
index 73c19d5..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.argeo.server.jcr.mvc</name>
-       <comment></comment>
-       <projects>
-       </projects>
-       <buildSpec>
-               <buildCommand>
-                       <name>org.eclipse.jdt.core.javabuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.pde.ManifestBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.pde.SchemaBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-       </buildSpec>
-       <natures>
-               <nature>org.eclipse.pde.PluginNature</nature>
-               <nature>org.eclipse.jdt.core.javanature</nature>
-       </natures>
-</projectDescription>
diff --git a/org.argeo.server.jcr.mvc/bnd.bnd b/org.argeo.server.jcr.mvc/bnd.bnd
deleted file mode 100644 (file)
index ce63cf6..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-Import-Package: org.springframework.core,\
-org.springframework.beans.factory,\
-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/build.properties b/org.argeo.server.jcr.mvc/build.properties
deleted file mode 100644 (file)
index 30f7153..0000000
+++ /dev/null
@@ -1 +0,0 @@
-source.. = src/
diff --git a/org.argeo.server.jcr.mvc/pom.xml b/org.argeo.server.jcr.mvc/pom.xml
deleted file mode 100644 (file)
index f907398..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-<?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">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.commons</groupId>
-               <artifactId>argeo-commons</artifactId>
-               <version>2.1.13-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.server.jcr.mvc</artifactId>
-       <name>Commons Server JCR MVC</name>
-       <build>
-               <plugins>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-compiler-plugin</artifactId>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-source-plugin</artifactId>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-jar-plugin</artifactId>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.felix</groupId>
-                               <artifactId>maven-bundle-plugin</artifactId>
-
-                               <configuration>
-                                       <instructions>
-                                               <Export-Package>
-                                                       org.argeo.jcr.mvc.*
-                                               </Export-Package>
-                                               <Import-Package>
-                                                       org.springframework.core,
-                                                       org.springframework.beans.factory,
-                                                       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",
-                                                       *
-                                               </Import-Package>
-                                       </instructions>
-                               </configuration>
-                       </plugin>
-               </plugins>
-       </build>
-       <dependencies>
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.server.jcr</artifactId>
-                       <version>2.1.13-SNAPSHOT</version>
-               </dependency>
-
-               <!-- Spring -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp</groupId> -->
-<!--                   <artifactId>org.springframework.context</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp</groupId> -->
-<!--                   <artifactId>org.springframework.core</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp</groupId> -->
-<!--                   <artifactId>org.springframework.beans</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp</groupId> -->
-<!--                   <artifactId>org.springframework.web</artifactId> -->
-<!--           </dependency> -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp</groupId> -->
-<!--                   <artifactId>org.springframework.web.servlet</artifactId> -->
-<!--           </dependency> -->
-
-               <!-- Logging -->
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.tp</groupId> -->
-<!--                   <artifactId>slf4j.org.apache.commons.logging</artifactId> -->
-<!--           </dependency> -->
-       </dependencies>
-</project>
\ No newline at end of file
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
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.jcr.mvc/src/org/argeo/jackrabbit/remote/ExtendedDispatcherServlet.java b/org.argeo.server.jcr.mvc/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.jcr.mvc/src/org/argeo/jackrabbit/remote/IOHandlerWrapper.java b/org.argeo.server.jcr.mvc/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.jcr.mvc/src/org/argeo/jackrabbit/remote/IOManagerBean.java b/org.argeo.server.jcr.mvc/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.jcr.mvc/src/org/argeo/jackrabbit/remote/JcrRemotingHandlerMapping.java b/org.argeo.server.jcr.mvc/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.jcr.mvc/src/org/argeo/jackrabbit/remote/JcrRemotingServlet.java b/org.argeo.server.jcr.mvc/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.jcr.mvc/src/org/argeo/jackrabbit/remote/OpenInViewSessionProvider.java b/org.argeo.server.jcr.mvc/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.jcr.mvc/src/org/argeo/jackrabbit/remote/ScopedSessionProvider.java b/org.argeo.server.jcr.mvc/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.jcr.mvc/src/org/argeo/jackrabbit/remote/SimpleSessionProvider.java b/org.argeo.server.jcr.mvc/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.jcr.mvc/src/org/argeo/jackrabbit/remote/SimpleWebdavHandlerMapping.java b/org.argeo.server.jcr.mvc/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.jcr.mvc/src/org/argeo/jackrabbit/remote/SimpleWebdavServlet.java b/org.argeo.server.jcr.mvc/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;
-       }
-
-}
diff --git a/org.argeo.server.jcr.mvc/src/org/argeo/jcr/mvc/MultipleRepositoryHandlerMapping.java b/org.argeo.server.jcr.mvc/src/org/argeo/jcr/mvc/MultipleRepositoryHandlerMapping.java
deleted file mode 100644 (file)
index fb3f1ae..0000000
+++ /dev/null
@@ -1,190 +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.jcr.mvc;
-
-import java.util.Enumeration;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import javax.jcr.Repository;
-import javax.jcr.RepositoryFactory;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.ArgeoJcrConstants;
-import org.argeo.jcr.ArgeoJcrUtils;
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.web.context.ServletContextAware;
-import org.springframework.web.servlet.HandlerExecutionChain;
-import org.springframework.web.servlet.HandlerMapping;
-
-/** Handles multiple JCR servers with a single servlet. */
-public abstract class MultipleRepositoryHandlerMapping implements
-               HandlerMapping, ApplicationContextAware, ServletContextAware {
-       private final static Log log = LogFactory
-                       .getLog(MultipleRepositoryHandlerMapping.class);
-
-       private final static String MKCOL = "MKCOL";
-
-       private ConfigurableApplicationContext applicationContext;
-       private ServletContext servletContext;
-
-       // private RepositoryRegister repositoryRegister;
-       private RepositoryFactory repositoryFactory;
-
-       /** Actually creates the servlet to be registered. */
-       protected abstract HttpServlet createServlet(Repository repository,
-                       String pathPrefix) throws ServletException;
-
-       public HandlerExecutionChain getHandler(HttpServletRequest request)
-                       throws Exception {
-               if (log.isTraceEnabled()) {
-                       log.trace("getContextPath=" + request.getContextPath());
-                       log.trace("getServletPath=" + request.getServletPath());
-                       log.trace("getPathInfo=" + request.getPathInfo());
-               }
-
-               String pathInfo = request.getPathInfo();
-               String repositoryAlias = extractRepositoryAlias(pathInfo);
-               if (repositoryAlias.equals(""))
-                       return null;
-
-               // MKCOL on repository or root node doesn't make sense
-               // and causes issues
-               if (request.getMethod().equals(MKCOL)) {
-                       StringTokenizer st = new StringTokenizer(pathInfo, "/");
-                       if (!st.hasMoreTokens())
-                               return null;
-                       st.nextToken();// repository
-                       if (!st.hasMoreTokens())
-                               return null;
-                       st.nextToken();// workspace
-                       if (!st.hasMoreTokens())
-                               return null;
-               }
-
-               request.setAttribute(ArgeoJcrConstants.JCR_REPOSITORY_ALIAS,
-                               repositoryAlias);
-               String pathPrefix = request.getServletPath() + '/' + repositoryAlias;
-               String beanName = pathPrefix;
-
-               if (!applicationContext.containsBean(beanName)) {
-                       Repository repository = ArgeoJcrUtils.getRepositoryByAlias(
-                                       repositoryFactory, repositoryAlias);
-                       // Repository repository = repositoryRegister.getRepositories().get(
-                       // repositoryAlias);
-                       HttpServlet servlet = createServlet(repository, pathPrefix);
-                       applicationContext.getBeanFactory().registerSingleton(beanName,
-                                       servlet);
-                       // TODO: unregister it as well
-               }
-               HttpServlet remotingServlet = (HttpServlet) applicationContext
-                               .getBean(beanName);
-               HandlerExecutionChain hec = new HandlerExecutionChain(remotingServlet);
-               return hec;
-       }
-
-       /** Returns the first two token of the path */
-       // protected String[] extractPrefix(String pathInfo) {
-       // String[] res = new String[2];
-       // StringTokenizer st = new StringTokenizer(pathInfo, "/");
-       // if (st.hasMoreTokens())
-       // res[0] = st.nextToken();
-       // if (st.hasMoreTokens())
-       // res[1] = st.nextToken();
-       // return res;
-       // }
-
-       /** Returns the first token of the path */
-       protected String extractRepositoryAlias(String pathInfo) {
-               StringBuffer buf = new StringBuffer();
-               for (int i = 1; i < pathInfo.length(); i++) {
-                       char c = pathInfo.charAt(i);
-                       if (c == '/')
-                               break;
-                       buf.append(c);
-               }
-               return buf.toString();
-       }
-
-       /** The repository name is the first part of the path info */
-       // protected String extractRepositoryName(List<String> pathTokens) {
-       // StringBuffer currName = new StringBuffer("");
-       // for (String token : pathTokens) {
-       // currName.append(token);
-       // if (repositoryRegister.getRepositories().containsKey(
-       // currName.toString()))
-       // return currName.toString();
-       // currName.append('/');
-       // }
-       // throw new ArgeoException("No repository can be found for request "
-       // + pathTokens);
-       // }
-
-       public void setApplicationContext(ApplicationContext applicationContext)
-                       throws BeansException {
-               this.applicationContext = (ConfigurableApplicationContext) applicationContext;
-       }
-
-       public void setServletContext(ServletContext servletContext) {
-               this.servletContext = servletContext;
-       }
-
-       // public void setRepositoryRegister(RepositoryRegister repositoryRegister)
-       // {
-       // this.repositoryRegister = repositoryRegister;
-       // }
-
-       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
-               this.repositoryFactory = repositoryFactory;
-       }
-
-       protected class DelegatingServletConfig implements ServletConfig {
-               private String name;
-               private Properties initParameters;
-
-               public DelegatingServletConfig(String name, Properties initParameters) {
-                       super();
-                       this.name = name;
-                       this.initParameters = initParameters;
-               }
-
-               public String getServletName() {
-                       return name;
-               }
-
-               public ServletContext getServletContext() {
-                       return servletContext;
-               }
-
-               public String getInitParameter(String paramName) {
-                       return initParameters.getProperty(paramName);
-               }
-
-               @SuppressWarnings("rawtypes")
-               public Enumeration getInitParameterNames() {
-                       return initParameters.keys();
-               }
-       }
-}
diff --git a/org.argeo.server.jcr.mvc/src/org/argeo/jcr/mvc/ResourceProxyServlet.java b/org.argeo.server.jcr.mvc/src/org/argeo/jcr/mvc/ResourceProxyServlet.java
deleted file mode 100644 (file)
index c821be0..0000000
+++ /dev/null
@@ -1,141 +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.jcr.mvc;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.jcr.Binary;
-import javax.jcr.Node;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.ArgeoException;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.jcr.proxy.ResourceProxy;
-
-/** Wraps a proxy via HTTP */
-public class ResourceProxyServlet extends HttpServlet {
-       private static final long serialVersionUID = -8886549549223155801L;
-
-       private final static Log log = LogFactory
-                       .getLog(ResourceProxyServlet.class);
-
-       private ResourceProxy proxy;
-
-       private String contentTypeCharset = "UTF-8";
-
-       @Override
-       protected void doGet(HttpServletRequest request,
-                       HttpServletResponse response) throws ServletException, IOException {
-               String path = request.getPathInfo();
-
-               if (log.isTraceEnabled()) {
-                       log.trace("path=" + path);
-                       log.trace("UserPrincipal = " + request.getUserPrincipal().getName());
-                       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"));
-               }
-
-               Node node = null;
-               try {
-                       node = proxy.proxy(path);
-                       if (node == null)
-                               response.sendError(404);
-                       else
-                               processResponse(node, response);
-               } finally {
-                       if (node != null)
-                               try {
-                                       JcrUtils.logoutQuietly(node.getSession());
-                               } catch (RepositoryException e) {
-                                       // silent
-                               }
-               }
-
-       }
-
-       /** Retrieve the content of the node. */
-       protected void processResponse(Node node, HttpServletResponse response) {
-               Binary binary = null;
-               InputStream in = null;
-               try {
-                       String fileName = node.getName();
-                       String ext = FilenameUtils.getExtension(fileName);
-
-                       // TODO use a more generic / standard approach
-                       // see http://svn.apache.org/viewvc/tomcat/trunk/conf/web.xml
-                       String contentType;
-                       if ("xml".equals(ext))
-                               contentType = "text/xml;charset=" + contentTypeCharset;
-                       else if ("jar".equals(ext))
-                               contentType = "application/java-archive";
-                       else if ("zip".equals(ext))
-                               contentType = "application/zip";
-                       else if ("gz".equals(ext))
-                               contentType = "application/x-gzip";
-                       else if ("bz2".equals(ext))
-                               contentType = "application/x-bzip2";
-                       else if ("tar".equals(ext))
-                               contentType = "application/x-tar";
-                       else if ("rpm".equals(ext))
-                               contentType = "application/x-redhat-package-manager";
-                       else
-                               contentType = "application/octet-stream";
-                       contentType = contentType + ";name=\"" + fileName + "\"";
-                       response.setHeader("Content-Disposition", "attachment; filename=\""
-                                       + fileName + "\"");
-                       response.setHeader("Expires", "0");
-                       response.setHeader("Cache-Control", "no-cache, must-revalidate");
-                       response.setHeader("Pragma", "no-cache");
-
-                       response.setContentType(contentType);
-
-                       try {
-                               binary = node.getNode(Property.JCR_CONTENT)
-                                               .getProperty(Property.JCR_DATA).getBinary();
-                       } catch (PathNotFoundException e) {
-                               log.error("Node " + node + " as no data under content");
-                               throw e;
-                       }
-                       in = binary.getStream();
-                       IOUtils.copy(in, response.getOutputStream());
-               } catch (Exception e) {
-                       throw new ArgeoException("Cannot download " + node, e);
-               } finally {
-                       IOUtils.closeQuietly(in);
-                       JcrUtils.closeQuietly(binary);
-               }
-       }
-
-       public void setProxy(ResourceProxy resourceProxy) {
-               this.proxy = resourceProxy;
-       }
-
-}