dsmiley commented on a change in pull request #2306:
URL: https://github.com/apache/lucene-solr/pull/2306#discussion_r571368100



##########
File path: 
solr/contrib/scripting/src/java/org/apache/solr/scripting/response/package-info.java
##########
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Support for transforming via XSL stylesheets search responses.

Review comment:
       The package name suggests nothing of XSLT yet we document it as only for 
XSLT?  Let's just put all XSLT stuff in the same package? (with or without a 
.response; I don't think that aspect is important)

##########
File path: 
solr/contrib/scripting/src/java/org/apache/solr/scripting/util/xslt/TransformerProvider.java
##########
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.solr.util.xslt;

Review comment:
       Let's ditch this "util" intermediate package; okay?  I can see maybe it 
had a role to play before, but not in scripting contrib.

##########
File path: 
solr/contrib/scripting/src/test/org/apache/solr/scripting/handler/XSLTOutputWriterTest.java
##########
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.scripting.handler;
+
+import org.apache.solr.SolrTestCaseJ4;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/** Tests the ability to configure multiple query output writers, and select 
those
+ * at query time.  This is specific to the XSLT writer, which isn't part of 
the core.
+ * 
+ * See the related unit test OutputWriterTest.
+ *
+ */
+public class XSLTOutputWriterTest extends SolrTestCaseJ4 {

Review comment:
       The formatting in this file is a bit off (indentation varies etc.).  
Lucene recently adopted the Google Java Format.  I use an IntelliJ plugin for 
this.  Can you please reformat this file with that?  Even the built-in 
formatter is probably fine.

##########
File path: solr/core/src/java/org/apache/solr/handler/UpdateRequestHandler.java
##########
@@ -134,12 +135,23 @@ protected void setAssumeContentType(String ct) {
   }
   private Map<String ,ContentStreamLoader> pathVsLoaders = new HashMap<>();
   protected Map<String,ContentStreamLoader> 
createDefaultLoaders(@SuppressWarnings({"rawtypes"})NamedList args) {
+
     SolrParams p = null;
     if(args!=null) {
       p = args.toSolrParams();
     }
     Map<String,ContentStreamLoader> registry = new HashMap<>();
-    registry.put("application/xml", new XMLLoader().init(p) );
+
+    // Try to load the scripting contrib modules XSLTLoader, and if not, fall 
back to the XMLLoader.
+    // Enable the XSLTLoader by including the Scripting contrib module.
+    try {
+      final Class<?> clazz = Class.forName( 
"org.apache.solr.scripting.util.xslt.XSLTLoader" );

Review comment:
       If the scripting contrib is added as a package, Solr core.jar will not 
be able to load it in this way, I think.

##########
File path: 
solr/contrib/scripting/src/java/org/apache/solr/scripting/util/xslt/XSLTParams.java
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.scripting.util.xslt;
+
+
+/**
+ * Parameters used across the XSLT related classes.
+ */
+public interface XSLTParams {

Review comment:
       I see why you added this here but I don't think there's a role for 
XSLTParams.  Just move this "tr" constant to the plugin that defines it for its 
internal use only.  CommonParams was in SolrJ deliberately; This XSLTParams you 
added is not (and should not be).

##########
File path: 
solr/contrib/scripting/src/test/org/apache/solr/scripting/handler/XsltUpdateRequestHandlerTest.java
##########
@@ -69,8 +77,8 @@ public void testUpdate() throws Exception
       "</random>";
 
     Map<String,String> args = new HashMap<>();
-    args.put(CommonParams.TR, "xsl-update-handler-test.xsl");
-      
+    args.put(XSLTParams.TR, "xsl-update-handler-test.xsl");

Review comment:
       In tests, you can just refer to the parameter directly: "tr".  Yonik 
advised this practice once on the reasoning that the test catches API changes 
you might not have meant to make.  Also, it's shorter :-)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to