Skip to content

Commit

Permalink
Add InfoServlet
Browse files Browse the repository at this point in the history
The InfoServlet has been added as a lightweight alternative to
InfoService without dependency on RESTEasy.

All clients have been modified to call the InfoServlet instead.
  • Loading branch information
edewata committed Nov 9, 2023
1 parent 5ca50b5 commit 3058989
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
2 changes: 1 addition & 1 deletion base/common/python/pki/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def __init__(self, connection):

self.connection = connection

self.info_url = '/pki/rest/info'
self.info_url = '/pki/v2/info'

@pki.handle_exceptions()
def get_info(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public class InfoClient extends Client {

public InfoClient(PKIClient client) throws Exception {
super(client, "pki", "info");
super(client, "pki", "v2", "info");
}

public Info getInfo() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// Copyright Red Hat, Inc.
//
// SPDX-License-Identifier: GPL-2.0-or-later
//
package org.dogtagpki.server.v2;

import java.io.PrintWriter;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.MediaType;

import org.dogtagpki.common.Info;
import org.dogtagpki.server.PKIEngine;
import org.dogtagpki.server.PKIServlet;

/**
* @author Endi S. Dewata
*/
@WebServlet("/v2/info")
public class InfoServlet extends PKIServlet {

private static final long serialVersionUID = 1L;

public void get(HttpServletRequest request, HttpServletResponse response) throws Exception {

PKIEngine engine = getPKIEngine();
Info info = engine.getInfo(request);

response.setContentType(MediaType.APPLICATION_JSON);

PrintWriter out = response.getWriter();
out.println(info.toJSON());
}
}
2 changes: 1 addition & 1 deletion base/server-webapp/webapps/pki/js/pki.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var PKI = {
getInfo: function(options) {
$.ajax({
type: "GET",
url: "/pki/rest/info",
url: "/pki/v2/info",
dataType: "json"
}).done(function(data, textStatus, jqXHR) {
if (options.success) options.success.call(self, data, textStatus, jqXHR);
Expand Down

0 comments on commit 3058989

Please sign in to comment.