Enable/disable kie logging #271

Allow to define a JMT token to give access to a project over reverse proxy #274
Hot deploy management #269 => UI for defiinition
This commit is contained in:
nheron 2021-07-24 22:11:11 +02:00
commit 488870e587
32 changed files with 664 additions and 167 deletions

View file

@ -0,0 +1,5 @@
package org.chtijbug.drools.common.rest;
public class Constants {
public final static String AUTHORISATION_HEADER = "Authorization";
}

View file

@ -32,7 +32,7 @@ import org.springframework.context.annotation.PropertySource;
@EnableAutoConfiguration
@PropertySource("classpath:application.properties")
public class Application {
public class SwimmingPoolApplication {
@Value(value = "${url.swimmingpool.calculate}")
private String url;
@ -42,7 +42,7 @@ public class Application {
private String password;
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
SpringApplication.run(SwimmingPoolApplication.class, args);
}
@Bean

View file

@ -27,6 +27,6 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
public class WebInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
return application.sources(SwimmingPoolApplication.class);
}
}

View file

@ -17,6 +17,7 @@ package org.chtijbug.swimmingpool.web.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.chtijbug.drools.common.rest.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@ -52,10 +53,10 @@ public class QuoteController {
Quote responseMoteur=null;
try {
String completeurl = urlCalcul+"/"+containerid;
String completeurl = urlCalcul+"/";
logger.info("url moteur reco : " + completeurl);
ResponseEntity<Quote> response = restTemplateKieServer
.execute(completeurl, HttpMethod.PUT, requestCallback(quoteRequest), clientHttpResponse -> {
.execute(completeurl, HttpMethod.PUT, requestCallback(quoteRequest,containerid), clientHttpResponse -> {
Quote extractedResponse = null;
if (clientHttpResponse.getBody() != null) {
Scanner s = new Scanner(clientHttpResponse.getBody()).useDelimiter("\\A");
@ -79,7 +80,7 @@ public class QuoteController {
}
return responseMoteur;
}
private RequestCallback requestCallback(final Quote updatedInstance) {
private RequestCallback requestCallback(final Quote updatedInstance,String token) {
return clientHttpRequest -> {
ObjectMapper mapper = new ObjectMapper();
mapper.writeValue(clientHttpRequest.getBody(), updatedInstance);
@ -89,6 +90,8 @@ public class QuoteController {
"transactionId", updatedInstance.getSessionLogging());
}
clientHttpRequest.getHeaders().add(
Constants.AUTHORISATION_HEADER, token);
clientHttpRequest.getHeaders().add(
HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
clientHttpRequest.getHeaders().add(

View file

@ -1,7 +1,8 @@
# See http://docs.spring.io/spring-boot/docs/1.1.4.RELEASE/reference/htmlsingle/#boot-features-external-config-profile-specific-properties
# for more details about creating profile-specific property files
# See http://docs.spring.io/spring-boot/docs/1.1.4.RELEASE/reference/htmlsingle/#howto-initialize-a-database-using-jpa
url.swimmingpool.calculate=http://localhost:9500/
url.swimmingpool.calculate=http://localhost:9500
#url.swimmingpool.calculate=https://proxy.kie.infra.pymma-software.net
url.swimmingpool.calculate.username=kieserver
url.swimmingpool.calculate.password=kieserver1!
server.port=12099

View file

@ -36,7 +36,7 @@
<tr>
<td><label for="containerid" class="control-label">Container id :</label></td>
<td><input id="containerid" type="text" ng-model="containerid" ng-maxlength="30"/></td>
<td><input id="containerid" type="text" ng-model="containerid" ng-maxlength="20000"/></td>
<td><label for="aClassName" class="control-label">Class name :</label></td>
<td><input id="aClassName" type="text" ng-model="aClassName" ng-maxlength="50"/></td>

View file

@ -66,7 +66,7 @@ productManagerModule.controller('quoteManagerController', function ($scope, $htt
$scope.productSearch = "";
$http.defaults.headers.post["Content-Type"] = "application/json";
$scope.allSessionExecutionDetails = [];
$scope.containerid = "dev";
$scope.containerid = "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI2MDk5OWEyZGQ3YWUyODNmY2MyNWFhNzciLCJpYXQiOjE2MjY4NzkxMjUsInN1YiI6ImFwaSIsImlzcyI6InB5bW1hIiwiZ3JvdXBJRCI6ImNvbS5weW1tYXNvZnR3YXJlLmpicG0udHJhaW5pbmciLCJhcnRpZmFjdElEIjoic3dpbW1pbmdwb29sLXR1dG9yaWFsIiwicHJvamVjdFZlcnNpb24iOiIyLjAuMC1TTkFQU0hPVCIsImJyYW5jaCI6Im1hc3RlciIsIm1haW5DbGFzcyI6Im9yZy50cmFpbmluZy5sZWlzdXJlLnN3aW1taW5ncG9vbC5RdW90ZSIsImV4cCI6MTY1ODQxNTEyNX0.sKYOY98Hsk4JcS546f7xmj1tPNxdrqRtw5y6w0qdu88";
$scope.aClassName = "org.training.leisure.swimmingpool.Quote";
var _lastGoodResult = '';
$scope.toPrettyJSON = function (objStr, tabWidth) {

View file

@ -17,6 +17,7 @@ package org.chtijbug.kieserver.services.drools;
import org.chtijbug.drools.ChtijbugObjectRequest;
import org.chtijbug.drools.SessionContext;
import org.chtijbug.drools.entity.history.HistoryEvent;
import org.chtijbug.drools.kieserver.extension.KieServerAddOnElement;
import org.chtijbug.drools.kieserver.extension.KieServerGlobalVariableDefinition;
import org.chtijbug.drools.kieserver.extension.KieServerListenerDefinition;
@ -32,9 +33,7 @@ import org.kie.server.services.api.KieServerRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
/**
* Direct rules execution service that allow use of typed objects instead of string only
@ -130,7 +129,10 @@ public class DroolsChtijbugRulesExecutionService {
RuleBasePackage ruleBasePackage = this.ruleBasePackages.get(kci.getResource().getContainerId());
if (ruleBasePackage != null) {
Date startTime = new Date();
ChtijbugHistoryListener chtijbugHistoryListener = new ChtijbugHistoryListener();
ChtijbugHistoryListener chtijbugHistoryListener=null;
if (!chtijbugObjectRequest.isDisableLogging()) {
chtijbugHistoryListener = new ChtijbugHistoryListener();
}
RuleBaseSession session = ruleBasePackage.createRuleBaseSession(sessionMaxNumberRulesToExecute, chtijbugHistoryListener, sessionName);
if (kieServerAddOnElement != null) {
@ -145,7 +147,11 @@ public class DroolsChtijbugRulesExecutionService {
result = session.fireAllRulesAndStartProcess(chtijbugObjectRequest.getObjectRequest(), processID);
session.dispose();
Date stopTime = new Date();
SessionContext sessionContext = this.messageHandlerResolver.getSessionFromHistoryEvent(chtijbugHistoryListener.getHistoryEventLinkedList());
List<HistoryEvent> events=new ArrayList<>();
if (chtijbugHistoryListener!= null){
events = chtijbugHistoryListener.getHistoryEventLinkedList();
}
SessionContext sessionContext = this.messageHandlerResolver.getSessionFromHistoryEvent(events);
sessionContext.setGroupID(kci.getResource().getReleaseId().getGroupId());
sessionContext.setArtefactID(kci.getResource().getReleaseId().getArtifactId());
sessionContext.setVersion(kci.getResource().getReleaseId().getVersion());

View file

@ -23,6 +23,8 @@ public class ChtijbugObjectRequest {
private SessionContext sessionLogging;
private boolean disableLogging;
public String getTransactionID() {
return transactionID;
}
@ -102,4 +104,12 @@ public class ChtijbugObjectRequest {
public void setVersion(String version) {
this.version = version;
}
public boolean isDisableLogging() {
return disableLogging;
}
public void setDisableLogging(boolean disableLogging) {
this.disableLogging = disableLogging;
}
}

View file

@ -6,6 +6,10 @@ import java.util.List;
public class ReverseProxyUpdate {
private String path;
private String tokenUUID;
private String containerID;
List<String> serverNames = new ArrayList<>();
public String getPath() {
@ -16,6 +20,14 @@ public class ReverseProxyUpdate {
this.path = path;
}
public String getTokenUUID() {
return tokenUUID;
}
public void setTokenUUID(String tokenUUID) {
this.tokenUUID = tokenUUID;
}
public List<String> getServerNames() {
return serverNames;
}
@ -23,4 +35,12 @@ public class ReverseProxyUpdate {
public void setServerNames(List<String> serverNames) {
this.serverNames = serverNames;
}
public void setContainerID(String containerID) {
this.containerID = containerID;
}
public String getContainerID() {
return containerID;
}
}