From 33fb2077cc26db4993b13e007e8dab7d037ac6b4 Mon Sep 17 00:00:00 2001 From: assimbly Date: Tue, 1 Jan 2019 19:56:13 +0100 Subject: [PATCH] Migration jhipster 4.13.3 --> 5.7.2 --- build.gradle | 3 +- package.json | 2 +- .../gateway/config/SecurityConfiguration.java | 3 + .../environment/DBExportXMLConfiguration.java | 1 + .../org/assimbly/gateway/domain/Header.java | 1 - .../gateway/event/FailureListener.java | 4 +- src/main/resources/config/application.yml | 12 ++-- src/main/webapp/app/core/core.module.ts | 2 + .../app/entities/flow/flow-row.component.html | 12 ++-- .../app/entities/flow/flow-row.component.ts | 66 +++++++++++++++++-- .../app/entities/flow/flow.component.ts | 1 + .../webapp/app/entities/flow/flow.service.ts | 19 ++++-- .../header/header-update.component.ts | 20 +++--- .../to-endpoint-update.component.ts | 6 +- src/main/webapp/app/shared/shared.module.ts | 3 +- 15 files changed, 113 insertions(+), 42 deletions(-) diff --git a/build.gradle b/build.gradle index 31a74610..03e60097 100644 --- a/build.gradle +++ b/build.gradle @@ -54,7 +54,7 @@ dependencyManagement { defaultTasks 'bootRun' group = 'org.assimbly.gateway' -version = '1.2.0' +version = '1.3.0' description = '' @@ -243,6 +243,7 @@ dependencies { compile "org.jdom:jdom2:2.0.6" compile "org.springframework:spring-websocket:5.0.7.RELEASE" compile "org.springframework.security:spring-security-messaging:5.0.7.RELEASE" + // compile "io.hawt:hawtio-springboot:2.4.0" // end custom dependencies diff --git a/package.json b/package.json index fb0891b5..49ff500d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gateway", - "version": "1.2.0", + "version": "1.3.0", "description": "A message gateway based on Apache camel", "private": true, "license": "Apache License 2.0", diff --git a/src/main/java/org/assimbly/gateway/config/SecurityConfiguration.java b/src/main/java/org/assimbly/gateway/config/SecurityConfiguration.java index e65391ba..c6dce554 100644 --- a/src/main/java/org/assimbly/gateway/config/SecurityConfiguration.java +++ b/src/main/java/org/assimbly/gateway/config/SecurityConfiguration.java @@ -105,6 +105,7 @@ public void configure(WebSecurity web) throws Exception { .antMatchers("/test/**") .antMatchers("/h2-console/**") .antMatchers("/management/jolokia/**") + .antMatchers("/management/hawtio/**") .antMatchers("/jolokia/**") .antMatchers("/test/**"); } @@ -151,6 +152,8 @@ public void configure(HttpSecurity http) throws Exception { .antMatchers("/api/**").authenticated() .antMatchers("/management/jolokia").permitAll() .antMatchers("/management/jolokia/**").permitAll() + .antMatchers("/management/hawtio").permitAll() + .antMatchers("/management/hawtio/**").permitAll() .antMatchers("/management/health").permitAll() .antMatchers("/management/info").permitAll() .antMatchers("/management/**").hasAuthority(AuthoritiesConstants.ADMIN); diff --git a/src/main/java/org/assimbly/gateway/config/environment/DBExportXMLConfiguration.java b/src/main/java/org/assimbly/gateway/config/environment/DBExportXMLConfiguration.java index 8b42cde0..135ba9bc 100644 --- a/src/main/java/org/assimbly/gateway/config/environment/DBExportXMLConfiguration.java +++ b/src/main/java/org/assimbly/gateway/config/environment/DBExportXMLConfiguration.java @@ -629,6 +629,7 @@ public void setXMLHeaderFromDB(String headerid, String type, Header headerDB) th Set headerKeys = headerDB.getHeaderKeys(); for (HeaderKeys headerKey : headerKeys) { + String parameterName = headerKey.getKey(); String parameterValue = headerKey.getValue(); String parameterType = headerKey.getType(); diff --git a/src/main/java/org/assimbly/gateway/domain/Header.java b/src/main/java/org/assimbly/gateway/domain/Header.java index 9f92365d..52ac1491 100644 --- a/src/main/java/org/assimbly/gateway/domain/Header.java +++ b/src/main/java/org/assimbly/gateway/domain/Header.java @@ -30,7 +30,6 @@ public class Header implements Serializable { @OneToMany(fetch = FetchType.EAGER, mappedBy = "header", cascade = {CascadeType.REMOVE, CascadeType.MERGE, CascadeType.REFRESH}) @JsonIgnore - @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) private Set headerKeys = new HashSet<>(); // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove public Long getId() { diff --git a/src/main/java/org/assimbly/gateway/event/FailureListener.java b/src/main/java/org/assimbly/gateway/event/FailureListener.java index cd5073d7..17cef0d5 100644 --- a/src/main/java/org/assimbly/gateway/event/FailureListener.java +++ b/src/main/java/org/assimbly/gateway/event/FailureListener.java @@ -31,7 +31,7 @@ public void notify(EventObject eventObject) throws Exception { String flowId = exchangeFailedEvent.getExchange().getFromRouteId(); if(this.messagingTemplate!=null) { - this.messagingTemplate.convertAndSend("/topic/alert", flowId); + this.messagingTemplate.convertAndSend("/topic/" + flowId + "/alert", flowId); }else { log.warn("Can't send alert to websocket. messagingTemplate=null"); } @@ -42,7 +42,7 @@ public void notify(EventObject eventObject) throws Exception { String flowId = exchangeFailedEvent.getExchange().getFromRouteId(); if(this.messagingTemplate!=null) { - this.messagingTemplate.convertAndSend("/topic/alert", flowId); + this.messagingTemplate.convertAndSend("/topic/" + flowId + "/alert", flowId); }else { log.warn("Can't send alert to websocket. messagingTemplate=null"); } diff --git a/src/main/resources/config/application.yml b/src/main/resources/config/application.yml index 4371e9d2..5006ed68 100644 --- a/src/main/resources/config/application.yml +++ b/src/main/resources/config/application.yml @@ -19,7 +19,7 @@ management: web: base-path: /management exposure: - include: ["configprops", "env", "health", "info", "threaddump", "logfile" ] + include: ["configprops", "env", "health", "info", "threaddump", "logfile", "hawtio", "jolokia"] endpoint: health: show-details: when-authorized @@ -31,7 +31,7 @@ management: enabled: false # When using the MailService, configure an SMTP server and set this to true metrics: enabled: false # http://micrometer.io/ is disabled by default, as we use http://metrics.dropwizard.io/ instead - + spring: application: name: gateway @@ -117,9 +117,7 @@ jhipster: application: documentation: url: https://github.com/assimbly/gateway/wiki - camel-url: https://github.com/apache/camel/blob/master + camel-url: https://github.com/apache/camel/blob/master -endpoints: - jolokia: - enabled: true - sensitive: false +hawtio: + authenticationEnabled: false diff --git a/src/main/webapp/app/core/core.module.ts b/src/main/webapp/app/core/core.module.ts index 92807732..2bd122ce 100644 --- a/src/main/webapp/app/core/core.module.ts +++ b/src/main/webapp/app/core/core.module.ts @@ -3,12 +3,14 @@ import { DatePipe, registerLocaleData } from '@angular/common'; import { HttpClientModule } from '@angular/common/http'; import { Title } from '@angular/platform-browser'; import locale from '@angular/common/locales/en'; +import { CSRFService } from "app/core"; @NgModule({ imports: [HttpClientModule], exports: [], declarations: [], providers: [ + CSRFService, Title, { provide: LOCALE_ID, diff --git a/src/main/webapp/app/entities/flow/flow-row.component.html b/src/main/webapp/app/entities/flow/flow-row.component.html index 3e361e41..2c240e29 100644 --- a/src/main/webapp/app/entities/flow/flow-row.component.html +++ b/src/main/webapp/app/entities/flow/flow-row.component.html @@ -47,24 +47,24 @@

- Active + [ngbPopover]="statusFlowButtonTemplate" [autoClose]="'outside'">Active Paused + [ngbPopover]="statusFlowButtonTemplate" [autoClose]="'outside'">Paused Inactive + [ngbPopover]="statusFlowButtonTemplate" [autoClose]="'outside'">Inactive Inactive + [ngbPopover]="statusFlowButtonTemplate" [autoClose]="'outside'">Inactive

@@ -74,7 +74,7 @@

class="badge badge-warning" *ngIf="flowAlerts === 'true'" (mouseenter)="p!=p" placement="right" on-mouseover='getFlowAlerts(flow.id)' triggers="mouseenter" popoverTitle="Show last alerts" - [popover]="alertsFlowButtonTemplate">{{numberOfAlerts}} Alerts + [ngbPopover]="alertsFlowButtonTemplate" [autoClose]="'outside'">{{numberOfAlerts}} Alerts

diff --git a/src/main/webapp/app/entities/flow/flow-row.component.ts b/src/main/webapp/app/entities/flow/flow-row.component.ts index d5b0c92d..6e41d20a 100644 --- a/src/main/webapp/app/entities/flow/flow-row.component.ts +++ b/src/main/webapp/app/entities/flow/flow-row.component.ts @@ -12,6 +12,7 @@ import { JhiEventManager } from 'ng-jhipster'; import { Router } from '@angular/router'; import * as moment from 'moment'; import { map } from "rxjs/operators"; +import { Observable, Observer, Subscription} from "rxjs"; enum Status { active = 'active', @@ -68,6 +69,18 @@ export class FlowRowComponent implements OnInit, OnDestroy { intervalTime: any; + stompClient = null; + subscriber = null; + connection: Promise; + connectedPromise: any; + listener: Observable; + listenerObserver: Observer; + + alreadyConnectedOnce = false; + private subscription: Subscription; + + + constructor( private flowService: FlowService, private fromEndpointService: FromEndpointService, @@ -76,6 +89,7 @@ export class FlowRowComponent implements OnInit, OnDestroy { private router: Router, private eventManager: JhiEventManager ) { + this.listener = this.createListener(); } ngOnInit() { @@ -87,12 +101,19 @@ export class FlowRowComponent implements OnInit, OnDestroy { this.getFlowStatus(this.flow.id); this.getFlowNumberOfAlerts(this.flow.id); this.registerTriggeredAction(); - this.flowService.subscribe(); - this.flowService.receive().subscribe(data => { + this.connection = this.flowService.connectionStomp(); + this.stompClient = this.flowService.client(); + this.subscribe(); + this.receive().subscribe(data => { + console.log('data'); + console.log(data); + console.log(this.flow.id); if (this.flow.id === data) { this.getFlowNumberOfAlerts(data); } + }); + } ngOnDestroy() { @@ -182,7 +203,7 @@ export class FlowRowComponent implements OnInit, OnDestroy { getFlowAlerts(id: number) { this.clickButton = true; this.flowService.getFlowAlerts(id).subscribe((response) => { - this.setFlowAlerts(response); + this.setFlowAlerts(response.body); }); } @@ -218,8 +239,8 @@ export class FlowRowComponent implements OnInit, OnDestroy { getFlowNumberOfAlerts(id: number) { this.clickButton = true; - this.flowService.getFlowNumberOfAlerts(id).subscribe((response) => { - this.setFlowNumberOfAlerts(response); + this.flowService.getFlowNumberOfAlerts(id).subscribe(response => { + this.setFlowNumberOfAlerts(response.body); }); } @@ -256,7 +277,7 @@ export class FlowRowComponent implements OnInit, OnDestroy { this.statusFlow = Status.inactiveError; } else { this.flowService.getFlowLastError(id).subscribe((response) => { - this.lastError = response === '0' ? '' : response; + this.lastError = response === '0' ? '' : response.body; this.flowStatusButton = ` Last action: ${action}
Status: Stopped after error

@@ -508,4 +529,37 @@ export class FlowRowComponent implements OnInit, OnDestroy { this.disableActionBtns = false; }); } + + receive() { + return this.listener; + } + + subscribe() { + const topic = '/topic/' + this.flow.id + '/alert'; + + this.connection.then(() => { + this.subscriber = this.stompClient.subscribe(topic, data => { + if(!this.listenerObserver){ + this.listener = this.createListener(); + } + this.listenerObserver.next(JSON.parse(data.body)); + }); + }); + } + + unsubscribe() { + if (this.subscriber !== null) { + this.subscriber.unsubscribe(); + } + this.listener = this.createListener(); + } + + private createListener(): Observable { + return new Observable(observer => { + this.listenerObserver = observer; + }); + } + + + } diff --git a/src/main/webapp/app/entities/flow/flow.component.ts b/src/main/webapp/app/entities/flow/flow.component.ts index 99e080d6..62ab01ff 100644 --- a/src/main/webapp/app/entities/flow/flow.component.ts +++ b/src/main/webapp/app/entities/flow/flow.component.ts @@ -97,6 +97,7 @@ export class FlowComponent implements OnInit, OnDestroy { this.getFromEndpoints(); this.accountService.identity().then(account => { this.currentAccount = account; + this.flowService.connect(); }); this.accountService.hasAuthority('ROLE_ADMIN').then((r) => this.isAdmin = r); this.registerChangeInFlows(); diff --git a/src/main/webapp/app/entities/flow/flow.service.ts b/src/main/webapp/app/entities/flow/flow.service.ts index ba2e70ac..28b47777 100644 --- a/src/main/webapp/app/entities/flow/flow.service.ts +++ b/src/main/webapp/app/entities/flow/flow.service.ts @@ -14,6 +14,7 @@ import { IFlow, Flow } from 'app/shared/model/flow.model'; import * as SockJS from 'sockjs-client'; import * as Stomp from 'webstomp-client'; import { tap } from "rxjs/operators"; +import { CSRFService } from "app/core"; type EntityResponseType = HttpResponse; type EntityArrayResponseType = HttpResponse; @@ -38,6 +39,7 @@ export class FlowService { constructor(protected http: HttpClient, protected router: Router, protected $window: WindowRef, + protected csrfService: CSRFService ) { this.connection = this.createConnection(); this.listener = this.createListener(); @@ -167,7 +169,6 @@ export class FlowService { } connect() { - if (this.connectedPromise === null) { this.connection = this.createConnection(); } @@ -188,7 +189,7 @@ export class FlowService { this.stompClient = Stomp.over(socket); const headers = {}; - // headers['X-XSRF-TOKEN'] = this.csrfService.getCSRF('XSRF-TOKEN'); + headers['X-XSRF-TOKEN'] = this.csrfService.getCSRF('XSRF-TOKEN'); this.stompClient.connect(headers, () => { @@ -214,9 +215,19 @@ export class FlowService { return this.listener; } - subscribe() { + connectionStomp(){ + return this.connection; + } + + client(){ + return this.stompClient; + } + + subscribe(id) { + const topic = '/topic/' + id + '/alert'; + this.connection.then(() => { - this.subscriber = this.stompClient.subscribe('/topic/alert', data => { + this.subscriber = this.stompClient.subscribe(topic, data => { this.listenerObserver.next(JSON.parse(data.body)); }); }); diff --git a/src/main/webapp/app/entities/header/header-update.component.ts b/src/main/webapp/app/entities/header/header-update.component.ts index 06cd57e0..b16e16af 100644 --- a/src/main/webapp/app/entities/header/header-update.component.ts +++ b/src/main/webapp/app/entities/header/header-update.component.ts @@ -36,13 +36,12 @@ export class HeaderUpdateComponent implements OnInit { this.isSaving = false; this.activatedRoute.data.subscribe(({ header }) => { this.header = header; + if(this.activatedRoute.fragment['value'] === 'clone'){ + this.loadHeaderKeys(true); + }else{ + this.loadHeaderKeys(false); + } }); - if(this.activatedRoute.fragment['value'] === 'clone'){ - this.loadHeaderKeys(true); - }else{ - this.loadHeaderKeys(false); - } - } clear() { @@ -130,9 +129,14 @@ export class HeaderUpdateComponent implements OnInit { } private loadHeaderKeys(cloneHeader: boolean) { + let criteria = { + 'headerId.equals' : this.header.id + }; + + if (this.header.id) { - this.headerKeysService.query().subscribe((res) => { - this.headerKeys = res.body; + this.headerKeysService.query({filter: 'headerid.equals=1'}).subscribe((res) => { + this.headerKeys = res.body.filter(headerkeys => headerkeys.headerId === this.header.id); }); this.header.id = cloneHeader ? null : this.header.id; }else { diff --git a/src/main/webapp/app/entities/to-endpoint/to-endpoint-update.component.ts b/src/main/webapp/app/entities/to-endpoint/to-endpoint-update.component.ts index 3f8ef835..1f844e0c 100644 --- a/src/main/webapp/app/entities/to-endpoint/to-endpoint-update.component.ts +++ b/src/main/webapp/app/entities/to-endpoint/to-endpoint-update.component.ts @@ -88,7 +88,7 @@ export class ToEndpointUpdateComponent implements OnInit { if (this.toEndpoint.id !== undefined) { this.subscribeToSaveResponse(this.toEndpointService.update(this.toEndpoint)); } else { - this.subscribeToSaveResponseOld(this.toEndpointService.create(this.toEndpoint)); + this.subscribeToSaveResponse(this.toEndpointService.create(this.toEndpoint)); } } @@ -96,10 +96,6 @@ export class ToEndpointUpdateComponent implements OnInit { result.subscribe((res: HttpResponse) => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError()); } - protected subscribeToSaveResponseOld(result: Observable) { - result.subscribe((res) => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError()); - } - protected onSaveSuccess() { this.isSaving = false; this.previousState(); diff --git a/src/main/webapp/app/shared/shared.module.ts b/src/main/webapp/app/shared/shared.module.ts index e80ce087..4dc4aa3b 100644 --- a/src/main/webapp/app/shared/shared.module.ts +++ b/src/main/webapp/app/shared/shared.module.ts @@ -4,11 +4,12 @@ import { NgbDateAdapter } from '@ng-bootstrap/ng-bootstrap'; import { NgbDateMomentAdapter } from './util/datepicker-adapter'; import { GatewaySharedLibsModule, GatewaySharedCommonModule, JhiLoginModalComponent, HasAnyAuthorityDirective } from './'; import { WindowRef } from "app/shared/auth/window.service"; +import { CSRFService } from "app/core"; @NgModule({ imports: [GatewaySharedLibsModule, GatewaySharedCommonModule], declarations: [JhiLoginModalComponent, HasAnyAuthorityDirective], - providers: [WindowRef,{ provide: NgbDateAdapter, useClass: NgbDateMomentAdapter }], + providers: [WindowRef, CSRFService,{ provide: NgbDateAdapter, useClass: NgbDateMomentAdapter }], entryComponents: [JhiLoginModalComponent], exports: [GatewaySharedCommonModule, JhiLoginModalComponent, HasAnyAuthorityDirective], schemas: [CUSTOM_ELEMENTS_SCHEMA]