You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by is...@apache.org on 2019/11/28 02:23:01 UTC
[lucene-solr] branch master updated: SOLR-13971: Removing velocity
from _default and disabling custom template support by default
This is an automated email from the ASF dual-hosted git repository.
ishan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/master by this push:
new 50e8cea SOLR-13971: Removing velocity from _default and disabling custom template support by default
50e8cea is described below
commit 50e8cea918062780299b2be1343a59a8bc7eb594
Author: Ishan Chattopadhyaya <is...@apache.org>
AuthorDate: Thu Nov 28 07:52:43 2019 +0530
SOLR-13971: Removing velocity from _default and disabling custom template support by default
---
solr/CHANGES.txt | 3 +++
.../apache/solr/response/VelocityResponseWriter.java | 12 +++++++-----
.../solr/velocity/VelocityResponseWriterTest.java | 9 +++++++++
.../solr/configsets/_default/conf/solrconfig.xml | 13 +------------
.../solr/configsets/_default/conf/solrconfig.xml | 13 +------------
solr/solr-ref-guide/src/velocity-response-writer.adoc | 18 +++++++++---------
6 files changed, 30 insertions(+), 38 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 24634a6..837429f 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -216,6 +216,9 @@ Bug Fixes
* SOLR-13963: JavaBinCodec has concurrent modification of CharArr resulting in corrupt internode updates (Colvin Cowie, noble)
+* SOLR-13971: Velocity response writer's resource loading now possible only through startup parameters. Also, removed velocity
+ response writer from _default configset. (Ishan Chattopadhyaya)
+
================== 8.3.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
diff --git a/solr/contrib/velocity/src/java/org/apache/solr/response/VelocityResponseWriter.java b/solr/contrib/velocity/src/java/org/apache/solr/response/VelocityResponseWriter.java
index 6279ee3..7617649 100644
--- a/solr/contrib/velocity/src/java/org/apache/solr/response/VelocityResponseWriter.java
+++ b/solr/contrib/velocity/src/java/org/apache/solr/response/VelocityResponseWriter.java
@@ -62,9 +62,11 @@ public class VelocityResponseWriter implements QueryResponseWriter, SolrCoreAwar
// init param names, these are _only_ loaded at init time (no per-request control of these)
// - multiple different named writers could be created with different init params
public static final String TEMPLATE_BASE_DIR = "template.base.dir";
+ public static final String PROPERTIES_FILE = "init.properties.file";
+
+ // System property names, these are _only_ loaded at node startup (no per-request control of these)
public static final String PARAMS_RESOURCE_LOADER_ENABLED = "params.resource.loader.enabled";
public static final String SOLR_RESOURCE_LOADER_ENABLED = "solr.resource.loader.enabled";
- public static final String PROPERTIES_FILE = "init.properties.file";
// request param names
public static final String TEMPLATE = "v.template";
@@ -106,12 +108,12 @@ public class VelocityResponseWriter implements QueryResponseWriter, SolrCoreAwar
}
// params resource loader: off by default
- Boolean prle = args.getBooleanArg(PARAMS_RESOURCE_LOADER_ENABLED);
+ Boolean prle = Boolean.getBoolean(PARAMS_RESOURCE_LOADER_ENABLED);
paramsResourceLoaderEnabled = (null == prle ? false : prle);
- // solr resource loader: on by default
- Boolean srle = args.getBooleanArg(SOLR_RESOURCE_LOADER_ENABLED);
- solrResourceLoaderEnabled = (null == srle ? true : srle);
+ // solr resource loader: off by default
+ Boolean srle = Boolean.getBoolean(SOLR_RESOURCE_LOADER_ENABLED);
+ solrResourceLoaderEnabled = (null == srle ? false : srle);
initPropertiesFileName = (String) args.get(PROPERTIES_FILE);
diff --git a/solr/contrib/velocity/src/test/org/apache/solr/velocity/VelocityResponseWriterTest.java b/solr/contrib/velocity/src/test/org/apache/solr/velocity/VelocityResponseWriterTest.java
index e36624e..f41ae5b 100644
--- a/solr/contrib/velocity/src/test/org/apache/solr/velocity/VelocityResponseWriterTest.java
+++ b/solr/contrib/velocity/src/test/org/apache/solr/velocity/VelocityResponseWriterTest.java
@@ -27,16 +27,25 @@ import org.apache.solr.response.QueryResponseWriter;
import org.apache.solr.response.SolrParamResourceLoader;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.response.VelocityResponseWriter;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class VelocityResponseWriterTest extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
+ System.setProperty("params.resource.loader.enabled", "true");
+ System.setProperty("solr.resource.loader.enabled", "true");
initCore("solrconfig.xml", "schema.xml", getFile("velocity/solr").getAbsolutePath());
System.out.println(getFile("velocity/solr").getAbsolutePath());
}
+ @AfterClass
+ public static void afterClass() throws Exception {
+ System.clearProperty("params.resource.loader.enabled");
+ System.clearProperty("solr.resource.loader.enabled");
+ }
+
@Test
public void testVelocityResponseWriterRegistered() {
QueryResponseWriter writer = h.getCore().getQueryResponseWriter("velocity");
diff --git a/solr/core/src/test-files/solr/configsets/_default/conf/solrconfig.xml b/solr/core/src/test-files/solr/configsets/_default/conf/solrconfig.xml
index db562a2..4fccb3a 100644
--- a/solr/core/src/test-files/solr/configsets/_default/conf/solrconfig.xml
+++ b/solr/core/src/test-files/solr/configsets/_default/conf/solrconfig.xml
@@ -81,8 +81,6 @@
<lib dir="${solr.install.dir:../../../..}/contrib/langid/lib/" regex=".*\.jar" />
<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-langid-\d.*\.jar" />
- <lib dir="${solr.install.dir:../../../..}/contrib/velocity/lib" regex=".*\.jar" />
- <lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-velocity-\d.*\.jar" />
<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-ltr-\d.*\.jar" />
<!-- an exact 'path' can be used instead of a 'dir' to specify a
@@ -780,7 +778,7 @@
(SearchHandler) can be registered multiple times with different
names (and different init parameters)
-->
- <requestHandler name="/browse" class="solr.SearchHandler" useParams="query,facets,velocity,browse">
+ <requestHandler name="/browse" class="solr.SearchHandler" useParams="query,facets,browse">
<lst name="defaults">
<str name="echoParams">explicit</str>
</lst>
@@ -1292,15 +1290,6 @@
</queryResponseWriter>
-->
- <!--
- Custom response writers can be declared as needed...
- -->
- <queryResponseWriter name="velocity" class="solr.VelocityResponseWriter" startup="lazy">
- <str name="template.base.dir">${velocity.template.base.dir:}</str>
- <str name="solr.resource.loader.enabled">${velocity.solr.resource.loader.enabled:true}</str>
- <str name="params.resource.loader.enabled">${velocity.params.resource.loader.enabled:false}</str>
- </queryResponseWriter>
-
<!-- XSLT response writer transforms the XML output by any xslt file found
in Solr's conf/xslt directory. Changes to xslt files are checked for
every xsltCacheLifetimeSeconds.
diff --git a/solr/server/solr/configsets/_default/conf/solrconfig.xml b/solr/server/solr/configsets/_default/conf/solrconfig.xml
index db562a2..4fccb3a 100644
--- a/solr/server/solr/configsets/_default/conf/solrconfig.xml
+++ b/solr/server/solr/configsets/_default/conf/solrconfig.xml
@@ -81,8 +81,6 @@
<lib dir="${solr.install.dir:../../../..}/contrib/langid/lib/" regex=".*\.jar" />
<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-langid-\d.*\.jar" />
- <lib dir="${solr.install.dir:../../../..}/contrib/velocity/lib" regex=".*\.jar" />
- <lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-velocity-\d.*\.jar" />
<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-ltr-\d.*\.jar" />
<!-- an exact 'path' can be used instead of a 'dir' to specify a
@@ -780,7 +778,7 @@
(SearchHandler) can be registered multiple times with different
names (and different init parameters)
-->
- <requestHandler name="/browse" class="solr.SearchHandler" useParams="query,facets,velocity,browse">
+ <requestHandler name="/browse" class="solr.SearchHandler" useParams="query,facets,browse">
<lst name="defaults">
<str name="echoParams">explicit</str>
</lst>
@@ -1292,15 +1290,6 @@
</queryResponseWriter>
-->
- <!--
- Custom response writers can be declared as needed...
- -->
- <queryResponseWriter name="velocity" class="solr.VelocityResponseWriter" startup="lazy">
- <str name="template.base.dir">${velocity.template.base.dir:}</str>
- <str name="solr.resource.loader.enabled">${velocity.solr.resource.loader.enabled:true}</str>
- <str name="params.resource.loader.enabled">${velocity.params.resource.loader.enabled:false}</str>
- </queryResponseWriter>
-
<!-- XSLT response writer transforms the XML output by any xslt file found
in Solr's conf/xslt directory. Changes to xslt files are checked for
every xsltCacheLifetimeSeconds.
diff --git a/solr/solr-ref-guide/src/velocity-response-writer.adoc b/solr/solr-ref-guide/src/velocity-response-writer.adoc
index bc6da16..8f1f914 100644
--- a/solr/solr-ref-guide/src/velocity-response-writer.adoc
+++ b/solr/solr-ref-guide/src/velocity-response-writer.adoc
@@ -27,8 +27,6 @@ Its JAR and dependencies must be added (via `<lib>` or solr/home lib inclusion),
<!--
<str name="init.properties.file">velocity-init.properties</str>
- <bool name="params.resource.loader.enabled">true</bool>
- <bool name="solr.resource.loader.enabled">false</bool>
<lst name="tools">
<str name="mytool">com.example.MyCustomTool</str>
</lst>
@@ -36,16 +34,11 @@ Its JAR and dependencies must be added (via `<lib>` or solr/home lib inclusion),
</queryResponseWriter>
----
-The above example shows the optional initialization and custom tool parameters used by VelocityResponseWriter; these are detailed in the following table. These initialization parameters are only specified in the writer registration in `solrconfig.xml`, not as request-time parameters. See further below for request-time parameters.
+The above example shows the optional initialization and custom tool parameters used by VelocityResponseWriter; these are detailed in the following table. These initialization parameters are only specified in the writer registration in `solrconfig.xml`, not as request-time parameters. In this example, all Solr nodes should be started with `-Dparams.resource.loader.enabled=true`. See further below for request-time parameters.
== Configuration & Usage
-=== VelocityResponseWriter Initialization Parameters
-
-`template.base.dir`::
-If specified and exists as a file system directory, a file resource loader will be added for this directory. Templates in this directory will override "solr" resource loader templates.
-
-`init.properties.file`:: Specifies a properties file name which must exist in the Solr `conf/` directory (*not* under a `velocity/` subdirectory) or root of a JAR file in a <lib>.
+=== VelocityResponseWriter Startup Parameters
`params.resource.loader.enabled`::
The "params" resource loader allows templates to be specified in Solr request parameters. For example:
@@ -58,6 +51,13 @@ where `v.template=custom` says to render a template called "custom" and the valu
`solr.resource.loader.enabled`::
The "solr" resource loader is the only template loader registered by default. Templates are served from resources visible to the SolrResourceLoader under a `velocity/` subdirectory. The VelocityResponseWriter itself has some built-in templates (in its JAR file, under `velocity/`) that are available automatically through this loader. These built-in templates can be overridden when the same template name is in conf/velocity/ or by using the `template.base.dir` option.
+=== VelocityResponseWriter Initialization Parameters
+
+`template.base.dir`::
+If specified and exists as a file system directory, a file resource loader will be added for this directory. Templates in this directory will override "solr" resource loader templates.
+
+`init.properties.file`:: Specifies a properties file name which must exist in the Solr `conf/` directory (*not* under a `velocity/` subdirectory) or root of a JAR file in a <lib>.
+
`tools`::
External "tools" can be specified as list of string name/value (tool name / class name) pairs. Tools, in the Velocity context, are simply Java objects. Tool classes are constructed using a no-arg constructor (or a single-SolrCore-arg constructor if it exists) and added to the Velocity context with the specified name.
+