]> source.dussan.org Git - gitblit.git/commitdiff
Reverted changes to ticket services
authorJames Moger <james.moger@gitblit.com>
Thu, 1 May 2014 19:55:20 +0000 (15:55 -0400)
committerJames Moger <james.moger@gitblit.com>
Thu, 1 May 2014 20:14:15 +0000 (16:14 -0400)
src/main/java/com/gitblit/tickets/FileTicketService.java
src/main/java/com/gitblit/tickets/ITicketService.java

index ea5d065f98059138fae30eb9d2b5aaca0cb060aa..4386020fa751c511b746f7b332f6906a3b18bea0 100644 (file)
@@ -207,82 +207,62 @@ public class FileTicketService extends ITicketService {
        @Override
        public List<TicketModel> getTickets(RepositoryModel repository, TicketFilter filter) {
                List<TicketModel> list = new ArrayList<TicketModel>();
-               List<Repository> databases = new ArrayList<Repository>();
-               List<RepositoryModel> models = new ArrayList<RepositoryModel>();
-               
-               if(repository == null)
-               {
-                       List<String> allRepo = repositoryManager.getRepositoryList();
-                       for(int i = 0; i < allRepo.size(); i++)
-                       {
-                               databases.add(repositoryManager.getRepository(allRepo.get(i)));
-                               models.add(repositoryManager.getRepositoryModel(allRepo.get(i)));
-                       }
-               }
-               else
-               {
-                       databases.add(repositoryManager.getRepository(repository.name));
-                       models.add(repository);
-               }
-               
-               for(int i = 0; i < databases.size(); i++)
-               {
-                       Repository db = databases.get(i);
-                       try {
-                               // Collect the set of all json files
-                               File dir = new File(db.getDirectory(), TICKETS_PATH);
-                               List<File> journals = findAll(dir, JOURNAL);
-       
-                               // Deserialize each ticket and optionally filter out unwanted tickets
-                               for (File journal : journals) {
-                                       String json = null;
-                                       try {
-                                               json = new String(FileUtils.readContent(journal), Constants.ENCODING);
-                                       } catch (Exception e) {
-                                               log.error(null, e);
-                                       }
-                                       if (StringUtils.isEmpty(json)) {
-                                               // journal was touched but no changes were written
+
+               Repository db = repositoryManager.getRepository(repository.name);
+               try {
+                       // Collect the set of all json files
+                       File dir = new File(db.getDirectory(), TICKETS_PATH);
+                       List<File> journals = findAll(dir, JOURNAL);
+
+                       // Deserialize each ticket and optionally filter out unwanted tickets
+                       for (File journal : journals) {
+                               String json = null;
+                               try {
+                                       json = new String(FileUtils.readContent(journal), Constants.ENCODING);
+                               } catch (Exception e) {
+                                       log.error(null, e);
+                               }
+                               if (StringUtils.isEmpty(json)) {
+                                       // journal was touched but no changes were written
+                                       continue;
+                               }
+                               try {
+                                       // Reconstruct ticketId from the path
+                                       // id/26/326/journal.json
+                                       String path = FileUtils.getRelativePath(dir, journal);
+                                       String tid = path.split("/")[1];
+                                       long ticketId = Long.parseLong(tid);
+                                       List<Change> changes = TicketSerializer.deserializeJournal(json);
+                                       if (ArrayUtils.isEmpty(changes)) {
+                                               log.warn("Empty journal for {}:{}", repository, journal);
                                                continue;
                                        }
-                                       try {
-                                               // Reconstruct ticketId from the path
-                                               // id/26/326/journal.json
-                                               String path = FileUtils.getRelativePath(dir, journal);
-                                               String tid = path.split("/")[1];
-                                               long ticketId = Long.parseLong(tid);
-                                               List<Change> changes = TicketSerializer.deserializeJournal(json);
-                                               if (ArrayUtils.isEmpty(changes)) {
-                                                       log.warn("Empty journal for {}:{}", models.get(i), journal);
-                                                       continue;
-                                               }
-                                               TicketModel ticket = TicketModel.buildTicket(changes);
-                                               ticket.project = models.get(i).projectPath;
-                                               ticket.repository = models.get(i).name;
-                                               ticket.number = ticketId;
-       
-                                               // add the ticket, conditionally, to the list
-                                               if (filter == null) {
+                                       TicketModel ticket = TicketModel.buildTicket(changes);
+                                       ticket.project = repository.projectPath;
+                                       ticket.repository = repository.name;
+                                       ticket.number = ticketId;
+
+                                       // add the ticket, conditionally, to the list
+                                       if (filter == null) {
+                                               list.add(ticket);
+                                       } else {
+                                               if (filter.accept(ticket)) {
                                                        list.add(ticket);
-                                               } else {
-                                                       if (filter.accept(ticket)) {
-                                                               list.add(ticket);
-                                                       }
                                                }
-                                       } catch (Exception e) {
-                                               log.error("failed to deserialize {}/{}\n{}",
-                                                               new Object [] { models.get(i), journal, e.getMessage()});
-                                               log.error(null, e);
                                        }
+                               } catch (Exception e) {
+                                       log.error("failed to deserialize {}/{}\n{}",
+                                                       new Object [] { repository, journal, e.getMessage()});
+                                       log.error(null, e);
                                }
-                       } finally {
-                               db.close();
                        }
+
+                       // sort the tickets by creation
+                       Collections.sort(list);
+                       return list;
+               } finally {
+                       db.close();
                }
-               
-               // sort the tickets by creation
-               Collections.sort(list);
-               return list;
        }
 
        private List<File> findAll(File dir, String filename) {
index e7b4c71d05e762b0614695343e4fba080fc9a066..3261ca963d32b1bdb4ede4c22071ed3f32b267a5 100644 (file)
@@ -779,21 +779,12 @@ public abstract class ITicketService {
         * @since 1.4.0
         */
        public abstract boolean hasTicket(RepositoryModel repository, long ticketId);
-       
-       /**
-        * Returns all tickets.  This is not a Lucene search!
-        * 
-        * @return all tickets
-        */
-       public List<TicketModel> getTickets() {
-               return getTickets(null, null);
-       }
 
        /**
         * Returns all tickets.  This is not a Lucene search!
         *
         * @param repository
-        * @return all tickets of a given repository
+        * @return all tickets
         * @since 1.4.0
         */
        public List<TicketModel> getTickets(RepositoryModel repository) {