mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-03 12:05:52 +01:00
subversion support for directory structures
This commit is contained in:
@@ -36,12 +36,26 @@ package sonia.scm.web;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.tmatesoft.svn.core.internal.server.dav.DAVConfig;
|
||||
import org.tmatesoft.svn.core.internal.server.dav.DAVServlet;
|
||||
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.SvnRepositoryHandler;
|
||||
import sonia.scm.util.AssertUtil;
|
||||
import sonia.scm.util.HttpUtil;
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -61,11 +75,34 @@ public class SvnDAVServlet extends DAVServlet
|
||||
*
|
||||
*
|
||||
* @param handler
|
||||
* @param repositoryProvider
|
||||
*/
|
||||
@Inject
|
||||
public SvnDAVServlet(SvnRepositoryHandler handler)
|
||||
public SvnDAVServlet(SvnRepositoryHandler handler,
|
||||
Provider<Repository> repositoryProvider)
|
||||
{
|
||||
this.handler = handler;
|
||||
this.repositoryProvider = repositoryProvider;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws ServletException
|
||||
*/
|
||||
@Override
|
||||
public void service(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
super.service(new SvnHttpServletRequestWrapper(request,
|
||||
repositoryProvider), response);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
@@ -79,11 +116,103 @@ public class SvnDAVServlet extends DAVServlet
|
||||
@Override
|
||||
protected DAVConfig getDAVConfig()
|
||||
{
|
||||
return new SvnDAVConfig(super.getDAVConfig(), handler.getConfig());
|
||||
return new SvnDAVConfig(super.getDAVConfig(), handler, repositoryProvider);
|
||||
}
|
||||
|
||||
//~--- inner classes --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class description
|
||||
*
|
||||
*
|
||||
* @version Enter version here..., 11/10/23
|
||||
* @author Enter your name here...
|
||||
*/
|
||||
private static class SvnHttpServletRequestWrapper
|
||||
extends HttpServletRequestWrapper
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
* @param repositoryProvider
|
||||
*/
|
||||
public SvnHttpServletRequestWrapper(HttpServletRequest request,
|
||||
Provider<Repository> repositoryProvider)
|
||||
{
|
||||
super(request);
|
||||
this.repositoryProvider = repositoryProvider;
|
||||
}
|
||||
|
||||
//~--- get methods --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getPathInfo()
|
||||
{
|
||||
String pathInfo = super.getPathInfo();
|
||||
|
||||
AssertUtil.assertIsNotEmpty(pathInfo);
|
||||
|
||||
Repository repository = repositoryProvider.get();
|
||||
|
||||
if (repository != null)
|
||||
{
|
||||
if (pathInfo.startsWith(HttpUtil.SEPARATOR_PATH))
|
||||
{
|
||||
pathInfo = pathInfo.substring(1);
|
||||
}
|
||||
|
||||
pathInfo = pathInfo.substring(repository.getName().length());
|
||||
}
|
||||
|
||||
return pathInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getServletPath()
|
||||
{
|
||||
String servletPath = super.getServletPath();
|
||||
Repository repository = repositoryProvider.get();
|
||||
|
||||
if (repository != null)
|
||||
{
|
||||
if (!servletPath.endsWith(HttpUtil.SEPARATOR_PATH))
|
||||
{
|
||||
servletPath = servletPath.concat(HttpUtil.SEPARATOR_PATH);
|
||||
}
|
||||
|
||||
servletPath = servletPath.concat(repository.getName());
|
||||
}
|
||||
|
||||
return servletPath;
|
||||
}
|
||||
|
||||
//~--- fields -------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private Provider<Repository> repositoryProvider;
|
||||
}
|
||||
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private SvnRepositoryHandler handler;
|
||||
|
||||
/** Field description */
|
||||
private Provider<Repository> repositoryProvider;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user