improve utils

This commit is contained in:
Sebastian Sdorra
2010-09-28 20:19:18 +02:00
parent af7b7b8e4d
commit 6fec6196a0
19 changed files with 483 additions and 126 deletions

View File

@@ -16,6 +16,7 @@ import sonia.scm.io.INIConfiguration;
import sonia.scm.io.INIConfigurationReader;
import sonia.scm.io.INIConfigurationWriter;
import sonia.scm.io.INISection;
import sonia.scm.util.IOUtil;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
@@ -115,7 +116,7 @@ public class HgRepositoryHandler extends AbstractRepositoryHandler<HgConfig>
if (new File(directory, ".hg").exists())
{
Util.delete(directory);
IOUtil.delete(directory);
}
else
{

View File

@@ -0,0 +1,74 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sonia.scm.web;
//~--- non-JDK imports --------------------------------------------------------
import com.google.inject.Singleton;
import sonia.scm.web.cgi.AbstractCGIServlet;
//~--- JDK imports ------------------------------------------------------------
import java.io.File;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
/**
*
* @author Sebastian Sdorra
*/
@Singleton
public class HgCGIServlet extends AbstractCGIServlet
{
/** Field description */
private static final long serialVersionUID = -3492811300905099810L;
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @throws ServletException
*/
@Override
public void init() throws ServletException
{
command = HgUtil.getCGI();
super.init();
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param req
*
* @return
*
* @throws IOException
* @throws ServletException
*/
@Override
protected File getCommand(HttpServletRequest req)
throws ServletException, IOException
{
return command;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private File command;
}

View File

@@ -9,18 +9,9 @@ package sonia.scm.web;
//~--- non-JDK imports --------------------------------------------------------
import com.google.inject.Scopes;
import com.google.inject.servlet.ServletModule;
import sonia.scm.web.filter.BasicAuthenticationFilter;
import sonia.scm.web.cgi.CGIServlet;
//~--- JDK imports ------------------------------------------------------------
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletContext;
/**
*
@@ -29,19 +20,6 @@ import javax.servlet.ServletContext;
public class HgServletModule extends ServletModule
{
/**
* Constructs ...
*
*
* @param servletContext
*/
HgServletModule(ServletContext servletContext)
{
cgiPath = HgUtil.getCGI().getAbsolutePath();
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
@@ -50,12 +28,7 @@ public class HgServletModule extends ServletModule
protected void configureServlets()
{
filter("/hg/*").through(BasicAuthenticationFilter.class);
Map<String, String> initParams = new HashMap<String, String>();
initParams.put("command", cgiPath);
bind(CGIServlet.class).in(Scopes.SINGLETON);
serve("/hg/*").with(CGIServlet.class, initParams);
serve("/hg/*").with(HgCGIServlet.class);
}
//~--- fields ---------------------------------------------------------------

View File

@@ -15,7 +15,7 @@ import sonia.scm.io.INISection;
import sonia.scm.io.RegexResourceProcessor;
import sonia.scm.io.ResourceProcessor;
import sonia.scm.repository.HgConfig;
import sonia.scm.util.Util;
import sonia.scm.util.IOUtil;
//~--- JDK imports ------------------------------------------------------------
@@ -102,8 +102,8 @@ public class HgWebConfigWriter
}
finally
{
Util.close(input);
Util.close(output);
IOUtil.close(input);
IOUtil.close(output);
}
}

View File

@@ -42,6 +42,6 @@ public class HgWebPlugin implements ScmWebPlugin
public void contextInitialized(ScmWebPluginContext context)
{
context.addScriptResource(new ClasspathWebResource(SCRIPT));
context.addInjectModule(new HgServletModule( context.getServletContext() ));
context.addInjectModule(new HgServletModule());
}
}