Skip to content

Commit

Permalink
bug fixes and https support (backend)
Browse files Browse the repository at this point in the history
  • Loading branch information
assimbly committed Apr 5, 2019
1 parent a16fd71 commit 56bd7b6
Show file tree
Hide file tree
Showing 30 changed files with 298 additions and 146 deletions.
Empty file added classpath
Empty file.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,7 +15,6 @@

import org.w3c.dom.Document;

@SuppressWarnings("deprecation")
@Service
public class DBConfiguration {

Expand All @@ -38,6 +37,8 @@ public class DBConfiguration {
@Autowired
private DBImportXMLConfiguration dbImportXML;

private String output;

// exports connector to object (List of treemaps)
public List<TreeMap<String, String>> convertDBToConfiguration(Long gatewayId) throws Exception {

Expand Down Expand Up @@ -149,16 +150,15 @@ private Document getDocument(String mediaType, String configuration) throws Exce
private String PlaceholdersReplacement(String input) {

List<EnvironmentVariables> environmentVariables = environmentVariablesRepository.findAll();

Map<String, String> values = new HashMap<String, String>();

for (EnvironmentVariables environmentVariable : environmentVariables) {
values.put(environmentVariable.getKey(), environmentVariable.getValue());
}

StrSubstitutor sub = new StrSubstitutor(values, "@{", "}");

String output = sub.replace(input);

Map<String, String> 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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -711,6 +712,29 @@ public ResponseEntity<String> 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<String> 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})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public ResponseEntity<String> 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) {
Expand Down Expand Up @@ -102,6 +105,9 @@ public ResponseEntity<String> setFlowConfiguration(@ApiParam(hidden = true) @Req
public ResponseEntity<String> 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());
Expand Down
Binary file added src/main/resources/keystore.jks
Binary file not shown.
6 changes: 3 additions & 3 deletions src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<include resource="org/springframework/boot/logging/logback/base.xml"/>

<!-- The FILE and ASYNC appenders are here as examples for a production configuration -->
<!--
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logFile.%d{yyyy-MM-dd}.log</fileNamePattern>
<fileNamePattern>${user.home}/.assimbly/%d{yyyy-MM-dd}.assimbly.log</fileNamePattern>
<maxHistory>90</maxHistory>
<totalSizeCap>20GB</totalSizeCap>
</rollingPolicy>
<encoder>
<charset>utf-8</charset>
Expand All @@ -25,7 +25,6 @@
<root level="${logging.level.root}">
<appender-ref ref="ASYNC"/>
</root>
-->

<logger name="javax.activation" level="WARN"/>
<logger name="javax.mail" level="WARN"/>
Expand Down Expand Up @@ -54,6 +53,7 @@
<logger name="springfox" level="WARN"/>
<logger name="sun.rmi" level="WARN"/>
<logger name="liquibase" level="WARN"/>
<logger name="org.quartz.core.QuartzSchedulerThread" level="WARN"/>
<logger name="LiquibaseSchemaResolver" level="INFO"/>
<logger name="sun.rmi.transport" level="WARN"/>

Expand Down
Binary file added src/main/resources/truststore.jks
Binary file not shown.
20 changes: 13 additions & 7 deletions src/main/webapp/app/entities/flow/flow-delete-dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,26 @@ import { FlowService } from './flow.service';
})
export class FlowDeleteDialogComponent {
flow: IFlow;
message = 'Are you sure you want to delete this Flow?';
disableDelete: boolean;

constructor(protected flowService: FlowService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager) {}
constructor(protected flowService: FlowService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager, protected router: Router) {}

clear() {
this.activeModal.dismiss('cancel');
}

confirmDelete(id: number) {
this.flowService.delete(id).subscribe(response => {
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);
});
}
});
}
}
Expand Down
14 changes: 9 additions & 5 deletions src/main/webapp/app/entities/flow/flow-edit-all.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ <h5>URI</h5>
<i triggers="mouseenter:mouseleave" popoverTitle="Info" [popover]="optionsPopover" container="body" placement="right" class="fa fa-info-circle"></i>
<div class="row mx-0 mb-1" *ngFor="let fromOption of fromEndpointOptions; let idx = index" [formGroupName]="idx">
<!-- <input type="text" class="col-5 right-border-radius-0 d-inline-block form-control" id="field_options-key-{{idx}}" formControlName="key" (focusout)="validateOptions(editFlowForm.controls.endpointsData.controls[0].controls.options.controls[idx])"/> -->
<ng-select [items]="fromComponentOptions" [ngStyle]="{'display':'block', 'width': '300px'}" formControlName="key" id="field_options-key-{{idx}}" (focusout)="validateOptions(editFlowForm.controls.endpointsData.controls[0].controls.options.controls[idx])"></ng-select>
<ng-select [items]="fromComponentOptions" [addTag]="true" [ngStyle]="{'display':'block', 'width': '300px'}" formControlName="key" id="field_options-key-{{idx}}" (focusout)="validateOptions(editFlowForm.controls.endpointsData.controls[0].controls.options.controls[idx])"></ng-select>
<input type="text" class="col-5 rounded-0 d-inline-block form-control" id="field_options-value-{{idx}}" formControlName="value" (focusout)="validateOptions(editFlowForm.controls.endpointsData.controls[0].controls.options.controls[idx])"/>
<button title="Add option" type="button" class="col-1 rounded-0 btn btn-primary" (click)="addOption(fromEndpointOptions, '0')"><span class="fa fa-plus"></span></button>
<button title="Remove option" type="button" class="col-1 left-border-radius-0 btn btn-danger" (click)="removeOption(fromEndpointOptions, fromOption, '0')" [disabled]="fromEndpointOptions.length === 1"><span class="fa fa-remove"></span></button>
Expand Down Expand Up @@ -264,7 +264,7 @@ <h5>URI</h5>
<i triggers="mouseenter:mouseleave" popoverTitle="Info" [popover]="optionsPopover" container="body" placement="right" class="fa fa-info-circle"></i>
<div class="row mx-0 mb-1" *ngFor="let toOption of toEndpointsOptions[toIndex]; index as idx" [formGroupName]="idx">
<!-- <input type="text" class="col-5 right-border-radius-0 d-inline-block form-control" id="field_options-key-{{idx}}" formControlName="key" (focusout)="validateOptions(editFlowForm.controls.endpointsData.controls[toIndex+2].controls.options.controls[idx])" data-toggle="tooltip" title="Name of the option. Click the Camel component button for documentation on valid options."/> -->
<ng-select [items]="toComponentOptions[toIndex]" [ngStyle]="{'display':'block', 'width': '300px'}" formControlName="key" id="field_options-key-{{idx}}" (focusout)="validateOptions(editFlowForm.controls.endpointsData.controls[toIndex+2].controls.options.controls[idx])"></ng-select>
<ng-select [items]="toComponentOptions[toIndex]" [addTag]="true" [ngStyle]="{'display':'block', 'width': '300px'}" formControlName="key" id="field_options-key-{{idx}}" (focusout)="validateOptions(editFlowForm.controls.endpointsData.controls[toIndex+2].controls.options.controls[idx])"></ng-select>
<input type="text" class="col-5 rounded-0 d-inline-block form-control" id="field_options-value-{{idx}}" formControlName="value" (focusout)="validateOptions(editFlowForm.controls.endpointsData.controls[toIndex+2].controls.options.controls[idx])" data-toggle="tooltip" title="Value of the option. Click the Camel component button for documentation on valid options."/>
<button title="Add option" type="button" class="col-1 rounded-0 btn btn-primary" (click)="addOption(toEndpointsOptions[toIndex], toIndex+2)" [disabled]="editFlowForm.controls.endpointsData.controls[toIndex+2].controls.type.value === 'WASTEBIN'"><span class="fa fa-plus"></span></button>
<button title="Remove option" type="button" class="col-1 left-border-radius-0 btn btn-danger" (click)="removeOption(toEndpointsOptions[toIndex], toOption, toIndex+2)" [disabled]="editFlowForm.controls.endpointsData.controls[toIndex+2].controls.type.value === 'WASTEBIN' || toEndpointsOptions[toIndex].length === 1"><span class="fa fa-remove"></span></button>
Expand Down Expand Up @@ -386,7 +386,7 @@ <h5>URI</h5>
<i triggers="mouseenter:mouseleave" popoverTitle="Info" [popover]="optionsPopover" container="body" placement="right" class="fa fa-info-circle"></i>
<div class="row mx-0 mb-1" *ngFor="let errOption of errorEndpointOptions; let idx = index" [formGroupName]="idx">
<!-- <input type="text" class="col-5 right-border-radius-0 d-inline-block form-control" id="field_options-key-{{idx}}" formControlName="key" (focusout)="validateOptions(editFlowForm.controls.endpointsData.controls[1].controls.options.controls[idx])" data-toggle="tooltip" title="Name of the option. Click the Camel component button for documentation on valid options."/>-->
<ng-select [items]="errorComponentOptions" [ngStyle]="{'display':'block', 'width': '300px'}" formControlName="key" id="field_options-key-{{idx}}" (focusout)="validateOptions(editFlowForm.controls.endpointsData.controls[1].controls.options.controls[idx])"></ng-select>
<ng-select [items]="errorComponentOptions" [addTag]="true" [ngStyle]="{'display':'block', 'width': '300px'}" formControlName="key" id="field_options-key-{{idx}}" (focusout)="validateOptions(editFlowForm.controls.endpointsData.controls[1].controls.options.controls[idx])"></ng-select>
<input type="text" class="col-5 rounded-0 d-inline-block form-control" id="field_options-value-{{idx}}" formControlName="value" (focusout)="validateOptions(editFlowForm.controls.endpointsData.controls[1].controls.options.controls[idx])" data-toggle="tooltip" title="Value of the option. Click the Camel component button for documentation on valid options."/>
<button title="Add option" type="button" class="col-1 rounded-0 btn btn-primary" (click)="addOption(errorEndpointOptions, '1')"><span class="fa fa-plus"></span></button>
<button title="Remove option" type="button" class="col-1 left-border-radius-0 btn btn-danger" (click)="removeOption(errorEndpointOptions, errOption, '1')" [disabled]="errorEndpointOptions.length === 1"><span class="fa fa-remove"></span></button>
Expand Down Expand Up @@ -458,9 +458,13 @@ <h5>URI</h5>
</button>
<button type="button" *ngIf="flow.id" (click)="load(flow.id, true)" class="btn btn-info">
<span class="fa fa-clone"></span>&nbsp;
<span> Clone</span>
<span>Clone</span>
</button>
<button type="button" *ngIf="flow.id" [routerLink]="['/', { outlets: { popup: 'flow/'+ flow.id + '/delete'} }]" replaceUrl="true" queryParamsHandling="merge" class="btn btn-danger">
<button type="button" *ngIf="flow.id" (click)="export(flow)" class="btn btn-primary">
<span class="fa fa-download"></span>&nbsp;
<span>Export</span>
</button>
<button type="button" *ngIf="flow.id" [routerLink]="['/', { outlets: { popup: 'flow/' + flow.id + '/delete'} }]" replaceUrl="true" queryParamsHandling="merge" class="btn btn-danger">
<span class="fa fa-remove"></span>
<span class="d-none d-md-inline">Delete</span>
</button>
Expand Down
Loading

0 comments on commit 56bd7b6

Please sign in to comment.