mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
Add POC protocol servlet with delegate to svn and hg
This commit is contained in:
@@ -42,7 +42,6 @@ import sonia.scm.repository.HgRepositoryHandler;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.api.Command;
|
||||
import sonia.scm.repository.api.ScmProtocol;
|
||||
import sonia.scm.web.HgCGIServlet;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -87,16 +86,17 @@ public class HgRepositoryServiceProvider extends RepositoryServiceProvider
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param handler
|
||||
* @param hookManager
|
||||
* @param handler
|
||||
* @param repository
|
||||
* @param httpScmProtocol
|
||||
*/
|
||||
HgRepositoryServiceProvider(HgRepositoryHandler handler,
|
||||
HgHookManager hookManager, Repository repository)
|
||||
HgHookManager hookManager, Repository repository, HttpScmProtocol httpScmProtocol)
|
||||
{
|
||||
this.repository = repository;
|
||||
this.handler = handler;
|
||||
this.httpScmProtocol = httpScmProtocol;
|
||||
this.repositoryDirectory = handler.getDirectory(repository);
|
||||
this.context = new HgCommandContext(hookManager, handler, repository,
|
||||
repositoryDirectory);
|
||||
@@ -276,7 +276,7 @@ public class HgRepositoryServiceProvider extends RepositoryServiceProvider
|
||||
|
||||
@Override
|
||||
public Set<ScmProtocol> getSupportedProtocols() {
|
||||
return Collections.singleton(new HgCGIServlet(null, null, null, null, null, null));
|
||||
return Collections.singleton(httpScmProtocol);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
@@ -292,4 +292,6 @@ public class HgRepositoryServiceProvider extends RepositoryServiceProvider
|
||||
|
||||
/** Field description */
|
||||
private File repositoryDirectory;
|
||||
|
||||
private final HttpScmProtocol httpScmProtocol;
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ package sonia.scm.repository.spi;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import sonia.scm.plugin.Extension;
|
||||
import sonia.scm.repository.HgHookManager;
|
||||
import sonia.scm.repository.HgRepositoryHandler;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.web.HgScmProtocolProviderWrapper;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -65,10 +65,11 @@ public class HgRepositoryServiceResolver implements RepositoryServiceResolver
|
||||
*/
|
||||
@Inject
|
||||
public HgRepositoryServiceResolver(HgRepositoryHandler handler,
|
||||
HgHookManager hookManager)
|
||||
HgHookManager hookManager, HgScmProtocolProviderWrapper httpScmProtocol)
|
||||
{
|
||||
this.handler = handler;
|
||||
this.hookManager = hookManager;
|
||||
this.httpScmProtocol = httpScmProtocol;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
@@ -89,7 +90,7 @@ public class HgRepositoryServiceResolver implements RepositoryServiceResolver
|
||||
if (TYPE.equalsIgnoreCase(repository.getType()))
|
||||
{
|
||||
provider = new HgRepositoryServiceProvider(handler, hookManager,
|
||||
repository);
|
||||
repository, httpScmProtocol);
|
||||
}
|
||||
|
||||
return provider;
|
||||
@@ -102,4 +103,6 @@ public class HgRepositoryServiceResolver implements RepositoryServiceResolver
|
||||
|
||||
/** Field description */
|
||||
private HgHookManager hookManager;
|
||||
|
||||
private final HttpScmProtocol httpScmProtocol;
|
||||
}
|
||||
|
||||
@@ -135,19 +135,6 @@ public class HgCGIServlet extends HttpServlet implements HttpScmProtocol
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws ServletException
|
||||
*/
|
||||
@Override
|
||||
public void init() throws ServletException
|
||||
{
|
||||
|
||||
super.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
@@ -37,27 +37,22 @@ package sonia.scm.web;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import sonia.scm.Priority;
|
||||
import sonia.scm.config.ScmConfiguration;
|
||||
import sonia.scm.filter.Filters;
|
||||
import sonia.scm.filter.WebElement;
|
||||
import sonia.scm.repository.RepositoryProvider;
|
||||
import sonia.scm.web.filter.ProviderPermissionFilter;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Permission filter for mercurial repositories.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Priority(Filters.PRIORITY_AUTHORIZATION)
|
||||
@WebElement(value = HgServletModule.MAPPING_HG)
|
||||
//@Priority(Filters.PRIORITY_AUTHORIZATION)
|
||||
//@WebElement(value = HgServletModule.MAPPING_HG)
|
||||
public class HgPermissionFilter extends ProviderPermissionFilter
|
||||
{
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package sonia.scm.web;
|
||||
|
||||
import sonia.scm.repository.spi.InitializingHttpScmProtocolWrapper;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class HgScmProtocolProviderWrapper extends InitializingHttpScmProtocolWrapper {
|
||||
@Inject
|
||||
public HgScmProtocolProviderWrapper(Provider<HgCGIServlet> servletProvider) {
|
||||
super(servletProvider);
|
||||
}
|
||||
}
|
||||
@@ -81,8 +81,5 @@ public class HgServletModule extends ServletModule
|
||||
|
||||
// bind servlets
|
||||
serve(MAPPING_HOOK).with(HgHookCallbackServlet.class);
|
||||
|
||||
// register hg cgi servlet
|
||||
serve(MAPPING_HG).with(HgCGIServlet.class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user