Skip to content

Commit 80a75b4

Browse files
committed
Use symlinks data from indexing for history.jsp too
1 parent 0698843 commit 80a75b4

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

opengrok-web/src/main/webapp/history.jsp

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,24 @@ Portions Copyright (c) 2018-2019, Chris Fraire <[email protected]>.
3131
java.text.Format,
3232
java.text.SimpleDateFormat,
3333
java.util.Date,
34+
java.util.logging.Level,
35+
java.util.logging.Logger,
3436
java.util.Objects,
3537
java.util.Set,
3638
java.util.regex.Pattern,
3739

40+
org.opengrok.indexer.configuration.RuntimeEnvironment,
3841
org.opengrok.indexer.history.History,
3942
org.opengrok.indexer.history.HistoryEntry,
40-
org.opengrok.indexer.configuration.RuntimeEnvironment"
43+
org.opengrok.indexer.logger.LoggerFactory,
44+
org.opengrok.indexer.util.ForbiddenSymlinkException,
45+
org.opengrok.indexer.web.SearchHelper"
4146
%>
4247
<%/* ---------------------- history.jsp start --------------------- */
4348
{
44-
PageConfig cfg = PageConfig.get(request);
49+
final Logger LOGGER = LoggerFactory.getLogger(getClass());
4550
51+
PageConfig cfg = PageConfig.get(request);
4652
cfg.checkSourceRootExistence();
4753
4854
// Need to set the title before including httpheader.jspf
@@ -51,10 +57,30 @@ org.opengrok.indexer.configuration.RuntimeEnvironment"
5157
String path = cfg.getPath();
5258
5359
if (path.length() > 0) {
54-
File f = cfg.getResourceFile();
55-
History hist = null;
60+
String primePath = path;
61+
Project project = cfg.getProject();
62+
if (project != null) {
63+
SearchHelper searchHelper = cfg.prepareInternalSearch();
64+
/*
65+
* N.b. searchHelper.destroy() is called via
66+
* WebappListener.requestDestroyed() on presence of the following
67+
* REQUEST_ATTR.
68+
*/
69+
request.setAttribute(SearchHelper.REQUEST_ATTR, searchHelper);
70+
searchHelper.prepareExec(project);
71+
72+
try {
73+
primePath = searchHelper.getPrimeRelativePath(project.getName(), path);
74+
} catch (IOException | ForbiddenSymlinkException ex) {
75+
LOGGER.log(Level.WARNING, String.format(
76+
"Error getting prime relative for %s", path), ex);
77+
}
78+
}
79+
80+
File file = cfg.getResourceFile(primePath);
81+
History hist;
5682
try {
57-
hist = HistoryGuru.getInstance().getHistoryUI(f);
83+
hist = HistoryGuru.getInstance().getHistoryUI(file);
5884
} catch (Exception e) {
5985
// should not happen
6086
response.sendError(HttpServletResponse.SC_NOT_FOUND, e.getMessage());

0 commit comments

Comments
 (0)