mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 08:55:44 +01:00
use svnkit to create svn repositories
This commit is contained in:
@@ -23,12 +23,22 @@
|
|||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.tmatesoft.svnkit</groupId>
|
||||||
|
<artifactId>svnkit</artifactId>
|
||||||
|
<version>${svnkit.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.tmatesoft.svnkit</groupId>
|
<groupId>org.tmatesoft.svnkit</groupId>
|
||||||
<artifactId>svnkit-dav</artifactId>
|
<artifactId>svnkit-dav</artifactId>
|
||||||
<version>1.3.4</version>
|
<version>${svnkit.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<svnkit.version>1.3.4</svnkit.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -37,12 +37,19 @@ package sonia.scm.repository;
|
|||||||
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
|
import org.tmatesoft.svn.core.SVNException;
|
||||||
|
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
|
||||||
|
|
||||||
import sonia.scm.Type;
|
import sonia.scm.Type;
|
||||||
import sonia.scm.io.ExtendedCommand;
|
import sonia.scm.io.ExtendedCommand;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -85,14 +92,21 @@ public class SvnRepositoryHandler
|
|||||||
* @param repository
|
* @param repository
|
||||||
* @param directory
|
* @param directory
|
||||||
*
|
*
|
||||||
* @return
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected ExtendedCommand buildCreateCommand(Repository repository,
|
protected void create(Repository repository, File directory)
|
||||||
File directory)
|
throws RepositoryException, IOException
|
||||||
{
|
{
|
||||||
return new ExtendedCommand(config.getSvnAdminBinary(), "create",
|
try
|
||||||
directory.getPath());
|
{
|
||||||
|
SVNRepositoryFactory.createLocalRepository(directory, true, false);
|
||||||
|
}
|
||||||
|
catch (SVNException ex)
|
||||||
|
{
|
||||||
|
throw new RepositoryException(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.repository;
|
package sonia.scm.repository;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
@@ -72,18 +74,6 @@ public abstract class AbstractSimpleRepositoryHandler<C extends SimpleRepository
|
|||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param repository
|
|
||||||
* @param directory
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected abstract ExtendedCommand buildCreateCommand(Repository repository,
|
|
||||||
File directory);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -106,19 +96,7 @@ public abstract class AbstractSimpleRepositoryHandler<C extends SimpleRepository
|
|||||||
throw new RepositoryAllreadyExistExeption();
|
throw new RepositoryAllreadyExistExeption();
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtendedCommand cmd = buildCreateCommand(repository, directory);
|
create(repository, directory);
|
||||||
CommandResult result = cmd.execute();
|
|
||||||
|
|
||||||
if (!result.isSuccessfull())
|
|
||||||
{
|
|
||||||
StringBuilder msg = new StringBuilder("command exit with error ");
|
|
||||||
|
|
||||||
msg.append(result.getReturnCode()).append(" and message: '");
|
|
||||||
msg.append(result.getOutput()).append("'");
|
|
||||||
|
|
||||||
throw new RepositoryException(msg.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
postCreate(repository, directory);
|
postCreate(repository, directory);
|
||||||
repository.setType(getType().getName());
|
repository.setType(getType().getName());
|
||||||
storeRepositoryConfig(repository);
|
storeRepositoryConfig(repository);
|
||||||
@@ -273,6 +251,48 @@ public abstract class AbstractSimpleRepositoryHandler<C extends SimpleRepository
|
|||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param repository
|
||||||
|
* @param directory
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected ExtendedCommand buildCreateCommand(Repository repository,
|
||||||
|
File directory)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException("method is not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param repository
|
||||||
|
* @param directory
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
|
*/
|
||||||
|
protected void create(Repository repository, File directory)
|
||||||
|
throws RepositoryException, IOException
|
||||||
|
{
|
||||||
|
ExtendedCommand cmd = buildCreateCommand(repository, directory);
|
||||||
|
CommandResult result = cmd.execute();
|
||||||
|
|
||||||
|
if (!result.isSuccessfull())
|
||||||
|
{
|
||||||
|
StringBuilder msg = new StringBuilder("command exit with error ");
|
||||||
|
|
||||||
|
msg.append(result.getReturnCode()).append(" and message: '");
|
||||||
|
msg.append(result.getOutput()).append("'");
|
||||||
|
|
||||||
|
throw new RepositoryException(msg.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user