Use static method for new StoreParameters instance

This commit is contained in:
René Pfeuffer
2018-12-03 11:28:03 +01:00
parent ab8b3bae42
commit 3638d3520f
16 changed files with 85 additions and 89 deletions

View File

@@ -39,11 +39,12 @@ import com.google.inject.Singleton;
import sonia.scm.group.Group;
import sonia.scm.group.GroupDAO;
import sonia.scm.store.StoreParameters;
import sonia.scm.xml.AbstractXmlDAO;
import sonia.scm.store.ConfigurationStoreFactory;
import static sonia.scm.store.StoreParameters.forType;
/**
*
* @author Sebastian Sdorra
@@ -66,10 +67,10 @@ public class XmlGroupDAO extends AbstractXmlDAO<Group, XmlGroupDatabase>
*/
@Inject
public XmlGroupDAO(ConfigurationStoreFactory storeFactory) {
super(storeFactory.getStore(new StoreParameters()
.withType(XmlGroupDatabase.class)
.withName(STORE_NAME)
.build()));
super(storeFactory.getStore(
forType(XmlGroupDatabase.class)
.withName(STORE_NAME)
.build()));
}
//~--- methods --------------------------------------------------------------

View File

@@ -73,10 +73,10 @@ public abstract class FileBasedStoreFactory {
protected File getStoreLocation(String name, Class type, Repository repository) {
if (storeDirectory == null) {
if (repository != null) {
LOG.debug("create store with type :{}, name:{} and repository {}", type, name, repository.getNamespaceAndName());
LOG.debug("create store with type: {}, name: {} and repository: {}", type, name, repository.getNamespaceAndName());
storeDirectory = this.getStoreDirectory(store, repository);
} else {
LOG.debug("create store with type :{} and name:{} ", type, name);
LOG.debug("create store with type: {} and name: {} ", type, name);
storeDirectory = this.getStoreDirectory(store);
}
IOUtil.mkdirs(storeDirectory);
@@ -91,7 +91,7 @@ public abstract class FileBasedStoreFactory {
* @return the store directory of a specific repository
*/
private File getStoreDirectory(Store store, Repository repository) {
return new File (repositoryLocationResolver.getPath(repository.getId()).toFile(), store.getRepositoryStoreDirectory());
return new File(repositoryLocationResolver.getPath(repository.getId()).toFile(), store.getRepositoryStoreDirectory());
}
/**

View File

@@ -36,12 +36,12 @@ package sonia.scm.user.xml;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import sonia.scm.store.StoreParameters;
import sonia.scm.store.ConfigurationStoreFactory;
import sonia.scm.user.User;
import sonia.scm.user.UserDAO;
import sonia.scm.xml.AbstractXmlDAO;
import sonia.scm.store.ConfigurationStoreFactory;
import static sonia.scm.store.StoreParameters.forType;
/**
*
@@ -66,10 +66,10 @@ public class XmlUserDAO extends AbstractXmlDAO<User, XmlUserDatabase>
@Inject
public XmlUserDAO(ConfigurationStoreFactory storeFactory)
{
super(storeFactory.getStore(new StoreParameters()
.withType(XmlUserDatabase.class)
.withName(STORE_NAME)
.build()));
super(storeFactory.getStore(
forType(XmlUserDatabase.class)
.withName(STORE_NAME)
.build()));
}
//~--- methods --------------------------------------------------------------