mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 00:45:44 +01:00
improve handler initialisation
This commit is contained in:
@@ -112,8 +112,14 @@ public class GitRepositoryHandler
|
||||
return GitConfig.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GitConfig createInitialConfig()
|
||||
{
|
||||
return new GitConfig();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private FileRepositoryBuilder builder = new FileRepositoryBuilder();
|
||||
}
|
||||
|
||||
@@ -41,16 +41,12 @@ import org.tmatesoft.svn.core.SVNException;
|
||||
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
|
||||
|
||||
import sonia.scm.Type;
|
||||
import sonia.scm.io.ExtendedCommand;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -109,6 +105,18 @@ public class SvnRepositoryHandler
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected SvnConfig createInitialConfig()
|
||||
{
|
||||
return new SvnConfig();
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@@ -115,8 +115,9 @@ public abstract class AbstractRepositoryHandler<C extends BasicRepositoryConfig>
|
||||
{
|
||||
String name = getType().getName();
|
||||
|
||||
baseDirectory = context.getBaseDirectory();
|
||||
configFile =
|
||||
new File(context.getBaseDirectory(),
|
||||
new File(baseDirectory,
|
||||
"config".concat(File.separator).concat(name).concat(".xml"));
|
||||
loadConfig();
|
||||
}
|
||||
@@ -260,6 +261,9 @@ public abstract class AbstractRepositoryHandler<C extends BasicRepositoryConfig>
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
protected File baseDirectory;
|
||||
|
||||
/** Field description */
|
||||
protected C config;
|
||||
|
||||
|
||||
@@ -68,6 +68,9 @@ public abstract class AbstractSimpleRepositoryHandler<C extends SimpleRepository
|
||||
extends AbstractRepositoryHandler<C>
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
public static final String DIRECTORY_REPOSITORY = "repositories";
|
||||
|
||||
/** Field description */
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(AbstractSimpleRepositoryHandler.class);
|
||||
@@ -142,6 +145,37 @@ public abstract class AbstractSimpleRepositoryHandler<C extends SimpleRepository
|
||||
createConfigDirectory(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void loadConfig()
|
||||
{
|
||||
super.loadConfig();
|
||||
|
||||
if (config == null)
|
||||
{
|
||||
config = createInitialConfig();
|
||||
|
||||
if (config != null)
|
||||
{
|
||||
File repositoryDirectory = config.getRepositoryDirectory();
|
||||
|
||||
if (repositoryDirectory == null)
|
||||
{
|
||||
repositoryDirectory = new File(
|
||||
baseDirectory,
|
||||
DIRECTORY_REPOSITORY.concat(File.separator).concat(
|
||||
getType().getName()));
|
||||
config.setRepositoryDirectory(repositoryDirectory);
|
||||
}
|
||||
|
||||
IOUtil.mkdirs(repositoryDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -301,8 +335,6 @@ public abstract class AbstractSimpleRepositoryHandler<C extends SimpleRepository
|
||||
*/
|
||||
protected void createConfigDirectory(SCMContextProvider context)
|
||||
{
|
||||
File baseDirectory = context.getBaseDirectory();
|
||||
|
||||
configDirectory =
|
||||
new File(baseDirectory,
|
||||
"config".concat(File.separator).concat(getType().getName()));
|
||||
@@ -313,6 +345,17 @@ public abstract class AbstractSimpleRepositoryHandler<C extends SimpleRepository
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected C createInitialConfig()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user