Merge pull request #3538 from ebarboni/release125api

#3443 to release125
diff --git a/nbbuild/antsrc/org/netbeans/nbbuild/ReleaseJsonProperties.java b/nbbuild/antsrc/org/netbeans/nbbuild/ReleaseJsonProperties.java
index 8de5ee0..3a0bd09 100644
--- a/nbbuild/antsrc/org/netbeans/nbbuild/ReleaseJsonProperties.java
+++ b/nbbuild/antsrc/org/netbeans/nbbuild/ReleaseJsonProperties.java
@@ -114,9 +114,7 @@
         } catch (ParseException | IOException ex) {
             throw new BuildException(ex);
         }
-        
-        // remove empty api doc 
-        ri.removeIf(e -> e.apidocurl.isEmpty());
+
         // sort all information
         Collections.sort(ri);
         // build a sorted xml
@@ -136,11 +134,12 @@
         }
 
         if (requiredbranchinfo == null) {
-            throw new BuildException("No Release Information found for branch '" + branch + "', update json file section");
+            throw new BuildException("No Release Information found for branch '" + branch + "', update json file section with ant -Dneedjsondownload=true");
         }
         List<String> updateValues = new ArrayList<>();
         for (ReleaseInfo releaseInfo : ri) {
-            if (releaseInfo.position < requiredbranchinfo.position) {
+            // take previous version of Apache NetBeans only if published, need for scan for old NetBeans version
+            if (releaseInfo.position < requiredbranchinfo.position && releaseInfo.publishapi ) {
                 updateValues.add(releaseInfo.version);
             }
         }
@@ -194,7 +193,7 @@
             throw new BuildException("Properties File for release cannot be created");
         }
 
-        log("Writing releasinfo file " + xmlFile);
+        log("Writing release info file " + xmlFile);
 
         xmlFile.getParentFile().mkdirs();
         try (OutputStream config = new FileOutputStream(xmlFile)) {
@@ -221,6 +220,7 @@
         releasesxml.setAttribute("position", Integer.toString(releaseInfo.position));
         releasesxml.setAttribute("version", releaseInfo.version);
         releasesxml.setAttribute("apidocurl", releaseInfo.apidocurl);
+        releasesxml.setAttribute("pubapidoc", Boolean.toString(releaseInfo.publishapi));
     }
 
     private ReleaseInfo manageRelease(String key, Object arelease) {
@@ -249,6 +249,8 @@
         ri.setJavaApiDocurl((String) getJSONInfo(jsonrelease, "jdk_apidoc", "Apidoc: javadoc for java jdk"));
         ri.setUpdateUrl((String) getJSONInfo(jsonrelease, "update_url", "Update catalog"));
         ri.setPluginsUrl((String) getJSONInfo(jsonrelease, "plugin_url", "Plugin URL"));
+        //
+        ri.setPublishApi(Boolean.parseBoolean((String) getJSONInfo(jsonrelease, "publish_apidoc", "Should we publish this Apidoc")));
         // optional section
         JSONObject milestone = (JSONObject) jsonrelease.get("milestones");
         if (milestone != null) {
@@ -284,7 +286,6 @@
 
     private Object getJSONInfo(JSONObject json, String key, String info) {
         Object result = json.get(key);
-        //log("Retriving " + key);
         if (result == null) {
             throw new BuildException("Cannot retrieve key " + key + ", this is for" + info);
         }
@@ -341,6 +342,7 @@
         private String javaapidocurl;
         private String updateurl;
         private String pluginsurl;
+        private boolean publishapi;
         private List<MileStone> milestones;
 
         public ReleaseInfo(String key) {
@@ -411,6 +413,10 @@
             this.milestones.add(milestone);
         }
 
+        private void setPublishApi(boolean publishok) {
+            this.publishapi = publishok;
+        }
+
     }
 
 }
diff --git a/nbbuild/javadoctools/jsonhelp.xsl b/nbbuild/javadoctools/jsonhelp.xsl
index 3b71e20..818c118 100644
--- a/nbbuild/javadoctools/jsonhelp.xsl
+++ b/nbbuild/javadoctools/jsonhelp.xsl
@@ -263,28 +263,21 @@
                 <xsl:for-each select="document($releaseinfo)//release">
                     <xsl:sort data-type="number" select="@position" order="descending" />
                     <xsl:choose>
-                        <xsl:when test="$currentversion = @position">
+                        <xsl:when test="$currentversion = @position  and @pubapidoc='true'  ">
                             <span>
                                 <xsl:value-of select="@version"/>
                             </span>
                         </xsl:when>
-                        <xsl:otherwise>
+                        <xsl:when test="$currentversion != @position  and @pubapidoc='true'  ">
                             <xsl:element name="a">
                                 <xsl:attribute name="class">apacheversion</xsl:attribute>
                                 <xsl:attribute name="href">
                                     <xsl:value-of select="@apidocurl"/><xsl:text>/</xsl:text><xsl:value-of select="$menukey"/><xsl:text>.html</xsl:text></xsl:attribute>
                                 <xsl:value-of select="@version"/>
-                            </xsl:element>                 
-                        </xsl:otherwise>
+                            </xsl:element>
+                        </xsl:when>
                     </xsl:choose>
-                    
                 </xsl:for-each>
-                <xsl:element name="a">
-                    <xsl:attribute name="href">
-                        <xsl:text>http://bits.netbeans.org/</xsl:text>
-                    </xsl:attribute>
-                    8.2 and previous
-                </xsl:element>           
             </div>
         </div>
     </xsl:template>