James Moger
2014-09-04 c70fcce5db7172a9c0a1f1347ef5db1453e23350
src/main/java/com/gitblit/tickets/ITicketService.java
@@ -36,6 +36,7 @@
import com.gitblit.IStoredSettings;
import com.gitblit.Keys;
import com.gitblit.extensions.TicketHook;
import com.gitblit.manager.IManager;
import com.gitblit.manager.INotificationManager;
import com.gitblit.manager.IPluginManager;
import com.gitblit.manager.IRepositoryManager;
@@ -63,7 +64,9 @@
 * @author James Moger
 *
 */
public abstract class ITicketService {
public abstract class ITicketService implements IManager {
   public static final String SETTING_UPDATE_DIFFSTATS = "migration.updateDiffstats";
   private static final String LABEL = "label";
@@ -106,6 +109,8 @@
   private final Map<String, List<TicketLabel>> labelsCache;
   private final Map<String, List<TicketMilestone>> milestonesCache;
   private final boolean updateDiffstats;
   private static class TicketKey {
      final String repository;
@@ -164,18 +169,22 @@
      this.labelsCache = new ConcurrentHashMap<String, List<TicketLabel>>();
      this.milestonesCache = new ConcurrentHashMap<String, List<TicketMilestone>>();
      this.updateDiffstats = settings.getBoolean(SETTING_UPDATE_DIFFSTATS, true);
   }
   /**
    * Start the service.
    * @since 1.4.0
    */
   @Override
   public abstract ITicketService start();
   /**
    * Stop the service.
    * @since 1.4.0
    */
   @Override
   public final ITicketService stop() {
      indexer.close();
      ticketsCache.invalidateAll();
@@ -245,6 +254,7 @@
    */
   public boolean isAcceptingTicketUpdates(RepositoryModel repository) {
      return isReady()
            && repository.hasCommits
            && repository.isBare
            && !repository.isFrozen
            && !repository.isMirror;
@@ -762,6 +772,15 @@
   }
   /**
    * Returns the set of assigned ticket ids in the repository.
    *
    * @param repository
    * @return a set of assigned ticket ids in the repository
    * @since 1.6.0
    */
   public abstract Set<Long> getIds(RepositoryModel repository);
   /**
    * Assigns a new ticket id.
    *
    * @param repository
@@ -823,7 +842,7 @@
         ticket = getTicketImpl(repository, ticketId);
         // if ticket exists
         if (ticket != null) {
            if (ticket.hasPatchsets()) {
            if (ticket.hasPatchsets() && updateDiffstats) {
               Repository r = repositoryManager.getRepository(repository.name);
               try {
                  Patchset patchset = ticket.getCurrentPatchset();
@@ -856,6 +875,33 @@
    */
   protected abstract TicketModel getTicketImpl(RepositoryModel repository, long ticketId);
   /**
    * Returns the journal used to build a ticket.
    *
    * @param repository
    * @param ticketId
    * @return the journal for the ticket, if it exists, otherwise null
    * @since 1.6.0
    */
   public final List<Change> getJournal(RepositoryModel repository, long ticketId) {
      if (hasTicket(repository, ticketId)) {
         List<Change> journal = getJournalImpl(repository, ticketId);
         return journal;
      }
      return null;
   }
   /**
    * Retrieves the ticket journal.
    *
    * @param repository
    * @param ticketId
    * @return a ticket, if it exists, otherwise null
    * @since 1.6.0
    */
   protected abstract List<Change> getJournalImpl(RepositoryModel repository, long ticketId);
   /**
    * Get the ticket url
    *