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