Skip to content

Commit

Permalink
Merge pull request #3745 from OpenLiberty/staging
Browse files Browse the repository at this point in the history
Update prod
  • Loading branch information
natalie-bernhard authored May 24, 2024
2 parents 95e40a1 + 200afef commit 217698d
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 4 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@
<version>5.5.4</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20240303</version>
</dependency>
</dependencies>

<build>
Expand Down
14 changes: 14 additions & 0 deletions src/main/content/_assets/js/builds.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var starter_domain =
isNotProdSite() ? 'https://starter-staging.rh9j6zz75er.us-east.codeengine.appdomain.cloud' : 'https://start.openliberty.io';
var starter_info_url = starter_domain + '/api/start/info';
var starter_submit_url = starter_domain + '/api/start';
var starter_plugin_url='/api/start/plugin-versions'
var failed_builds_request = false;

// Controls what build zips are exposed on openliberty.io. This will need to be updated
Expand Down Expand Up @@ -1565,6 +1566,19 @@ $(document).ready(function () {
}
})

$.ajax({
url: starter_plugin_url,
type: 'GET',
dataType: 'json',
success: function(data) {
$('#maven_version').text(data.mavenVersion);
$('#gradle_version').text(data.gradleVersion);
},
error: function(error) {
console.error('Error fetching Maven and Gradle plugin versions:', error);
}
});

$(window).on('scroll', function (event) {
// start animation if images are in viewport
if ($('#bottom_images_container').isInViewport()) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/content/start.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ <h2 id="getOL" class="section_title"><a class="anchor" href="#getOL"></a>{% t st
<div class="code_block_wrapper" title="Code block">
<div class="copied_confirmation">Copied to clipboard</div>
<input type="image" class="copy_to_clipboard" src="/img/guides_copy_button.svg" alt="Copy code block" title="Copy code block"/>
<pre class="code_container">&lt;plugin&gt;<br> &lt;groupId&gt;io.openliberty.tools&lt;/groupId&gt;<br> &lt;artifactId&gt;liberty-maven-plugin&lt;/artifactId&gt;<br> &lt;version&gt;<span class="latest_version">3.10.2</span>&lt;/version&gt;<br>&lt;/plugin&gt;</pre>
<pre class="code_container">&lt;plugin&gt;<br> &lt;groupId&gt;io.openliberty.tools&lt;/groupId&gt;<br> &lt;artifactId&gt;liberty-maven-plugin&lt;/artifactId&gt;<br> &lt;version&gt;<span class="latest_version" id="maven_version">3.10.3</span>&lt;/version&gt;<br>&lt;/plugin&gt;</pre>
</div>
<p>
{% t start.add_to_existing_app.maven_guide_text %}
Expand All @@ -177,7 +177,7 @@ <h2 id="getOL" class="section_title"><a class="anchor" href="#getOL"></a>{% t st
<div class="code_block_wrapper" title="Code block">
<div class="copied_confirmation">Copied to clipboard</div>
<input type="image" class="copy_to_clipboard" src="/img/guides_copy_button.svg" alt="Copy code block" title="Copy code block"/>
<pre class="code_container">buildscript { <br> repositories { <br> mavenCentral()<br> }<br> dependencies {<br> classpath 'io.openliberty.tools:liberty-gradle-plugin:'<span class="latest_version">3.8.2</span>'<br> }<br>}</pre>
<pre class="code_container">buildscript { <br> repositories { <br> mavenCentral()<br> }<br> dependencies {<br> classpath 'io.openliberty.tools:liberty-gradle-plugin:'<span class="latest_version" id="gradle_version">3.8.3</span>'<br> }<br>}</pre>
</div>
<p>The plugin also needs to be applied in the build file in order to be utilized.</p>
<div class="code_block_wrapper" title="Code block">
Expand Down
58 changes: 58 additions & 0 deletions src/main/java/io/openliberty/website/OpenLibertyEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,19 @@
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Response;

import io.openliberty.website.data.BuildData;
import io.openliberty.website.data.LastUpdate;
import io.openliberty.website.data.LatestReleases;

import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import org.json.JSONArray;

/**
* This is the main JAX-RS entry point for the Open Liberty website REST API.
* The API is defined in the source repo website-api.yml.
Expand All @@ -33,6 +41,31 @@ public class OpenLibertyEndpoint extends Application {

@Inject private BuildsManager buildsManager;
@Inject private GitHubManager githubManager;

public String getJsonData(String jsonUrl) throws Exception{
URL url = new URL(jsonUrl);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");

BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuilder response = new StringBuilder();

while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
con.disconnect();
return parseJsonObject(new JSONObject(response.toString()));
}

private String parseJsonObject(JSONObject jsonObject) {
JSONObject response = jsonObject.getJSONObject("response");
JSONArray docs = response.getJSONArray("docs");
JSONObject doc=docs.getJSONObject(0);
String pluginVersion = doc.getString("v");
return pluginVersion;
}

@GET
@Path("builds")
Expand Down Expand Up @@ -61,4 +94,29 @@ public LatestReleases latestsReleases() {
public String githubIssues() {
return githubManager.getIssues();
}

String mavenUrl="https://search.maven.org/solrsearch/select?q=g:io.openliberty.tools+AND+a:liberty-maven-plugin&core=gav&rows=20&wt=json";
String gradleUrl="https://search.maven.org/solrsearch/select?q=g:io.openliberty.tools+AND+a:liberty-gradle-plugin&core=gav&rows=20&wt=json";
@GET
@Produces({ "application/json" })
@Path("start/plugin-versions")
public Response getVersionFromJson() {
try {
String mavenVersion=getJsonData(mavenUrl);
String gradleVersion=getJsonData(gradleUrl);
return Response.ok(new JSONObject()
.put("mavenVersion", mavenVersion)
.put("gradleVersion", gradleVersion)
.toString())
.build();
} catch (Exception e) {
e.printStackTrace();
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
.entity(new JSONObject()
.put("status", "error")
.put("message", "Failed to fetch plugin versions")
.toString())
.build();
}
}
}
6 changes: 4 additions & 2 deletions src/main/java/io/openliberty/website/SecurityFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain
req.getRequestDispatcher(uri.concat(".gz")).include(req, response);
}
catch(FileNotFoundException e) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
response.sendRedirect("/404.html");
response.reset();
response.setHeader("Content-Type", "text/html");
response.sendError(404);
return;
}
}
} else if (uri.startsWith("/api/builds/") || uri.startsWith("/api/github/")) {
Expand Down

0 comments on commit 217698d

Please sign in to comment.