diff options
author | James Moger <james.moger@gitblit.com> | 2014-07-02 16:45:37 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-07-03 17:00:41 -0400 |
commit | c42032df0911f51c81a91a961eff2066b380607c (patch) | |
tree | 6be77276875bf07dc535491fd72e92effcdd9ef3 /src/main/java/com/gitblit/manager | |
parent | 241f57365649ffbbcc1923a1712ab86f6a443bc6 (diff) | |
download | gitblit-c42032df0911f51c81a91a961eff2066b380607c.tar.gz gitblit-c42032df0911f51c81a91a961eff2066b380607c.zip |
Extract ticket service into an injectable object with a custom provider
Diffstat (limited to 'src/main/java/com/gitblit/manager')
-rw-r--r-- | src/main/java/com/gitblit/manager/GitblitManager.java | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/src/main/java/com/gitblit/manager/GitblitManager.java b/src/main/java/com/gitblit/manager/GitblitManager.java index fbbafacb..02b2d675 100644 --- a/src/main/java/com/gitblit/manager/GitblitManager.java +++ b/src/main/java/com/gitblit/manager/GitblitManager.java @@ -109,6 +109,8 @@ public class GitblitManager implements IGitblit { protected final Provider<IPublicKeyManager> publicKeyManagerProvider; + protected final Provider<ITicketService> ticketServiceProvider; + protected final IStoredSettings settings; protected final IRuntimeManager runtimeManager; @@ -130,6 +132,7 @@ public class GitblitManager implements IGitblit { @Inject public GitblitManager( Provider<IPublicKeyManager> publicKeyManagerProvider, + Provider<ITicketService> ticketServiceProvider, IRuntimeManager runtimeManager, IPluginManager pluginManager, INotificationManager notificationManager, @@ -140,6 +143,7 @@ public class GitblitManager implements IGitblit { IFederationManager federationManager) { this.publicKeyManagerProvider = publicKeyManagerProvider; + this.ticketServiceProvider = ticketServiceProvider; this.settings = runtimeManager.getSettings(); this.runtimeManager = runtimeManager; @@ -478,13 +482,9 @@ public class GitblitManager implements IGitblit { } } - /** - * Throws an exception if trying to get a ticket service. - * - */ @Override public ITicketService getTicketService() { - throw new RuntimeException("This class does not have a ticket service!"); + return ticketServiceProvider.get(); } @Override @@ -960,10 +960,23 @@ public class GitblitManager implements IGitblit { return repositoryManager.getRepositoryDefaultMetrics(model, repository); } + /** + * Detect renames and reindex as appropriate. + */ @Override public void updateRepositoryModel(String repositoryName, RepositoryModel repository, boolean isCreate) throws GitBlitException { + RepositoryModel oldModel = null; + boolean isRename = !isCreate && !repositoryName.equalsIgnoreCase(repository.name); + if (isRename) { + oldModel = repositoryManager.getRepositoryModel(repositoryName); + } + repositoryManager.updateRepositoryModel(repositoryName, repository, isCreate); + + if (isRename && ticketServiceProvider.get() != null) { + ticketServiceProvider.get().rename(oldModel, repository); + } } @Override @@ -976,14 +989,23 @@ public class GitblitManager implements IGitblit { return repositoryManager.canDelete(model); } + /** + * Delete the repository and all associated tickets. + */ @Override public boolean deleteRepositoryModel(RepositoryModel model) { - return repositoryManager.deleteRepositoryModel(model); + boolean success = repositoryManager.deleteRepositoryModel(model); + if (success && ticketServiceProvider.get() != null) { + ticketServiceProvider.get().deleteAll(model); + } + return success; } @Override public boolean deleteRepository(String repositoryName) { - return repositoryManager.deleteRepository(repositoryName); + // delegate to deleteRepositoryModel() to destroy indexed tickets + RepositoryModel repository = repositoryManager.getRepositoryModel(repositoryName); + return deleteRepositoryModel(repository); } @Override |