From 6651a8e96bdc51b0c558b88e1c77fcfbed1837da Mon Sep 17 00:00:00 2001 From: James Moger Date: Sun, 8 Jun 2014 10:30:39 -0400 Subject: Move repository ownership to the UserModel and prepare for project ownership --- .../java/com/gitblit/tickets/BranchTicketService.java | 4 ++-- .../java/com/gitblit/tickets/FileTicketService.java | 4 ++-- .../java/com/gitblit/tickets/RedisTicketService.java | 4 ++-- src/main/java/com/gitblit/tickets/TicketNotifier.java | 17 ++++++++++++----- 4 files changed, 18 insertions(+), 11 deletions(-) (limited to 'src/main/java/com/gitblit/tickets') diff --git a/src/main/java/com/gitblit/tickets/BranchTicketService.java b/src/main/java/com/gitblit/tickets/BranchTicketService.java index 8c000550..448014f7 100644 --- a/src/main/java/com/gitblit/tickets/BranchTicketService.java +++ b/src/main/java/com/gitblit/tickets/BranchTicketService.java @@ -494,7 +494,7 @@ public class BranchTicketService extends ITicketService implements RefsChangedLi continue; } TicketModel ticket = TicketModel.buildTicket(changes); - ticket.project = repository.projectPath; + ticket.project = repository.getProject(); ticket.repository = repository.name; ticket.number = ticketId; @@ -540,7 +540,7 @@ public class BranchTicketService extends ITicketService implements RefsChangedLi } TicketModel ticket = TicketModel.buildTicket(changes); if (ticket != null) { - ticket.project = repository.projectPath; + ticket.project = repository.getProject(); ticket.repository = repository.name; ticket.number = ticketId; } diff --git a/src/main/java/com/gitblit/tickets/FileTicketService.java b/src/main/java/com/gitblit/tickets/FileTicketService.java index b3d8838e..33b5307b 100644 --- a/src/main/java/com/gitblit/tickets/FileTicketService.java +++ b/src/main/java/com/gitblit/tickets/FileTicketService.java @@ -257,7 +257,7 @@ public class FileTicketService extends ITicketService { continue; } TicketModel ticket = TicketModel.buildTicket(changes); - ticket.project = repository.projectPath; + ticket.project = repository.getProject(); ticket.repository = repository.name; ticket.number = ticketId; @@ -320,7 +320,7 @@ public class FileTicketService extends ITicketService { } TicketModel ticket = TicketModel.buildTicket(changes); if (ticket != null) { - ticket.project = repository.projectPath; + ticket.project = repository.getProject(); ticket.repository = repository.name; ticket.number = ticketId; } diff --git a/src/main/java/com/gitblit/tickets/RedisTicketService.java b/src/main/java/com/gitblit/tickets/RedisTicketService.java index d773b0bd..465bda31 100644 --- a/src/main/java/com/gitblit/tickets/RedisTicketService.java +++ b/src/main/java/com/gitblit/tickets/RedisTicketService.java @@ -276,7 +276,7 @@ public class RedisTicketService extends ITicketService { continue; } TicketModel ticket = TicketModel.buildTicket(changes); - ticket.project = repository.projectPath; + ticket.project = repository.getProject(); ticket.repository = repository.name; ticket.number = ticketId; @@ -325,7 +325,7 @@ public class RedisTicketService extends ITicketService { return null; } TicketModel ticket = TicketModel.buildTicket(changes); - ticket.project = repository.projectPath; + ticket.project = repository.getProject(); ticket.repository = repository.name; ticket.number = ticketId; log.debug("rebuilt ticket {} from Redis @ {}", ticketId, getUrl()); diff --git a/src/main/java/com/gitblit/tickets/TicketNotifier.java b/src/main/java/com/gitblit/tickets/TicketNotifier.java index 07371b1b..d4307106 100644 --- a/src/main/java/com/gitblit/tickets/TicketNotifier.java +++ b/src/main/java/com/gitblit/tickets/TicketNotifier.java @@ -49,6 +49,7 @@ import com.gitblit.manager.IRepositoryManager; import com.gitblit.manager.IRuntimeManager; import com.gitblit.manager.IUserManager; import com.gitblit.models.Mailing; +import com.gitblit.models.Owner; import com.gitblit.models.PathModel.PathChangeModel; import com.gitblit.models.RepositoryModel; import com.gitblit.models.TicketModel; @@ -551,11 +552,6 @@ public class TicketNotifier { // Set ccs = new TreeSet(); - // repository owners - if (!ArrayUtils.isEmpty(repository.owners)) { - ccs.addAll(repository.owners); - } - // cc users mentioned in last comment Change lastChange = ticket.changes.get(ticket.changes.size() - 1); if (lastChange.hasComment()) { @@ -573,6 +569,7 @@ public class TicketNotifier { // TODO cc users who are watching the repository Set ccAddresses = new TreeSet(); + for (String name : ccs) { UserModel user = userManager.getUserModel(name); if (user != null && !user.disabled) { @@ -588,6 +585,16 @@ public class TicketNotifier { } } + // repository owners + for (Owner owner : userManager.getOwners(repository)) { + if (owner instanceof UserModel) { + UserModel user = (UserModel) owner; + if (!StringUtils.isEmpty(user.emailAddress)) { + ccAddresses.add(user.emailAddress); + } + } + } + // cc repository mailing list addresses if (!ArrayUtils.isEmpty(repository.mailingLists)) { ccAddresses.addAll(repository.mailingLists); -- cgit v1.2.3