call pre processors in new repository api

This commit is contained in:
Sebastian Sdorra
2012-06-13 16:28:19 +02:00
parent 6de86c82c5
commit 50dc72be50
4 changed files with 49 additions and 7 deletions

View File

@@ -40,6 +40,7 @@ import com.google.common.base.Objects;
import sonia.scm.cache.Cache; import sonia.scm.cache.Cache;
import sonia.scm.cache.CacheManager; import sonia.scm.cache.CacheManager;
import sonia.scm.repository.BrowserResult; import sonia.scm.repository.BrowserResult;
import sonia.scm.repository.PreProcessorUtil;
import sonia.scm.repository.Repository; import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryException; import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.BrowseCommand; import sonia.scm.repository.spi.BrowseCommand;
@@ -73,14 +74,16 @@ public final class BrowseCommandBuilder
* @param logCommand implementation of the {@link LogCommand} * @param logCommand implementation of the {@link LogCommand}
* @param browseCommand * @param browseCommand
* @param repository repository to query * @param repository repository to query
* @param preProcessorUtil
*/ */
BrowseCommandBuilder(CacheManager cacheManager, BrowseCommand browseCommand, BrowseCommandBuilder(CacheManager cacheManager, BrowseCommand browseCommand,
Repository repository) Repository repository, PreProcessorUtil preProcessorUtil)
{ {
this.cache = cacheManager.getCache(CacheKey.class, BrowserResult.class, this.cache = cacheManager.getCache(CacheKey.class, BrowserResult.class,
CACHE_NAME); CACHE_NAME);
this.browseCommand = browseCommand; this.browseCommand = browseCommand;
this.repository = repository; this.repository = repository;
this.preProcessorUtil = preProcessorUtil;
} }
//~--- methods -------------------------------------------------------------- //~--- methods --------------------------------------------------------------
@@ -130,6 +133,11 @@ public final class BrowseCommandBuilder
} }
} }
if (result != null)
{
preProcessorUtil.prepareForReturn(repository, result);
}
return result; return result;
} }
@@ -268,6 +276,9 @@ public final class BrowseCommandBuilder
/** disables the cache */ /** disables the cache */
private boolean disableCache; private boolean disableCache;
/** Field description */
private PreProcessorUtil preProcessorUtil;
/** the repsitory */ /** the repsitory */
private Repository repository; private Repository repository;

View File

@@ -42,6 +42,7 @@ import sonia.scm.cache.Cache;
import sonia.scm.cache.CacheManager; import sonia.scm.cache.CacheManager;
import sonia.scm.repository.Changeset; import sonia.scm.repository.Changeset;
import sonia.scm.repository.ChangesetPagingResult; import sonia.scm.repository.ChangesetPagingResult;
import sonia.scm.repository.PreProcessorUtil;
import sonia.scm.repository.Repository; import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryException; import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.LogCommand; import sonia.scm.repository.spi.LogCommand;
@@ -112,14 +113,16 @@ public final class LogCommandBuilder
* @param cacheManager cache manager * @param cacheManager cache manager
* @param logCommand implementation of the {@link LogCommand} * @param logCommand implementation of the {@link LogCommand}
* @param repository repository to query * @param repository repository to query
* @param preProcessorUtil
*/ */
LogCommandBuilder(CacheManager cacheManager, LogCommand logCommand, LogCommandBuilder(CacheManager cacheManager, LogCommand logCommand,
Repository repository) Repository repository, PreProcessorUtil preProcessorUtil)
{ {
this.cache = cacheManager.getCache(CacheKey.class, this.cache = cacheManager.getCache(CacheKey.class,
ChangesetPagingResult.class, CACHE_NAME); ChangesetPagingResult.class, CACHE_NAME);
this.logCommand = logCommand; this.logCommand = logCommand;
this.repository = repository; this.repository = repository;
this.preProcessorUtil = preProcessorUtil;
} }
//~--- methods -------------------------------------------------------------- //~--- methods --------------------------------------------------------------
@@ -196,6 +199,11 @@ public final class LogCommandBuilder
} }
} }
if (changeset != null)
{
preProcessorUtil.prepareForReturn(repository, changeset);
}
return changeset; return changeset;
} }
@@ -234,6 +242,11 @@ public final class LogCommandBuilder
} }
} }
if (cpr != null)
{
preProcessorUtil.prepareForReturn(repository, cpr);
}
return cpr; return cpr;
} }
@@ -453,6 +466,9 @@ public final class LogCommandBuilder
/** Implementation of the log command */ /** Implementation of the log command */
private LogCommand logCommand; private LogCommand logCommand;
/** Field description */
private PreProcessorUtil preProcessorUtil;
/** repository to query */ /** repository to query */
private Repository repository; private Repository repository;

View File

@@ -36,6 +36,7 @@ package sonia.scm.repository.api;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
import sonia.scm.cache.CacheManager; import sonia.scm.cache.CacheManager;
import sonia.scm.repository.PreProcessorUtil;
import sonia.scm.repository.Repository; import sonia.scm.repository.Repository;
import sonia.scm.repository.spi.RepositoryServiceProvider; import sonia.scm.repository.spi.RepositoryServiceProvider;
@@ -64,13 +65,16 @@ public final class RepositoryService
* @param cacheManager cache manager * @param cacheManager cache manager
* @param provider implementation for {@link RepositoryServiceProvider} * @param provider implementation for {@link RepositoryServiceProvider}
* @param repository the repository * @param repository the repository
* @param preProcessorUtil
*/ */
RepositoryService(CacheManager cacheManager, RepositoryService(CacheManager cacheManager,
RepositoryServiceProvider provider, Repository repository) RepositoryServiceProvider provider, Repository repository,
PreProcessorUtil preProcessorUtil)
{ {
this.cacheManager = cacheManager; this.cacheManager = cacheManager;
this.provider = provider; this.provider = provider;
this.repository = repository; this.repository = repository;
this.preProcessorUtil = preProcessorUtil;
} }
//~--- get methods ---------------------------------------------------------- //~--- get methods ----------------------------------------------------------
@@ -98,7 +102,7 @@ public final class RepositoryService
public BrowseCommandBuilder getBrowseCommand() public BrowseCommandBuilder getBrowseCommand()
{ {
return new BrowseCommandBuilder(cacheManager, provider.getBrowseCommand(), return new BrowseCommandBuilder(cacheManager, provider.getBrowseCommand(),
repository); repository, preProcessorUtil);
} }
/** /**
@@ -136,7 +140,7 @@ public final class RepositoryService
public LogCommandBuilder getLogCommand() public LogCommandBuilder getLogCommand()
{ {
return new LogCommandBuilder(cacheManager, provider.getLogCommand(), return new LogCommandBuilder(cacheManager, provider.getLogCommand(),
repository); repository, preProcessorUtil);
} }
/** /**
@@ -157,6 +161,9 @@ public final class RepositoryService
/** cache manager */ /** cache manager */
private CacheManager cacheManager; private CacheManager cacheManager;
/** Field description */
private PreProcessorUtil preProcessorUtil;
/** implementation of the repository service provider */ /** implementation of the repository service provider */
private RepositoryServiceProvider provider; private RepositoryServiceProvider provider;

View File

@@ -44,6 +44,7 @@ import com.google.inject.Singleton;
import sonia.scm.cache.CacheManager; import sonia.scm.cache.CacheManager;
import sonia.scm.repository.PermissionType; import sonia.scm.repository.PermissionType;
import sonia.scm.repository.PermissionUtil; import sonia.scm.repository.PermissionUtil;
import sonia.scm.repository.PreProcessorUtil;
import sonia.scm.repository.Repository; import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryManager; import sonia.scm.repository.RepositoryManager;
import sonia.scm.repository.RepositoryNotFoundException; import sonia.scm.repository.RepositoryNotFoundException;
@@ -98,17 +99,20 @@ public final class RepositoryServiceFactory
* @param repositoryManager manager for repositories * @param repositoryManager manager for repositories
* @param securityContextProvider provider for the current security context * @param securityContextProvider provider for the current security context
* @param resolvers a set of {@link RepositoryServiceResolver} * @param resolvers a set of {@link RepositoryServiceResolver}
* @param preProcessorUtil helper object for pre processor handling
*/ */
@Inject @Inject
public RepositoryServiceFactory( public RepositoryServiceFactory(
CacheManager cacheManager, RepositoryManager repositoryManager, CacheManager cacheManager, RepositoryManager repositoryManager,
Provider<WebSecurityContext> securityContextProvider, Provider<WebSecurityContext> securityContextProvider,
Set<RepositoryServiceResolver> resolvers) Set<RepositoryServiceResolver> resolvers,
PreProcessorUtil preProcessorUtil)
{ {
this.cacheManager = cacheManager; this.cacheManager = cacheManager;
this.repositoryManager = repositoryManager; this.repositoryManager = repositoryManager;
this.securityContextProvider = securityContextProvider; this.securityContextProvider = securityContextProvider;
this.resolvers = resolvers; this.resolvers = resolvers;
this.preProcessorUtil = preProcessorUtil;
} }
//~--- methods -------------------------------------------------------------- //~--- methods --------------------------------------------------------------
@@ -219,7 +223,8 @@ public final class RepositoryServiceFactory
if (provider != null) if (provider != null)
{ {
service = new RepositoryService(cacheManager, provider, repository); service = new RepositoryService(cacheManager, provider, repository,
preProcessorUtil);
break; break;
} }
@@ -238,6 +243,9 @@ public final class RepositoryServiceFactory
/** Field description */ /** Field description */
private CacheManager cacheManager; private CacheManager cacheManager;
/** Field description */
private PreProcessorUtil preProcessorUtil;
/** Field description */ /** Field description */
private RepositoryManager repositoryManager; private RepositoryManager repositoryManager;