Skip to content

Commit

Permalink
Migration jhipster 4.13.3 --> 5.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
assimbly committed Jan 1, 2019
1 parent 47f722d commit 33fb207
Show file tree
Hide file tree
Showing 15 changed files with 113 additions and 42 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Expand Up @@ -54,7 +54,7 @@ dependencyManagement {
defaultTasks 'bootRun'

group = 'org.assimbly.gateway'
version = '1.2.0'
version = '1.3.0'

description = ''

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion 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",
Expand Down
Expand Up @@ -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/**");
}
Expand Down Expand Up @@ -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);
Expand Down
Expand Up @@ -629,6 +629,7 @@ public void setXMLHeaderFromDB(String headerid, String type, Header headerDB) th
Set<HeaderKeys> headerKeys = headerDB.getHeaderKeys();

for (HeaderKeys headerKey : headerKeys) {

String parameterName = headerKey.getKey();
String parameterValue = headerKey.getValue();
String parameterType = headerKey.getType();
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/assimbly/gateway/domain/Header.java
Expand Up @@ -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> headerKeys = new HashSet<>();
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/assimbly/gateway/event/FailureListener.java
Expand Up @@ -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");
}
Expand All @@ -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");
}
Expand Down
12 changes: 5 additions & 7 deletions src/main/resources/config/application.yml
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions src/main/webapp/app/core/core.module.ts
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions src/main/webapp/app/entities/flow/flow-row.component.html
Expand Up @@ -47,24 +47,24 @@
</ng-template>
<p>
<h4 class="float-left">
<span class="badge badge-success" *ngIf="statusFlow === 'active'"
<span class="badge badge-success" *ngIf="statusFlow === 'active'"
(mouseenter)="p!=p" triggers="mouseenter"
placement="right" popoverTitle="Status"
[popover]="statusFlowButtonTemplate">Active</span>
[ngbPopover]="statusFlowButtonTemplate" [autoClose]="'outside'">Active</span>
<span
class="badge badge-warning" *ngIf="statusFlow === 'paused'"
(mouseenter)="p!=p" placement="right"
triggers="mouseenter" popoverTitle="Status"
[popover]="statusFlowButtonTemplate">Paused</span>
[ngbPopover]="statusFlowButtonTemplate" [autoClose]="'outside'">Paused</span>
<span
class="badge badge-primary" *ngIf="statusFlow === 'inactive'"
(mouseenter)="p!=p" placement="right" popoverTitle="Status" triggers="mouseenter"
[popover]="statusFlowButtonTemplate">Inactive</span>
[ngbPopover]="statusFlowButtonTemplate" [autoClose]="'outside'">Inactive</span>
<span
class="badge badge-danger" *ngIf="statusFlow === 'inactiveError'"
(mouseenter)="p!=p" placement="right"
triggers="mouseenter" popoverTitle="Status"
[popover]="statusFlowButtonTemplate">Inactive</span>
[ngbPopover]="statusFlowButtonTemplate" [autoClose]="'outside'">Inactive</span>
</h4>
<ng-template #alertsFlowButtonTemplate let-message="message">
<div [innerHtml]="flowAlertsButton"></div>
Expand All @@ -74,7 +74,7 @@ <h4 class="float-left" style="margin-left: 10px;">
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</span>
[ngbPopover]="alertsFlowButtonTemplate" [autoClose]="'outside'">{{numberOfAlerts}} Alerts</span>
</h4>
</p>
</div>
Expand Down
66 changes: 60 additions & 6 deletions src/main/webapp/app/entities/flow/flow-row.component.ts
Expand Up @@ -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',
Expand Down Expand Up @@ -68,6 +69,18 @@ export class FlowRowComponent implements OnInit, OnDestroy {

intervalTime: any;

stompClient = null;
subscriber = null;
connection: Promise<any>;
connectedPromise: any;
listener: Observable<any>;
listenerObserver: Observer<any>;

alreadyConnectedOnce = false;
private subscription: Subscription;



constructor(
private flowService: FlowService,
private fromEndpointService: FromEndpointService,
Expand All @@ -76,6 +89,7 @@ export class FlowRowComponent implements OnInit, OnDestroy {
private router: Router,
private eventManager: JhiEventManager
) {
this.listener = this.createListener();
}

ngOnInit() {
Expand All @@ -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() {
Expand Down Expand Up @@ -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);
});
}

Expand Down Expand Up @@ -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);
});
}

Expand Down Expand Up @@ -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} <br/>
Status: Stopped after error <br/><br/>
Expand Down Expand Up @@ -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<any> {
return new Observable(observer => {
this.listenerObserver = observer;
});
}



}
1 change: 1 addition & 0 deletions src/main/webapp/app/entities/flow/flow.component.ts
Expand Up @@ -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();
Expand Down
19 changes: 15 additions & 4 deletions src/main/webapp/app/entities/flow/flow.service.ts
Expand Up @@ -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<IFlow>;
type EntityArrayResponseType = HttpResponse<IFlow[]>;
Expand All @@ -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();
Expand Down Expand Up @@ -167,7 +169,6 @@ export class FlowService {
}

connect() {

if (this.connectedPromise === null) {
this.connection = this.createConnection();
}
Expand All @@ -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, () => {

Expand All @@ -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));
});
});
Expand Down
20 changes: 12 additions & 8 deletions src/main/webapp/app/entities/header/header-update.component.ts
Expand Up @@ -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() {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 33fb207

Please sign in to comment.