mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
use new store-api
This commit is contained in:
@@ -35,12 +35,14 @@ package sonia.scm.repository;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
|
||||
|
||||
import sonia.scm.Type;
|
||||
import sonia.scm.plugin.ext.Extension;
|
||||
import sonia.scm.store.StoreFactory;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -66,6 +68,20 @@ public class GitRepositoryHandler
|
||||
/** Field description */
|
||||
public static final Type TYPE = new Type(TYPE_NAME, TYPE_DISPLAYNAME);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param storeFactory
|
||||
*/
|
||||
@Inject
|
||||
public GitRepositoryHandler(StoreFactory storeFactory)
|
||||
{
|
||||
super(storeFactory);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,6 +35,7 @@ package sonia.scm.repository;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import sonia.scm.Type;
|
||||
@@ -43,6 +44,7 @@ import sonia.scm.io.INIConfiguration;
|
||||
import sonia.scm.io.INIConfigurationWriter;
|
||||
import sonia.scm.io.INISection;
|
||||
import sonia.scm.plugin.ext.Extension;
|
||||
import sonia.scm.store.StoreFactory;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -68,6 +70,20 @@ public class HgRepositoryHandler
|
||||
/** Field description */
|
||||
public static final Type TYPE = new Type(TYPE_NAME, TYPE_DISPLAYNAME);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param storeFactory
|
||||
*/
|
||||
@Inject
|
||||
public HgRepositoryHandler(StoreFactory storeFactory)
|
||||
{
|
||||
super(storeFactory);
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,6 +35,7 @@ package sonia.scm.repository;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.tmatesoft.svn.core.SVNException;
|
||||
@@ -42,6 +43,7 @@ import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
|
||||
|
||||
import sonia.scm.Type;
|
||||
import sonia.scm.plugin.ext.Extension;
|
||||
import sonia.scm.store.StoreFactory;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -67,6 +69,20 @@ public class SvnRepositoryHandler
|
||||
/** Field description */
|
||||
public static final Type TYPE = new Type(TYPE_NAME, TYPE_DISPLAYNAME);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param storeFactory
|
||||
*/
|
||||
@Inject
|
||||
public SvnRepositoryHandler(StoreFactory storeFactory)
|
||||
{
|
||||
super(storeFactory);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,7 +40,8 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.ConfigChangedListener;
|
||||
import sonia.scm.SCMContextProvider;
|
||||
import sonia.scm.util.IOUtil;
|
||||
import sonia.scm.store.Store;
|
||||
import sonia.scm.store.StoreFactory;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -50,8 +51,6 @@ import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.JAXB;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -66,6 +65,19 @@ public abstract class AbstractRepositoryHandler<C extends SimpleRepositoryConfig
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(AbstractRepositoryHandler.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param storeFactory
|
||||
*/
|
||||
protected AbstractRepositoryHandler(StoreFactory storeFactory)
|
||||
{
|
||||
this.store = storeFactory.getStore(getConfigClass(), getType().getName());
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -115,9 +127,6 @@ public abstract class AbstractRepositoryHandler<C extends SimpleRepositoryConfig
|
||||
String name = getType().getName();
|
||||
|
||||
baseDirectory = context.getBaseDirectory();
|
||||
configFile =
|
||||
new File(baseDirectory,
|
||||
"config".concat(File.separator).concat(name).concat(".xml"));
|
||||
loadConfig();
|
||||
}
|
||||
|
||||
@@ -126,16 +135,13 @@ public abstract class AbstractRepositoryHandler<C extends SimpleRepositoryConfig
|
||||
*
|
||||
*/
|
||||
public void loadConfig()
|
||||
{
|
||||
if (configFile.exists())
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("load config {}", configFile.getPath());
|
||||
logger.debug("load config from store");
|
||||
}
|
||||
|
||||
config = JAXB.unmarshal(configFile, getConfigClass());
|
||||
}
|
||||
config = store.get();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,13 +166,10 @@ public abstract class AbstractRepositoryHandler<C extends SimpleRepositoryConfig
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("store config {}", configFile.getPath());
|
||||
logger.debug("store config");
|
||||
}
|
||||
|
||||
File parent = configFile.getParentFile();
|
||||
|
||||
IOUtil.mkdirs(parent);
|
||||
JAXB.marshal(config, configFile);
|
||||
store.set(config);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +235,7 @@ public abstract class AbstractRepositoryHandler<C extends SimpleRepositoryConfig
|
||||
protected C config;
|
||||
|
||||
/** Field description */
|
||||
protected File configFile;
|
||||
protected Store<C> store;
|
||||
|
||||
/** Field description */
|
||||
private Set<ConfigChangedListener> listenerSet =
|
||||
|
||||
@@ -42,6 +42,7 @@ import sonia.scm.ConfigurationException;
|
||||
import sonia.scm.SCMContextProvider;
|
||||
import sonia.scm.io.CommandResult;
|
||||
import sonia.scm.io.ExtendedCommand;
|
||||
import sonia.scm.store.StoreFactory;
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
@@ -67,6 +68,19 @@ public abstract class AbstractSimpleRepositoryHandler<C extends SimpleRepository
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(AbstractSimpleRepositoryHandler.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param storeFactory
|
||||
*/
|
||||
public AbstractSimpleRepositoryHandler(StoreFactory storeFactory)
|
||||
{
|
||||
super(storeFactory);
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,10 +41,13 @@ import sonia.scm.Validateable;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@XmlRootElement
|
||||
public class SimpleRepositoryConfig implements Validateable
|
||||
{
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ package sonia.scm.repository;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.Type;
|
||||
import sonia.scm.util.IOUtil;
|
||||
import sonia.scm.store.StoreFactory;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -60,6 +60,19 @@ public class DummyRepositoryHandler
|
||||
/** Field description */
|
||||
public static final Type TYPE = new Type(TYPE_NAME, TYPE_DISPLAYNAME);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param storeFactory
|
||||
*/
|
||||
public DummyRepositoryHandler(StoreFactory storeFactory)
|
||||
{
|
||||
super(storeFactory);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@@ -62,12 +62,10 @@ public class XmlRepositoryManagerTest extends RepositoryManagerTestBase
|
||||
protected Manager<Repository, RepositoryException> createManager()
|
||||
{
|
||||
Set<RepositoryHandler> handlerSet = new HashSet<RepositoryHandler>();
|
||||
|
||||
handlerSet.add(new DummyRepositoryHandler());
|
||||
|
||||
StoreFactory factory = new JAXBStoreFactory();
|
||||
|
||||
factory.init(provider);
|
||||
handlerSet.add(new DummyRepositoryHandler(factory));
|
||||
|
||||
return new XmlRepositoryManager(getAdminSecurityContextProvider(), factory,
|
||||
handlerSet);
|
||||
|
||||
Reference in New Issue
Block a user