@@ -20,7 +20,7 @@ CDDL HEADER END
20
20
21
21
Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
22
22
Portions Copyright 2011 Jens Elkner.
23
- Portions Copyright (c) 2017-2019 , Chris Fraire <[email protected] >.
23
+ Portions Copyright (c) 2017-2020 , Chris Fraire <[email protected] >.
24
24
25
25
--%>
26
26
<%@page errorPage =" error.jsp" import="
@@ -34,8 +34,9 @@ java.nio.charset.StandardCharsets,
34
34
java.util.List,
35
35
java.util.Locale,
36
36
java.util.logging.Level,
37
- java.util.Set,
38
37
java.util.logging.Logger,
38
+ java.util.Set,
39
+ java.util.TreeSet,
39
40
org.opengrok.indexer.analysis.AnalyzerGuru,
40
41
org.opengrok.indexer.analysis.Ctags,
41
42
org.opengrok.indexer.analysis.Definitions,
@@ -129,14 +130,15 @@ document.pageReady.push(function() { pageReadyList();});
129
130
// mast.jsp assures, that resourceFile is valid and not /
130
131
// see cfg.resourceNotAvailable()
131
132
String cookieValue = cfg. getRequestedProjectsAsString();
133
+ String projectName = null ;
132
134
if (project != null ) {
135
+ projectName = project. getName();
133
136
Set<String > projects = cfg. getRequestedProjects();
134
- if (! projects. contains(project . getName() )) {
135
- projects. add(project . getName() );
137
+ if (! projects. contains(projectName )) {
138
+ projects. add(projectName );
136
139
// update cookie
137
- cookieValue = cookieValue. length() == 0
138
- ? project. getName()
139
- : project. getName() + ' ,' + cookieValue;
140
+ cookieValue = cookieValue. length() == 0 ? projectName :
141
+ projectName + ' ,' + cookieValue;
140
142
Cookie cookie = new Cookie (PageConfig . OPEN_GROK_PROJECT , URLEncoder . encode(cookieValue, " utf-8" ));
141
143
// TODO hmmm, projects.jspf doesn't set a path
142
144
cookie. setPath(request. getContextPath() + ' /' );
@@ -148,26 +150,30 @@ document.pageReady.push(function() { pageReadyList();});
148
150
List<String > files = cfg. getResourceFileList();
149
151
if (! files. isEmpty()) {
150
152
List<FileExtra > extras = null ;
153
+ SearchHelper searchHelper = cfg. prepareInternalSearch();
154
+ /*
155
+ * N.b. searchHelper.destroy() is called via
156
+ * WebappListener.requestDestroyed() on presence of the following
157
+ * REQUEST_ATTR.
158
+ */
159
+ request. setAttribute(SearchHelper . REQUEST_ATTR , searchHelper);
151
160
if (project != null ) {
152
- SearchHelper searchHelper = cfg. prepareInternalSearch();
153
- // N.b. searchHelper.destroy() is called via
154
- // WebappListener.requestDestroyed() on presence of the
155
- // following REQUEST_ATTR.
156
- request. setAttribute(SearchHelper . REQUEST_ATTR , searchHelper);
157
161
searchHelper. prepareExec(project);
162
+ } else {
163
+ // noinspection Convert2Diamond
164
+ searchHelper. prepareExec(new TreeSet<String > ());
165
+ }
158
166
159
- if (searchHelper. searcher != null ) {
160
- DirectoryExtraReader extraReader =
161
- new DirectoryExtraReader ();
162
- String primePath = path;
163
- try {
164
- primePath = searchHelper. getPrimeRelativePath(project. getName(), path);
165
- } catch (IOException | ForbiddenSymlinkException ex) {
166
- LOGGER . log(Level . WARNING , String . format(
167
- " Error getting prime relative for %s" , path), ex);
168
- }
169
- extras = extraReader. search(searchHelper. searcher, primePath);
167
+ if (searchHelper. searcher != null ) {
168
+ DirectoryExtraReader extraReader = new DirectoryExtraReader ();
169
+ String primePath = path;
170
+ try {
171
+ primePath = searchHelper. getPrimeRelativePath(projectName, path);
172
+ } catch (IOException | ForbiddenSymlinkException ex) {
173
+ LOGGER . log(Level . WARNING , String . format(
174
+ " Error getting prime relative for %s" , path), ex);
170
175
}
176
+ extras = extraReader. search(searchHelper. searcher, primePath);
171
177
}
172
178
173
179
FileExtraZipper zipper = new FileExtraZipper ();
0 commit comments