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