summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/tickets
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2014-04-12 10:00:12 -0400
committerJames Moger <james.moger@gitblit.com>2014-04-12 11:40:10 -0400
commitba567069542e1f6769097ff78cd9612a9f08eb83 (patch)
treecd87bc2dd205b5c346a35fecaf0f52fe6e00c416 /src/main/java/com/gitblit/tickets
parentaa89bef3a9e06404afb268426cbab1ef20c3857c (diff)
downloadgitblit-ba567069542e1f6769097ff78cd9612a9f08eb83.tar.gz
gitblit-ba567069542e1f6769097ff78cd9612a9f08eb83.zip
Add TicketHook extension
Diffstat (limited to 'src/main/java/com/gitblit/tickets')
-rw-r--r--src/main/java/com/gitblit/tickets/BranchTicketService.java3
-rw-r--r--src/main/java/com/gitblit/tickets/FileTicketService.java3
-rw-r--r--src/main/java/com/gitblit/tickets/ITicketService.java28
-rw-r--r--src/main/java/com/gitblit/tickets/NullTicketService.java3
-rw-r--r--src/main/java/com/gitblit/tickets/RedisTicketService.java3
5 files changed, 40 insertions, 0 deletions
diff --git a/src/main/java/com/gitblit/tickets/BranchTicketService.java b/src/main/java/com/gitblit/tickets/BranchTicketService.java
index 56055a4a..3a634e05 100644
--- a/src/main/java/com/gitblit/tickets/BranchTicketService.java
+++ b/src/main/java/com/gitblit/tickets/BranchTicketService.java
@@ -58,6 +58,7 @@ import org.eclipse.jgit.treewalk.TreeWalk;
import com.gitblit.Constants;
import com.gitblit.git.ReceiveCommandEvent;
import com.gitblit.manager.INotificationManager;
+import com.gitblit.manager.IPluginManager;
import com.gitblit.manager.IRepositoryManager;
import com.gitblit.manager.IRuntimeManager;
import com.gitblit.manager.IUserManager;
@@ -92,11 +93,13 @@ public class BranchTicketService extends ITicketService implements RefsChangedLi
public BranchTicketService(
IRuntimeManager runtimeManager,
+ IPluginManager pluginManager,
INotificationManager notificationManager,
IUserManager userManager,
IRepositoryManager repositoryManager) {
super(runtimeManager,
+ pluginManager,
notificationManager,
userManager,
repositoryManager);
diff --git a/src/main/java/com/gitblit/tickets/FileTicketService.java b/src/main/java/com/gitblit/tickets/FileTicketService.java
index 2247a66c..4386020f 100644
--- a/src/main/java/com/gitblit/tickets/FileTicketService.java
+++ b/src/main/java/com/gitblit/tickets/FileTicketService.java
@@ -29,6 +29,7 @@ import org.eclipse.jgit.lib.Repository;
import com.gitblit.Constants;
import com.gitblit.manager.INotificationManager;
+import com.gitblit.manager.IPluginManager;
import com.gitblit.manager.IRepositoryManager;
import com.gitblit.manager.IRuntimeManager;
import com.gitblit.manager.IUserManager;
@@ -58,11 +59,13 @@ public class FileTicketService extends ITicketService {
public FileTicketService(
IRuntimeManager runtimeManager,
+ IPluginManager pluginManager,
INotificationManager notificationManager,
IUserManager userManager,
IRepositoryManager repositoryManager) {
super(runtimeManager,
+ pluginManager,
notificationManager,
userManager,
repositoryManager);
diff --git a/src/main/java/com/gitblit/tickets/ITicketService.java b/src/main/java/com/gitblit/tickets/ITicketService.java
index 90f9c6dd..9522e420 100644
--- a/src/main/java/com/gitblit/tickets/ITicketService.java
+++ b/src/main/java/com/gitblit/tickets/ITicketService.java
@@ -35,7 +35,9 @@ import org.slf4j.LoggerFactory;
import com.gitblit.IStoredSettings;
import com.gitblit.Keys;
+import com.gitblit.extensions.TicketHook;
import com.gitblit.manager.INotificationManager;
+import com.gitblit.manager.IPluginManager;
import com.gitblit.manager.IRepositoryManager;
import com.gitblit.manager.IRuntimeManager;
import com.gitblit.manager.IUserManager;
@@ -94,6 +96,8 @@ public abstract class ITicketService {
protected final IRepositoryManager repositoryManager;
+ protected final IPluginManager pluginManager;
+
protected final TicketIndexer indexer;
private final Cache<TicketKey, TicketModel> ticketsCache;
@@ -136,6 +140,7 @@ public abstract class ITicketService {
*/
public ITicketService(
IRuntimeManager runtimeManager,
+ IPluginManager pluginManager,
INotificationManager notificationManager,
IUserManager userManager,
IRepositoryManager repositoryManager) {
@@ -143,6 +148,7 @@ public abstract class ITicketService {
this.log = LoggerFactory.getLogger(getClass());
this.settings = runtimeManager.getSettings();
this.runtimeManager = runtimeManager;
+ this.pluginManager = pluginManager;
this.notificationManager = notificationManager;
this.userManager = userManager;
this.repositoryManager = repositoryManager;
@@ -832,6 +838,17 @@ public abstract class ITicketService {
if (success) {
TicketModel ticket = getTicket(repository, ticketId);
indexer.index(ticket);
+
+ // call the ticket hooks
+ if (pluginManager != null) {
+ for (TicketHook hook : pluginManager.getExtensions(TicketHook.class)) {
+ try {
+ hook.onNewTicket(ticket);
+ } catch (Exception e) {
+ log.error("Failed to execute extension", e);
+ }
+ }
+ }
return ticket;
}
return null;
@@ -862,6 +879,17 @@ public abstract class ITicketService {
TicketModel ticket = getTicket(repository, ticketId);
ticketsCache.put(key, ticket);
indexer.index(ticket);
+
+ // call the ticket hooks
+ if (pluginManager != null) {
+ for (TicketHook hook : pluginManager.getExtensions(TicketHook.class)) {
+ try {
+ hook.onUpdateTicket(ticket, change);
+ } catch (Exception e) {
+ log.error("Failed to execute extension", e);
+ }
+ }
+ }
return ticket;
}
return null;
diff --git a/src/main/java/com/gitblit/tickets/NullTicketService.java b/src/main/java/com/gitblit/tickets/NullTicketService.java
index 0ff33176..749d8018 100644
--- a/src/main/java/com/gitblit/tickets/NullTicketService.java
+++ b/src/main/java/com/gitblit/tickets/NullTicketService.java
@@ -19,6 +19,7 @@ import java.util.Collections;
import java.util.List;
import com.gitblit.manager.INotificationManager;
+import com.gitblit.manager.IPluginManager;
import com.gitblit.manager.IRepositoryManager;
import com.gitblit.manager.IRuntimeManager;
import com.gitblit.manager.IUserManager;
@@ -37,11 +38,13 @@ public class NullTicketService extends ITicketService {
public NullTicketService(
IRuntimeManager runtimeManager,
+ IPluginManager pluginManager,
INotificationManager notificationManager,
IUserManager userManager,
IRepositoryManager repositoryManager) {
super(runtimeManager,
+ pluginManager,
notificationManager,
userManager,
repositoryManager);
diff --git a/src/main/java/com/gitblit/tickets/RedisTicketService.java b/src/main/java/com/gitblit/tickets/RedisTicketService.java
index 58f7243c..2c5b181f 100644
--- a/src/main/java/com/gitblit/tickets/RedisTicketService.java
+++ b/src/main/java/com/gitblit/tickets/RedisTicketService.java
@@ -32,6 +32,7 @@ import redis.clients.jedis.exceptions.JedisException;
import com.gitblit.Keys;
import com.gitblit.manager.INotificationManager;
+import com.gitblit.manager.IPluginManager;
import com.gitblit.manager.IRepositoryManager;
import com.gitblit.manager.IRuntimeManager;
import com.gitblit.manager.IUserManager;
@@ -61,11 +62,13 @@ public class RedisTicketService extends ITicketService {
public RedisTicketService(
IRuntimeManager runtimeManager,
+ IPluginManager pluginManager,
INotificationManager notificationManager,
IUserManager userManager,
IRepositoryManager repositoryManager) {
super(runtimeManager,
+ pluginManager,
notificationManager,
userManager,
repositoryManager);