You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mb...@apache.org on 2017/10/10 12:54:55 UTC

svn commit: r1811688 - in /ofbiz/ofbiz-plugins/trunk: lucene/ lucene/src/main/java/org/apache/ofbiz/content/search/ solr/ solr/home/solrdefault/conf/ solr/servicedef/ solr/src/main/java/org/apache/ofbiz/solr/ solr/widget/forms/

Author: mbrohl
Date: Tue Oct 10 12:54:54 2017
New Revision: 1811688

URL: http://svn.apache.org/viewvc?rev=1811688&view=rev
Log:
Improved: Update Apache Solr/Lucene to release 6.6.0.
(OFBIZ-9391)

This also fixes the problems with the Guava dependency in OFBIZ-9444 and
adds some tests (see OFBIZ-9442). It makes sense to have more tests in
the course of further refactoring.

Thanks Julian Leichert for helping with the tests.

Modified:
    ofbiz/ofbiz-plugins/trunk/lucene/build.gradle
    ofbiz/ofbiz-plugins/trunk/lucene/src/main/java/org/apache/ofbiz/content/search/SearchWorker.java
    ofbiz/ofbiz-plugins/trunk/solr/build.gradle
    ofbiz/ofbiz-plugins/trunk/solr/home/solrdefault/conf/solrconfig.xml
    ofbiz/ofbiz-plugins/trunk/solr/ofbiz-component.xml
    ofbiz/ofbiz-plugins/trunk/solr/servicedef/solrservices.xml
    ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/SolrProductSearch.java
    ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java
    ofbiz/ofbiz-plugins/trunk/solr/widget/forms/SolrForms.xml

Modified: ofbiz/ofbiz-plugins/trunk/lucene/build.gradle
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/lucene/build.gradle?rev=1811688&r1=1811687&r2=1811688&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/lucene/build.gradle (original)
+++ ofbiz/ofbiz-plugins/trunk/lucene/build.gradle Tue Oct 10 12:54:54 2017
@@ -17,7 +17,7 @@
  * under the License.
  */
 dependencies {
-    pluginLibsCompile 'org.apache.lucene:lucene-core:6.5.1'
-    pluginLibsCompile 'org.apache.lucene:lucene-queryparser:6.5.1'
-    pluginLibsCompile 'org.apache.lucene:lucene-analyzers-common:6.5.1'
-}
+    pluginLibsCompile 'org.apache.lucene:lucene-core:6.6.0'
+    pluginLibsCompile 'org.apache.lucene:lucene-queryparser:6.6.0'
+    pluginLibsCompile 'org.apache.lucene:lucene-analyzers-common:6.6.0'
+}
\ No newline at end of file

Modified: ofbiz/ofbiz-plugins/trunk/lucene/src/main/java/org/apache/ofbiz/content/search/SearchWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/lucene/src/main/java/org/apache/ofbiz/content/search/SearchWorker.java?rev=1811688&r1=1811687&r2=1811688&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/lucene/src/main/java/org/apache/ofbiz/content/search/SearchWorker.java (original)
+++ ofbiz/ofbiz-plugins/trunk/lucene/src/main/java/org/apache/ofbiz/content/search/SearchWorker.java Tue Oct 10 12:54:54 2017
@@ -41,7 +41,7 @@ public final class SearchWorker {
 
     public static final String module = SearchWorker.class.getName();
 
-    private static final Version LUCENE_VERSION = Version.LUCENE_6_5_1;
+    private static final Version LUCENE_VERSION = Version.LUCENE_6_6_0;
 
     private SearchWorker() {}
 

Modified: ofbiz/ofbiz-plugins/trunk/solr/build.gradle
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/solr/build.gradle?rev=1811688&r1=1811687&r2=1811688&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/solr/build.gradle (original)
+++ ofbiz/ofbiz-plugins/trunk/solr/build.gradle Tue Oct 10 12:54:54 2017
@@ -17,5 +17,14 @@
  * under the License.
  */
 dependencies {
-    pluginLibsCompile 'org.apache.solr:solr-core:6.5.1'
+    pluginLibsCompile 'org.apache.solr:solr-core:6.6.0'
+    pluginLibsCompile 'com.google.guava:guava:20.0'
 }
+
+configurations.all {
+    resolutionStrategy {
+      dependencySubstitution {
+          substitute module('com.google.guava:guava') with module('com.google.guava:guava:20.0')
+      }
+    }
+}
\ No newline at end of file

Modified: ofbiz/ofbiz-plugins/trunk/solr/home/solrdefault/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/solr/home/solrdefault/conf/solrconfig.xml?rev=1811688&r1=1811687&r2=1811688&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/solr/home/solrdefault/conf/solrconfig.xml (original)
+++ ofbiz/ofbiz-plugins/trunk/solr/home/solrdefault/conf/solrconfig.xml Tue Oct 10 12:54:54 2017
@@ -35,7 +35,7 @@
        that you fully re-index after changing this setting as it can
        affect both how text is indexed and queried.
   -->
-  <luceneMatchVersion>6.5.1</luceneMatchVersion>
+  <luceneMatchVersion>6.6.0</luceneMatchVersion>
 
   <!-- <lib/> directives can be used to instruct Solr to load any Jars
        identified and use them to resolve any "plugins" specified in

Modified: ofbiz/ofbiz-plugins/trunk/solr/ofbiz-component.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/solr/ofbiz-component.xml?rev=1811688&r1=1811687&r2=1811688&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/solr/ofbiz-component.xml (original)
+++ ofbiz/ofbiz-plugins/trunk/solr/ofbiz-component.xml Tue Oct 10 12:54:54 2017
@@ -30,6 +30,8 @@ under the License.
 
     <service-resource type="model" loader="main" location="servicedef/solrservices.xml"/>
     <service-resource type="eca" loader="main" location="servicedef/secas.xml"/>
+    
+    <test-suite loader="main" location="testdef/solrtests.xml"/>
 
     <webapp name="solr"
         title="Apache Solr Integration"

Modified: ofbiz/ofbiz-plugins/trunk/solr/servicedef/solrservices.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/solr/servicedef/solrservices.xml?rev=1811688&r1=1811687&r2=1811688&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/solr/servicedef/solrservices.xml (original)
+++ ofbiz/ofbiz-plugins/trunk/solr/servicedef/solrservices.xml Tue Oct 10 12:54:54 2017
@@ -30,7 +30,7 @@ under the License.
         location="org.apache.ofbiz.solr.SolrProductSearch"
         invoke="rebuildSolrIndex" debug="true" validate="true">
         <description>rebuild SOLR Index</description>
-        <attribute mode="IN" name="indexName" optional="false" type="String"/>
+        <attribute mode="IN" name="indexName" optional="false" type="String" default-value="solrdefault"/>
         <attribute mode="IN" name="treatConnectErrorNonFatal" optional="true" type="Boolean" default-value="false" />
     </service>
 
@@ -50,7 +50,7 @@ under the License.
         location="org.apache.ofbiz.solr.SolrProductSearch"
         invoke="addToSolrIndex" debug="true" validate="true">
         <description>Add a Product to Solr Index</description>
-        <attribute mode="IN" name="indexName" optional="false" type="String"/>
+        <attribute mode="IN" name="indexName" optional="false" type="String" default-value="solrdefault"/>
         <attribute mode="IN" name="treatConnectErrorNonFatal" optional="true" type="Boolean" />
         <attribute mode="IN" name="productId" optional="false" type="String" />
         <attribute mode="IN" name="sku" optional="true" type="String" />
@@ -83,7 +83,7 @@ under the License.
         location="org.apache.ofbiz.solr.SolrProductSearch"
         invoke="addListToSolrIndex" debug="true" validate="true">
         <description>Add a List of Products to Solr Index and flush after all have been added</description>
-        <attribute mode="IN" name="indexName" optional="false" type="String"/>
+        <attribute mode="IN" name="indexName" optional="false" type="String" default-value="solrdefault"/>
         <attribute mode="IN" name="treatConnectErrorNonFatal" optional="true" type="Boolean" />
         <attribute mode="IN" name="fieldList" optional="false" type="List" />
         <attribute mode="OUT" name="errorType" optional="true" type="String" />
@@ -95,7 +95,7 @@ under the License.
         location="org.apache.ofbiz.solr.SolrProductSearch"
         invoke="productsSearch" debug="true" validate="true">
         <description>Run a query on Solr and return the results</description>
-        <attribute mode="IN" name="indexName" optional="false" type="String"/>
+        <attribute mode="IN" name="indexName" optional="false" type="String" default-value="solrdefault"/>
         <attribute mode="IN" optional="false" name="productCategoryId" type="String"/>
         <attribute mode="IN" optional="true" name="viewSize" type="String"/>
         <attribute mode="IN" optional="true" name="viewIndex" type="String"/>
@@ -112,7 +112,7 @@ under the License.
         location="org.apache.ofbiz.solr.SolrProductSearch"
         invoke="keywordSearch" debug="true" validate="true">
         <description>Run a query on Solr and return the results</description>
-        <attribute mode="IN" name="indexName" optional="false" type="String"/>
+        <attribute mode="IN" name="indexName" optional="false" type="String" default-value="solrdefault"/>
         <attribute mode="IN" optional="false" name="query" type="String"/>
         <attribute mode="IN" optional="true" name="viewSize" type="String"/>
         <attribute mode="IN" optional="true" name="viewIndex" type="String"/>
@@ -137,7 +137,7 @@ under the License.
         location="org.apache.ofbiz.solr.SolrProductSearch"
         invoke="runSolrQuery" debug="true" validate="true">
         <description>Run a query on Solr and return the results</description>
-        <attribute mode="IN" name="indexName" optional="false" type="String"/>
+        <attribute mode="IN" name="indexName" optional="false" type="String" default-value="solrdefault"/>
         <attribute mode="IN" optional="false" name="query" type="String"/>
         <attribute mode="IN" optional="true" name="viewSize" type="Integer"/>
         <attribute mode="IN" optional="true" name="viewIndex" type="Integer"/>
@@ -157,7 +157,7 @@ under the License.
         location="org.apache.ofbiz.solr.SolrProductSearch"
         invoke="getAvailableCategories" debug="true" validate="true">
         <description>Run a query on Solr and return the results</description>
-        <attribute mode="IN" name="indexName" optional="false" type="String"/>
+        <attribute mode="IN" name="indexName" optional="false" type="String" default-value="solrdefault"/>
         <attribute mode="IN" optional="true" name="productCategoryId" type="String"/>
         <attribute mode="IN" optional="true" name="productId" type="String"/>
         <attribute mode="IN" optional="true" name="catalogId" type="String"/>
@@ -173,7 +173,7 @@ under the License.
         location="org.apache.ofbiz.solr.SolrProductSearch"
         invoke="getSideDeepCategories" debug="true" validate="true">
         <description>Run a query on Solr and return the results</description>
-        <attribute mode="IN" name="indexName" optional="false" type="String"/>
+        <attribute mode="IN" name="indexName" optional="false" type="String" default-value="solrdefault"/>
         <attribute mode="IN" optional="true" name="productCategoryId" type="String"/>
         <attribute mode="IN" optional="true" name="catalogId" type="String"/>
         <attribute name="numFound" type="Long" mode="OUT" optional="false"/>

Modified: ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/SolrProductSearch.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/SolrProductSearch.java?rev=1811688&r1=1811687&r2=1811688&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/SolrProductSearch.java (original)
+++ ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/SolrProductSearch.java Tue Oct 10 12:54:54 2017
@@ -63,6 +63,7 @@ public abstract class SolrProductSearch
 
     public static final String module = SolrProductSearch.class.getName();
     public static final String resource = "SolrUiLabels";
+
     /**
      * Adds product to solr, with product denoted by productId field in instance attribute
      * - intended for use with ECAs/SECAs.
@@ -74,7 +75,7 @@ public abstract class SolrProductSearch
         GenericValue productInstance = (GenericValue) context.get("instance");
         String productId = (String) productInstance.get("productId");
         String solrIndexName = (String) context.get("indexName");
-        
+
         if (SolrUtil.isSolrEcaEnabled()) {
             // Debug.logVerbose("Solr: addToSolr: Running indexing for productId '" + productId + "'", module);
             try {
@@ -89,25 +90,25 @@ public abstract class SolrProductSearch
                 }
                 if (ServiceUtil.isError(runResult)) {
                     result = ServiceUtil.returnError(runMsg);
-                }
-                else if (ServiceUtil.isFailure(runResult)) {
+                } else if (ServiceUtil.isFailure(runResult)) {
                     result = ServiceUtil.returnFailure(runMsg);
-                }
-                else {
+                } else {
                     result = ServiceUtil.returnSuccess();
                 }
-            } catch (GenericEntityException gee) {
+            }
+            catch (GenericEntityException gee) {
                 Debug.logError(gee, gee.getMessage(), module);
                 result = ServiceUtil.returnError(gee.toString());
-            } catch (GenericServiceException gse) {
+            }
+            catch (GenericServiceException gse) {
                 Debug.logError(gse, gse.getMessage(), module);
                 result = ServiceUtil.returnError(gse.toString());
-            } catch (Exception e) {
+            }
+            catch (Exception e) {
                 Debug.logError(e, e.getMessage(), module);
                 result = ServiceUtil.returnError(e.toString());
             }
-        }
-        else {
+        } else {
             final String statusMsg = "Solr ECA indexing disabled; skipping indexing for productId '" + productId + "'";
             Debug.logVerbose("Solr: addToSolr: " + statusMsg, module);
             result = ServiceUtil.returnSuccess();
@@ -120,7 +121,7 @@ public abstract class SolrProductSearch
      */
     public static Map<String, Object> addToSolrIndex(DispatchContext dctx, Map<String, Object> context) throws GenericEntityException {
         HttpSolrClient client = null;
-        Locale locale = (Locale)context.get("locale");
+        Locale locale = (Locale) context.get("locale");
         Map<String, Object> result;
         String productId = (String) context.get("productId");
         String solrIndexName = (String) context.get("indexName");
@@ -129,58 +130,61 @@ public abstract class SolrProductSearch
         Boolean treatConnectErrorNonFatal = (Boolean) context.get("treatConnectErrorNonFatal");
         try {
             Debug.logInfo("Solr: Generating and indexing document for productId '" + productId + "'", module);
-            
+
             client = SolrUtil.getInstance().getHttpSolrClient(solrIndexName);
-            //Debug.log(server.ping().toString());
 
             // Construct Documents
             SolrInputDocument doc1 = SolrUtil.generateSolrDocument(context);
             Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
-            
+
             if (Debug.verboseOn()) {
                 Debug.logVerbose("Solr: Indexing document: " + doc1.toString(), module);
             }
-            
+
             docs.add(doc1);
 
             // push Documents to server
             client.add(docs);
             client.commit();
-            
+
             final String statusStr = UtilProperties.getMessage(resource, "SolrDocumentForProductIdAddedToSolrIndex", UtilMisc.toMap("productId", context.get("productId")), locale);
             Debug.logInfo("Solr: " + statusStr, module);
             result = ServiceUtil.returnSuccess(statusStr);
-        } catch (MalformedURLException e) {
+        }
+        catch (MalformedURLException e) {
             Debug.logError(e, e.getMessage(), module);
             result = ServiceUtil.returnError(e.toString());
             result.put("errorType", "urlError");
-        } catch (SolrServerException e) {
+        }
+        catch (SolrServerException e) {
             if (e.getCause() != null && e.getCause() instanceof ConnectException) {
-                final String statusStr = UtilProperties.getMessage(resource, "SolrFailureConnectingToSolrServerToCommitProductId", UtilMisc.toMap("productId", context.get("productId")), locale);
+                final String statusStr = UtilProperties.getMessage(resource, "SolrFailureConnectingToSolrServerToCommitProductId",
+                        UtilMisc.toMap("productId", context.get("productId")), locale);
                 if (Boolean.TRUE.equals(treatConnectErrorNonFatal)) {
                     Debug.logWarning(e, "Solr: " + statusStr, module);
                     result = ServiceUtil.returnFailure(statusStr);
-                }
-                else {
+                } else {
                     Debug.logError(e, "Solr: " + statusStr, module);
                     result = ServiceUtil.returnError(statusStr);
                 }
                 result.put("errorType", "connectError");
-            }
-            else {
+            } else {
                 Debug.logError(e, e.getMessage(), module);
                 result = ServiceUtil.returnError(e.toString());
                 result.put("errorType", "solrServerError");
             }
-        } catch (IOException e) {
+        }
+        catch (IOException e) {
             Debug.logError(e, e.getMessage(), module);
             result = ServiceUtil.returnError(e.toString());
             result.put("errorType", "ioError");
-        } finally {
+        }
+        finally {
             if (client != null) {
                 try {
                     client.close();
-                } catch (IOException e) {
+                }
+                catch (IOException e) {
                     // do nothing
                 }
             }
@@ -203,10 +207,10 @@ public abstract class SolrProductSearch
             Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
 
             // Construct Documents
-            List<Map<String, Object>> fieldList = UtilGenerics.<Map<String, Object>>checkList(context.get("fieldList"));
-            
+            List<Map<String, Object>> fieldList = UtilGenerics.<Map<String, Object>> checkList(context.get("fieldList"));
+
             Debug.logInfo("Solr: Generating and adding " + fieldList.size() + " documents to solr index", module);
-            
+
             for (Iterator<Map<String, Object>> fieldListIterator = fieldList.iterator(); fieldListIterator.hasNext();) {
                 SolrInputDocument doc1 = SolrUtil.generateSolrDocument(fieldListIterator.next());
                 if (Debug.verboseOn()) {
@@ -218,41 +222,45 @@ public abstract class SolrProductSearch
             client = SolrUtil.getInstance().getHttpSolrClient(solrIndexName);
             client.add(docs);
             client.commit();
-            
+
             final String statusStr = UtilProperties.getMessage(resource, "SolrAddedDocumentsToSolrIndex", UtilMisc.toMap("fieldList", fieldList.size()), locale);
             Debug.logInfo("Solr: " + statusStr, module);
             result = ServiceUtil.returnSuccess(statusStr);
-        } catch (MalformedURLException e) {
+        }
+        catch (MalformedURLException e) {
             Debug.logError(e, e.getMessage(), module);
             result = ServiceUtil.returnError(e.toString());
             result.put("errorType", "urlError");
-        } catch (SolrServerException e) {
+        }
+        catch (SolrServerException e) {
             if (e.getCause() != null && e.getCause() instanceof ConnectException) {
-                final String statusStr = UtilProperties.getMessage(resource, "SolrFailureConnectingToSolrServerToCommitProductList", UtilMisc.toMap("productId", context.get("productId")), locale);
+                final String statusStr = UtilProperties.getMessage(resource, "SolrFailureConnectingToSolrServerToCommitProductList",
+                        UtilMisc.toMap("productId", context.get("productId")), locale);
                 if (Boolean.TRUE.equals(treatConnectErrorNonFatal)) {
                     Debug.logWarning(e, "Solr: " + statusStr, module);
                     result = ServiceUtil.returnFailure(statusStr);
-                }
-                else {
+                } else {
                     Debug.logError(e, "Solr: " + statusStr, module);
                     result = ServiceUtil.returnError(statusStr);
                 }
                 result.put("errorType", "connectError");
-            }
-            else {
+            } else {
                 Debug.logError(e, e.getMessage(), module);
                 result = ServiceUtil.returnError(e.toString());
                 result.put("errorType", "solrServerError");
             }
-        } catch (IOException e) {
+        }
+        catch (IOException e) {
             Debug.logError(e, e.getMessage(), module);
             result = ServiceUtil.returnError(e.toString());
             result.put("errorType", "ioError");
-        } finally {
+        }
+        finally {
             if (client != null) {
                 try {
                     client.close();
-                } catch (IOException e) {
+                }
+                catch (IOException e) {
                     // do nothing
                 }
             }
@@ -276,7 +284,6 @@ public abstract class SolrProductSearch
             // create Query Object
             SolrQuery solrQuery = new SolrQuery();
             solrQuery.setQuery((String) context.get("query"));
-            // solrQuery.setQueryType("dismax");
             boolean faceted = (Boolean) context.get("facet");
             if (faceted) {
                 solrQuery.setFacet(faceted);
@@ -296,12 +303,12 @@ public abstract class SolrProductSearch
                 solrQuery.addFacetQuery("listPrice:[10000 TO 50000]");
                 solrQuery.addFacetQuery("listPrice:[50000 TO *]");
             }
-            
+
             boolean spellCheck = (Boolean) context.get("spellcheck");
-            if(spellCheck){
+            if (spellCheck) {
                 solrQuery.setParam("spellcheck", spellCheck);
             }
-            
+
             boolean highLight = (Boolean) context.get("highlight");
             if (highLight) {
                 solrQuery.setHighlight(highLight);
@@ -331,8 +338,8 @@ public abstract class SolrProductSearch
             // solrQuery.setFilterQueries(tn);
             // }
             String queryFilter = (String) context.get("queryFilter");
-            if(UtilValidate.isNotEmpty(queryFilter))
-            solrQuery.setFilterQueries(queryFilter.split(" "));
+            if (UtilValidate.isNotEmpty(queryFilter))
+                solrQuery.setFilterQueries(queryFilter.split(" "));
             if ((String) context.get("returnFields") != null) {
                 solrQuery.setFields((String) context.get("returnFields"));
             }
@@ -354,14 +361,17 @@ public abstract class SolrProductSearch
             QueryResponse rsp = client.query(solrQuery);
             result = ServiceUtil.returnSuccess();
             result.put("queryResult", rsp);
-        } catch (Exception e) {
+        }
+        catch (Exception e) {
             Debug.logError(e, e.getMessage(), module);
             result = ServiceUtil.returnError(e.toString());
-        } finally {
+        }
+        finally {
             if (client != null) {
                 try {
                     client.close();
-                } catch (IOException e) {
+                }
+                catch (IOException e) {
                     // do nothing
                 }
             }
@@ -380,11 +390,10 @@ public abstract class SolrProductSearch
 
         try {
             Map<String, Object> dispatchMap = new HashMap<String, Object>();
-            if (UtilValidate.isNotEmpty(context.get("productCategoryId"))){
+            if (UtilValidate.isNotEmpty(context.get("productCategoryId"))) {
                 String productCategoryId = (String) context.get("productCategoryId");
-                dispatchMap.put("query", "cat:*" + productCategoryId+"*");
-            }
-            else
+                dispatchMap.put("query", "cat:*" + productCategoryId + "*");
+            } else
                 return ServiceUtil.returnError(UtilProperties.getMessage(resource, "SolrMissingProductCategoryId", locale));
             if (context.get("viewSize") != null)
                 dispatchMap.put("viewSize", Integer.parseInt(((String) context.get("viewSize"))));
@@ -396,14 +405,22 @@ public abstract class SolrProductSearch
             dispatchMap.put("spellcheck", true);
             dispatchMap.put("highlight", true);
             dispatchMap.put("indexName", solrIndexName);
+
             Map<String, Object> searchResult = dispatcher.runSync("runSolrQuery", dispatchMap);
+
             QueryResponse queryResult = (QueryResponse) searchResult.get("queryResult");
-            result = ServiceUtil.returnSuccess();
-            result.put("results", queryResult.getResults());
-            result.put("listSize", queryResult.getResults().getNumFound());
-            result.put("viewIndex", queryResult.getResults().getStart());
-            result.put("viewSize", queryResult.getResults().size());
-        } catch (Exception e) {
+
+            if (queryResult != null) {
+                result = ServiceUtil.returnSuccess();
+                result.put("results", queryResult.getResults());
+                result.put("listSize", queryResult.getResults().getNumFound());
+                result.put("viewIndex", queryResult.getResults().getStart());
+                result.put("viewSize", queryResult.getResults().size());
+            } else {
+                result = ServiceUtil.returnFailure();
+            }
+        }
+        catch (Exception e) {
             Debug.logError(e, e.getMessage(), module);
             result = ServiceUtil.returnError(e.toString());
         }
@@ -485,7 +502,8 @@ public abstract class SolrProductSearch
             result.put("viewSize", queryResult.getResults().size());
             result.put("suggestions", suggestions);
 
-        } catch (Exception e) {
+        }
+        catch (Exception e) {
             Debug.logError(e, e.getMessage(), module);
             result = ServiceUtil.returnError(e.toString());
         }
@@ -512,10 +530,12 @@ public abstract class SolrProductSearch
             String catalogId = null;
             if (UtilValidate.isNotEmpty(context.get("catalogId")))
                 catalogId = (String) context.get("catalogId");
-            
-            String productCategoryId = (String) context.get("productCategoryId") != null ? CategoryUtil.getCategoryNameWithTrail((String) context.get("productCategoryId"),dctx) : null;
+
+            String productCategoryId = (String) context.get("productCategoryId") != null ? CategoryUtil.getCategoryNameWithTrail((String) context.get("productCategoryId"), dctx)
+                    : null;
             Debug.logInfo("productCategoryId " + productCategoryId, module);
-            Map<String, Object> query = SolrUtil.categoriesAvailable(catalogId, productCategoryId, (String) context.get("productId"), displayProducts, viewIndex, viewSize, solrIndexName);
+            Map<String, Object> query = SolrUtil.categoriesAvailable(catalogId, productCategoryId, (String) context.get("productId"), displayProducts, viewIndex, viewSize,
+                    solrIndexName);
 
             QueryResponse cat = (QueryResponse) query.get("rows");
             result = ServiceUtil.returnSuccess();
@@ -538,14 +558,14 @@ public abstract class SolrProductSearch
                     // Debug.logInfo("The returned map is this:" + result, module);
                 }
             }
-        } catch (Exception e) {
+        }
+        catch (Exception e) {
             result = ServiceUtil.returnError(e.toString());
             result.put("numFound", (long) 0);
         }
         return result;
     }
-    
-    
+
     /**
      * Return a map of the side deep categories.
      */
@@ -556,72 +576,70 @@ public abstract class SolrProductSearch
             String catalogId = null;
             if (UtilValidate.isNotEmpty(context.get("catalogId")))
                 catalogId = (String) context.get("catalogId");
-            
-            String productCategoryId = (String) context.get("productCategoryId") != null ? CategoryUtil.getCategoryNameWithTrail((String) context.get("productCategoryId"),dctx) : null;
+
+            String productCategoryId = (String) context.get("productCategoryId") != null ? CategoryUtil.getCategoryNameWithTrail((String) context.get("productCategoryId"), dctx)
+                    : null;
             result = ServiceUtil.returnSuccess();
             Map<String, List<Map<String, Object>>> catLevel = new HashMap<String, List<Map<String, Object>>>();
-            Debug.logInfo("productCategoryId: "+productCategoryId, module);
-            
+            Debug.logInfo("productCategoryId: " + productCategoryId, module);
+
             //Add toplevel categories
             String[] trailElements = productCategoryId.split("/");
-            
+
             //iterate over actual results
-            for(String elements : trailElements){
+            for (String elements : trailElements) {
                 //catIds must be greater than 3 chars
-                if(elements.length()>3){
-                Debug.logInfo("elements: "+elements,module);
-                String categoryPath = CategoryUtil.getCategoryNameWithTrail(elements,dctx);
-                String[] categoryPathArray = categoryPath.split("/");
-                int level = Integer.parseInt(categoryPathArray[0]);
-                String facetQuery = CategoryUtil.getFacetFilterForCategory(categoryPath, dctx);
-                //Debug.logInfo("categoryPath: "+categoryPath + " facetQuery: "+facetQuery,module);
-                Map<String, Object> query = SolrUtil.categoriesAvailable(catalogId, categoryPath, null, facetQuery, false, 0, 0, solrIndexName);
-                QueryResponse cat = (QueryResponse) query.get("rows");
-                List<Map<String, Object>> categories = new ArrayList<Map<String, Object>>();
-                
-                
-                List<FacetField> catList = (List<FacetField>) cat.getFacetFields();
-                for (Iterator<FacetField> catIterator = catList.iterator(); catIterator.hasNext();) {
-                    FacetField field = (FacetField) catIterator.next();
-                    List<Count> catL = (List<Count>) field.getValues();
-                    if (catL != null) {
-                        for (Iterator<Count> catIter = catL.iterator(); catIter.hasNext();) {
-                            FacetField.Count f = (FacetField.Count) catIter.next();
-                            if (f.getCount() > 0) {
-                                Map<String, Object> catMap = new HashMap<String, Object>();
-                                LinkedList<String> iName = new LinkedList<String>();
-                                iName.addAll(Arrays.asList(f.getName().split("/")));
-                                //Debug.logInfo("topLevel "+topLevel,"");
-                                // int l = Integer.parseInt((String) iName.getFirst());
-                                catMap.put("catId",iName.getLast());
-                                iName.removeFirst();
-                                String path = f.getName();
-                                catMap.put("path",path);
-                                if(level>0){
-                                    iName.removeLast();    
-                                    catMap.put("parentCategory",StringUtils.join(iName, "/"));
-                                }else{
-                                    catMap.put("parentCategory",null);
+                if (elements.length() > 3) {
+                    Debug.logInfo("elements: " + elements, module);
+                    String categoryPath = CategoryUtil.getCategoryNameWithTrail(elements, dctx);
+                    String[] categoryPathArray = categoryPath.split("/");
+                    int level = Integer.parseInt(categoryPathArray[0]);
+                    String facetQuery = CategoryUtil.getFacetFilterForCategory(categoryPath, dctx);
+                    Map<String, Object> query = SolrUtil.categoriesAvailable(catalogId, categoryPath, null, facetQuery, false, 0, 0, solrIndexName);
+                    QueryResponse cat = (QueryResponse) query.get("rows");
+                    List<Map<String, Object>> categories = new ArrayList<Map<String, Object>>();
+
+                    List<FacetField> catList = (List<FacetField>) cat.getFacetFields();
+                    for (Iterator<FacetField> catIterator = catList.iterator(); catIterator.hasNext();) {
+                        FacetField field = (FacetField) catIterator.next();
+                        List<Count> catL = (List<Count>) field.getValues();
+                        if (catL != null) {
+                            for (Iterator<Count> catIter = catL.iterator(); catIter.hasNext();) {
+                                FacetField.Count f = (FacetField.Count) catIter.next();
+                                if (f.getCount() > 0) {
+                                    Map<String, Object> catMap = new HashMap<String, Object>();
+                                    LinkedList<String> iName = new LinkedList<String>();
+                                    iName.addAll(Arrays.asList(f.getName().split("/")));
+                                    catMap.put("catId", iName.getLast());
+                                    iName.removeFirst();
+                                    String path = f.getName();
+                                    catMap.put("path", path);
+                                    if (level > 0) {
+                                        iName.removeLast();
+                                        catMap.put("parentCategory", StringUtils.join(iName, "/"));
+                                    } else {
+                                        catMap.put("parentCategory", null);
+                                    }
+                                    catMap.put("count", Long.toString(f.getCount()));
+                                    categories.add(catMap);
                                 }
-                                catMap.put("count", Long.toString(f.getCount()));
-                                categories.add(catMap);
                             }
                         }
                     }
-                }
-                catLevel.put("menu-"+level, categories);
+                    catLevel.put("menu-" + level, categories);
                 }
             }
             result.put("categories", catLevel);
             result.put("numFound", (long) 0);
-            
-        } catch (Exception e) {
+
+        }
+        catch (Exception e) {
             result = ServiceUtil.returnError(e.toString());
             result.put("numFound", (long) 0);
         }
         return result;
     }
-    
+
     /**
      * Rebuilds the solr index.
      */
@@ -633,9 +651,9 @@ public abstract class SolrProductSearch
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         Locale locale = (Locale) context.get("locale");
         String solrIndexName = (String) context.get("indexName");
-        
+
         Boolean treatConnectErrorNonFatal = (Boolean) context.get("treatConnectErrorNonFatal");
-        
+
         try {
             client = SolrUtil.getInstance().getHttpSolrClient(solrIndexName);
 
@@ -646,9 +664,9 @@ public abstract class SolrProductSearch
             if (products != null) {
                 numDocs = products.size();
             }
-            
+
             Debug.logInfo("Solr: Clearing solr index and rebuilding with " + numDocs + " found products", module);
-            
+
             Iterator<GenericValue> productIterator = products.iterator();
             while (productIterator.hasNext()) {
                 GenericValue product = productIterator.next();
@@ -661,62 +679,67 @@ public abstract class SolrProductSearch
             client.commit();
 
             // THis adds all products to the Index (instantly)
-            Map<String, Object> runResult = dispatcher.runSync("addListToSolrIndex", UtilMisc.toMap("fieldList", solrDocs, "userLogin", userLogin, 
-                    "locale", locale, "indexName", solrIndexName, "treatConnectErrorNonFatal", treatConnectErrorNonFatal));
-            
+            Map<String, Object> runResult = dispatcher.runSync("addListToSolrIndex", UtilMisc.toMap("fieldList", solrDocs, "userLogin", userLogin, "locale", locale, "indexName",
+                    solrIndexName, "treatConnectErrorNonFatal", treatConnectErrorNonFatal));
+
             String runMsg = ServiceUtil.getErrorMessage(runResult);
             if (UtilValidate.isEmpty(runMsg)) {
                 runMsg = null;
             }
             if (ServiceUtil.isError(runResult)) {
                 result = ServiceUtil.returnError(runMsg);
-            }
-            else if (ServiceUtil.isFailure(runResult)) {
+            } else if (ServiceUtil.isFailure(runResult)) {
                 result = ServiceUtil.returnFailure(runMsg);
-            }
-            else {
+            } else {
                 final String statusMsg = UtilProperties.getMessage(resource, "SolrClearedSolrIndexAndReindexedDocuments", UtilMisc.toMap("numDocs", numDocs), locale);
                 result = ServiceUtil.returnSuccess(statusMsg);
             }
-        } catch (MalformedURLException e) {
+        }
+        catch (MalformedURLException e) {
             Debug.logError(e, e.getMessage(), module);
             result = ServiceUtil.returnError(e.toString());
-        } catch (SolrServerException e) {
+        }
+        catch (SolrServerException e) {
             if (e.getCause() != null && e.getCause() instanceof ConnectException) {
                 final String statusStr = UtilProperties.getMessage(resource, "SolrFailureConnectingToSolrServerToRebuildIndex", locale);
                 if (Boolean.TRUE.equals(treatConnectErrorNonFatal)) {
                     Debug.logWarning(e, "Solr: " + statusStr, module);
                     result = ServiceUtil.returnFailure(statusStr);
-                }
-                else {
+                } else {
                     Debug.logError(e, "Solr: " + statusStr, module);
                     result = ServiceUtil.returnError(statusStr);
                 }
-            }
-            else {
+            } else {
                 Debug.logError(e, e.getMessage(), module);
                 result = ServiceUtil.returnError(e.toString());
             }
-        } catch (IOException e) {
+        }
+        catch (IOException e) {
             Debug.logError(e, e.getMessage(), module);
             result = ServiceUtil.returnError(e.toString());
-        } catch (ServiceAuthException e) {
+        }
+        catch (ServiceAuthException e) {
             Debug.logError(e, e.getMessage(), module);
             result = ServiceUtil.returnError(e.toString());
-        } catch (ServiceValidationException e) {
+        }
+        catch (ServiceValidationException e) {
             Debug.logError(e, e.getMessage(), module);
             result = ServiceUtil.returnError(e.toString());
-        } catch (GenericServiceException e) {
+        }
+        catch (GenericServiceException e) {
             Debug.logError(e, e.getMessage(), module);
             result = ServiceUtil.returnError(e.toString());
-        } catch (Exception e) {
+        }
+        catch (Exception e) {
             Debug.logError(e, e.getMessage(), module);
             result = ServiceUtil.returnError(e.toString());
-        } finally {
+        }
+        finally {
             if (client != null) {
                 try {
                     client.close();
-                } catch (IOException e) {
+                }
+                catch (IOException e) {
                     // do nothing
                 }
             }

Modified: ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java?rev=1811688&r1=1811687&r2=1811688&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java (original)
+++ ofbiz/ofbiz-plugins/trunk/solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java Tue Oct 10 12:54:54 2017
@@ -85,7 +85,7 @@ public final class SolrUtil {
         if (UtilValidate.isNotEmpty(solrWebappPortOverride)) {
             solrPort = solrWebappPortOverride;
         } else {
-            solrPort = UtilProperties.getPropertyValue("url", ("https".equals(solrWebappProtocol) ? "port.https" : "port.http"));
+            solrPort = UtilProperties.getPropertyValue("url", ("https".equals(solrWebappProtocol) ? "port.https" : "port.http"), ("https".equals(solrWebappProtocol) ? "8443" : "8080"));
         }
         
         return solrWebappProtocol + "://" + solrWebappDomainName + ":" + solrPort + solrWebappPath;

Modified: ofbiz/ofbiz-plugins/trunk/solr/widget/forms/SolrForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/solr/widget/forms/SolrForms.xml?rev=1811688&r1=1811687&r2=1811688&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/solr/widget/forms/SolrForms.xml (original)
+++ ofbiz/ofbiz-plugins/trunk/solr/widget/forms/SolrForms.xml Tue Oct 10 12:54:54 2017
@@ -21,7 +21,7 @@
 <forms xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns="http://ofbiz.apache.org/Widget-Form" xsi:schemaLocation="http://ofbiz.apache.org/Widget-Form http://ofbiz.apache.org/dtds/widget-form.xsd">
     
-    <form name="NewQuery" type="single" target="query">
+    <form name="NewQuery" type="single" target="newquery">
         <field name="query" title="${uiLabelMap.QueryString}"><textarea cols="120" rows="5"/></field>
         <field name="search" title="${uiLabelMap.CommonFind}" widget-style="smallSubmit">
             <submit button-type="button"/>