Skip to content

Commit

Permalink
Broker validation and improve broker configuration editing
Browse files Browse the repository at this point in the history
  • Loading branch information
assimbly committed Jan 18, 2020
1 parent 9f87c78 commit e4b5bcc
Show file tree
Hide file tree
Showing 15 changed files with 1,736 additions and 187 deletions.
2 changes: 1 addition & 1 deletion .sts4-cache/classpath-data.json

Large diffs are not rendered by default.

82 changes: 21 additions & 61 deletions broker.xml
Original file line number Diff line number Diff line change
@@ -1,64 +1,24 @@
<?xml version='1.0'?>
<?xml version="1.0"?>
<!-- Example broker.xml -->

<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:activemq" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
<core xmlns="urn:activemq:core">

<persistence-enabled>true</persistence-enabled>

<cluster-user>test</cluster-user>
<cluster-password>test01</cluster-password>

<acceptors>
<acceptor name="in-vm">vm://0</acceptor>
<acceptor name="tcp">tcp://127.0.0.1:61617</acceptor>
</acceptors>

<security-settings>
<security-setting match="#">
<permission type="createAddress" roles="user"/>
<permission type="createDurableQueue" roles="user"/>
<permission type="deleteDurableQueue" roles="user"/>
<permission type="createNonDurableQueue" roles="user"/>
<permission type="deleteNonDurableQueue" roles="user"/>
<permission type="consume" roles="user"/>
<permission type="send" roles="user"/>
</security-setting>
</security-settings>

<address-settings>
<address-setting match="jms.#">
<redistribution-delay>0</redistribution-delay>
</address-setting>
</address-settings>

<addresses>
<address name="testInbox">
<anycast>
<queue name="testInbox"/>
</anycast>
</address>
<address name="CasInbox">
<anycast>
<queue name="CasInbox"/>
</anycast>
</address>
<address name="ForceCMInbox">
<anycast>
<queue name="ForceCMInbox"/>
</anycast>
</address>
<address name="IrisInbox">
<anycast>
<queue name="IrisInbox"/>
</anycast>
</address>
<address name="MessageProcessorInbox">
<anycast>
<queue name="MessageProcessorInbox"/>
</anycast>
</address>
</addresses>

</core>
<core xmlns="urn:activemq:core">
<persistence-enabled>false</persistence-enabled>
<cluster-user>myUsername2</cluster-user>
<cluster-password>myPassword2</cluster-password>
<acceptors>
<acceptor name="in-vm">vm://0</acceptor>
<acceptor name="tcp">tcp://127.0.0.1:61616</acceptor>
</acceptors>
<security-settings>
<security-setting match="#">
<permission type="createAddress" roles="user"/>
<permission type="createDurableQueue" roles="user"/>
<permission type="deleteDurableQueue" roles="user"/>
<permission type="createNonDurableQueue" roles="user"/>
<permission type="deleteNonDurableQueue" roles="user"/>
<permission type="consume" roles="user"/>
<permission type="send" roles="user"/>
</security-setting>
</security-settings>
</core>
</configuration>
Binary file modified data/bindings/activemq-bindings-1.bindings
Binary file not shown.
Binary file modified data/bindings/activemq-bindings-2.bindings
Binary file not shown.
Binary file modified data/journal/activemq-data-2.amq
Binary file not shown.
Empty file.
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,24 @@
"core-js": "2.5.7",
"file-saver": "^1.3.8",
"font-awesome": "4.7.0",
"i": "^0.3.6",
"jquery": "3.2.1",
"moment": "2.22.2",
"ng-jhipster": "0.5.6",
"ng2-ace-editor": "^0.3.9",
"ng2-ace-editor": "0.3.9",
"ngx-ace-wrapper": "^8.0.0",
"ngx-bootstrap": "3.1.3",
"ngx-cookie": "2.0.1",
"ngx-infinite-scroll": "6.0.1",
"ngx-webstorage": "2.0.1",
"npm": "^6.13.6",
"reflect-metadata": "0.1.12",
"rxjs": "6.3.3",
"sockjs-client": "1.4.0",
"swagger-ui": "2.2.10",
"tether": "1.4.0",
"tslib": "1.9.3",
"vkbeautify": "0.99.3",
"webstomp-client": "1.2.6",
"xml-js": "^1.6.7",
"yaml-js": "^0.2.3",
Expand Down Expand Up @@ -88,15 +92,15 @@
"tslint-config-prettier": "1.16.0",
"tslint-loader": "3.6.0",
"typescript": "3.1.6",
"url-loader": "2.2.0",
"webpack": "4.26.0",
"webpack-cli": "3.1.2",
"webpack-dev-server": "3.1.10",
"webpack-merge": "4.1.4",
"webpack-notifier": "1.7.0",
"webpack-visualizer-plugin": "0.1.11",
"workbox-webpack-plugin": "3.6.3",
"write-file-webpack-plugin": "4.5.0",
"url-loader": "2.2.0"
"write-file-webpack-plugin": "4.5.0"
},
"engines": {
"node": ">=8.9.0",
Expand Down
18 changes: 12 additions & 6 deletions src/main/java/org/assimbly/gateway/web/rest/BrokerResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public String statusBroker(@PathVariable Long id) {
@GetMapping("/brokers/{id}/getconfiguration")
@Timed
public String getConfigurationBroker(@PathVariable Long id) {
log.debug("REST request to get configuration of Broker : {}", id);
log.debug("REST request to get configuration of Broker : {}");
Optional<BrokerDTO> brokerDTO = brokerService.findOne(id);
String brokerType = brokerDTO.get().getType();

Expand All @@ -160,18 +160,24 @@ public String getConfigurationBroker(@PathVariable Long id) {
*/
@PostMapping(path = "/brokers/{id}/setconfiguration")
@Timed
public ResponseEntity<String> setConfigurationBroker(@ApiParam(hidden = true) @RequestHeader("Accept") String mediaType,@ApiParam(hidden = true) @RequestHeader("Content-Type") String contentType, @PathVariable Long id, @RequestBody String brokerConfiguration) throws Exception {
public ResponseEntity<String> setConfigurationBroker(@PathVariable Long id, @RequestBody(required = false) String brokerConfiguration) throws Exception {
log.debug("REST request to set configuration of Broker : {}", id);
Optional<BrokerDTO> brokerDTO = brokerService.findOne(id);
String brokerType = brokerDTO.get().getType();
String brokerConfigurationType = brokerDTO.get().getConfigurationType();

try {
System.out.println("new Config file="+brokerConfiguration);
String result = brokermanager.setConfiguration(brokerType,brokerConfigurationType, brokerConfiguration);
return org.assimbly.gateway.web.rest.util.ResponseUtil.createSuccessResponse(id, mediaType, "setConfigurationBroker", result);
String result = brokermanager.setConfiguration(brokerType,brokerConfigurationType, brokerConfiguration);
if(result.equals("configuration set")) {
System.out.println("result succes: " + result);
return org.assimbly.gateway.web.rest.util.ResponseUtil.createSuccessResponse(id, "text", "setConfiguration", result);
}else {
System.out.println("result failed: " + result);
return org.assimbly.gateway.web.rest.util.ResponseUtil.createFailureResponse(id, "text", "setConfiguration", result);
}
} catch (Exception e) {
return org.assimbly.gateway.web.rest.util.ResponseUtil.createFailureResponse(id, mediaType, "setConfigurationBroker", e.getMessage());
System.out.println("result failed 2: " + e.getMessage());
return org.assimbly.gateway.web.rest.util.ResponseUtil.createFailureResponse(id, "text", "setConfiguration", e.getMessage());
}

}
Expand Down
22 changes: 17 additions & 5 deletions src/main/webapp/app/entities/broker/broker-update.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ <h2 id="jhi-broker-heading">Create or edit a Broker</h2>
<ng-template #brokerConfigurationPopover let-message="message">
<div [innerHtml]="brokerConfigurationPopoverMessage"></div>
</ng-template>

<ng-template #brokerErrorConfigurationPopover let-message="message">
<div class="row">
<div class="col-12 alert alert-secondary" role="alert">
<div [innerHtml]="brokerConfigurationFailed"></div>
</div>
</div>
</ng-template>

<div class="form-group" [style.display]="'none'" [hidden]="!broker.id">
<label for="id">ID</label>
<input type="text" class="form-control" id="id" name="id"
Expand All @@ -56,7 +63,7 @@ <h2 id="jhi-broker-heading">Create or edit a Broker</h2>
<label class="form-control-label" for="field_type">Type</label>
<i class="fa fa-info-circle" triggers="mouseenter:mouseleave" placement="right"
popoverTitle="Info" [ngbPopover]="typePopover" #p="ngbPopover"></i>
<select type="text" class="form-control" id="field_type" name="type" [(ngModel)]="broker.type">
<select type="text" class="form-control" id="field_type" name="type" [(ngModel)]="broker.type" (ngModelChange)="onTypeChange($event)">
<option value="classic">ActiveMQ Classic</option>
<option value="artemis">ActiveMQ Artemis</option>
</select>
Expand All @@ -65,16 +72,21 @@ <h2 id="jhi-broker-heading">Create or edit a Broker</h2>
<label class="form-control-label" for="field_type">Configuration Type</label>
<i class="fa fa-info-circle" triggers="mouseenter:mouseleave" placement="right"
popoverTitle="Info" [ngbPopover]="configurationTypePopover" #p="ngbPopover"></i>
<select type="text" class="form-control" id="field_configuration_type" name="configurationType" id="field_configuration_type" [(ngModel)]="broker.configurationType">
<select type="text" class="form-control" id="field_configuration_type" name="configurationType" [(ngModel)]="broker.configurationType" >
<option value="embedded">Embedded</option>
<option value="file">File</option>
</select>
</div>
<div class="form-group" *ngIf="broker.configurationType == 'file' ">
<label class="form-control-label" for="field_type">Configuration</label>
<!-- <div *ngIf="brokerConfigurationFailed" class="alert alert-secondary" role="alert">{{brokerConfigurationFailed}}</div> -->
<i class="fa fa-info-circle" triggers="mouseenter:mouseleave" placement="right"
popoverTitle="Info" [ngbPopover]="brokerConfigurationPopover" #p="ngbPopover"></i>
<div ace-editor [(text)]="brokerConfiguration" [mode]="'XML'" [theme]="'xcode'" [options]="{maxLines: 'Infinity'}" style="min-height: 250px; width: 100%; overflow: auto; border: 1px solid #ced4da"></div>
popoverTitle="Info" [ngbPopover]="brokerConfigurationPopover" #p="ngbPopover"></i>
<span *ngIf="brokerConfigurationFailed" style="color: Tomato;">
<i class="fa fa-exclamation-circle" popoverClass="increase-popover-width" triggers="mouseenter:mouseleave" placement="right"
popoverTitle="Error" [ngbPopover]="brokerErrorConfigurationPopover" #p="ngbPopover"></i>
</span>
<ace-editor #editor [(text)]="brokerConfiguration" [mode]="'xml'" [theme]="'eclipse'" [options]="options" contenteditable="true" style="min-height: 250px; width: 100%; overflow: auto; border: 1px solid #ced4da"></ace-editor>
</div>

</div>
Expand Down
Loading

0 comments on commit e4b5bcc

Please sign in to comment.