SOLR-13971: Removing velocity from _default and disabling custom template support by default

This commit is contained in:
Ishan Chattopadhyaya 2019-11-28 07:52:43 +05:30
parent bed694ec88
commit 50e8cea918
6 changed files with 30 additions and 38 deletions

View File

@ -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.

View File

@ -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);

View File

@ -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");

View File

@ -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.

View File

@ -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.

View File

@ -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.
+