Improved: handle patches in demos

I have decided to apply patches once and for all. The reason is else they are
applied once and not later. So it's easier like that.

If we need to change the patches they will be reverted and applied again.
Hopefully only when changing stable and old.

But in R16 (old demo, still uses specialpurpose) the ones under plugins must be
applied  each time because pullAllPluginsSource removes the plugins dir, hence
the patched files
diff --git a/demo-backup/old-manual.sh b/demo-backup/old-manual.sh
index 917799f..2142924 100755
--- a/demo-backup/old-manual.sh
+++ b/demo-backup/old-manual.sh
@@ -5,6 +5,21 @@
 cd /home/ofbizDemo/branch16.11
 svn up
 rm /home/ofbizDemo/branch16.11/framework/base/config/*.jks
+
+# I have decided to apply patches once for all. The reason is else they are 
+# applied once and not later. So it's easier like that. 
+# If we need to change the patches they will be reverted and applied again. 
+# Hopefully only when changing stable and old.
+
+
+#patch -p0 < /home/ofbizDemo/branch16.11/url.properties.patch
+#patch -p0 < /home/ofbizDemo/branch16.11/fop.xconf.patch
+
+#cd /home/ofbizDemo/branch16.11/specialpurpose
+#patch -p0 < /home/ofbizDemo/branch16.11/solr.config.patch
+#cd ..
+
+
 ./gradlew --no-daemon "ofbiz --shutdown --portoffset 20000"
 ./gradlew --no-daemon cleanAll
 ./gradlew --no-daemon "ofbiz --load-data"
diff --git a/demo-backup/patch/old/fop.xconf.old.patch b/demo-backup/patch/old/fop.xconf.patch
similarity index 100%
rename from demo-backup/patch/old/fop.xconf.old.patch
rename to demo-backup/patch/old/fop.xconf.patch
diff --git a/demo-backup/patch/old/solr.config.patch b/demo-backup/patch/old/solr.config.patch
new file mode 100644
index 0000000..69d1f4e
--- /dev/null
+++ b/demo-backup/patch/old/solr.config.patch
@@ -0,0 +1,30 @@
+diff --git solr/config/solrconfig.properties solr/config/solrconfig.properties
+index b87a305..b87142b 100644
+--- solr/config/solrconfig.properties
++++ solr/config/solrconfig.properties
+@@ -25,6 +25,10 @@ solr.webapp.domainName=localhost
+ solr.webapp.portOverride=
+ solr.webapp.path=/solr
+ 
++# complete url with protocol, domainName,port(if require), and webapp path
++# complete url will be given preference if set
++solr.complete.url=https://demo-old.ofbiz.apache.org/solr
++
+ # Global solr ECA service toggling
+ # Set to true to enable solr indexing using ECAs/SECAs.
+ # If set to false, solr services meant to be triggered by ECA/SECA will not execute and will "succeed" silently.
+diff --git solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java
+index 3e05b70..50c8bad 100644
+--- solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java
++++ solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java
+@@ -76,6 +76,10 @@ public final class SolrUtil {
+     private static final boolean trustSelfSignedCert = getTrustSelfSignedCert();
+     
+     public static String makeSolrWebappUrl() {
++        final String solrCompleteUrl = UtilProperties.getPropertyValue(solrConfigName, "solr.complete.url");
++        if (UtilValidate.isNotEmpty(solrCompleteUrl)) {
++            return solrCompleteUrl;
++        }
+         final String solrWebappProtocol = UtilProperties.getPropertyValue(solrConfigName, "solr.webapp.protocol");
+         final String solrWebappDomainName = UtilProperties.getPropertyValue(solrConfigName, "solr.webapp.domainName");
+         final String solrWebappPath = UtilProperties.getPropertyValue(solrConfigName, "solr.webapp.path");
diff --git a/demo-backup/patch/old/url.properties.old.patch b/demo-backup/patch/old/url.properties.patch
similarity index 100%
rename from demo-backup/patch/old/url.properties.old.patch
rename to demo-backup/patch/old/url.properties.patch
diff --git a/demo-backup/patch/stable/fop.xconf.stable.patch b/demo-backup/patch/stable/fop.xconf.patch
similarity index 100%
rename from demo-backup/patch/stable/fop.xconf.stable.patch
rename to demo-backup/patch/stable/fop.xconf.patch
diff --git a/demo-backup/patch/stable/solr.config.patch b/demo-backup/patch/stable/solr.config.patch
new file mode 100644
index 0000000..dcd3d3d
--- /dev/null
+++ b/demo-backup/patch/stable/solr.config.patch
@@ -0,0 +1,30 @@
+diff --git solr/config/solrconfig.properties solr/config/solrconfig.properties
+index b87a305..b87142b 100644
+--- solr/config/solrconfig.properties
++++ solr/config/solrconfig.properties
+@@ -25,6 +25,10 @@ solr.webapp.domainName=localhost
+ solr.webapp.portOverride=
+ solr.webapp.path=/solr
+ 
++# complete url with protocol, domainName,port(if require), and webapp path
++# complete url will be given preference if set
++solr.complete.url=https://demo-stable.ofbiz.apache.org/solr
++
+ # Global solr ECA service toggling
+ # Set to true to enable solr indexing using ECAs/SECAs.
+ # If set to false, solr services meant to be triggered by ECA/SECA will not execute and will "succeed" silently.
+diff --git solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java
+index 3e05b70..50c8bad 100644
+--- solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java
++++ solr/src/main/java/org/apache/ofbiz/solr/SolrUtil.java
+@@ -76,6 +76,10 @@ public final class SolrUtil {
+     private static final boolean trustSelfSignedCert = getTrustSelfSignedCert();
+     
+     public static String makeSolrWebappUrl() {
++        final String solrCompleteUrl = UtilProperties.getPropertyValue(solrConfigName, "solr.complete.url");
++        if (UtilValidate.isNotEmpty(solrCompleteUrl)) {
++            return solrCompleteUrl;
++        }
+         final String solrWebappProtocol = UtilProperties.getPropertyValue(solrConfigName, "solr.webapp.protocol");
+         final String solrWebappDomainName = UtilProperties.getPropertyValue(solrConfigName, "solr.webapp.domainName");
+         final String solrWebappPath = UtilProperties.getPropertyValue(solrConfigName, "solr.webapp.path");
diff --git a/demo-backup/patch/stable/url.properties.stable.patch b/demo-backup/patch/stable/url.properties.patch
similarity index 100%
rename from demo-backup/patch/stable/url.properties.stable.patch
rename to demo-backup/patch/stable/url.properties.patch
diff --git a/demo-backup/patch/trunk/fop.xconf.patch b/demo-backup/patch/trunk/fop.xconf.patch
new file mode 100644
index 0000000..916b7b6
--- /dev/null
+++ b/demo-backup/patch/trunk/fop.xconf.patch
@@ -0,0 +1,16 @@
+ framework/webapp/config/fop.xconf | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git framework/webapp/config/fop.xconf framework/webapp/config/fop.xconf
+index 27576e37a5..df21bf75b2 100644
+--- framework/webapp/config/fop.xconf
++++ framework/webapp/config/fop.xconf
+@@ -32,7 +32,7 @@ the location of this file.
+ 
+   <!-- Base URL for resolving relative URLs -->
+   <!-- We have to keep HTTP URL , FOP does not support HTTPS baseUrl for external graphics due to certificate issue (not remember exact reason) -->
+-  <base>http://localhost:8080</base>
++  <base>https://demo-trunk.ofbiz.apache.org</base>
+ 
+   <!-- Source resolution in dpi (dots/pixels per inch) for determining the size of pixels in SVG and bitmap images, default: 72dpi -->
+   <source-resolution>72</source-resolution>
diff --git a/demo-backup/patch/trunk/fop.xconf.trunk.patch b/demo-backup/patch/trunk/fop.xconf.trunk.patch
deleted file mode 100644
index 725744a..0000000
--- a/demo-backup/patch/trunk/fop.xconf.trunk.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Index: framework/webapp/config/fop.xconf
-===================================================================
---- framework/webapp/config/fop.xconf   (revision 1785051)
-+++ framework/webapp/config/fop.xconf   (working copy)
-@@ -31,7 +31,7 @@
- <fop version="1.0">
-
-   <!-- Base URL for resolving relative URLs -->
--  <base>http://localhost:8080</base>
-+  <base>https://demo-trunk.ofbiz.apache.org</base>
-
-   <!-- Source resolution in dpi (dots/pixels per inch) for determining the size of pixels in SVG and bitmap images, default: 72dpi -->
-   <source-resolution>72</source-resolution>
diff --git a/demo-backup/patch/trunk/url.properties.trunk.patch b/demo-backup/patch/trunk/url.properties.patch
similarity index 99%
rename from demo-backup/patch/trunk/url.properties.trunk.patch
rename to demo-backup/patch/trunk/url.properties.patch
index 76f5a63..0297000 100644
--- a/demo-backup/patch/trunk/url.properties.trunk.patch
+++ b/demo-backup/patch/trunk/url.properties.patch
@@ -13,3 +13,4 @@
  
  # Here you can set the domain string to use for new cookies
  cookie.domain=
+
diff --git a/demo-backup/stable-manual.sh b/demo-backup/stable-manual.sh
index 108ed0d..e45c539 100755
--- a/demo-backup/stable-manual.sh
+++ b/demo-backup/stable-manual.sh
@@ -5,7 +5,23 @@
 git pull
 rm /home/ofbizDemo/branch17.12/framework/base/config/*.jks
 
+# I have decided to apply patches once for all. The reason is else they are 
+# applied once and not later. So it's easier like that. 
+# If we need to change the patches they will be reverted and applied again. 
+# Hopefully only when changing stable and old.
+
+#patch -p0 < /home/ofbizDemo/branch17.12/url.properties.patch
+#patch -p0 < /home/ofbizDemo/branch17.12/fop.xconf.patch
+
+
+#the ones under plugins must be applied  each time 
+# because pullAllPluginsSource removes the plugins dir
+
 ./gradlew --no-daemon pullAllPluginsSource
+cd /home/ofbizDemo/branch17.12/plugins
+patch -p0 < /home/ofbizDemo/branch17.12/solr.config.patch
+cd ..
+
 ./gradlew --no-daemon "ofbiz --shutdown --portoffset 10000"
 ./gradlew --no-daemon cleanAll
 ./gradlew --no-daemon loadAll
diff --git a/demo-backup/trunk.sh b/demo-backup/trunk.sh
index ffef72c..b81de0f 100755
--- a/demo-backup/trunk.sh
+++ b/demo-backup/trunk.sh
@@ -4,7 +4,22 @@
 git pull
 rm /home/ofbizDemo/trunk/framework/base/config/*.jks
 
+# I have decided to apply patches once for all. The reason is else they are 
+# applied once and not later. So it's easier like that. 
+# If we need to change the patches they will be reverted and applied again. 
+# Hopefully only when changing stable and old.
+
+#patch -p0 < /home/ofbizDemo/trunk/url.properties.patch
+#patch -p0 < /home/ofbizDemo/trunk/fop.xconf.patch
+
+#the ones under plugins must be applied  each time 
+# because pullAllPluginsSource removes the plugins dir
+
 ./gradlew --no-daemon pullAllPluginsSource
+cd /home/ofbizDemo/trunk/plugins
+patch -p0 < /home/ofbizDemo/trunk/solr.config.patch
+cd ..
+
 ./gradlew --no-daemon terminateOfbiz
 ./gradlew --no-daemon cleanAll
 ./gradlew --no-daemon loadAll