Use repository dao to find repository for given directory in hooks

This commit is contained in:
René Pfeuffer
2018-11-23 10:13:47 +01:00
parent 4925370a43
commit e8558e07ec
13 changed files with 79 additions and 253 deletions

View File

@@ -90,7 +90,8 @@ public class SvnRepositoryHandler
FileSystem fileSystem,
HookEventFacade eventFacade,
RepositoryLocationResolver repositoryLocationResolver,
InitialRepositoryLocationResolver initialRepositoryLocationResolver)
InitialRepositoryLocationResolver initialRepositoryLocationResolver,
RepositoryDAO repositoryDAO)
{
super(storeFactory, fileSystem, repositoryLocationResolver, initialRepositoryLocationResolver);
@@ -103,7 +104,7 @@ public class SvnRepositoryHandler
// register hook
if (eventFacade != null)
{
FSHooks.registerHook(new SvnRepositoryHook(eventFacade, this));
FSHooks.registerHook(new SvnRepositoryHook(eventFacade, repositoryDAO));
}
else if (logger.isWarnEnabled())
{

View File

@@ -70,19 +70,10 @@ public class SvnRepositoryHook implements FSHook
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*
*
* @param hookEventFacade
* @param handler
*/
public SvnRepositoryHook(HookEventFacade hookEventFacade,
SvnRepositoryHandler handler)
public SvnRepositoryHook(HookEventFacade hookEventFacade, RepositoryDAO repositoryDAO)
{
this.hookEventFacade = hookEventFacade;
this.handler = handler;
this.repositoryDAO = repositoryDAO;
}
//~--- methods --------------------------------------------------------------
@@ -197,18 +188,17 @@ public class SvnRepositoryHook implements FSHook
*
* @throws IOException
*/
private String getRepositoryId(File directory) throws IOException
private String getRepositoryId(File directory)
{
AssertUtil.assertIsNotNull(directory);
return RepositoryUtil.getRepositoryId(handler, directory);
return repositoryDAO.getIdForDirectory(directory);
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private SvnRepositoryHandler handler;
/** Field description */
private HookEventFacade hookEventFacade;
private final RepositoryDAO repositoryDAO;
}

View File

@@ -68,6 +68,9 @@ public class SvnRepositoryHandlerTest extends SimpleRepositoryHandlerTestBase {
@Mock
private com.google.inject.Provider<RepositoryManager> repositoryManagerProvider;
@Mock
private RepositoryDAO repositoryDAO;
private HookContextFactory hookContextFactory = new HookContextFactory(mock(PreProcessorUtil.class));
private HookEventFacade facade = new HookEventFacade(repositoryManagerProvider, hookContextFactory);
@@ -93,7 +96,7 @@ public class SvnRepositoryHandlerTest extends SimpleRepositoryHandlerTestBase {
File directory) {
initialRepositoryLocationResolver = new InitialRepositoryLocationResolver(contextProvider);
repositoryLocationResolver = new RepositoryLocationResolver(repoDao, initialRepositoryLocationResolver);
SvnRepositoryHandler handler = new SvnRepositoryHandler(factory, new DefaultFileSystem(), null, repositoryLocationResolver, initialRepositoryLocationResolver);
SvnRepositoryHandler handler = new SvnRepositoryHandler(factory, new DefaultFileSystem(), null, repositoryLocationResolver, initialRepositoryLocationResolver, repositoryDAO);
handler.init(contextProvider);
@@ -109,7 +112,7 @@ public class SvnRepositoryHandlerTest extends SimpleRepositoryHandlerTestBase {
public void getDirectory() {
when(factory.getStore(any(), any())).thenReturn(store);
SvnRepositoryHandler repositoryHandler = new SvnRepositoryHandler(factory,
new DefaultFileSystem(), facade, repositoryLocationResolver, initialRepositoryLocationResolver);
new DefaultFileSystem(), facade, repositoryLocationResolver, initialRepositoryLocationResolver, repositoryDAO);
SvnConfig svnConfig = new SvnConfig();
repositoryHandler.setConfig(svnConfig);