Skip to content

Commit

Permalink
Merge pull request #89 from assimbly/develop
Browse files Browse the repository at this point in the history
Release 3.9.0
  • Loading branch information
skin27 authored Feb 7, 2023
2 parents e64b9aa + 1d1dc84 commit 7028170
Show file tree
Hide file tree
Showing 22 changed files with 297 additions and 220 deletions.
11 changes: 10 additions & 1 deletion .github/issue-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@ branches:
- label: '*'
prefix: issues/

- label: no-branch
- label: [ major ]
skip: true

- label: [ minor ]
skip: true

- label: [ patch ]
skip: true

- label: skip-release
skip: true

autoCloseIssue: true
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/issue-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
issues:
types: [ created, assigned ]

pull_request:
types: [ closed ]

jobs:
create_issue_branch_job:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion broker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>runtime</artifactId>
<groupId>org.assimbly</groupId>
<version>3.8.2</version>
<version>3.9.0</version>
</parent>

<name>broker</name>
Expand Down
2 changes: 1 addition & 1 deletion brokerRest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>runtime</artifactId>
<groupId>org.assimbly</groupId>
<version>3.8.2</version>
<version>3.9.0</version>
</parent>

<name>broker-rest</name>
Expand Down
2 changes: 1 addition & 1 deletion dil/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>runtime</artifactId>
<groupId>org.assimbly</groupId>
<version>3.8.2</version>
<version>3.9.0</version>
</parent>

<name>dil</name>
Expand Down
2 changes: 1 addition & 1 deletion dil/pom.xml.versionsBackup
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>runtime</artifactId>
<groupId>org.assimbly</groupId>
<version>3.8.1</version>
<version>3.8.2</version>
</parent>

<name>dil</name>
Expand Down
21 changes: 12 additions & 9 deletions dil/src/main/java/org/assimbly/dil/loader/FlowLoader.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.assimbly.dil.loader;

import java.util.Set;
import java.util.List;
import java.util.TreeMap;
import org.apache.camel.*;
import org.apache.camel.builder.*;
Expand Down Expand Up @@ -66,21 +66,24 @@ private void init(){

flowLoaderReport = new FlowLoaderReport();

flowLoaderReport.initReport(flowId, flowName);
flowLoaderReport.initReport(flowId, flowName, "start");

setExtendedCamelContext();

}

private void finish() {

flowLoaderReport.logResult(flowId,flowName,flowEvent);

if (isFlowLoaded){
flowLoaderReport.finishReport(flowId, flowName, flowEvent, flowVersion, flowEnvironment, "Started flow successfully");
}else{
flowLoaderReport.finishReport(flowId, flowName, flowEvent, flowVersion, flowEnvironment, "Failed to load flow");
}
}

private void setExtendedCamelContext() {
private void setExtendedCamelContext() {
context = getContext();
extendedCamelContext = context.adapt(ExtendedCamelContext.class);
}
Expand Down Expand Up @@ -121,6 +124,7 @@ private void setRouteConfigurations() throws Exception{
String id = props.get(prop + ".id");

if(routeConfiguration!=null && !routeConfiguration.isEmpty()){
context.removeRoute(id);
loadOrUpdateStep(routeConfiguration, "routeconfiguration", id, null);
}
}
Expand Down Expand Up @@ -163,7 +167,7 @@ private void setRouteTemplates() throws Exception{

private void setRoutes() throws Exception{
for(String prop : props.keySet()){
if(prop.endsWith("route")){
if(prop.endsWith("route")){

String route = props.get(prop);
String id = props.get(prop + ".id");
Expand Down Expand Up @@ -196,7 +200,7 @@ private void loadOrUpdateStep(String route, String type, String id, String uri)
private void updateStep(Resource resource, String route, String type, String id, String uri){
try {
log.info(logMessage("Updating step", id, type, route));
loader.updateRoutes(resource);
loader.updateRoutes(List.of(resource));

//context
flowLoaderReport.setStep(id, uri, type, "success", null);
Expand All @@ -212,15 +216,14 @@ private void updateStep(Resource resource, String route, String type, String id,

private void loadStep(Resource resource, String route, String type, String id, String uri){

System.out.println("1. id=" + id);
System.out.println("1. StepUri=" + uri);

try {
log.info(logMessage("Loading step", id, type, route));
loader.loadRoutes(resource);

loader.loadRoutes(List.of(resource));
flowEvent = "start";
flowLoaderReport.setStep(id, uri, type, "success", null);
}catch (Exception e){
e.printStackTrace();
try {
String errorMessage = e.getMessage();

Expand Down
17 changes: 8 additions & 9 deletions dil/src/main/java/org/assimbly/dil/loader/FlowLoaderReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ public class FlowLoaderReport {
private JSONObject stepsLoaded;


public void initReport(String flowId, String flowName){
public void initReport(String flowId, String flowName, String event){

log.info("Start flow | name=" + flowName + " | id=" + flowId);
String eventCapitalized = StringUtils.capitalize(event);
log.info(eventCapitalized + " flow | id=" + flowId);

json = new JSONObject();
flow = new JSONObject();
Expand Down Expand Up @@ -55,8 +56,6 @@ public void finishReport(String flowId, String flowName, String event, String ve

report = json.toString(4);

logResult(flowId, flowName, event);

}

public void setStep(String stepId, String stepUri, String stepType, String stepStatus, String message){
Expand Down Expand Up @@ -93,19 +92,19 @@ public String getReport(){
return report;
}

private void logResult(String flowId, String flowName, String event){
public void logResult(String flowId, String flowName, String event){
//logging
if(loaded == loadedSuccess) {
if(loadedSuccess == 1){
log.info(loadedSuccess + " step loaded succesfully");
}else{
log.info(loadedSuccess + " steps loaded succesfully");
log.info(loadedSuccess + " step loaded successfully");
}else if(loadedSuccess > 1){
log.info(loadedSuccess + " steps loaded successfully");
}
log.info("Start flow | name=" + flowName + " | id=" + flowId);
}else{
if(loadedError == 1){
log.error(loadedError + " step failed to load");
}else{
}else if(loadedError > 1){
log.error(loadedError + " steps failed to load");
}
log.error("Event=" + event + " | name=" + flowName + " | id=" + flowId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import org.assimbly.dil.transpiler.transform.Transform;
import org.assimbly.docconverter.DocConverter;
import org.assimbly.util.IntegrationUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.ErrorHandler;
Expand All @@ -40,6 +42,8 @@

public class XMLFileConfiguration {

final static Logger log = LoggerFactory.getLogger(XMLFileConfiguration.class);

private TreeMap<String, String> properties;
private List<TreeMap<String, String>> propertiesList;

Expand Down Expand Up @@ -90,7 +94,7 @@ public List<TreeMap<String, String>> getFlowConfigurations(String integrationId,

public TreeMap<String, String> getFlowConfiguration(String flowId, String xml) throws Exception {

System.out.println(xml);
log.debug("Configuration File: " + xml);

String dilXml = xml;
if(!xml.endsWith("</dil>")){
Expand All @@ -112,7 +116,7 @@ public TreeMap<String, String> getFlowConfiguration(String flowId, String xml) t

properties = new Unmarshall().getProperties(conf,flowId);

IntegrationUtil.printTreemap(properties);
//IntegrationUtil.printTreemap(properties);

return properties;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.xpath.*;
import java.sql.Timestamp;
import java.util.*;

import static org.assimbly.util.IntegrationUtil.*;
Expand Down Expand Up @@ -50,6 +51,8 @@ public class RouteTemplate {

private String outRulesList;

private String updatedRouteConfigurationId;


public RouteTemplate(TreeMap<String, String> properties, XMLConfiguration conf) {
this.properties = properties;
Expand Down Expand Up @@ -301,11 +304,16 @@ private void createCustomStep(List<String> optionProperties, String[] links, Str
}else if(blockType.equalsIgnoreCase("routeConfiguration")){

String routeConfigurationId = baseUri;
String timestamp = getTimestamp();
Node routeNode = IntegrationUtil.getNode(conf,"/dil/core/routeConfigurations/routeConfiguration[@id='" + routeConfigurationId + "']");
String routeConfiguration = DocConverter.convertNodeToString(routeNode);

properties.put(type + "." + stepId + ".routeconfiguration.id", routeConfigurationId);
properties.put(type + "." + stepId + ".routeconfiguration", routeConfiguration);

updatedRouteConfigurationId = baseUri + "_" + timestamp;
String updatedRouteConfiguration = StringUtils.replace(routeConfiguration,routeConfigurationId,updatedRouteConfigurationId);

properties.put(type + "." + stepId + ".routeconfiguration.id", updatedRouteConfiguration);
properties.put(type + "." + stepId + ".routeconfiguration", updatedRouteConfiguration);
}

}
Expand Down Expand Up @@ -353,8 +361,9 @@ private void createTemplatedRoutes(){

private void createTemplatedRoute(List<String> optionProperties, String[] links, String stepXPath, String type, String flowId){

templatedRoute = templateDoc.createElement("templatedRoute");
templatedRoute = templateDoc.createElementNS("http://camel.apache.org/schema/spring", "templatedRoute");
templatedRoute.setAttribute("routeTemplateRef", templateId);

templatedRoute.setAttribute("routeId", routeId);
templatedRoutes.appendChild(templatedRoute);

Expand Down Expand Up @@ -429,7 +438,7 @@ private void createTemplateParameter(String name, String value){

private Element createParameter(Document doc, String name, String value){

Element parameter = doc.createElement("parameter");
Element parameter = doc.createElementNS("http://camel.apache.org/schema/spring","parameter");
parameter.setAttribute("name", name);
parameter.setAttribute("value", value);

Expand Down Expand Up @@ -710,7 +719,7 @@ private void createConfigurationId(){
String routeConfiguratinID = Objects.toString(conf.getProperty("integration/flows/flow/steps/step[type='error']/routeconfiguration_id"), null);

if(routeConfiguratinID!=null){
Element parameter = createParameter(templateDoc, "routeconfigurationid", routeConfiguratinID);
Element parameter = createParameter(templateDoc, "routeconfigurationid", updatedRouteConfigurationId);
templatedRoute.appendChild(parameter);
}
}
Expand Down Expand Up @@ -761,4 +770,11 @@ private void createCoreComponents() throws XPathExpressionException, Transformer
}
}
}

private String getTimestamp(){
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
long unix_timestamp = timestamp.getTime();
return Long.toString(unix_timestamp);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,4 @@ public void initTrustStoresForHttpsCertificateValidator(

}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.apache.camel.Exchange;
import org.apache.camel.language.groovy.GroovyExpression;
import org.apache.camel.language.js.JavaScriptExpression;
//import org.apache.camel.language.js.JavaScriptExpression;
import org.assimbly.dil.validation.beans.script.EvaluationRequest;
import org.assimbly.dil.validation.beans.script.EvaluationResponse;
import org.assimbly.dil.validation.beans.script.ExchangeDto;
Expand Down Expand Up @@ -53,6 +53,10 @@ private EvaluationResponse validateGroovyScript(ExchangeDto exchangeDto, String
}

private EvaluationResponse validateJavaScript(ExchangeDto exchangeDto, String script) {

return createBadRequestResponse(exchangeDto, "JavaScript not supported");

/*
try {
JavaScriptExpression javaScriptEvaluator = new JavaScriptExpression(script, String.class);
Exchange exchangeRequest = ExchangeMarshaller.unmarshall(exchangeDto);
Expand All @@ -62,6 +66,8 @@ private EvaluationResponse validateJavaScript(ExchangeDto exchangeDto, String sc
} catch (Exception e) {
return createBadRequestResponse(exchangeDto, "Invalid javascript: '" + e.getMessage() + "'");
}
*/
}

private EvaluationResponse createOKRequestResponse(ExchangeDto exchange, String message) {
Expand All @@ -71,4 +77,4 @@ private EvaluationResponse createOKRequestResponse(ExchangeDto exchange, String
private EvaluationResponse createBadRequestResponse(ExchangeDto exchange, String message) {
return new EvaluationResponse(exchange, message, -1);
}
}
}
5 changes: 3 additions & 2 deletions dil/src/main/resources/transform-to-dil.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
<routeconfiguration_id>
<xsl:choose>
<xsl:when test="//*:camelContext/@id">
<xsl:value-of select="concat(//*:camelContext/@id,'_',$timestamp)"/>
<xsl:value-of select="//*:camelContext/@id"/>
</xsl:when>
<xsl:otherwise>
Expand Down Expand Up @@ -197,7 +198,7 @@
<xsl:attribute name="routeConfigurationId">
<xsl:choose>
<xsl:when test="@id">
<xsl:attribute name="id" select="//*:camelContext/@id"/>
<xsl:attribute name="id" select="concat(//*:camelContext/@id,'_',$timestamp)"/>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="id" select="generate-id(.)"/>
Expand All @@ -215,7 +216,7 @@
<xsl:attribute name="id">
<xsl:choose>
<xsl:when test="//*:camelContext/@id">
<xsl:attribute name="id" select="//*:camelContext/@id"/>
<xsl:attribute name="id" select="concat(//*:camelContext/@id,'_',$timestamp)"/>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="id" select="generate-id(.)"/>
Expand Down
2 changes: 1 addition & 1 deletion integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>runtime</artifactId>
<groupId>org.assimbly</groupId>
<version>3.8.2</version>
<version>3.9.0</version>
</parent>

<name>integration</name>
Expand Down
2 changes: 1 addition & 1 deletion integration/pom.xml.versionsBackup
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>runtime</artifactId>
<groupId>org.assimbly</groupId>
<version>3.8.1</version>
<version>3.8.2</version>
</parent>

<name>integration</name>
Expand Down
Loading

0 comments on commit 7028170

Please sign in to comment.