From 56bd7b6b76ff622e06a6344e9247f3d7cd123773 Mon Sep 17 00:00:00 2001 From: assimbly Date: Fri, 5 Apr 2019 11:54:54 +0200 Subject: [PATCH] bug fixes and https support (backend) --- classpath | 0 package.json | 6 +- .../gateway/aop/logging/LoggingAspect.java | 3 +- .../config/environment/DBConfiguration.java | 26 +++---- .../environment/DBExportProperties.java | 8 --- .../domain/enumeration/EndpointType.java | 2 +- .../gateway/web/rest/ConnectorResource.java | 26 ++++++- .../gateway/web/rest/EnvironmentResource.java | 6 ++ src/main/resources/keystore.jks | Bin 0 -> 5452 bytes src/main/resources/logback-spring.xml | 6 +- src/main/resources/truststore.jks | Bin 0 -> 32 bytes .../flow/flow-delete-dialog.component.ts | 20 ++++-- .../flow/flow-edit-all.component.html | 14 ++-- .../entities/flow/flow-edit-all.component.ts | 14 ++-- .../app/entities/flow/flow-popup.service.ts | 54 ++++++++++++++ .../app/entities/flow/flow-row.component.html | 2 +- .../app/entities/flow/flow-row.component.ts | 67 +++++++++++++----- .../webapp/app/entities/flow/flow.module.ts | 9 ++- .../webapp/app/entities/flow/flow.route.ts | 2 +- .../webapp/app/entities/flow/flow.service.ts | 17 ++++- src/main/webapp/app/entities/flow/index.ts | 1 + .../service-keys/service-keys.component.ts | 2 +- .../service/service-dialog.component.ts | 2 +- .../service/service-update.component.ts | 2 +- .../wire-tap-endpoint-edit.component.html | 6 +- .../wire-tap-endpoint-edit.component.ts | 25 ++++++- .../wire-tap-endpoint-update.component.html | 3 +- .../wire-tap-endpoint-update.component.ts | 5 ++ .../webapp/app/shared/camel/component-type.ts | 50 ++++++++++--- yarn.lock | 66 +++-------------- 30 files changed, 298 insertions(+), 146 deletions(-) create mode 100644 classpath create mode 100644 src/main/resources/keystore.jks create mode 100644 src/main/resources/truststore.jks create mode 100644 src/main/webapp/app/entities/flow/flow-popup.service.ts diff --git a/classpath b/classpath new file mode 100644 index 00000000..e69de29b diff --git a/package.json b/package.json index 49ff500d..3d8e448c 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "@fortawesome/fontawesome-svg-core": "1.2.8", "@fortawesome/free-solid-svg-icons": "5.5.0", "@ng-bootstrap/ng-bootstrap": "4.0.0", - "@ng-select/ng-select": "^2.13.3", + "@ng-select/ng-select": "^2.16.3", "bootstrap": "4.1.3", "core-js": "2.5.7", "file-saver": "^1.3.8", @@ -35,8 +35,8 @@ "reflect-metadata": "0.1.12", "rxjs": "6.3.3", "swagger-ui": "2.2.10", - "sockjs-client": "1.1.4", - "webstomp-client": "1.2.5", + "sockjs-client": "1.3.0", + "webstomp-client": "1.2.6", "tether": "1.4.0", "xml-js": "^1.6.7", "yaml-js": "^0.2.3", diff --git a/src/main/java/org/assimbly/gateway/aop/logging/LoggingAspect.java b/src/main/java/org/assimbly/gateway/aop/logging/LoggingAspect.java index a07bde63..4fa3b7ff 100644 --- a/src/main/java/org/assimbly/gateway/aop/logging/LoggingAspect.java +++ b/src/main/java/org/assimbly/gateway/aop/logging/LoggingAspect.java @@ -44,8 +44,7 @@ public void springBeanPointcut() { * Pointcut that matches all Spring beans in the application's main packages. */ @Pointcut("within(org.assimbly.gateway.repository..*)"+ - " || within(org.assimbly.gateway.service..*)"+ - " || within(org.assimbly.gateway.web.rest..*)") + " || within(org.assimbly.gateway.service..*)") public void applicationPackagePointcut() { // Method is empty as this is just a Pointcut, the implementations are in the advices. } diff --git a/src/main/java/org/assimbly/gateway/config/environment/DBConfiguration.java b/src/main/java/org/assimbly/gateway/config/environment/DBConfiguration.java index de97cbb4..2264f353 100644 --- a/src/main/java/org/assimbly/gateway/config/environment/DBConfiguration.java +++ b/src/main/java/org/assimbly/gateway/config/environment/DBConfiguration.java @@ -1,12 +1,12 @@ package org.assimbly.gateway.config.environment; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; +import java.util.stream.Collectors; -import org.apache.commons.lang3.text.StrSubstitutor; +import org.apache.commons.text.StringSubstitutor; import org.assimbly.docconverter.DocConverter; import org.assimbly.gateway.domain.EnvironmentVariables; import org.assimbly.gateway.repository.EnvironmentVariablesRepository; @@ -15,7 +15,6 @@ import org.w3c.dom.Document; -@SuppressWarnings("deprecation") @Service public class DBConfiguration { @@ -38,6 +37,8 @@ public class DBConfiguration { @Autowired private DBImportXMLConfiguration dbImportXML; + private String output; + // exports connector to object (List of treemaps) public List> convertDBToConfiguration(Long gatewayId) throws Exception { @@ -149,16 +150,15 @@ private Document getDocument(String mediaType, String configuration) throws Exce private String PlaceholdersReplacement(String input) { List environmentVariables = environmentVariablesRepository.findAll(); - - Map values = new HashMap(); - - for (EnvironmentVariables environmentVariable : environmentVariables) { - values.put(environmentVariable.getKey(), environmentVariable.getValue()); - } - - StrSubstitutor sub = new StrSubstitutor(values, "@{", "}"); - - String output = sub.replace(input); + + Map values = environmentVariables.stream().collect(Collectors.toMap(EnvironmentVariables::getKey, EnvironmentVariables::getValue)); + + if(values.containsValue("")) { + output = "Error: Environment variables contain empty values"; + }else { + StringSubstitutor sub = new StringSubstitutor(values, "@{", "}"); + output = sub.replace(input); + } return output; diff --git a/src/main/java/org/assimbly/gateway/config/environment/DBExportProperties.java b/src/main/java/org/assimbly/gateway/config/environment/DBExportProperties.java index da3851e3..982a6c56 100644 --- a/src/main/java/org/assimbly/gateway/config/environment/DBExportProperties.java +++ b/src/main/java/org/assimbly/gateway/config/environment/DBExportProperties.java @@ -12,8 +12,6 @@ import org.assimbly.gateway.domain.HeaderKeys; import org.assimbly.gateway.domain.ToEndpoint; import org.assimbly.gateway.repository.FlowRepository; -import org.assimbly.gateway.service.FlowService; -import org.assimbly.gateway.service.dto.FlowDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -34,12 +32,6 @@ public class DBExportProperties { @Autowired private FlowRepository flowRepository; - @Autowired - private FlowRepository flowMapper; - - @Autowired - private FlowService flowService; - private FromEndpoint fromEndpoint; private ErrorEndpoint errorEndpoint; diff --git a/src/main/java/org/assimbly/gateway/domain/enumeration/EndpointType.java b/src/main/java/org/assimbly/gateway/domain/enumeration/EndpointType.java index 1cff92b8..3e24664b 100644 --- a/src/main/java/org/assimbly/gateway/domain/enumeration/EndpointType.java +++ b/src/main/java/org/assimbly/gateway/domain/enumeration/EndpointType.java @@ -4,5 +4,5 @@ * The EndpointType enumeration. */ public enum EndpointType { - ACTIVEMQ, DIRECT, FILE, FTP, FTPS, HTTP4, IMAP, IMAPS, NETTY4, KAFKA, REST, SJMS, SMTP, SMTPS3, SQL, SFTP, SONICMQ, STREAM, TELEGRAM, VM, WASTEBIN + ACTIVEMQ, DIRECT, FILE, FTP, FTPS, HTTP4, HTTPS4, IMAP, IMAPS, JETTY, NETTY4, KAFKA, REST, SJMS, SMTP, SMTPS3, SQL, SFTP, SONICMQ, STREAM, TELEGRAM, VM, WASTEBIN } diff --git a/src/main/java/org/assimbly/gateway/web/rest/ConnectorResource.java b/src/main/java/org/assimbly/gateway/web/rest/ConnectorResource.java index 65b3b8e7..1c2a656b 100644 --- a/src/main/java/org/assimbly/gateway/web/rest/ConnectorResource.java +++ b/src/main/java/org/assimbly/gateway/web/rest/ConnectorResource.java @@ -261,7 +261,8 @@ public void run() flowId = id.toString(); status = connector.getFlowStatus(flowId); - if(status.equals("suspended")) { + if(status.equals("suspended")) { + status = connector.startFlow(flowId); if(status.equals("started")) { if(this.messagingTemplate!=null) { this.messagingTemplate.convertAndSend("/topic/" + flowId + "/event","event:resumed"); @@ -711,6 +712,29 @@ public ResponseEntity getFlowStats(@ApiParam(hidden = true) @RequestHead return ResponseUtil.createFailureResponse(connectorId, mediaType,"/connector/{connectorId}/flow/stats/{id}",e.getMessage()); } } + + /** + * POST /connector/{connectorId}/setcertificates : Sets TLS certificates. + * + * @param connectorid (gatewayId) + * @param id (FlowId) + * @param configuration as XML / if empty get from db (for the time being) + * @return the ResponseEntity with status 200 (Successful) and status 400 (Bad Request) if the configuration failed + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PostMapping(path = "/connector/{connectorId}/setcertificates", consumes = {"text/plain","application/xml","application/json"}, produces = {"text/plain","application/xml","application/json"}) + @Timed + public ResponseEntity setCertificates(@ApiParam(hidden = true) @RequestHeader("Accept") String mediaType, @PathVariable Long connectorId,@RequestBody String url) throws Exception { + + try { + connector.setCertificates(url); + return ResponseUtil.createSuccessResponse(connectorId, mediaType,"/connector/{connectorId}/setflowconfiguration/{id}","Connector certificates set"); + } catch (Exception e) { + e.printStackTrace(); + return ResponseUtil.createFailureResponse(connectorId, mediaType,"/connector/{connectorId}/setflowconfiguration/{id}",e.getMessage()); + } + } + // Generates a generic error response (exceptions outside try catch): @ExceptionHandler({Exception.class}) diff --git a/src/main/java/org/assimbly/gateway/web/rest/EnvironmentResource.java b/src/main/java/org/assimbly/gateway/web/rest/EnvironmentResource.java index 2935f40a..9ad38028 100644 --- a/src/main/java/org/assimbly/gateway/web/rest/EnvironmentResource.java +++ b/src/main/java/org/assimbly/gateway/web/rest/EnvironmentResource.java @@ -63,6 +63,9 @@ public ResponseEntity getGatewayConfiguration(@ApiParam(hidden = true) @ try { configuration = DBConfiguration.convertDBToConfiguration(gatewayid, mediaType); + if(configuration.startsWith("Error")||configuration.startsWith("Warning")) { + return ResponseUtil.createFailureResponse(gatewayid, mediaType, "getConfiguration", configuration); + } return ResponseUtil.createSuccessResponse(gatewayid, mediaType, "getFlowConfiguration", configuration, true); } catch (Exception e) { @@ -102,6 +105,9 @@ public ResponseEntity setFlowConfiguration(@ApiParam(hidden = true) @Req public ResponseEntity getFlowConfiguration(@ApiParam(hidden = true) @RequestHeader("Accept") String mediaType, @PathVariable Long gatewayid, @PathVariable Long flowid) throws Exception { try { configuration = DBConfiguration.convertDBToFlowConfiguration(flowid, mediaType); + if(configuration.startsWith("Error")||configuration.startsWith("Warning")) { + return ResponseUtil.createFailureResponse(gatewayid, mediaType, "getFlowConfiguration", configuration); + } return ResponseUtil.createSuccessResponse(gatewayid, mediaType, "getFlowConfiguration", configuration, true); } catch (Exception e) { return ResponseUtil.createFailureResponse(gatewayid, mediaType, "getFlowConfiguration", e.getMessage()); diff --git a/src/main/resources/keystore.jks b/src/main/resources/keystore.jks new file mode 100644 index 0000000000000000000000000000000000000000..b83b94b6bace842beda344843bacf3b0582e64a1 GIT binary patch literal 5452 zcmchb2{@G9`^V>*8Dmd&S;rDu@QhtV_PsFKiZYFD7~9OCD9aS>Qj;htOCmzDmo?rb zAw(s6B@uZ`p)CJrOnT|0nX(6V-dW!M?R1_I16W%#UA-*MCqSTt*EtH{xsffnr`li_a9 zMy8?=Ie~NG*TfT!OqQ8tu=I2ngmGx0JR&VzB`O7HbE_xipHm{k4qkSS@%DF-R<^9! zSv$JN?{#2J==z#@;A_mwY@_u~%C~}ry4usLO^4-trmv{XnzOi_ezw1O+p(Io91E)> zx^27m6GQf;T56oX)+;sQ*UBdx=hM8{QpD#j*tmDoHRYO5lixbo4W8we=_~heJo`8s z-F5%0lU|9)sJVQ4U=Ie_H*;6ulNH-e=IjZJ?fXh1GvezDg!qT9T5n+Zff7f_7eunsAJ=->`Q7L9YRTHDA@pG2`W7`_^Z4b(h_p>4ALYmqUkGGGv72Ew>!2RjBA{T%4|x zaB431yBbD$m$WIDyX19XYFdlciOaMz=L3gxxkRgJx0di-Z_ZmAL zhySLR^{Uu&;DBd$yTAU~PYNYtp%&LuoQAhJ*Y1#>P>`n@>mJ&DK{jbH$}C&s<5c${ zH-Y}!qw8AyZyO0}Dw+2T8S8GYP{+1yvq8-$jy5=&6LFG4UC6wHI$O6z`DTq5@bkTY zak8#LlQ?{ycxuVLB6Oo8SSuovG1U8h!1QoQu?!0n_(7qHy~eo4rsCG;@g#sJ@6m~e zNviwLvgtg0-<6Qy*T0t5u}1tSYp`be%4jTOv9OHAf{^o1`QDrF6mMPE0P@GH?e*88@_*UtQuX@P zQjp;{_l;4{CWX?ir#zpsk^Q-o)CJuOG*TA6=^ra-EI6|$Otx-QNsLdwbR2thOU2D# zGX*gRjqo0fvhefUxv1$JSIaU}lfKQg`g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89a|6F>c;ca%CNTD#N^~=&NOswa=C@RUum2Lw6l+2`IAfuL}ISa)x>&`{gRRhs#P)l!W*93*~Gt z+T>a9>agpA1;ZvStIC2~-R=z;5F~Pku6br~MeM&rdT|ui5PmW&d!d=(*T{L&y&5Fuld`&S{^+6~gDVzXie3J1U#k@tvySw^c8g_1ZJw zFCoQ!bep(th&rumwn}UK3N+pOF9#|mP6d_FE=ninTnIPSbWC8&wHpwHGkx-)E9)XSl17nx1B!bUESEazoETqQ`^%$Gjn*= zW(^+22Gh>FdM~K~@jcugU*5kk(dFp!%3ge;H+6M8hkO2GS~@PUX!<1PsiXS2&p9)Z z=Gg1mG#jaS=ERhI1iyCRl;{bP@UyY*m%g98gQQiRFNZsw8r=43YS$R`(K++zs4QoJ zHse|6e7nM1Y=Nmu)!z0L(Lvj<2bWAWZ|6QVxnA~7G&AT@TE|5}oWB<{Vy-dzULe+U zB>iAP%By#oz@sS_*Fn)&K>{3e7i0jnsCQrEDkB@#$9|)++#-Z;7A@ - @@ -54,6 +53,7 @@ + diff --git a/src/main/resources/truststore.jks b/src/main/resources/truststore.jks new file mode 100644 index 0000000000000000000000000000000000000000..936813a96a23e77eba25dd5a008af1cda0ab4dc6 GIT binary patch literal 32 ncmezO_TO6u1_mY|X0Tbtz`j(P@urpculd1S)om{*O}GO9!e { - this.eventManager.broadcast({ - name: 'flowListModification', - content: 'Deleted an flow' - }); - this.activeModal.dismiss(true); + this.flowService.getFlowStatus(id).subscribe((response) => { + if (response.body === 'started') { + this.message = 'Active flow can not be deleted. Please stop flow before first.'; + this.disableDelete = true; + } else { + this.flowService.delete(id).subscribe((r) => { + this.router.navigate(['/']); + this.activeModal.dismiss(true); + }); + } }); } } diff --git a/src/main/webapp/app/entities/flow/flow-edit-all.component.html b/src/main/webapp/app/entities/flow/flow-edit-all.component.html index 8fef1fc9..30f71315 100644 --- a/src/main/webapp/app/entities/flow/flow-edit-all.component.html +++ b/src/main/webapp/app/entities/flow/flow-edit-all.component.html @@ -151,7 +151,7 @@
URI
- + @@ -264,7 +264,7 @@
URI
- + @@ -386,7 +386,7 @@
URI
- + @@ -458,9 +458,13 @@
URI
- + diff --git a/src/main/webapp/app/entities/flow/flow-edit-all.component.ts b/src/main/webapp/app/entities/flow/flow-edit-all.component.ts index 28e53647..11cb6e0f 100644 --- a/src/main/webapp/app/entities/flow/flow-edit-all.component.ts +++ b/src/main/webapp/app/entities/flow/flow-edit-all.component.ts @@ -77,6 +77,7 @@ export class FlowEditAllComponent implements OnInit, OnDestroy { fromUriPlaceholder: string; fromUriPopoverMessage: string; + componentOptions: any; fromComponentOptions: any; toComponentOptions: Array = []; errorComponentOptions: any; @@ -331,7 +332,7 @@ export class FlowEditAllComponent implements OnInit, OnDestroy { // get options keys this.getComponentOptions(componentType).subscribe((data) => { - this.fromComponentOptions = Object.keys(data.properties); + this.fromComponentOptions = Object.keys(data.properties).sort(); }); } else if (endpoint instanceof ToEndpoint) { @@ -344,7 +345,7 @@ export class FlowEditAllComponent implements OnInit, OnDestroy { // set options keys this.getComponentOptions(componentType).subscribe((data) => { - this.toComponentOptions[this.toEndpoints.indexOf(endpoint)] = Object.keys(data.properties); + this.toComponentOptions[this.toEndpoints.indexOf(endpoint)] = Object.keys(data.properties).sort(); }); } else if (endpoint instanceof ErrorEndpoint) { @@ -357,7 +358,7 @@ export class FlowEditAllComponent implements OnInit, OnDestroy { // set options keys this.getComponentOptions(componentType).subscribe((data) => { - this.errorComponentOptions = Object.keys(data.properties); + this.errorComponentOptions = Object.keys(data.properties).sort(); }); } @@ -476,7 +477,7 @@ export class FlowEditAllComponent implements OnInit, OnDestroy { getOptions(endpoint: any, endpointForm: any, endpointOptions: Array