Skip to content

Commit a03922c

Browse files
committed
Merge remote-tracking branch 'upstream/master' into mavenize
# Conflicts: # jrcs/pom.xml # opengrok-indexer/pom.xml # opengrok-web/pom.xml # plugins/pom.xml # pom.xml
2 parents 686556f + ee56df7 commit a03922c

File tree

16 files changed

+264
-80
lines changed

16 files changed

+264
-80
lines changed

distribution/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.opengrok</groupId>
99
<artifactId>opengrok-top</artifactId>
10-
<version>1.1-rc29</version>
10+
<version>1.1-rc30</version>
1111
</parent>
1212

1313
<artifactId>opengrok-dist</artifactId>
@@ -24,13 +24,13 @@
2424
<dependency>
2525
<groupId>org.opengrok</groupId>
2626
<artifactId>opengrok</artifactId>
27-
<version>1.1-rc29</version>
27+
<version>1.1-rc30</version>
2828
</dependency>
2929

3030
<dependency>
3131
<groupId>org.opengrok</groupId>
3232
<artifactId>opengrok-web</artifactId>
33-
<version>1.1-rc29</version>
33+
<version>1.1-rc30</version>
3434
<type>war</type>
3535
</dependency>
3636
</dependencies>

jrcs/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
<parent>
66
<groupId>org.opengrok</groupId>
77
<artifactId>opengrok-top</artifactId>
8-
<version>1.1-rc29</version>
8+
<version>1.1-rc30</version>
99
</parent>
1010

1111
<artifactId>jrcs</artifactId>
1212
<packaging>jar</packaging>
13-
<version>1.1-rc29</version>
13+
<version>1.1-rc30</version>
1414

1515
<name>Java RCS</name>
1616

opengrok-indexer/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
2828
<parent>
2929
<groupId>org.opengrok</groupId>
3030
<artifactId>opengrok-top</artifactId>
31-
<version>1.1-rc29</version>
31+
<version>1.1-rc30</version>
3232
</parent>
3333

3434
<artifactId>opengrok</artifactId>
35-
<version>1.1-rc29</version>
35+
<version>1.1-rc30</version>
3636
<packaging>jar</packaging>
3737

3838
<name>OpenGrok Indexer</name>

opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Configuration.java

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ public final class Configuration {
143143
private Set<Group> groups;
144144
private String sourceRoot;
145145
private String dataRoot;
146+
/**
147+
* directory with include files for web application (header, footer, etc.)
148+
*/
149+
private String includeRoot;
146150
private List<RepositoryInfo> repositories;
147151
/**
148152
* @deprecated This is kept around so not to break object deserialization
@@ -804,6 +808,18 @@ public void setDataRoot(String dataRoot) {
804808
this.dataRoot = dataRoot;
805809
}
806810

811+
/**
812+
* If {@link includeRoot} is not set, {@link dataRoot} will be returned.
813+
* @return web include root directory
814+
*/
815+
public String getIncludeRoot() {
816+
return includeRoot != null ? includeRoot : dataRoot;
817+
}
818+
819+
public void setIncludeRoot(String newRoot) {
820+
this.includeRoot = newRoot;
821+
}
822+
807823
public List<RepositoryInfo> getRepositories() {
808824
return repositories;
809825
}
@@ -1175,13 +1191,14 @@ private static String getFileContent(File file) {
11751191
/**
11761192
* Get the contents of the footer include file.
11771193
*
1194+
* @param force if true, reload even if already set
11781195
* @return an empty string if it could not be read successfully, the
11791196
* contents of the file otherwise.
11801197
* @see #FOOTER_INCLUDE_FILE
11811198
*/
1182-
public String getFooterIncludeFileContent() {
1183-
if (footer == null) {
1184-
footer = getFileContent(new File(getDataRoot(), FOOTER_INCLUDE_FILE));
1199+
public String getFooterIncludeFileContent(boolean force) {
1200+
if (footer == null || force) {
1201+
footer = getFileContent(new File(getIncludeRoot(), FOOTER_INCLUDE_FILE));
11851202
}
11861203
return footer;
11871204
}
@@ -1197,17 +1214,18 @@ public String getFooterIncludeFileContent() {
11971214
/**
11981215
* Get the contents of the header include file.
11991216
*
1217+
* @param force if true, reload even if already set
12001218
* @return an empty string if it could not be read successfully, the
12011219
* contents of the file otherwise.
12021220
* @see #HEADER_INCLUDE_FILE
12031221
*/
1204-
public String getHeaderIncludeFileContent() {
1205-
if (header == null) {
1206-
header = getFileContent(new File(getDataRoot(), HEADER_INCLUDE_FILE));
1222+
public String getHeaderIncludeFileContent(boolean force) {
1223+
if (header == null || force) {
1224+
header = getFileContent(new File(getIncludeRoot(), HEADER_INCLUDE_FILE));
12071225
}
12081226
return header;
12091227
}
1210-
1228+
12111229
/**
12121230
* The name of the file relative to the <var>DATA_ROOT</var>, which should
12131231
* be included into the body of web app's "Home" page.
@@ -1219,13 +1237,14 @@ public String getHeaderIncludeFileContent() {
12191237
/**
12201238
* Get the contents of the body include file.
12211239
*
1240+
* @param force if true, reload even if already set
12221241
* @return an empty string if it could not be read successfully, the
12231242
* contents of the file otherwise.
12241243
* @see Configuration#BODY_INCLUDE_FILE
12251244
*/
1226-
public String getBodyIncludeFileContent() {
1227-
if (body == null) {
1228-
body = getFileContent(new File(getDataRoot(), BODY_INCLUDE_FILE));
1245+
public String getBodyIncludeFileContent(boolean force) {
1246+
if (body == null || force) {
1247+
body = getFileContent(new File(getIncludeRoot(), BODY_INCLUDE_FILE));
12291248
}
12301249
return body;
12311250
}
@@ -1243,13 +1262,14 @@ public String getBodyIncludeFileContent() {
12431262
* Get the contents of the page for forbidden error page (403 Forbidden)
12441263
* include file.
12451264
*
1265+
* @param force if true, reload even if already set
12461266
* @return an empty string if it could not be read successfully, the
12471267
* contents of the file otherwise.
12481268
* @see Configuration#E_FORBIDDEN_INCLUDE_FILE
12491269
*/
1250-
public String getForbiddenIncludeFileContent() {
1251-
if (eforbidden_content == null) {
1252-
eforbidden_content = getFileContent(new File(getDataRoot(), E_FORBIDDEN_INCLUDE_FILE));
1270+
public String getForbiddenIncludeFileContent(boolean force) {
1271+
if (eforbidden_content == null || force) {
1272+
eforbidden_content = getFileContent(new File(getIncludeRoot(), E_FORBIDDEN_INCLUDE_FILE));
12531273
}
12541274
return eforbidden_content;
12551275
}

opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/RuntimeEnvironment.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,15 @@ public boolean isLastEditedDisplayMode() {
317317
return threadConfig.get().isLastEditedDisplayMode();
318318
}
319319

320+
/**
321+
* Get the path to the where the web application includes are stored
322+
*
323+
* @return the path to the web application include files
324+
*/
325+
public String getIncludeRootPath() {
326+
return threadConfig.get().getIncludeRoot();
327+
}
328+
320329
/**
321330
* Get the path to the where the index database is stored
322331
*
@@ -1552,6 +1561,15 @@ public void setConfiguration(Configuration configuration, List<String> subFileLi
15521561
// The invalidation of repositories above might have excluded some
15531562
// repositories in HistoryGuru so the configuration needs to reflect that.
15541563
configuration.setRepositories(new ArrayList<>(histGuru.getRepositories()));
1564+
1565+
reloadIncludeFiles(configuration);
1566+
}
1567+
1568+
private void reloadIncludeFiles(Configuration configuration1) {
1569+
configuration1.getBodyIncludeFileContent(true);
1570+
configuration1.getHeaderIncludeFileContent(true);
1571+
configuration1.getFooterIncludeFileContent(true);
1572+
configuration1.getForbiddenIncludeFileContent(true);
15551573
}
15561574

15571575
public Configuration getConfiguration() {

opengrok-indexer/src/test/java/org/opengrok/indexer/configuration/RuntimeEnvironmentTest.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* CDDL HEADER END
1818
*/
1919

20-
/*
20+
/*
2121
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
2323
*/
@@ -119,6 +119,26 @@ public void testDataRoot() throws IOException {
119119
assertEquals(path, instance.getDataRootFile().getCanonicalPath());
120120
}
121121

122+
@Test
123+
public void testIncludeRoot() throws IOException {
124+
RuntimeEnvironment instance = RuntimeEnvironment.getInstance();
125+
assertNull(instance.getIncludeRootPath());
126+
127+
// set data root
128+
File f = File.createTempFile("dataroot", null);
129+
String path = f.getCanonicalPath();
130+
instance.setDataRoot(path);
131+
132+
// verify they are the same
133+
assertEquals(instance.getDataRootPath(), instance.getIncludeRootPath());
134+
135+
// set include root
136+
f = File.createTempFile("includeroot", null);
137+
path = f.getCanonicalPath();
138+
instance.getConfiguration().setIncludeRoot(path);
139+
assertEquals(path, instance.getIncludeRootPath());
140+
}
141+
122142
@Test
123143
public void testSourceRoot() throws IOException {
124144
RuntimeEnvironment instance = RuntimeEnvironment.getInstance();

opengrok-web/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<parent>
66
<groupId>org.opengrok</groupId>
77
<artifactId>opengrok-top</artifactId>
8-
<version>1.1-rc29</version>
8+
<version>1.1-rc30</version>
99
</parent>
1010

1111
<artifactId>opengrok-web</artifactId>
12-
<version>1.1-rc29</version>
12+
<version>1.1-rc30</version>
1313
<packaging>war</packaging>
1414

1515
<name>OpenGrok Web</name>

opengrok-web/src/main/java/org/opengrok/web/AuthorizationFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain fc) thr
7676
config.getEnv().getStatistics().addRequestTime("requests_forbidden",
7777
System.currentTimeMillis() - processTime);
7878

79-
if (!config.getEnv().getConfiguration().getForbiddenIncludeFileContent().isEmpty()) {
79+
if (!config.getEnv().getConfiguration().getForbiddenIncludeFileContent(false).isEmpty()) {
8080
sr.getRequestDispatcher("/eforbidden").forward(sr, sr1);
8181
return;
8282
}

opengrok-web/src/main/webapp/foot.jspf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ org.opengrok.indexer.web.Prefix"
4545
<% if(dateForLastIndexRun != null) { %>
4646
<p>Last Index update <%= dateForLastIndexRun %></p>
4747
<%}%>
48-
<%= cfg.getEnv().getConfiguration().getFooterIncludeFileContent() %>
48+
<%= cfg.getEnv().getConfiguration().getFooterIncludeFileContent(false) %>
4949
<%
5050
if (needAddDiv.contains(cfg.getPrefix())) {
5151
%></div><% // #content

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ include file="menu.jspf"
5858
%></div>
5959
</div>
6060
<div id="results">
61-
<%= PageConfig.get(request).getEnv().getConfiguration().getBodyIncludeFileContent() %>
61+
<%= PageConfig.get(request).getEnv().getConfiguration().getBodyIncludeFileContent(false) %>
6262
<% if (PageConfig.get(request).getEnv().getDisplayRepositories()) { %><%@
6363
6464
include file="repos.jspf"

0 commit comments

Comments
 (0)