1818 */
1919
2020/*
21- * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
21+ * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2222 */
2323package org .opengrok .web .api .v1 .controller ;
2424
3232import jakarta .ws .rs .QueryParam ;
3333import jakarta .ws .rs .core .Context ;
3434import jakarta .ws .rs .core .MediaType ;
35+ import org .jetbrains .annotations .TestOnly ;
3536import org .opengrok .indexer .configuration .RuntimeEnvironment ;
3637import org .opengrok .indexer .history .History ;
3738import org .opengrok .indexer .history .HistoryEntry ;
4546import java .util .ArrayList ;
4647import java .util .Date ;
4748import java .util .List ;
49+ import java .util .Map ;
4850import java .util .Objects ;
4951import java .util .SortedSet ;
5052
@@ -79,11 +81,14 @@ static class HistoryEntryDTO implements JSONable {
7981 this .revision = entry .getRevision ();
8082 this .date = entry .getDate ();
8183 this .author = entry .getAuthor ();
82- // TODO this.tags = entry.getTags();
8384 this .message = entry .getMessage ();
8485 this .files = entry .getFiles ();
8586 }
8687
88+ public void setTags (String tags ) {
89+ this .tags = tags ;
90+ }
91+
8792 // for testing
8893 public String getAuthor () {
8994 return author ;
@@ -135,7 +140,7 @@ static class HistoryDTO implements JSONable {
135140 @ JsonProperty
136141 private int total ;
137142
138- // for testing
143+ @ TestOnly
139144 HistoryDTO () {
140145 this .entries = new ArrayList <>();
141146 }
@@ -147,7 +152,7 @@ static class HistoryDTO implements JSONable {
147152 this .total = total ;
148153 }
149154
150- // for testing
155+ @ TestOnly
151156 public List <HistoryEntryDTO > getEntries () {
152157 return entries ;
153158 }
@@ -181,9 +186,11 @@ public int hashCode() {
181186 }
182187 }
183188
184- static HistoryDTO getHistoryDTO (List <HistoryEntry > historyEntries , int start , int count , int total ) {
189+ static HistoryDTO getHistoryDTO (List <HistoryEntry > historyEntries , Map <String , String > tags ,
190+ int start , int count , int total ) {
185191 List <HistoryEntryDTO > entries = new ArrayList <>();
186192 historyEntries .stream ().map (HistoryEntryDTO ::new ).forEach (entries ::add );
193+ entries .forEach (e -> e .setTags (tags .get (e .revision )));
187194 return new HistoryDTO (entries , start , count , total );
188195 }
189196
@@ -205,7 +212,7 @@ public HistoryDTO get(@Context HttpServletRequest request,
205212 return null ;
206213 }
207214
208- return getHistoryDTO (history .getHistoryEntries (maxEntries , startIndex ),
215+ return getHistoryDTO (history .getHistoryEntries (maxEntries , startIndex ), history . getTags (),
209216 startIndex , maxEntries , history .getHistoryEntries ().size ());
210217 }
211218}
0 commit comments