From 05449aee540c18fd766ae667d8e0a2f1d84281f7 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Tue, 13 Feb 2018 10:25:29 +0100 Subject: update TSL monitoring servlet update TSL libs/tsl-lib-2.0.1.jar --- moaSig/libs/tsl-lib-2.0.1.jar | Bin 801197 -> 803994 bytes .../server/monitoring/ServiceStatusContainer.java | 17 ++++++-- .../server/service/TSLClientStatusServlet.java | 44 +++++++++++++++++++-- 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/moaSig/libs/tsl-lib-2.0.1.jar b/moaSig/libs/tsl-lib-2.0.1.jar index e1efda6..45e18e3 100644 Binary files a/moaSig/libs/tsl-lib-2.0.1.jar and b/moaSig/libs/tsl-lib-2.0.1.jar differ diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/monitoring/ServiceStatusContainer.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/monitoring/ServiceStatusContainer.java index 88e6474..3d100a4 100644 --- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/monitoring/ServiceStatusContainer.java +++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/monitoring/ServiceStatusContainer.java @@ -1,6 +1,9 @@ package at.gv.egovernment.moa.spss.server.monitoring; -import at.gv.egovernment.moaspss.util.StringUtils; +import java.util.List; + +import at.gv.egovernment.moa.sig.tsl.engine.data.TSLProcessingResultElement; +import at.gv.egovernment.moa.spss.tsl.TSLServiceFactory; public class ServiceStatusContainer { @@ -9,7 +12,7 @@ public class ServiceStatusContainer { private static boolean TSLStatusValid = false; private static String TSLStatusMsg = STATUS_NOT_SET; - + private static List tslDetailStatus = null; public static boolean getStatus() { return TSLStatusValid; @@ -20,9 +23,17 @@ public class ServiceStatusContainer { return TSLStatusMsg; } - + + public static List getTslDetailStatus() { + return tslDetailStatus; + } + public static void setStatus(boolean currentStatus) { TSLStatusValid = currentStatus; + + if (TSLServiceFactory.isInitialized()) + tslDetailStatus = TSLServiceFactory.getTSLServiceClient().getCurrentTSLClientStatus(); + } public static void setStatusMsg(String msg) { diff --git a/moaSig/moa-sig/src/main/java/at/gv/egovernment/moa/spss/server/service/TSLClientStatusServlet.java b/moaSig/moa-sig/src/main/java/at/gv/egovernment/moa/spss/server/service/TSLClientStatusServlet.java index 7bb7217..d763c44 100644 --- a/moaSig/moa-sig/src/main/java/at/gv/egovernment/moa/spss/server/service/TSLClientStatusServlet.java +++ b/moaSig/moa-sig/src/main/java/at/gv/egovernment/moa/spss/server/service/TSLClientStatusServlet.java @@ -3,13 +3,17 @@ package at.gv.egovernment.moa.spss.server.service; import java.io.IOException; import java.io.PrintWriter; import java.text.MessageFormat; +import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import at.gv.egovernment.moa.sig.tsl.TslClientFactory; +import at.gv.egovernment.moa.sig.tsl.engine.data.TSLProcessingResultElement; import at.gv.egovernment.moa.spss.server.monitoring.ServiceStatusContainer; +import at.gv.egovernment.moa.spss.tsl.TSLServiceFactory; public class TSLClientStatusServlet extends HttpServlet { @@ -19,12 +23,14 @@ public class TSLClientStatusServlet extends HttpServlet { private static final long serialVersionUID = 1L; - public static final String STATUS_RESP = "{\"TSLStatus\":\"{0}\", \"TSLStatusMsg\":\"{1}\"}"; + public static final String STATUS_RESP = "'{'\"EUTSLStatus\":\"{0}\", \"EUTSLStatusMsg\":\"{1}\"{2}'}'"; + public static final String DETAIL_INFO = ", \"Details\":'{'{0}'}'"; + //public static final String DETAIL_ENTRY = "\"{0}\":'{'\"verified\":\"{1}\", \"processed\":\"{2}\"'}'"; + public static final String DETAIL_ENTRY = "\"{0}\":'{'\"processed\":\"{2}\"'}'"; public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - - + if (ServiceStatusContainer.getStatus()) response.setStatus(200); else @@ -35,11 +41,41 @@ public class TSLClientStatusServlet extends HttpServlet { out.println(MessageFormat.format(STATUS_RESP, new Object[] { String.valueOf(ServiceStatusContainer.getStatus()), - ServiceStatusContainer.getStatusMsg() + ServiceStatusContainer.getStatusMsg(), + getTSLClientDetailInfos() })); out.flush(); out.close(); } + private String getTSLClientDetailInfos() { + String detailInfo = ""; + List tslDetailStatus = ServiceStatusContainer.getTslDetailStatus(); + if (tslDetailStatus != null) { + String detailElements = null; + + for (TSLProcessingResultElement el : tslDetailStatus) { + String entry = MessageFormat.format(DETAIL_ENTRY, + new Object[] { + el.getCountryCode(), + String.valueOf(el.isVerified()), + String.valueOf(el.isProcessed()) + }); + if (detailElements == null) + detailElements = entry; + else + detailElements += ", " + entry; + + } + + if (detailElements != null) + detailInfo = MessageFormat.format(DETAIL_INFO, + new Object[] { + detailElements + }); + } + + return detailInfo; + } } -- cgit v1.2.3