diff --git a/bin/mac/updateversion.sh b/bin/mac/updateversion.sh index 71f2b53d..2e7af2b7 100755 --- a/bin/mac/updateversion.sh +++ b/bin/mac/updateversion.sh @@ -1,6 +1,7 @@ if [ -n "$1" ]; then printf "\nupdate version to: $1\n" mvn -f ../../pom.xml versions:set -DgenerateBackupPoms=false -DnewVersion="$1" + mvn -f ../../pom.xml versions:set-property -Dproperty=assimbly.version -DnewVersion="$1" else printf "\nUsage:\n" printf "\nupdateversion.sh \n" diff --git a/bin/win/checkversions.bat b/bin/win/checkversions.bat index 40b99a5a..a9b8f9e3 100644 --- a/bin/win/checkversions.bat +++ b/bin/win/checkversions.bat @@ -1 +1 @@ -mvn -f ..\..\pom.xml versions:display-dependency-updates -Dexcludes=org.apache.camel:* \ No newline at end of file +mvn -f ..\..\pom.xml versions:display-dependency-updates -Dexcludes=org.apache.camel:* -DlogOutput=false \ No newline at end of file diff --git a/bin/win/updateversion.bat b/bin/win/updateversion.bat index 99789ba2..468cb14b 100644 --- a/bin/win/updateversion.bat +++ b/bin/win/updateversion.bat @@ -5,6 +5,7 @@ echo: @echo update version to %1 echo: mvn -f ..\..\pom.xml versions:set -DgenerateBackupPoms=false -DnewVersion=%1 +mvn -f ..\..\pom.xml versions:set-property -Dproperty=assimbly.version -DnewVersion=%1 :usage echo: @echo updateversion ^ diff --git a/broker/pom.xml b/broker/pom.xml index 221a7b3f..ab59703e 100644 --- a/broker/pom.xml +++ b/broker/pom.xml @@ -6,7 +6,7 @@ runtime org.assimbly - 3.8.1 + 3.8.2 broker diff --git a/brokerRest/pom.xml b/brokerRest/pom.xml index 1b7e62cb..87871ec7 100644 --- a/brokerRest/pom.xml +++ b/brokerRest/pom.xml @@ -6,7 +6,7 @@ runtime org.assimbly - 3.8.1 + 3.8.2 broker-rest @@ -34,11 +34,6 @@ broker ${assimbly.version} - - org.springdoc - springdoc-openapi-ui - ${springdoc-openapi-ui.version} - diff --git a/dil/pom.xml b/dil/pom.xml index 69ed9142..86593f4b 100644 --- a/dil/pom.xml +++ b/dil/pom.xml @@ -4,7 +4,7 @@ runtime org.assimbly - 3.8.1 + 3.8.2 dil diff --git a/dil/src/main/java/org/assimbly/dil/blocks/templates/Javascript.java b/dil/src/main/java/org/assimbly/dil/blocks/templates/Javascript.java new file mode 100644 index 00000000..739509c3 --- /dev/null +++ b/dil/src/main/java/org/assimbly/dil/blocks/templates/Javascript.java @@ -0,0 +1,30 @@ +package org.assimbly.dil.blocks.templates; + +import org.apache.camel.builder.RouteBuilder; + +public class Javascript extends RouteBuilder { + + @Override + public void configure() throws Exception { + + routeTemplate("javascript-action") + .templateParameter("routeconfiguration_id","0") + .templateOptionalParameter("path") + .templateParameter("in") + .templateParameter("out") + .from("{{in}}") + .routeConfigurationId("{{routeconfiguration_id}}") + .setBody().js("{{path}}") + .to("{{out}}"); + + routeTemplate("javascript-sink") + .templateParameter("routeconfiguration_id","0") + .templateOptionalParameter("path") + .templateParameter("in") + .from("{{in}}") + .routeConfigurationId("{{routeconfiguration_id}}") + .setBody().js("{{path}}"); + + } + +} diff --git a/dil/src/main/java/org/assimbly/dil/blocks/templates/Link.java b/dil/src/main/java/org/assimbly/dil/blocks/templates/Link.java index fc924ab8..f07b7428 100644 --- a/dil/src/main/java/org/assimbly/dil/blocks/templates/Link.java +++ b/dil/src/main/java/org/assimbly/dil/blocks/templates/Link.java @@ -11,7 +11,6 @@ public void configure() throws Exception { .templateParameter("routeconfiguration_id","0") .templateParameter("uri") .templateParameter("out") - .templateParameter("exchangePattern","InOnly") .from("{{in}}") .routeConfigurationId("{{routeconfiguration_id}}") .to("{{out}}"); @@ -23,13 +22,12 @@ public void configure() throws Exception { .templateParameter("out") .from("{{in}}") .routeConfigurationId("{{routeconfiguration_id}}") - .to("{{out}}"); + .to("{{out}}"); routeTemplate("link-sink") .templateParameter("routeconfiguration_id","0") .templateParameter("uri") .templateParameter("in") - .templateParameter("exchangePattern","InOnly") .from("{{in}}") .routeConfigurationId("{{routeconfiguration_id}}"); diff --git a/dil/src/main/java/org/assimbly/dil/blocks/templates/Python.java b/dil/src/main/java/org/assimbly/dil/blocks/templates/Python.java new file mode 100644 index 00000000..86d1f56e --- /dev/null +++ b/dil/src/main/java/org/assimbly/dil/blocks/templates/Python.java @@ -0,0 +1,30 @@ +package org.assimbly.dil.blocks.templates; + +import org.apache.camel.builder.RouteBuilder; + +public class Python extends RouteBuilder { + + @Override + public void configure() throws Exception { + + routeTemplate("python-action") + .templateParameter("routeconfiguration_id","0") + .templateOptionalParameter("path") + .templateParameter("in") + .templateParameter("out") + .from("{{in}}") + .routeConfigurationId("{{routeconfiguration_id}}") + .setBody().python("{{path}}") + .to("{{out}}"); + + routeTemplate("python-sink") + .templateParameter("routeconfiguration_id","0") + .templateOptionalParameter("path") + .templateParameter("in") + .from("{{in}}") + .routeConfigurationId("{{routeconfiguration_id}}") + .setBody().python("{{path}}"); + + } + +} diff --git a/dil/src/main/java/org/assimbly/dil/blocks/templates/SetPattern.java b/dil/src/main/java/org/assimbly/dil/blocks/templates/SetPattern.java index 83302ca4..7e28cf67 100644 --- a/dil/src/main/java/org/assimbly/dil/blocks/templates/SetPattern.java +++ b/dil/src/main/java/org/assimbly/dil/blocks/templates/SetPattern.java @@ -12,11 +12,11 @@ public void configure() throws Exception { .templateParameter("path") .templateParameter("in") .templateParameter("out") + .templateParameter("pattern","InOnly") .from("{{in}}") .routeConfigurationId("{{routeconfiguration_id}}") - .setProperty("pattern").constant("{{path}}") - .process("SetPatternProcessor") - .to("{{out}}"); + .setExchangePattern("{{pattern}}") + .to("{{out}}"); } } diff --git a/dil/src/main/java/org/assimbly/dil/blocks/templates/Simple.java b/dil/src/main/java/org/assimbly/dil/blocks/templates/Simple.java new file mode 100644 index 00000000..0b1e7e2e --- /dev/null +++ b/dil/src/main/java/org/assimbly/dil/blocks/templates/Simple.java @@ -0,0 +1,30 @@ +package org.assimbly.dil.blocks.templates; + +import org.apache.camel.builder.RouteBuilder; + +public class Simple extends RouteBuilder { + + @Override + public void configure() throws Exception { + + routeTemplate("simple-action") + .templateParameter("routeconfiguration_id","0") + .templateOptionalParameter("path") + .templateParameter("in") + .templateParameter("out") + .from("{{in}}") + .routeConfigurationId("{{routeconfiguration_id}}") + .setBody().simple("{{path}}") + .to("{{out}}"); + + routeTemplate("simple-sink") + .templateParameter("routeconfiguration_id","0") + .templateOptionalParameter("path") + .templateParameter("in") + .from("{{in}}") + .routeConfigurationId("{{routeconfiguration_id}}") + .setBody().simple("{{path}}"); + + } + +} diff --git a/dil/src/main/java/org/assimbly/dil/blocks/templates/Split.java b/dil/src/main/java/org/assimbly/dil/blocks/templates/Split.java index 279683ba..20872385 100644 --- a/dil/src/main/java/org/assimbly/dil/blocks/templates/Split.java +++ b/dil/src/main/java/org/assimbly/dil/blocks/templates/Split.java @@ -1,13 +1,14 @@ package org.assimbly.dil.blocks.templates; import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.language.xpath.XPathBuilder; public class Split extends RouteBuilder { @Override public void configure() throws Exception { - //XPathBuilder myXpath = new XPathBuilder("").saxon().threadSafety(true); + //currently using the regular split / xpathbuilder wit saxon needs to be tested) routeTemplate("split-xpath-router") .templateParameter("routeconfiguration_id","0") @@ -19,6 +20,7 @@ public void configure() throws Exception { .from("{{in}}") .routeConfigurationId("{{routeconfiguration_id}}") .split().xpath("{{expression}}") + //.split(new XPathBuilder("{{expression}}").saxon().threadSafety(true)) .setHeader("CamelSplitIndex").simple("${exchangeProperty.CamelSplitIndex}") .setHeader("CamelSplitSize").simple("${exchangeProperty.CamelSplitSize}") .setHeader("CamelSplitComplete").simple("${exchangeProperty.CamelSplitComplete.toString().trim()}") diff --git a/integration/pom.xml b/integration/pom.xml index 35a85bc3..c26c735c 100644 --- a/integration/pom.xml +++ b/integration/pom.xml @@ -4,7 +4,7 @@ runtime org.assimbly - 3.8.1 + 3.8.2 integration @@ -28,12 +28,6 @@ - - org.assimbly - dil - ${assimbly.version} - - org.assimbly common-base @@ -44,6 +38,11 @@ camel-components ${assimbly.version} + + org.assimbly + dil + ${assimbly.version} + org.assimbly database-drivers @@ -55,29 +54,6 @@ ${assimbly.version} - - io.dropwizard.metrics - metrics-core - ${dropwizard-metrics.version} - - - - - org.jolokia - jolokia-core - ${jolokia.version} - - - org.jolokia - jolokia-jvm - ${jolokia.version} - - - org.jolokia - jolokia-client-java - ${jolokia.version} - - diff --git a/integration/src/main/java/org/assimbly/integration/Integration.java b/integration/src/main/java/org/assimbly/integration/Integration.java index 5a91b67c..64e65494 100644 --- a/integration/src/main/java/org/assimbly/integration/Integration.java +++ b/integration/src/main/java/org/assimbly/integration/Integration.java @@ -275,6 +275,15 @@ public interface Integration { */ public String getStats(String mediaType) throws Exception; + /** + * Gets the stats of an integration + * + * @param mediaType (xml or json) + * @throws Exception if flow doesn't start + * @return returns number of messages + */ + public String getMessages(String mediaType) throws Exception; + /** * Gets the stats of an integration * @@ -304,13 +313,53 @@ public interface Integration { public String getHistoryMetrics(String mediaType) throws Exception; /** - * Gets the ids of running flows + * Gets the ids of (loaded) flows + * + * @param filter by status (started, stopped, suspended) + * @param mediaType (xml or json) + * @throws Exception if flow doesn't start + * @return returns an array of flows with id + */ + public String getListOfFlows(String filter, String mediaType) throws Exception; + + /** + * Gets the details of (loaded) flows + * + * @param filter by status (started, stopped, suspended) + * @param mediaType (xml or json) + * @throws Exception if flow doesn't start + * @return returns an array of flows with id, name, status etc + */ + public String getListOfFlowsDetails(String filter, String mediaType) throws Exception; + + /** + * Gets the soap actions for a SOAP service (WSDL) + * + * @param mediaType (xml or json) + * @throws Exception if flow doesn't start + * @return returns an array of SOAP actions + */ + public String getListOfSoapActions(String url, String mediaType) throws Exception; + + /** + * Count the number of (loaded) flows * + * @param filter by status (started, stopped, suspended) * @param mediaType (xml or json) * @throws Exception if flow doesn't start * @return returns an array of flows with id */ - public String getRunningFlows(String mediaType) throws Exception; + public String countFlows(String filter, String mediaType) throws Exception; + + /** + * Counts the number of (loaded) steps + * + * @param filter by status (started, stopped, suspended) + * @param mediaType (xml or json) + * @throws Exception if flow doesn't start + * @return returns an array of flows with id + */ + public String countSteps(String filter, String mediaType) throws Exception; /** * Gets the version of documentation/integration framework @@ -596,7 +645,17 @@ public interface Integration { * @return returns true if flow is started. */ public boolean isFlowStarted(String flowId) throws Exception; - + + /** + * Gets info of a flow + * + * @param flowId the id of the flow + * @param mediaType (XML,JSON,TEXT) + * @throws Exception if flow doesn't start + * @return returns info (id, name, version, environment, isError, status, uptime, lastError). + */ + public String getFlowInfo(String flowId, String mediaType) throws Exception; + /** * Gets the status of a flow * @@ -622,10 +681,21 @@ public interface Integration { * @throws Exception if flow doesn't start * @return returns number of messages */ - public String getFlowLastError(String flowId) throws Exception; + public String getFlowLastError(String flowId) throws Exception; + + /** + * Gets the processed messages of a flow + * + * @param flowId the id of the flow + * @param includeSteps Whether or not to include steps + * @param mediaType (XML,JSON or TEXT) + * @throws Exception if flow doesn't start + * @return returns number of messages (total, completed, failed, pending) + */ + public String getFlowMessages(String flowId, boolean includeSteps, String mediaType) throws Exception; /** - * Gets the last error of a flow + * Gets the total number of messages a flow has processed * * @param flowId the id of the flow * @throws Exception if flow doesn't start @@ -634,7 +704,7 @@ public interface Integration { public String getFlowTotalMessages(String flowId) throws Exception; /** - * Gets the total number of messages a flow has processed + * Gets the total number of completed messages a flow has processed * * @param flowId the id of the flow * @throws Exception if flow doesn't start @@ -649,7 +719,26 @@ public interface Integration { * @throws Exception if flow doesn't start * @return returns number of messages */ - public String getFlowFailedMessages(String flowId) throws Exception; + public String getFlowFailedMessages(String flowId) throws Exception; + + /** + * Gets the total number of pending messages a flow has processed + * + * @param flowId the id of the flow + * @throws Exception if flow doesn't start + * @return returns number of messages + */ + public String getFlowPendingMessages(String flowId) throws Exception; + + /** + * Gets the processed messaged of a step in a flow + * + * @param flowId the id of the flow + * @param stepId the id of the step + * @throws Exception if flow doesn't start + * @return returns number of messages (total, completed, failed, pending) + */ + public String getStepMessages(String flowId, String stepId, String mediaType) throws Exception; /** * Gets the failure log for the specified flow @@ -696,7 +785,7 @@ public interface Integration { * @throws Exception if flow doesn't start * @return returns number of messages */ - public String getFlowStats(String flowId, boolean fullStats, String mediaType) throws Exception; + public String getFlowStats(String flowId, boolean fullStats, boolean includeSteps, String mediaType) throws Exception; /** * Gets the details stats of a flow step diff --git a/integration/src/main/java/org/assimbly/integration/impl/BaseIntegration.java b/integration/src/main/java/org/assimbly/integration/impl/BaseIntegration.java index 451446eb..d02ce804 100644 --- a/integration/src/main/java/org/assimbly/integration/impl/BaseIntegration.java +++ b/integration/src/main/java/org/assimbly/integration/impl/BaseIntegration.java @@ -274,6 +274,8 @@ public String testConnection(String host, int port, int timeOut) { public abstract String getStats(String mediaType) throws Exception; + public abstract String getMessages(String mediaType) throws Exception; + public abstract String getStatsByFlowIds(String flowIds, String mediaType) throws Exception; public abstract String getMetrics(String mediaType) throws Exception; @@ -328,18 +330,26 @@ public String testConnection(String host, int port, int timeOut) { public abstract String fileUninstallFlow(String id, String mediaType) throws Exception; public abstract boolean isFlowStarted(String id) throws Exception; - + + public abstract String getFlowInfo(String id, String mediaType) throws Exception; + public abstract String getFlowStatus(String id) throws Exception; public abstract String getFlowUptime(String id) throws Exception; - public abstract String getFlowLastError(String id); - - public abstract String getFlowTotalMessages(String id) throws Exception; + public abstract String getFlowLastError(String id); + + public abstract String getFlowMessages(String id, boolean includeSteps, String mediaType) throws Exception; + + public abstract String getFlowTotalMessages(String id) throws Exception; public abstract String getFlowCompletedMessages(String id) throws Exception; - public abstract String getFlowFailedMessages(String id) throws Exception; + public abstract String getFlowFailedMessages(String id) throws Exception; + + public abstract String getFlowPendingMessages(String id) throws Exception; + + public abstract String getStepMessages(String id, String stepId, String mediaType) throws Exception; public abstract String getFlowAlertsLog(String id, Integer numberOfEntries) throws Exception; @@ -349,11 +359,20 @@ public String testConnection(String host, int port, int timeOut) { public abstract String getFlowEventsLog(String id, Integer numberOfEntries) throws Exception; - public abstract String getFlowStats(String id, boolean fullStats, String mediaType) throws Exception; + public abstract String getFlowStats(String id, boolean fullStats, boolean includeSteps, String mediaType) throws Exception; public abstract String getFlowStepStats(String id, String stepid, boolean fullStats, String mediaType) throws Exception; - public abstract String getRunningFlows(String mediaType) throws Exception; + public abstract String getListOfFlows(String filter, String mediaType) throws Exception; + + public abstract String getListOfFlowsDetails(String filter, String mediaType) throws Exception; + + public abstract String getListOfSoapActions(String url, String mediaType) throws Exception; + + public abstract String countFlows(String filter, String mediaType) throws Exception; + + public abstract String countSteps(String filter, String mediaType) throws Exception; + //certificates public abstract Certificate[] getCertificates(String url) throws Exception; diff --git a/integration/src/main/java/org/assimbly/integration/impl/CamelIntegration.java b/integration/src/main/java/org/assimbly/integration/impl/CamelIntegration.java index 5651ae49..72d6a72b 100644 --- a/integration/src/main/java/org/assimbly/integration/impl/CamelIntegration.java +++ b/integration/src/main/java/org/assimbly/integration/impl/CamelIntegration.java @@ -53,6 +53,7 @@ import javax.xml.xpath.XPath; import javax.xml.xpath.XPathFactory; import java.io.File; +import java.lang.reflect.Method; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; @@ -81,7 +82,6 @@ public class CamelIntegration extends BaseIntegration { private final MetricRegistry metricRegistry = new MetricRegistry(); private org.apache.camel.support.SimpleRegistry registry = new org.apache.camel.support.SimpleRegistry(); private String flowInfo; - private final String baseDir = BaseDirectory.getInstance().getBaseDirectory(); private RouteController routeController; private ManagedCamelContext managed; @@ -1132,6 +1132,38 @@ public boolean isFlowStarted(String id) { } + public String getFlowInfo(String id, String mediaType) throws Exception { + + JSONObject json = new JSONObject(); + JSONObject flow = new JSONObject(); + + TreeMap props = super.getFlowConfiguration(id); + + if(props != null){ + flow.put("id",props.get("id")); + flow.put("name",props.get("flow.name")); + flow.put("version",props.get("flow.version")); + flow.put("environment",props.get("environment")); + flow.put("isRunning",isFlowStarted(id)); + flow.put("status",getFlowStatus(id)); + flow.put("uptime",getFlowUptime(id)); + }else{ + flow.put("id",props.get("id")); + flow.put("status",getFlowStatus(id)); + } + + json.put("flow",flow); + + String integrationInfo = json.toString(4); + if(mediaType.contains("xml")) { + integrationInfo = DocConverter.convertJsonToXml(integrationInfo); + } + + return integrationInfo; + + } + + public String getFlowStatus(String id) { if(hasFlow(id)) { @@ -1200,19 +1232,71 @@ public String getFlowLastError(String id) { return flowInfo; } + public String getFlowMessages(String flowId, boolean includeSteps, String mediaType) throws Exception { + + JSONObject json = new JSONObject(); + JSONObject flow = new JSONObject(); + JSONArray steps = new JSONArray(); - public String getFlowTotalMessages(String id) throws Exception { + long totalMessages = 0; + long completedMessages = 0; + long failedMessages = 0; + long pendingMessages = 0; - List routeList = getRoutesByFlowId(id); + List routes = getRoutesByFlowId(flowId); + + for(Route r : routes){ + String routeId = r.getId(); + + ManagedRouteMBean route = managed.getManagedRoute(routeId); + if(route != null){ + totalMessages += route.getExchangesTotal(); + completedMessages += route.getExchangesCompleted(); + failedMessages += route.getExchangesFailed(); + pendingMessages += route.getExchangesInflight(); + if(includeSteps){ + JSONObject step = new JSONObject(); + String stepId = StringUtils.substringAfter(routeId,flowId + "-"); + step.put("id", stepId); + step.put("total",route.getExchangesTotal()); + step.put("completed",route.getExchangesCompleted()); + step.put("failed",route.getExchangesFailed()); + step.put("pending",route.getExchangesInflight()); + steps.put(step); + } + } + } + + flow.put("id",flowId); + flow.put("total",totalMessages); + flow.put("completed",completedMessages); + flow.put("failed",failedMessages); + flow.put("pending",pendingMessages); + if(includeSteps){ + flow.put("steps",steps); + } + json.put("flow",flow); + + String flowStats = json.toString(4); + if(mediaType.contains("xml")) { + flowStats = DocConverter.convertJsonToXml(flowStats); + } + + return flowStats; + + } + + public String getFlowTotalMessages(String flowId) throws Exception { + + List routeList = getRoutesByFlowId(flowId); long totalMessages = 0; for(Route r : routeList){ String routeId = r.getId(); - String description = r.getDescription(); ManagedRouteMBean route = managed.getManagedRoute(routeId); - if(route != null && "from".equals(description)){ + if(route != null){ totalMessages += route.getExchangesTotal(); } } @@ -1223,17 +1307,16 @@ public String getFlowTotalMessages(String id) throws Exception { } - public String getFlowCompletedMessages(String id) throws Exception { + public String getFlowCompletedMessages(String flowId) throws Exception { - List routeList = getRoutesByFlowId(id); + List routeList = getRoutesByFlowId(flowId); long completedMessages = 0; for(Route r : routeList){ String routeId = r.getId(); - String description = r.getDescription(); ManagedRouteMBean route = managed.getManagedRoute(routeId); - if(route != null && "from".equals(description)){ + if(route != null){ completedMessages += route.getExchangesCompleted(); } } @@ -1244,17 +1327,16 @@ public String getFlowCompletedMessages(String id) throws Exception { } - public String getFlowFailedMessages(String id) throws Exception { + public String getFlowFailedMessages(String flowId) throws Exception { - List routeList = getRoutesByFlowId(id); + List routeList = getRoutesByFlowId(flowId); long failedMessages = 0; for(Route r : routeList){ String routeId = r.getId(); - String description = r.getDescription(); ManagedRouteMBean route = managed.getManagedRoute(routeId); - if(route != null && "from".equals(description)){ + if(route != null){ failedMessages += route.getExchangesFailed(); } } @@ -1265,6 +1347,64 @@ public String getFlowFailedMessages(String id) throws Exception { } + public String getFlowPendingMessages(String flowId) throws Exception { + + List routeList = getRoutesByFlowId(flowId); + long pendingMessages = 0; + + for(Route r : routeList){ + String routeId = r.getId(); + + ManagedRouteMBean route = managed.getManagedRoute(routeId); + if(route != null){ + pendingMessages += route.getExchangesInflight(); + } + } + + flowInfo = Long.toString(pendingMessages); + + return flowInfo; + + } + + public String getStepMessages(String flowId, String stepId, String mediaType) throws Exception { + + long totalMessages = 0; + long completedMessages = 0; + long failedMessages = 0; + long pendingMessages = 0; + + String routeId = flowId + "-" + stepId; + + ManagedRouteMBean route = managed.getManagedRoute(routeId); + if(route != null){ + totalMessages += route.getExchangesTotal(); + completedMessages += route.getExchangesCompleted(); + failedMessages += route.getExchangesFailed(); + pendingMessages += route.getExchangesInflight(); + } + + JSONObject json = new JSONObject(); + JSONObject step = new JSONObject(); + + List routes = getRoutesByFlowId(flowId); + + step.put("id",flowId); + step.put("total",totalMessages); + step.put("completed",completedMessages); + step.put("failed",failedMessages); + step.put("pending",pendingMessages); + json.put("step",step); + + String flowStats = json.toString(4); + if(mediaType.contains("xml")) { + flowStats = DocConverter.convertJsonToXml(flowStats); + } + + return flowStats; + + } + public String getFlowAlertsLog(String id, Integer numberOfEntries) throws Exception { Date date = new Date(); @@ -1377,6 +1517,109 @@ public String getAllCamelRoutesConfiguration(String mediaType) throws Exception } + + public String getFlowStats(String flowId, boolean fullStats, boolean includeSteps, String mediaType) throws Exception { + + JSONObject json = new JSONObject(); + JSONObject flow = new JSONObject(); + JSONArray steps = new JSONArray(); + + long totalMessages = 0; + long completedMessages = 0; + long failedMessages = 0; + long pendingMessages = 0; + String uptime = null; + long uptimeMillis = 0; + Date lastFailed = null; + Date lastCompleted = null; + String status = "Stopped"; + Boolean tracing = false; + + List routes = getRoutesByFlowId(flowId); + + for(Route r : routes){ + String routeId = r.getId(); + + ManagedRouteMBean route = managed.getManagedRoute(routeId); + if(route != null){ + totalMessages += route.getExchangesTotal(); + completedMessages += route.getExchangesCompleted(); + failedMessages += route.getExchangesFailed(); + pendingMessages += route.getExchangesInflight(); + if(fullStats){ + if(uptime==null){ + uptime = route.getUptime(); + } + if(uptimeMillis==0){ + uptimeMillis = route.getUptimeMillis(); + } + if(lastFailed==null){ + lastFailed = route.getLastExchangeFailureTimestamp(); + }else{ + Date failure = route.getLastExchangeFailureTimestamp(); + if(failure!=null && failure.after(lastFailed)){ + lastFailed = failure; + } + } + if(lastCompleted==null){ + lastCompleted = route.getLastExchangeCompletedTimestamp(); + }else{ + Date completed = route.getLastExchangeFailureTimestamp(); + if(completed!=null && completed.after(lastCompleted)){ + lastCompleted = completed; + } + } + status = route.getState(); + tracing = route.getTracing(); + } + + if(includeSteps){ + JSONObject step = new JSONObject();; + if(fullStats){ + step = getStepStats(routeId, fullStats); + }else{ + String stepId = StringUtils.substringAfter(routeId,flowId + "-"); + step.put("id", stepId); + step.put("total",route.getExchangesTotal()); + step.put("completed",route.getExchangesCompleted()); + step.put("failed",route.getExchangesFailed()); + step.put("pending",route.getExchangesInflight()); + } + steps.put(step); + } + } + } + + flow.put("id",flowId); + flow.put("total",totalMessages); + flow.put("completed",completedMessages); + flow.put("failed",failedMessages); + flow.put("pending",pendingMessages); + if(fullStats){ + flow.put("uptime",uptime); + flow.put("uptimeMillis",uptimeMillis); + flow.put("status",status); + flow.put("tracing",tracing); + flow.put("lastFailed",lastFailed); + flow.put("lastCompleted",lastCompleted); + flow.put("failed",failedMessages); + flow.put("pending",pendingMessages); + } + if(includeSteps){ + flow.put("steps",steps); + } + json.put("flow",flow); + + String flowStats = json.toString(4); + if(mediaType.contains("xml")) { + flowStats = DocConverter.convertJsonToXml(flowStats); + } + + return flowStats; + + } + + /* public String getFlowStats(String id, boolean fullStats, String mediaType) throws Exception { JSONObject json = new JSONObject(); @@ -1402,6 +1645,9 @@ public String getFlowStats(String id, boolean fullStats, String mediaType) throw return flowStats; } + */ + + public String getFlowStepStats(String flowId, String stepid, boolean fullStats, String mediaType) throws Exception { @@ -1477,7 +1723,31 @@ public String getStats(String mediaType) throws Exception { } } - String result = getStatsFromList(flowIds, false); + String result = getStatsFromList(flowIds, true, false); + + if(mediaType.contains("xml")) { + result = DocConverter.convertJsonToXml(result); + } + + return result; + + } + + public String getMessages(String mediaType) throws Exception { + + Set flowIds = new HashSet(); + + List routes = context.getRoutes(); + + for(Route route: routes){ + String routeId = route.getId(); + String flowId = StringUtils.substringBefore(routeId,"-"); + if(flowId!=null && !flowId.isEmpty()) { + flowIds.add(flowId); + } + } + + String result = getStatsFromList(flowIds, false, false); if(mediaType.contains("xml")) { result = DocConverter.convertJsonToXml(result); @@ -1492,7 +1762,7 @@ public String getStatsByFlowIds(String flowIds, String mediaType) throws Excepti String[] values = flowIds.split(","); Set flowSet = new HashSet(Arrays.asList(values)); - String result = getStatsFromList(flowSet, false); + String result = getStatsFromList(flowSet, true, false); if(mediaType.contains("xml")) { result = DocConverter.convertJsonToXml(result); @@ -1502,12 +1772,12 @@ public String getStatsByFlowIds(String flowIds, String mediaType) throws Excepti } - private String getStatsFromList(Set flowIds, boolean fullStats) throws Exception { + private String getStatsFromList(Set flowIds, boolean fullStats, boolean includeSteps) throws Exception { JSONArray flows = new JSONArray(); for(String flowId: flowIds){ - String flowstats = getFlowStats(flowId, fullStats,"application/json"); + String flowstats = getFlowStats(flowId, fullStats,includeSteps,"application/json"); JSONObject flow = new JSONObject(flowstats); flows.put(flow); } @@ -1579,22 +1849,37 @@ public String info(String mediaType) throws Exception { } + private Set getListOfFlowIds(String filter){ - - public String getRunningFlows(String mediaType) throws Exception { + //get all routes + List routes = context.getRoutes(); Set flowIds = new HashSet(); - List routes = context.getRoutes(); - + //filter flows from routes for(Route route: routes){ String routeId = route.getId(); String flowId = StringUtils.substringBefore(routeId,"-"); if(flowId!=null && !flowId.isEmpty()) { - flowIds.add(flowId); + if (filter != null && !filter.isEmpty()) { + String status = getFlowStatus(flowId); + if (status.equalsIgnoreCase(filter)) { + flowIds.add(flowId); + } + }else{ + flowIds.add(flowId); + } } } + return flowIds; + + } + + public String getListOfFlows(String filter, String mediaType) throws Exception { + + Set flowIds = getListOfFlowIds(filter); + JSONArray flowsArray = new JSONArray(); for(String flowId: flowIds){ @@ -1617,6 +1902,83 @@ public String getRunningFlows(String mediaType) throws Exception { } + public String getListOfFlowsDetails(String filter, String mediaType) throws Exception { + + Set flowIds = getListOfFlowIds(filter); + + JSONArray flowsArray = new JSONArray(); + + for(String flowId: flowIds) { + JSONObject flowObject = new JSONObject(getFlowInfo(flowId, "application/json")); + flowsArray.put(flowObject); + } + + String result = flowsArray.toString(); + + if(mediaType.contains("xml")) { + JSONObject flowsObject = new JSONObject(); + JSONObject flowObject = new JSONObject(); + flowObject.put("flow",flowsArray); + flowsObject.put("flows",flowObject); + result = DocConverter.convertJsonToXml(flowsObject.toString()); + } + + return result; + + } + + public String getListOfSoapActions(String url, String mediaType) throws Exception { + + String result; + + Class clazz; + try { + clazz = Class.forName("world.dovetail.soap.SoapActionsService"); + Object soapActions = clazz.getDeclaredConstructor().newInstance(); + Method method = clazz.getDeclaredMethod("getSoapActions", String.class); + result = (String) method.invoke(soapActions, url); + } catch (Exception e) { + log.error("SOAP Actions couldn't be retrieved."); + result = "[]"; + } + + return result; + + } + + public String countFlows(String filter, String mediaType) throws Exception { + + Set flowIds = getListOfFlowIds(filter); + + return Integer.toString(flowIds.size()); + + } + + public String countSteps(String filter, String mediaType) throws Exception { + + List routes = context.getRoutes(); + + Set stepIds = new HashSet(); + + for(Route route: routes){ + String routeId = route.getId(); + ManagedRouteMBean managedRoute = managed.getManagedRoute(routeId); + + if (filter != null && !filter.isEmpty()) { + String status = managedRoute.getState(); + if (status.equalsIgnoreCase(filter)) { + stepIds.add(routeId); + } + }else{ + stepIds.add(routeId); + } + } + + String numberOfSteps = Integer.toString(stepIds.size()); + + return numberOfSteps; + + } //Other management tasks diff --git a/integrationRest/pom.xml b/integrationRest/pom.xml index 5647e8f5..d54b9c93 100644 --- a/integrationRest/pom.xml +++ b/integrationRest/pom.xml @@ -6,7 +6,7 @@ runtime org.assimbly - 3.8.1 + 3.8.2 integration-rest @@ -34,11 +34,6 @@ integration ${assimbly.version} - - org.springdoc - springdoc-openapi-ui - ${springdoc-openapi-ui.version} - diff --git a/integrationRest/src/main/java/org/assimbly/integrationrest/FlowManagerResource.java b/integrationRest/src/main/java/org/assimbly/integrationrest/FlowManagerResource.java index fda2efcd..cd07774f 100644 --- a/integrationRest/src/main/java/org/assimbly/integrationrest/FlowManagerResource.java +++ b/integrationRest/src/main/java/org/assimbly/integrationrest/FlowManagerResource.java @@ -52,15 +52,15 @@ public ResponseEntity startflow(@Parameter(hidden = true) @RequestHeader status = integration.startFlow(flowId); - if(mediaType.equals("application/xml")){ - status = DocConverter.convertJsonToXml(status); - } - //Send message to websocket if (this.messagingTemplate != null) { this.messagingTemplate.convertAndSend("/topic/" + flowId + "/event", status); } + if(mediaType.equals("application/xml")){ + status = DocConverter.convertJsonToXml(status); + } + if (status.contains("Started flow successfully")) { return ResponseUtil.createSuccessResponse(integrationId, mediaType,"/integration/{integrationId}/flow/start/{flowId}",status,plainResponse); } else { @@ -117,15 +117,15 @@ public ResponseEntity restartflow(@Parameter(hidden = true) @RequestHea status = integration.restartFlow(flowId); - if(mediaType.equals("application/xml")){ - status = DocConverter.convertJsonToXml(status); - } - //Send message to websocket if (this.messagingTemplate != null) { this.messagingTemplate.convertAndSend("/topic/" + flowId + "/event", status); } + if(mediaType.equals("application/xml")){ + status = DocConverter.convertJsonToXml(status); + } + if (status.contains("Started flow successfully")) { return ResponseUtil.createSuccessResponse(integrationId, mediaType,"/integration/{integrationId}/flow/restart/{flowId}",status,plainResponse); } else { @@ -149,15 +149,15 @@ public ResponseEntity pauseflow(@Parameter(hidden = true) @RequestHeade status = integration.pauseFlow(flowId); - if(mediaType.equals("application/xml")){ - status = DocConverter.convertJsonToXml(status); - } - //Send message to websocket if (this.messagingTemplate != null) { this.messagingTemplate.convertAndSend("/topic/" + flowId + "/event", status); } + if(mediaType.equals("application/xml")){ + status = DocConverter.convertJsonToXml(status); + } + if (status.contains("Paused flow successfully")) { return ResponseUtil.createSuccessResponse(integrationId, mediaType,"/integration/{integrationId}/flow/pause/{flowId}",status,plainResponse); } else { @@ -181,15 +181,15 @@ public ResponseEntity resumeflow(@Parameter(hidden = true) @RequestHeade status = integration.resumeFlow(flowId); - if(mediaType.equals("application/xml")){ - status = DocConverter.convertJsonToXml(status); - } - //Send message to websocket if (this.messagingTemplate != null) { this.messagingTemplate.convertAndSend("/topic/" + flowId + "/event", status); } + if(mediaType.equals("application/xml")){ + status = DocConverter.convertJsonToXml(status); + } + if (status.contains("Resumed flow successfully")) { return ResponseUtil.createSuccessResponse(integrationId, mediaType,"/integration/{integrationId}/flow/resume/{flowId}",status,plainResponse); } else { @@ -202,7 +202,6 @@ public ResponseEntity resumeflow(@Parameter(hidden = true) @RequestHeade } } - @PostMapping(path = "/integration/{integrationId}/flow/test/{flowId}", consumes = {"application/xml"}, produces = {"application/xml","application/json","text/plain"}) public ResponseEntity testflow(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @RequestHeader(value = "StopTest", defaultValue = "false") boolean stopTest, @PathVariable Long integrationId, @PathVariable String flowId, @RequestBody String configuration) throws Exception { @@ -213,15 +212,15 @@ public ResponseEntity testflow(@Parameter(hidden = true) @RequestHeader( status = integration.testFlow(flowId, mediaType, configuration, stopTest); - if(mediaType.equals("application/xml")){ - status = DocConverter.convertJsonToXml(status); - } - //Send message to websocket if (this.messagingTemplate != null) { this.messagingTemplate.convertAndSend("/topic/" + flowId + "/event", status); } + if(mediaType.equals("application/xml")){ + status = DocConverter.convertJsonToXml(status); + } + if (status.equals("started") || status.equals("stopped")) { return ResponseUtil.createSuccessResponse(integrationId, mediaType,"/integration/{integrationId}/flow/test/{flowId}",status,plainResponse); } else { @@ -314,12 +313,26 @@ public ResponseEntity isFlowStarted(@Parameter(hidden = true) @RequestHe } + @GetMapping(path = "/integration/{integrationId}/flow/info/{flowId}", produces = {"application/xml","application/json","text/plain"}) + public ResponseEntity getFlowInfo(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @PathVariable Long integrationId, @PathVariable String flowId) throws Exception { + + plainResponse = true; + + try { + integration = integrationResource.getIntegration(); + String info = integration.getFlowInfo(flowId, mediaType); + return ResponseUtil.createSuccessResponse(integrationId, mediaType,"/integration/{integrationId}/flow/info/{flowId}",info,true); + } catch (Exception e) { + log.error("Get status of flow " + flowId + " failed",e); + return ResponseUtil.createFailureResponse(integrationId, mediaType,"/integration/{integrationId}/flow/info/{flowId}",e.getMessage(),false); + } + + } @GetMapping(path = "/integration/{integrationId}/flow/status/{flowId}", produces = {"application/xml","application/json","text/plain"}) public ResponseEntity getFlowStatus(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @PathVariable Long integrationId, @PathVariable String flowId) throws Exception { try { - //integrationResource.init(); integration = integrationResource.getIntegration(); status = integration.getFlowStatus(flowId); diff --git a/integrationRest/src/main/java/org/assimbly/integrationrest/IntegrationResource.java b/integrationRest/src/main/java/org/assimbly/integrationrest/IntegrationResource.java index 0215c8bd..20fec331 100644 --- a/integrationRest/src/main/java/org/assimbly/integrationrest/IntegrationResource.java +++ b/integrationRest/src/main/java/org/assimbly/integrationrest/IntegrationResource.java @@ -253,15 +253,68 @@ public ResponseEntity setBaseDirectory(@Parameter(hidden = true) @Reques } - @GetMapping(path = "/integration/{integrationId}/runningflows", produces = {"text/plain","application/xml","application/json"}) - public ResponseEntity getRunningFlows(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @PathVariable Long integrationId) throws Exception { + @GetMapping(path = "/integration/{integrationId}/list/flows", produces = {"text/plain","application/xml","application/json"}) + public ResponseEntity getListOfFlows(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @RequestParam(required=false,value="filterByStatus") String filter, @PathVariable Long integrationId) throws Exception { try { - String runningFlows = integration.getRunningFlows(mediaType); - return ResponseUtil.createSuccessResponse(integrationId, mediaType,"/integration/{integrationId}/runningflows",runningFlows,true); + String flows = integration.getListOfFlows(filter, mediaType); + return ResponseUtil.createSuccessResponse(integrationId, mediaType,"/integration/{integrationId}/list/flows",flows,true); } catch (Exception e) { - log.error("Get running flows for integration=" + integrationId + " failed",e); - return ResponseUtil.createFailureResponse(integrationId, mediaType,"/integration/{integrationId}/runningflows",e.getMessage()); + log.error("Get list of flows for integration=" + integrationId + " failed",e); + return ResponseUtil.createFailureResponse(integrationId, mediaType,"/integration/{integrationId}/list/flows",e.getMessage()); + } + + } + + @GetMapping(path = "/integration/{integrationId}/list/flows/details", produces = {"text/plain","application/xml","application/json"}) + public ResponseEntity getRunningFlowsDetails(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @RequestParam(required=false,value="filterByStatus") String filter, @PathVariable Long integrationId) throws Exception { + + try { + String flowsDetails = integration.getListOfFlowsDetails(filter, mediaType); + return ResponseUtil.createSuccessResponse(integrationId, mediaType,"/integration/{integrationId}/list/flows",flowsDetails,true); + } catch (Exception e) { + log.error("Get list of flows with details for integration=" + integrationId + " failed",e); + return ResponseUtil.createFailureResponse(integrationId, mediaType,"/integration/{integrationId}/list/flows/details",e.getMessage()); + } + + } + + + @PostMapping(path = "/integration/{integrationId}/list/soap/action", produces = {"text/plain","application/xml","application/json"}) + public ResponseEntity getListOfSoapActions(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @PathVariable Long integrationId, @RequestBody String url) throws Exception { + + try { + String flows = integration.getListOfSoapActions(url, mediaType); + return ResponseUtil.createSuccessResponse(integrationId, mediaType,"/integration/{integrationId}/list/soap/actions",flows,true); + } catch (Exception e) { + log.error("Get list of soap actions for integration=" + integrationId + " failed",e); + return ResponseUtil.createFailureResponse(integrationId, mediaType,"/integration/{integrationId}/list/soap/actions",e.getMessage()); + } + + } + + @GetMapping(path = "/integration/{integrationId}/count/flows", produces = {"text/plain","application/xml","application/json"}) + public ResponseEntity countFlows(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @RequestParam(required=false,value="filterByStatus") String filter, @PathVariable Long integrationId) throws Exception { + + try { + String flowsCount = integration.countFlows(filter, mediaType); + return ResponseUtil.createSuccessResponse(integrationId, mediaType,"/integration/{integrationId}/count/flows",flowsCount,false); + } catch (Exception e) { + log.error("Count running flows for integration=" + integrationId + " failed",e); + return ResponseUtil.createFailureResponse(integrationId, mediaType,"/integration/{integrationId}/count/flows",e.getMessage()); + } + + } + + @GetMapping(path = "/integration/{integrationId}/count/steps", produces = {"text/plain","application/xml","application/json"}) + public ResponseEntity countSteps(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @RequestParam(required=false,value="filterByStatus") String filter, @PathVariable Long integrationId) throws Exception { + + try { + String stepsCount = integration.countSteps(filter, mediaType); + return ResponseUtil.createSuccessResponse(integrationId, mediaType,"/integration/{integrationId}/count/steps",stepsCount,false); + } catch (Exception e) { + log.error("Count running steps for integration=" + integrationId + " failed",e); + return ResponseUtil.createFailureResponse(integrationId, mediaType,"/integration/{integrationId}/count/steps",e.getMessage()); } } diff --git a/integrationRest/src/main/java/org/assimbly/integrationrest/StatisticsResource.java b/integrationRest/src/main/java/org/assimbly/integrationrest/StatisticsResource.java index bea68908..905a36ba 100644 --- a/integrationRest/src/main/java/org/assimbly/integrationrest/StatisticsResource.java +++ b/integrationRest/src/main/java/org/assimbly/integrationrest/StatisticsResource.java @@ -49,6 +49,22 @@ public ResponseEntity getStats(@Parameter(hidden = true) @RequestHeader( } } + @GetMapping(path = "/integration/{integrationId}/messages", produces = {"text/plain","application/xml","application/json"}) + public ResponseEntity getMessages(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @PathVariable Long integrationId) throws Exception { + + plainResponse = true; + integration = integrationResource.getIntegration(); + + try { + String stats = integration.getMessages(mediaType); + if(stats.startsWith("Error")||stats.startsWith("Warning")) {plainResponse = false;} + return ResponseUtil.createSuccessResponse(integrationId, mediaType,"/integration/{integrationId}/messages",stats,plainResponse); + } catch (Exception e) { + log.error("Get messages failed",e); + return ResponseUtil.createFailureResponse(integrationId, mediaType,"/integration/{integrationId}/messages",e.getMessage()); + } + } + @GetMapping(path = "/integration/{integrationId}/statsbyflowids", produces = {"text/plain","application/xml","application/json"}) public ResponseEntity getStatsByFlowIds(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @RequestHeader String flowIds, @PathVariable Long integrationId) throws Exception { @@ -60,31 +76,30 @@ public ResponseEntity getStatsByFlowIds(@Parameter(hidden = true) @Reque if(stats.startsWith("Error")||stats.startsWith("Warning")) {plainResponse = false;} return ResponseUtil.createSuccessResponse(integrationId, mediaType,"/integration/{integrationId}/statsbyflowids",stats,plainResponse); } catch (Exception e) { - log.error("Get stats failed",e); + log.error("Get stats by flow ids failed",e); return ResponseUtil.createFailureResponse(integrationId, mediaType,"/integration/{integrationId}/statsbyflowids",e.getMessage()); } } - @GetMapping(path = "/integration/{integrationId}/flow/stats/{flowId}", produces = {"application/xml","application/json","text/plain"}) - public ResponseEntity getFlowStats(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @RequestHeader("FullStats") boolean fullStats, @PathVariable Long integrationId, @PathVariable String flowId) throws Exception { + @GetMapping(path = "/integration/{integrationId}/flow/{flowId}/stats", produces = {"application/xml","application/json","text/plain"}) + public ResponseEntity getFlowStats(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @RequestHeader(required=true,defaultValue="false",value="FullStats") boolean fullStats, @RequestHeader(required=true,defaultValue="false",value="IncludeSteps") boolean includeSteps, @PathVariable Long integrationId, @PathVariable String flowId) throws Exception { plainResponse = true; try { - //integrationResource.init(); integration = integrationResource.getIntegration(); - String flowStats = integration.getFlowStats(flowId, fullStats, mediaType); + String flowStats = integration.getFlowStats(flowId, fullStats, includeSteps, mediaType); if(flowStats.startsWith("Error")||flowStats.startsWith("Warning")) {plainResponse = false;} - return ResponseUtil.createSuccessResponse(integrationId, mediaType,"/integration/{integrationId}/flow/stats/{flowId}",flowStats,plainResponse); + return ResponseUtil.createSuccessResponse(integrationId, mediaType,"/integration/{integrationId}/flow/{flowId}/stats",flowStats,plainResponse); } catch (Exception e) { log.error("Get flowstats " + flowId + " failed",e); - return ResponseUtil.createFailureResponse(integrationId, mediaType,"/integration/{integrationId}/flow/stats/{flowId}",e.getMessage()); + return ResponseUtil.createFailureResponse(integrationId, mediaType,"/integration/{integrationId}/flow/{flowId}/stats",e.getMessage()); } } - @GetMapping(path = "/integration/{integrationId}/flow/stats/{flowId}/step/{stepId}", produces = {"application/xml","application/json","text/plain"}) - public ResponseEntity getFlowStepStats(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @RequestHeader("FullStats") boolean fullStats, @PathVariable Long integrationId, @PathVariable String flowId, @PathVariable String stepId) throws Exception { + @GetMapping(path = "/integration/{integrationId}/flow/{flowId}/step/{stepId}/stats", produces = {"text/plain","application/xml","application/json"}) + public ResponseEntity getFlowStepStats(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @RequestHeader(required=true,defaultValue="false",value="FullStats") boolean fullStats, @PathVariable Long integrationId, @PathVariable String flowId, @PathVariable String stepId) throws Exception { plainResponse = true; @@ -93,58 +108,98 @@ public ResponseEntity getFlowStepStats(@Parameter(hidden = true) @Reques String flowStats = integration.getFlowStepStats(flowId, stepId, fullStats, mediaType); if(flowStats.startsWith("Error")||flowStats.startsWith("Warning")) {plainResponse = false;} - return ResponseUtil.createSuccessResponse(integrationId, mediaType,"/integration/{integrationId}/flow/stats/{flowId}",flowStats,plainResponse); + return ResponseUtil.createSuccessResponse(integrationId, mediaType,"/integration/{integrationId}/flow/{flowId}/step/{stepId}/stats",flowStats,plainResponse); + } catch (Exception e) { + log.error("Get flowstats " + flowId + " for stepId=" + stepId + " failed",e); + return ResponseUtil.createFailureResponse(integrationId, mediaType,"/integration/{integrationId}/flow/{flowId}/step/{stepId}/stats",e.getMessage()); + } + } + + @GetMapping(path = "/integration/{integrationId}/flow/{flowId}/messages", produces = {"text/plain","application/xml","application/json"}) + public ResponseEntity getFlowMessages(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @RequestHeader(required=true,defaultValue="false",value="IncludeSteps") boolean includeSteps, @PathVariable Long integrationId, @PathVariable String flowId) throws Exception { + + try { + integration = integrationResource.getIntegration(); + + String numberOfMessages = integration.getFlowMessages(flowId, includeSteps, mediaType); + return ResponseUtil.createSuccessResponse(integrationId, mediaType,"/integration/{integrationId}/flow/{flowId}/messages",numberOfMessages,true); } catch (Exception e) { - log.error("Get flowstats " + flowId + " with stepId=" + stepId + " failed",e); - return ResponseUtil.createFailureResponse(integrationId, mediaType,"/integration/{integrationId}/flow/stats/{flowId}",e.getMessage()); + log.error("Get messages for flow " + flowId + " failed",e); + return ResponseUtil.createFailureResponseWithHeaders(integrationId, mediaType,"/integration/{integrationId}/flow/{flowId}/messages",e.getMessage(),"unable to get total messages of flow " + flowId,flowId); } } - @GetMapping(path = "/integration/{integrationId}/flow/totalmessages/{flowId}", produces = {"application/xml","application/json","text/plain"}) + @GetMapping(path = "/integration/{integrationId}/flow/{flowId}/messages/total", produces = {"application/xml","application/json","text/plain"}) public ResponseEntity getFlowTotalMessages(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @PathVariable Long integrationId, @PathVariable String flowId) throws Exception { try { - //integrationResource.init(); integration = integrationResource.getIntegration(); String numberOfMessages = integration.getFlowTotalMessages(flowId); - return ResponseUtil.createSuccessResponseWithHeaders(integrationId, mediaType,"/integration/{integrationId}/flow/totalmessages/{flowId}",numberOfMessages,numberOfMessages,flowId); + return ResponseUtil.createSuccessResponseWithHeaders(integrationId, mediaType,"/integration/{integrationId}/flow/{flowId}/messages/total",numberOfMessages,numberOfMessages,flowId); } catch (Exception e) { log.error("Get total messages for flow " + flowId + " failed",e); - return ResponseUtil.createFailureResponseWithHeaders(integrationId, mediaType,"/integration/{integrationId}/flow/totalmessages/{flowId}",e.getMessage(),"unable to get total messages of flow " + flowId,flowId); + return ResponseUtil.createFailureResponseWithHeaders(integrationId, mediaType,"/integration/{integrationId}/flow/{flowId}/messages/total",e.getMessage(),"unable to get total messages of flow " + flowId,flowId); } } - @GetMapping(path = "/integration/{integrationId}/flow/completedmessages/{flowId}", produces = {"application/xml","application/json","text/plain"}) + @GetMapping(path = "/integration/{integrationId}/flow/{flowId}/messages/completed", produces = {"text/plain","application/xml","application/json"}) public ResponseEntity getFlowCompletedMessages(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @PathVariable Long integrationId, @PathVariable String flowId) throws Exception { try { - //integrationResource.init(); integration = integrationResource.getIntegration(); String completedMessages = integration.getFlowCompletedMessages(flowId); - return ResponseUtil.createSuccessResponseWithHeaders(integrationId, mediaType,"/integration/{integrationId}/flow/completedmessages/{flowId}",completedMessages,completedMessages,flowId); + return ResponseUtil.createSuccessResponseWithHeaders(integrationId, mediaType,"/integration/{integrationId}/flow/{flowId}/messages/completed",completedMessages,completedMessages,flowId); } catch (Exception e) { log.error("Get completed messages for flow " + flowId + " failed",e); - return ResponseUtil.createFailureResponseWithHeaders(integrationId, mediaType,"/integration/{integrationId}/flow/completedmessages/{flowId}",e.getMessage(),"unable to get completed messages of flow " + flowId,flowId); + return ResponseUtil.createFailureResponseWithHeaders(integrationId, mediaType,"/integration/{integrationId}/flow/{flowId}/messages/completed",e.getMessage(),"unable to get completed messages of flow " + flowId,flowId); } } - @GetMapping(path = "/integration/{integrationId}/flow/failedmessages/{flowId}", produces = {"application/xml","application/json","text/plain"}) + @GetMapping(path = "/integration/{integrationId}/flow/{flowId}/messages/failed", produces = {"application/xml","application/json","text/plain"}) public ResponseEntity getFlowFailedMessages(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @PathVariable Long integrationId, @PathVariable String flowId) throws Exception { try { - ////integrationResource.init(); integration = integrationResource.getIntegration(); String failedMessages = integration.getFlowFailedMessages(flowId); - return ResponseUtil.createSuccessResponseWithHeaders(integrationId, mediaType,"/integration/{integrationId}/flow/failedmessages/{flowId}",failedMessages,failedMessages,flowId); + return ResponseUtil.createSuccessResponseWithHeaders(integrationId, mediaType,"/integration/{integrationId}/flow/{flowId}/messages/failed",failedMessages,failedMessages,flowId); } catch (Exception e) { log.error("Get failed messages for flow " + flowId + " failed",e); - return ResponseUtil.createFailureResponseWithHeaders(integrationId, mediaType,"/integration/{integrationId}/flow/failedmessages/{flowId}",e.getMessage(),"unable to get failed messages of flow " + flowId,flowId); + return ResponseUtil.createFailureResponseWithHeaders(integrationId, mediaType,"/integration/{integrationId}/flow/{flowId}/messages/failed",e.getMessage(),"unable to get failed messages of flow " + flowId,flowId); + } + } + + @GetMapping(path = "/integration/{integrationId}/flow/{flowId}/messages/pending", produces = {"text/plain","application/xml","application/json"}) + public ResponseEntity getFlowPendingMessages(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @PathVariable Long integrationId, @PathVariable String flowId) throws Exception { + + try { + integration = integrationResource.getIntegration(); + + String failedMessages = integration.getFlowPendingMessages(flowId); + return ResponseUtil.createSuccessResponseWithHeaders(integrationId, mediaType,"/integration/{integrationId}/flow/{flowId}/messages/pending",failedMessages,failedMessages,flowId); + } catch (Exception e) { + log.error("Get pending messages for flow " + flowId + " failed",e); + return ResponseUtil.createFailureResponseWithHeaders(integrationId, mediaType,"/integration/{integrationId}/flow/{flowId}/messages/pending",e.getMessage(),"unable to get failed messages of flow " + flowId,flowId); } } + @GetMapping(path = "/integration/{integrationId}/flow/{flowId}/step/{stepId}/messages", produces = {"text/plain","application/xml","application/json"}) + public ResponseEntity getStepMessages(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @PathVariable Long integrationId, @PathVariable String flowId, @PathVariable String stepId) throws Exception { + + try { + integration = integrationResource.getIntegration(); + + String numberOfMessages = integration.getStepMessages(flowId, stepId, mediaType); + return ResponseUtil.createSuccessResponse(integrationId, mediaType,"/integration/{integrationId}/flow/{flowId}/step/{stepId}/messages",numberOfMessages,true); + } catch (Exception e) { + log.error("Get messages for flow " + flowId + " for step " + stepId + " failed",e); + return ResponseUtil.createFailureResponseWithHeaders(integrationId, mediaType,"/integration/{integrationId}/flow/{flowId}/step/{stepId}/messages",e.getMessage(),"unable to get total messages of flow " + flowId,flowId); + } + + } + @GetMapping(path = "/integration/{integrationId}/metrics", produces = {"text/plain","application/xml","application/json"}) public ResponseEntity getMetrics(@Parameter(hidden = true) @RequestHeader("Accept") String mediaType, @PathVariable Long integrationId) throws Exception { diff --git a/pom.xml b/pom.xml index 715b9955..4fca4702 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.assimbly runtime - 3.8.1 + 3.8.2 broker @@ -24,11 +24,7 @@ 11 UTF-8 ${project.basedir} - - 3.8.1 - 4.2.13 - 1.7.1 - 1.6.13 + 3.8.2 diff --git a/pom.xml.versionsBackup b/pom.xml.versionsBackup new file mode 100644 index 00000000..efbdbfab --- /dev/null +++ b/pom.xml.versionsBackup @@ -0,0 +1,139 @@ + + + + 4.0.0 + + runtime + https://github.com/assimbly/runtime + pom + + org.assimbly + runtime + 3.8.2 + + + broker + brokerRest + dil + integration + integrationRest + + + + 11 + 11 + UTF-8 + ${project.basedir} + 3.8.1 + + + + + github + Temporary Staging Repository + https://maven.pkg.github.com/assimbly/runtime + + + + + + + org.codehaus.mojo + versions-maven-plugin + 2.8.1 + + + + dependency-updates-report + plugin-updates-report + property-updates-report + + + + + + + + + + + + + maven-clean-plugin + 3.1.0 + + + + maven-resources-plugin + 3.2.0 + + + maven-compiler-plugin + 3.8.1 + + + maven-toolchains-plugin + 3.0.0 + + + + toolchain + + + + + 11 + + + + + + + + maven-surefire-plugin + 2.22.2 + + + maven-jar-plugin + 3.2.0 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + maven-site-plugin + 3.9.1 + + + maven-project-info-reports-plugin + 3.1.2 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 11 + 11 + + + + org.codehaus.mojo + versions-maven-plugin + 2.8.1 + + ${maven-versions-rules} + + + + + +