mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-04-01 18:00:12 +02:00
use new store-api
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -127,15 +136,12 @@ public abstract class AbstractRepositoryHandler<C extends SimpleRepositoryConfig
|
||||
*/
|
||||
public void loadConfig()
|
||||
{
|
||||
if (configFile.exists())
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("load config {}", configFile.getPath());
|
||||
}
|
||||
|
||||
config = JAXB.unmarshal(configFile, getConfigClass());
|
||||
logger.debug("load config from store");
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user