@@ -38,6 +38,7 @@ java.util.List,
38
38
java.util.Set,
39
39
java.util.logging.Level,
40
40
java.util.zip.GZIPInputStream,
41
+ javax.servlet.http.HttpServletResponse,
41
42
42
43
org.opensolaris.opengrok.analysis.AnalyzerGuru,
43
44
org.opensolaris.opengrok.analysis.Definitions,
@@ -147,95 +148,115 @@ document.pageReady.push(function() { pageReadyList();});
147
148
}
148
149
}
149
150
} else if (rev. length() != 0 ) {
150
- // requesting a previous revision
151
- FileAnalyzerFactory a = AnalyzerGuru . find(basename);
152
- Genre g = AnalyzerGuru . getGenre(a);
153
- String error = null ;
154
- if (g == Genre . PLAIN|| g == Genre . HTML || g == null ) {
155
- InputStream in = null ;
156
- try {
157
- in = HistoryGuru . getInstance()
158
- .getRevision(resourceFile. getParent(), basename, rev);
159
- } catch (Exception e) {
160
- // fall through to error message
161
- error = e. getMessage();
162
- }
163
- if (in != null ) {
164
- try {
165
- if (g == null ) {
166
- a = AnalyzerGuru . find(in);
167
- g = AnalyzerGuru . getGenre(a);
168
- }
169
- if (g == Genre . DATA || g == Genre . XREFABLE
170
- || g == null )
171
- {
172
- % >
173
- <div id =" src" >
174
- Binary file [Click <a href =" <%= rawPath % > ?r=<%= Util . URIEncode(rev) % >" >here</a > to download]
175
- </div ><%
176
- } else {
151
+ // requesting a revision
152
+ if (cfg. isLatestRevision(rev)) {
153
+ File xrefFile = cfg. findDataFile();
154
+ if (xrefFile != null ) {
177
155
% >
178
- <div id =" src" >
156
+ <div id =" src" data-navigate-window-enabled = " <%= navigateWindowEnabled % > " >
179
157
<pre ><%
180
- if (g == Genre . PLAIN ) {
181
- // We don't have any way to get definitions
182
- // for old revisions currently.
183
- Definitions defs = null ;
184
- Annotation annotation = cfg. getAnnotation();
185
- // not needed yet
186
- // annotation.writeTooltipMap(out);
187
- r = IOUtils . createBOMStrippedReader(in);
188
- AnalyzerGuru . writeXref(a, r, out, defs,
189
- annotation, Project . getProject(resourceFile));
190
- } else if (g == Genre . IMAGE ) {
158
+ Util . dump(out, xrefFile, xrefFile. getName(). endsWith(" .gz" ));
191
159
% > </pre >
192
- <img src =" <%= rawPath % > ?r=<%= Util . URIEncode(rev) % >" />
193
- <pre ><%
194
- } else if (g == Genre . HTML ) {
195
- r = new InputStreamReader (in);
196
- Util . dump(out, r);
160
+ </div ><%
161
+ }
162
+ } else {
163
+ // requesting a previous revision
164
+ FileAnalyzerFactory a = AnalyzerGuru . find(basename);
165
+ Genre g = AnalyzerGuru . getGenre(a);
166
+ String error = null ;
167
+ if (g == Genre . PLAIN|| g == Genre . HTML || g == null ) {
168
+ InputStream in = null ;
169
+ try {
170
+ in = HistoryGuru . getInstance()
171
+ .getRevision(resourceFile. getParent(), basename, rev);
172
+ } catch (Exception e) {
173
+ // fall through to error message
174
+ error = e. getMessage();
175
+ }
176
+ if (in != null ) {
177
+ try {
178
+ if (g == null ) {
179
+ a = AnalyzerGuru . find(in);
180
+ g = AnalyzerGuru . getGenre(a);
181
+ }
182
+ if (g == Genre . DATA || g == Genre . XREFABLE
183
+ || g == null )
184
+ {
185
+ % >
186
+ <div id =" src" >
187
+ Binary file [Click <a href =" <%= rawPath % > ?r=<%= Util . URIEncode(rev) % >" >here</a > to download]
188
+ </div ><%
197
189
} else {
198
- % > Click <a href =" <%= rawPath % > ?r=<%= Util . URIEncode(rev) % >" >download <%= basename % > </a ><%
190
+ % >
191
+ <div id =" src" >
192
+ <pre ><%
193
+ if (g == Genre . PLAIN ) {
194
+ // We don't have any way to get definitions
195
+ // for old revisions currently.
196
+ Definitions defs = null ;
197
+ Annotation annotation = cfg. getAnnotation();
198
+ // not needed yet
199
+ // annotation.writeTooltipMap(out);
200
+ r = IOUtils . createBOMStrippedReader(in);
201
+ AnalyzerGuru . writeXref(a, r, out, defs,
202
+ annotation, Project . getProject(resourceFile));
203
+ } else if (g == Genre . IMAGE ) {
204
+ % > </pre >
205
+ <img src =" <%= rawPath % > ?r=<%= Util . URIEncode(rev) % >" />
206
+ <pre ><%
207
+ } else if (g == Genre . HTML ) {
208
+ r = new InputStreamReader (in);
209
+ Util . dump(out, r);
210
+ } else {
211
+ % > Click <a href =" <%= rawPath % > ?r=<%= Util . URIEncode(rev) % >" >download <%= basename % > </a ><%
212
+ }
213
+ }
214
+ } catch (IOException e) {
215
+ error = e. getMessage();
216
+ } finally {
217
+ if (r != null ) {
218
+ try { r. close(); in = null ;}
219
+ catch (Exception e) { /* ignore */ }
220
+ }
221
+ if (in != null ) {
222
+ try { in. close(); }
223
+ catch (Exception e) { /* ignore */ }
199
224
}
200
225
}
201
- } catch (IOException e) {
202
- error = e. getMessage();
203
- } finally {
204
- if (r != null ) {
205
- try { r. close(); in = null ;}
206
- catch (Exception e) { /* ignore */ }
207
- }
208
- if (in != null ) {
209
- try { in. close(); }
210
- catch (Exception e) { /* ignore */ }
226
+ % > </pre >
227
+ </div ><%
228
+ } else {
229
+ % >
230
+ <h3 class =" error" >Error reading file</h3 ><%
231
+ if (error != null ) {
232
+ % >
233
+ <p class =" error" ><%= error % > </p ><%
211
234
}
212
235
}
213
- % > </pre >
214
- </div ><%
236
+ } else if (g == Genre . IMAGE ) {
237
+ % >
238
+ <div id =" src" >
239
+ <img src =" <%= rawPath % > ?r=<%= Util . URIEncode(rev) % >" />
240
+ </div ><%
215
241
} else {
216
- % >
217
- <h3 class =" error" >Error reading file</h3 ><%
218
- if (error != null ) {
219
- % >
220
- <p class =" error" ><%= error % > </p ><%
221
- }
242
+ % >
243
+ <div id =" src" >
244
+ Binary file [Click <a href =" <%= rawPath % > ?r=<%= Util . URIEncode(rev) % >" >here</a > to download]
245
+ </div ><%
222
246
}
223
- } else if (g == Genre . IMAGE ) {
224
- % >
225
- <div id =" src" >
226
- <img src =" <%= rawPath % > ?r=<%= Util . URIEncode(rev) % >" />
227
- </div ><%
228
- } else {
229
- % >
230
- <div id =" src" >
231
- Binary file [Click <a href =" <%= rawPath % > ?r=<%= Util . URIEncode(rev) % >" >here</a > to download]
232
- </div ><%
233
247
}
234
248
} else {
235
249
// requesting cross referenced file
236
250
File xrefFile = null ;
237
251
if (! cfg. annotate()) {
238
- xrefFile = cfg. findDataFile();
252
+ // Get the latest revision and redirect so that the revision number
253
+ // appears in the URL.
254
+ String location = cfg. getLatestRevisionLocation();
255
+ if (location != null ) {
256
+ response. sendRedirect(location);
257
+ } else {
258
+ xrefFile = cfg. findDataFile();
259
+ }
239
260
}
240
261
if (xrefFile != null ) {
241
262
% >
0 commit comments