Le Business Proxy doit prendre sa configuration dans mongodb et ne plus exposer un rest d'administration
This commit is contained in:
parent
0025a7cec0
commit
824c4336b7
23 changed files with 250 additions and 458 deletions
|
|
@ -205,7 +205,7 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.pymmasoftware.jbpm</groupId>
|
<groupId>com.pymmasoftware.jbpm</groupId>
|
||||||
<artifactId>drools-framewwork-business-proxy-persistence</artifactId>
|
<artifactId>drools-framework-business-proxy-persistence</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
|
||||||
|
|
@ -2,20 +2,13 @@ package org.chtijbug.drools.console;
|
||||||
|
|
||||||
|
|
||||||
import org.chtijbug.drools.console.service.util.ApplicationContextProvider;
|
import org.chtijbug.drools.console.service.util.ApplicationContextProvider;
|
||||||
import org.elasticsearch.client.Client;
|
|
||||||
import org.elasticsearch.client.transport.TransportClient;
|
|
||||||
import org.elasticsearch.common.settings.Settings;
|
|
||||||
import org.elasticsearch.transport.client.PreBuiltTransportClient;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||||
import org.springframework.context.annotation.*;
|
import org.springframework.context.annotation.*;
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
|
|
||||||
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
||||||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ import org.drools.workbench.models.guided.template.backend.RuleTemplateModelXMLP
|
||||||
import org.drools.workbench.models.guided.template.shared.TemplateModel;
|
import org.drools.workbench.models.guided.template.shared.TemplateModel;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.core.ParameterizedTypeReference;
|
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.*;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.client.RequestCallback;
|
import org.springframework.web.client.RequestCallback;
|
||||||
|
|
|
||||||
|
|
@ -1,213 +0,0 @@
|
||||||
package org.chtijbug.drools.console.service;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.vaadin.flow.component.UI;
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
|
||||||
import org.chtijbug.drools.console.AddLog;
|
|
||||||
import org.chtijbug.drools.console.service.model.kie.KieContainerInfo;
|
|
||||||
import org.chtijbug.drools.console.service.model.kie.KieServerJobStatus;
|
|
||||||
import org.chtijbug.drools.console.service.model.kie.SpaceProject;
|
|
||||||
import org.chtijbug.drools.proxy.persistence.model.ProjectPersist;
|
|
||||||
import org.kie.server.api.model.KieContainerResource;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.HttpMethod;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.web.client.RequestCallback;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Scanner;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class KieServerRepositoryService {
|
|
||||||
|
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(KieServerRepositoryService.class);
|
|
||||||
|
|
||||||
|
|
||||||
private RestTemplate restTemplateKiewb = new RestTemplate();
|
|
||||||
|
|
||||||
private ObjectMapper mapper = new ObjectMapper();
|
|
||||||
|
|
||||||
///spaces/{spaceName}/projects/{projectName}
|
|
||||||
|
|
||||||
public void getProjectContent(String url, String username, String password, String space, String project) {
|
|
||||||
String completeurl = url + "/spaces/" + space + "/projects/" + project;
|
|
||||||
logger.info("url project content : " + completeurl);
|
|
||||||
ResponseEntity<SpaceProject> response = restTemplateKiewb
|
|
||||||
.execute(completeurl, HttpMethod.GET, requestCallback(null, username, password), clientHttpResponse -> {
|
|
||||||
SpaceProject extractedResponse = null;
|
|
||||||
if (clientHttpResponse.getBody() != null) {
|
|
||||||
Scanner s = new Scanner(clientHttpResponse.getBody()).useDelimiter("\\A");
|
|
||||||
String result = s.hasNext() ? s.next() : "";
|
|
||||||
|
|
||||||
SpaceProject values = mapper.readValue(result, SpaceProject.class);
|
|
||||||
extractedResponse = values;
|
|
||||||
}
|
|
||||||
ResponseEntity<SpaceProject> extractedValue = new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
|
||||||
return extractedValue;
|
|
||||||
});
|
|
||||||
SpaceProject reponseMoteur;
|
|
||||||
|
|
||||||
reponseMoteur = response.getBody();
|
|
||||||
System.out.println(reponseMoteur);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<KieContainerInfo> getContainerList(String url, String username, String password) {
|
|
||||||
List<KieContainerInfo> results = new ArrayList<>();
|
|
||||||
String completeurl = url ;
|
|
||||||
logger.info("url kie server container : " + completeurl);
|
|
||||||
ResponseEntity<Map<String, Object>> response = restTemplateKiewb
|
|
||||||
.execute(completeurl, HttpMethod.GET, requestCallback(null, username, password), clientHttpResponse -> {
|
|
||||||
Map<String, Object> extractedResponse = null;
|
|
||||||
if (clientHttpResponse.getBody() != null) {
|
|
||||||
Scanner s = new Scanner(clientHttpResponse.getBody()).useDelimiter("\\A");
|
|
||||||
String result = s.hasNext() ? s.next() : "";
|
|
||||||
Map<String, Object> map = mapper.readValue(
|
|
||||||
result,
|
|
||||||
new TypeReference<Map<String, Object>>() {
|
|
||||||
});
|
|
||||||
Map<String, Object> values = mapper.readValue(result, Map.class);
|
|
||||||
extractedResponse = values;
|
|
||||||
}
|
|
||||||
ResponseEntity<Map<String, Object>> extractedValue = new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
|
||||||
return extractedValue;
|
|
||||||
});
|
|
||||||
Map<String, Object> reponseMoteur;
|
|
||||||
|
|
||||||
reponseMoteur = response.getBody();
|
|
||||||
// Object resultMap = reponseMoteur.get("containers");
|
|
||||||
// Object containersMap = ((Map) resultMap).get("kie-containers");
|
|
||||||
// Map containerMap = ((Map) containersMap);
|
|
||||||
if (reponseMoteur != null
|
|
||||||
&& reponseMoteur.get("containers")!= null) {
|
|
||||||
List<Map<String, Object>> listContainers = (List) reponseMoteur.get("containers");
|
|
||||||
for (Map<String, Object> container : listContainers) {
|
|
||||||
KieContainerInfo kieContainerInfo = new KieContainerInfo();
|
|
||||||
System.out.println("coucou");
|
|
||||||
kieContainerInfo.setContainerId((String) container.get("containerId"));
|
|
||||||
Map artifact = (Map) container.get("resolvedReleaseId");
|
|
||||||
if (artifact != null) {
|
|
||||||
kieContainerInfo.setArtifactId((String) artifact.get("artifactId"));
|
|
||||||
kieContainerInfo.setGroupId((String) artifact.get("groupId"));
|
|
||||||
kieContainerInfo.setVersion((String) artifact.get("version"));
|
|
||||||
}
|
|
||||||
kieContainerInfo.setContainerAlias((String) container.get("container-alias"));
|
|
||||||
results.add(kieContainerInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public KieServerJobStatus stopContainer(String url, String username, String password, String containerId, AddLog workOnGoingView, UI ui) {
|
|
||||||
KieServerJobStatus results = null;
|
|
||||||
String completeurl = url +"/"+ containerId;
|
|
||||||
logger.info("url kie server container : " + completeurl);
|
|
||||||
ResponseEntity<KieServerJobStatus> response = restTemplateKiewb
|
|
||||||
.execute(completeurl, HttpMethod.DELETE, requestCallback(null, username, password), clientHttpResponse -> {
|
|
||||||
KieServerJobStatus extractedResponse = null;
|
|
||||||
if (clientHttpResponse.getBody() != null) {
|
|
||||||
Scanner s = new Scanner(clientHttpResponse.getBody()).useDelimiter("\\A");
|
|
||||||
String result = s.hasNext() ? s.next() : "";
|
|
||||||
KieServerJobStatus values = mapper.readValue(result, KieServerJobStatus.class);
|
|
||||||
extractedResponse = values;
|
|
||||||
}
|
|
||||||
ResponseEntity<KieServerJobStatus> extractedValue = new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
|
||||||
return extractedValue;
|
|
||||||
});
|
|
||||||
KieServerJobStatus reponseMoteur;
|
|
||||||
reponseMoteur = response.getBody();
|
|
||||||
workOnGoingView.addRow(reponseMoteur.toString(),ui);
|
|
||||||
return reponseMoteur;
|
|
||||||
}
|
|
||||||
|
|
||||||
public KieContainerInfo createContainer(String url, String username, String password, String containerId, KieContainerResource request, AddLog workOnGoingView,UI ui) {
|
|
||||||
String completeurl = url + "/"+containerId;
|
|
||||||
logger.info("url kie server container : " + completeurl);
|
|
||||||
ResponseEntity<Map<String, Object>> response = restTemplateKiewb
|
|
||||||
.execute(completeurl, HttpMethod.PUT, requestCallback(request, username, password), clientHttpResponse -> {
|
|
||||||
Map<String, Object> extractedResponse = null;
|
|
||||||
if (clientHttpResponse.getBody() != null) {
|
|
||||||
Scanner s = new Scanner(clientHttpResponse.getBody()).useDelimiter("\\A");
|
|
||||||
String result = s.hasNext() ? s.next() : "";
|
|
||||||
Map<String, Object> map = mapper.readValue(
|
|
||||||
result,
|
|
||||||
new TypeReference<Map<String, Object>>() {
|
|
||||||
});
|
|
||||||
Map<String, Object> values = mapper.readValue(result, Map.class);
|
|
||||||
extractedResponse = values;
|
|
||||||
}
|
|
||||||
ResponseEntity<Map<String, Object>> extractedValue = new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
|
||||||
return extractedValue;
|
|
||||||
});
|
|
||||||
Map<String, Object> reponseMoteur;
|
|
||||||
|
|
||||||
reponseMoteur = response.getBody();
|
|
||||||
workOnGoingView.addRow(reponseMoteur.toString(),ui);
|
|
||||||
KieContainerInfo result = new KieContainerInfo();
|
|
||||||
if (reponseMoteur.get("result") != null) {
|
|
||||||
String containerID = (String) ((Map) ((Map) reponseMoteur.get("result")).get("kie-container")).get("container-id");
|
|
||||||
result.setContainerId(containerID);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public KieContainerInfo createContainerWithBusinessInterface(String url, String username, String password, ProjectPersist projectPersist, KieContainerResource request, AddLog workOnGoingView, UI ui) {
|
|
||||||
String completeurl = url + "/business/"+projectPersist.getContainerID()+"/"+projectPersist.getMainClass()+"/"+projectPersist.getProcessID();
|
|
||||||
logger.info("url kie server business container : " + completeurl);
|
|
||||||
ResponseEntity<Map<String, Object>> response = restTemplateKiewb
|
|
||||||
.execute(completeurl, HttpMethod.POST, requestCallback(request, username, password), clientHttpResponse -> {
|
|
||||||
Map<String, Object> extractedResponse = null;
|
|
||||||
if (clientHttpResponse.getBody() != null) {
|
|
||||||
Scanner s = new Scanner(clientHttpResponse.getBody()).useDelimiter("\\A");
|
|
||||||
String result = s.hasNext() ? s.next() : "";
|
|
||||||
Map<String, Object> map = mapper.readValue(
|
|
||||||
result,
|
|
||||||
new TypeReference<Map<String, Object>>() {
|
|
||||||
});
|
|
||||||
Map<String, Object> values = mapper.readValue(result, Map.class);
|
|
||||||
extractedResponse = values;
|
|
||||||
}
|
|
||||||
ResponseEntity<Map<String, Object>> extractedValue = new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
|
||||||
return extractedValue;
|
|
||||||
});
|
|
||||||
Map<String, Object> reponseMoteur;
|
|
||||||
|
|
||||||
reponseMoteur = response.getBody();
|
|
||||||
workOnGoingView.addRow(reponseMoteur.toString(),ui);
|
|
||||||
KieContainerInfo result = new KieContainerInfo();
|
|
||||||
if (reponseMoteur.get("result") != null) {
|
|
||||||
String containerID = (String) ((Map) ((Map) reponseMoteur.get("result")).get("kie-container")).get("container-id");
|
|
||||||
result.setContainerId(containerID);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private RequestCallback requestCallback(final Object content, String username, String password) {
|
|
||||||
return clientHttpRequest -> {
|
|
||||||
if (content != null) {
|
|
||||||
mapper.writeValue(clientHttpRequest.getBody(), content);
|
|
||||||
}
|
|
||||||
clientHttpRequest.getHeaders().add(
|
|
||||||
HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
|
||||||
clientHttpRequest.getHeaders().add(
|
|
||||||
HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE);
|
|
||||||
String auth = username + ":" + password;
|
|
||||||
byte[] encodedAuth = Base64.encodeBase64(
|
|
||||||
auth.getBytes(Charset.forName("UTF-8")));
|
|
||||||
String authHeader = "Basic " + new String(encodedAuth);
|
|
||||||
clientHttpRequest.getHeaders().add(
|
|
||||||
HttpHeaders.AUTHORIZATION, authHeader);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -6,16 +6,15 @@ import org.chtijbug.drools.console.AddLog;
|
||||||
import org.chtijbug.drools.console.service.model.UserConnected;
|
import org.chtijbug.drools.console.service.model.UserConnected;
|
||||||
import org.chtijbug.drools.console.service.model.kie.JobStatus;
|
import org.chtijbug.drools.console.service.model.kie.JobStatus;
|
||||||
import org.chtijbug.drools.console.service.model.kie.KieConfigurationData;
|
import org.chtijbug.drools.console.service.model.kie.KieConfigurationData;
|
||||||
import org.chtijbug.drools.console.service.model.kie.KieContainerInfo;
|
|
||||||
import org.chtijbug.drools.console.service.model.kie.KieServerJobStatus;
|
|
||||||
import org.chtijbug.drools.console.service.util.AppContext;
|
import org.chtijbug.drools.console.service.util.AppContext;
|
||||||
import org.chtijbug.drools.proxy.persistence.json.KeyProject;
|
import org.chtijbug.drools.proxy.persistence.json.KeyProject;
|
||||||
|
import org.chtijbug.drools.proxy.persistence.model.ContainerPojoPersist;
|
||||||
import org.chtijbug.drools.proxy.persistence.model.ProjectPersist;
|
import org.chtijbug.drools.proxy.persistence.model.ProjectPersist;
|
||||||
import org.chtijbug.drools.proxy.persistence.model.RuntimePersist;
|
import org.chtijbug.drools.proxy.persistence.model.RuntimePersist;
|
||||||
|
import org.chtijbug.drools.proxy.persistence.repository.ContainerRepository;
|
||||||
import org.chtijbug.drools.proxy.persistence.repository.ProjectRepository;
|
import org.chtijbug.drools.proxy.persistence.repository.ProjectRepository;
|
||||||
|
import org.chtijbug.drools.proxy.persistence.repository.RuntimeRepository;
|
||||||
import org.chtijbug.guvnor.server.jaxrs.model.PlatformProjectResponse;
|
import org.chtijbug.guvnor.server.jaxrs.model.PlatformProjectResponse;
|
||||||
import org.kie.server.api.model.KieContainerResource;
|
|
||||||
import org.kie.server.api.model.ReleaseId;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
@ -38,9 +37,12 @@ public class ProjectPersistService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserConnectedService userConnectedService;
|
private UserConnectedService userConnectedService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private KieServerRepositoryService kieServerRepositoryService;
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ContainerRepository containerRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RuntimeRepository runtimeRepository;
|
||||||
|
|
||||||
public ProjectPersistService(){
|
public ProjectPersistService(){
|
||||||
this.config = AppContext.getApplicationContext().getBean(KieConfigurationData.class);
|
this.config = AppContext.getApplicationContext().getBean(KieConfigurationData.class);
|
||||||
|
|
@ -145,21 +147,44 @@ public class ProjectPersistService {
|
||||||
userConnected.getUserPassword(), projectPersist.getProjectName().getSpaceName(), projectPersist.getProjectName().getName(), "install", workOnGoingView,ui);
|
userConnected.getUserPassword(), projectPersist.getProjectName().getSpaceName(), projectPersist.getProjectName().getName(), "install", workOnGoingView,ui);
|
||||||
|
|
||||||
executeWrite(url,username,password,workOnGoingView,result.getJobId(),ui);
|
executeWrite(url,username,password,workOnGoingView,result.getJobId(),ui);
|
||||||
|
/**
|
||||||
if (projectPersist.getContainerID() != null) {
|
if (projectPersist.getContainerID() != null) {
|
||||||
KieServerJobStatus jobresult = kieServerRepositoryService.stopContainer(config.getKieserverUrl(), config.getKieserverUserName(), config.getKieserverPassword(), projectPersist.getContainerID(), workOnGoingView,ui);
|
KieServerJobStatus jobresult = kieServerRepositoryService.stopContainer(config.getKieserverUrl(), config.getKieserverUserName(), config.getKieserverPassword(), projectPersist.getContainerID(), workOnGoingView,ui);
|
||||||
if (jobresult != null
|
if (jobresult != null
|
||||||
&& "SUCCESS".equals(jobresult.getType())) {
|
&& "SUCCESS".equals(jobresult.getType())) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
KieContainerResource newContainer = new KieContainerResource();
|
**/
|
||||||
newContainer.setContainerId(projectPersist.getContainerID());
|
// ContainerPojoPersist toto = containerRepository.findByServerNameAndContainerId(projectPersist.getContainerID());
|
||||||
newContainer.setReleaseId(new ReleaseId());
|
List<RuntimePersist> kieservers = runtimeRepository.findByServerName(projectPersist.getServerName());
|
||||||
newContainer.getReleaseId().setArtifactId(projectPersist.getArtifactID());
|
if (kieservers.size()==1) {
|
||||||
newContainer.getReleaseId().setGroupId(projectPersist.getGroupID());
|
ContainerPojoPersist existingContainer = containerRepository.findByServerNameAndContainerId(projectPersist.getServerName(),projectPersist.getContainerID());
|
||||||
newContainer.getReleaseId().setVersion(projectPersist.getProjectVersion());
|
if (existingContainer==null) {
|
||||||
KieContainerInfo createdContainer = kieServerRepositoryService.createContainerWithBusinessInterface(config.getKieserverUrl(), config.getKieserverUserName(), config.getKieserverPassword(), projectPersist, newContainer, workOnGoingView,ui);
|
ContainerPojoPersist newContainer = new ContainerPojoPersist();
|
||||||
|
newContainer.setStatus(ContainerPojoPersist.STATUS.TODEPLOY.toString());
|
||||||
|
newContainer.setClassName(projectPersist.getMainClass());
|
||||||
|
newContainer.setProcessID(projectPersist.getProcessID());
|
||||||
|
newContainer.setContainerId(projectPersist.getContainerID());
|
||||||
|
newContainer.setServerName(projectPersist.getServerName());
|
||||||
|
newContainer.setGroupId(projectPersist.getGroupID());
|
||||||
|
newContainer.setArtifactId(projectPersist.getArtifactID());
|
||||||
|
newContainer.setVersion(projectPersist.getProjectVersion());
|
||||||
|
containerRepository.save(newContainer);
|
||||||
|
}else{
|
||||||
|
existingContainer.setStatus(ContainerPojoPersist.STATUS.TODEPLOY.toString());
|
||||||
|
containerRepository.save(existingContainer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
KieContainerResource newContainer = new KieContainerResource();
|
||||||
|
newContainer.setContainerId(projectPersist.getContainerID());
|
||||||
|
newContainer.setReleaseId(new ReleaseId());
|
||||||
|
newContainer.getReleaseId().setArtifactId(projectPersist.getArtifactID());
|
||||||
|
newContainer.getReleaseId().setGroupId(projectPersist.getGroupID());
|
||||||
|
newContainer.getReleaseId().setVersion(projectPersist.getProjectVersion());
|
||||||
|
KieContainerInfo createdContainer = kieServerRepositoryService.createContainerWithBusinessInterface(config.getKieserverUrl(), config.getKieserverUserName(), config.getKieserverPassword(), projectPersist, newContainer, workOnGoingView, ui);
|
||||||
|
**/
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import org.springframework.web.client.RestTemplate;
|
||||||
public class RuntimeService {
|
public class RuntimeService {
|
||||||
|
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(KieServerRepositoryService.class);
|
private static Logger logger = LoggerFactory.getLogger(RuntimeService.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RuntimeRepository runtimeRepository;
|
private RuntimeRepository runtimeRepository;
|
||||||
|
|
|
||||||
|
|
@ -1,124 +0,0 @@
|
||||||
package org.chtijbug.drools.console.vaadinComponent.componentView;
|
|
||||||
|
|
||||||
import com.vaadin.flow.component.button.Button;
|
|
||||||
import com.vaadin.flow.component.dependency.StyleSheet;
|
|
||||||
import com.vaadin.flow.component.dialog.Dialog;
|
|
||||||
import com.vaadin.flow.component.icon.VaadinIcon;
|
|
||||||
import com.vaadin.flow.component.html.Label;
|
|
||||||
import com.vaadin.flow.component.notification.Notification;
|
|
||||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
|
||||||
import com.vaadin.flow.data.value.ValueChangeMode;
|
|
||||||
import org.chtijbug.drools.console.service.RuntimeService;
|
|
||||||
import org.chtijbug.drools.console.service.model.ReturnPerso;
|
|
||||||
import org.chtijbug.drools.console.service.util.AppContext;
|
|
||||||
import org.chtijbug.drools.console.vaadinComponent.ComponentPerso.TextFieldPerso;
|
|
||||||
import org.chtijbug.drools.console.vaadinComponent.Squelette.SqueletteComposant;
|
|
||||||
import org.chtijbug.drools.proxy.persistence.model.RuntimePersist;
|
|
||||||
import org.kie.server.api.model.KieServerInfo;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@StyleSheet("css/accueil.css")
|
|
||||||
public class AddRuntime extends VerticalLayout {
|
|
||||||
|
|
||||||
private TextFieldPerso host;
|
|
||||||
|
|
||||||
private TextFieldPerso port;
|
|
||||||
|
|
||||||
private Button testConnexion;
|
|
||||||
|
|
||||||
private Label label;
|
|
||||||
|
|
||||||
private RuntimeService runtimeService;
|
|
||||||
|
|
||||||
public AddRuntime(Dialog dialog, SqueletteComposant squeletteComposant){
|
|
||||||
|
|
||||||
runtimeService = AppContext.getApplicationContext().getBean(RuntimeService.class);
|
|
||||||
|
|
||||||
setClassName("creation-runtime-content");
|
|
||||||
|
|
||||||
label=new Label("Add Runtime");
|
|
||||||
label.setClassName("creation-runtime-title");
|
|
||||||
add(label);
|
|
||||||
|
|
||||||
host=new TextFieldPerso("Host","http://111.111.1.111",VaadinIcon.HARDDRIVE.create());
|
|
||||||
host.getTextField().setRequired(true);
|
|
||||||
host.getTextField().setValueChangeMode(ValueChangeMode.EAGER);
|
|
||||||
host.getTextField().addValueChangeListener(textFieldStringComponentValueChangeEvent -> {
|
|
||||||
verify();
|
|
||||||
});
|
|
||||||
|
|
||||||
add(host);
|
|
||||||
|
|
||||||
port=new TextFieldPerso("Port","",VaadinIcon.INBOX.create());
|
|
||||||
port.getTextField().setRequired(true);
|
|
||||||
port.getTextField().setValueChangeMode(ValueChangeMode.EAGER);
|
|
||||||
port.getTextField().addValueChangeListener(textFieldStringComponentValueChangeEvent -> {
|
|
||||||
verify();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
add(port);
|
|
||||||
|
|
||||||
testConnexion=new Button("Tester connexion");
|
|
||||||
testConnexion.setEnabled(false);
|
|
||||||
testConnexion.setClassName("login-application-connexion");
|
|
||||||
add(testConnexion);
|
|
||||||
testConnexion.addClickListener(buttonClickEvent -> {
|
|
||||||
|
|
||||||
ReturnPerso<KieServerInfo> returnPerso= runtimeService.verifyIfKieServerExist(
|
|
||||||
host.getTextField().getValue()+":"+port.getTextField().getValue()
|
|
||||||
);
|
|
||||||
|
|
||||||
if(returnPerso.getaBoolean()){
|
|
||||||
Notification.show(returnPerso.getError());
|
|
||||||
runtimeService.saveRuntime(new RuntimePersist(
|
|
||||||
returnPerso.getBody().getName(),
|
|
||||||
returnPerso.getBody().getVersion(),host.getTextField().getValue()+":"+port.getTextField().getValue()
|
|
||||||
));
|
|
||||||
|
|
||||||
List<RuntimePersist> runtimePersists=runtimeService.getRuntimeRepository().findAll();
|
|
||||||
squeletteComposant.getLeftMenuGlobal().getInformationStructure().actualiseKieServer(runtimePersists!=null?runtimePersists.size():0);
|
|
||||||
dialog.close();
|
|
||||||
}else {
|
|
||||||
Notification.show(returnPerso.getError());
|
|
||||||
testConnexion.setClassName("login-application-connexion-error");
|
|
||||||
testConnexion.setIcon(VaadinIcon.ROTATE_LEFT.create());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void verify(){
|
|
||||||
if(port.getTextField().isInvalid()||port.getTextField().getValue().isEmpty()||port.getTextField().getValue()==null&&
|
|
||||||
host.getTextField().isInvalid()||host.getTextField().getValue().isEmpty()||host.getTextField().getValue()==null){
|
|
||||||
testConnexion.setEnabled(false);
|
|
||||||
}else {
|
|
||||||
testConnexion.setEnabled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public TextFieldPerso getHost() {
|
|
||||||
return host;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHost(TextFieldPerso host) {
|
|
||||||
this.host = host;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TextFieldPerso getPort() {
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPort(TextFieldPerso port) {
|
|
||||||
this.port = port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Button getTestConnexion() {
|
|
||||||
return testConnexion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTestConnexion(Button testConnexion) {
|
|
||||||
this.testConnexion = testConnexion;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +1,14 @@
|
||||||
package org.chtijbug.drools.console.vaadinComponent.leftMenu.Action;
|
package org.chtijbug.drools.console.vaadinComponent.leftMenu.Action;
|
||||||
|
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
||||||
import com.vaadin.flow.component.dialog.Dialog;
|
|
||||||
import com.vaadin.flow.component.html.Label;
|
|
||||||
import com.vaadin.flow.component.icon.VaadinIcon;
|
import com.vaadin.flow.component.icon.VaadinIcon;
|
||||||
import com.vaadin.flow.component.notification.Notification;
|
import com.vaadin.flow.component.notification.Notification;
|
||||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||||
import com.vaadin.flow.component.textfield.TextField;
|
|
||||||
import com.vaadin.flow.data.value.ValueChangeMode;
|
import com.vaadin.flow.data.value.ValueChangeMode;
|
||||||
import org.chtijbug.drools.console.service.IndexerService;
|
import org.chtijbug.drools.console.service.IndexerService;
|
||||||
import org.chtijbug.drools.console.service.util.AppContext;
|
import org.chtijbug.drools.console.service.util.AppContext;
|
||||||
import org.chtijbug.drools.console.vaadinComponent.ComponentPerso.DialogPerso;
|
import org.chtijbug.drools.console.vaadinComponent.ComponentPerso.DialogPerso;
|
||||||
import org.chtijbug.drools.console.vaadinComponent.ComponentPerso.TextFieldPerso;
|
import org.chtijbug.drools.console.vaadinComponent.ComponentPerso.TextFieldPerso;
|
||||||
import org.chtijbug.drools.console.vaadinComponent.Squelette.SqueletteComposant;
|
|
||||||
import org.chtijbug.drools.console.vaadinComponent.componentView.AddRuntime;
|
|
||||||
import org.chtijbug.drools.console.vaadinComponent.componentView.DefineProject;
|
|
||||||
import org.chtijbug.drools.console.vaadinComponent.componentView.GridActionLogging;
|
|
||||||
import org.chtijbug.drools.console.vaadinComponent.componentView.GridLogging;
|
|
||||||
import org.chtijbug.drools.console.view.ActionLoggingView;
|
import org.chtijbug.drools.console.view.ActionLoggingView;
|
||||||
import org.chtijbug.drools.console.view.LoggingView;
|
import org.chtijbug.drools.console.view.LoggingView;
|
||||||
import org.chtijbug.drools.indexer.persistence.model.BusinessTransactionPersistence;
|
import org.chtijbug.drools.indexer.persistence.model.BusinessTransactionPersistence;
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,19 @@
|
||||||
package org.chtijbug.drools.console.vaadinComponent.leftMenu.Action;
|
package org.chtijbug.drools.console.vaadinComponent.leftMenu.Action;
|
||||||
|
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
||||||
import com.vaadin.flow.component.dialog.Dialog;
|
|
||||||
import com.vaadin.flow.component.icon.VaadinIcon;
|
|
||||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||||
import org.chtijbug.drools.console.vaadinComponent.ComponentPerso.DialogPerso;
|
|
||||||
import org.chtijbug.drools.console.vaadinComponent.Squelette.SqueletteComposant;
|
import org.chtijbug.drools.console.vaadinComponent.Squelette.SqueletteComposant;
|
||||||
import org.chtijbug.drools.console.vaadinComponent.componentView.AddRuntime;
|
|
||||||
|
|
||||||
public class RuntimesAction extends VerticalLayout {
|
public class RuntimesAction extends VerticalLayout {
|
||||||
|
|
||||||
private Button addRuntime;
|
// private Button addRuntime;
|
||||||
|
|
||||||
|
|
||||||
public RuntimesAction(SqueletteComposant squeletteComposant){
|
public RuntimesAction(SqueletteComposant squeletteComposant){
|
||||||
|
|
||||||
setClassName("leftMenu-global-action");
|
setClassName("leftMenu-global-action");
|
||||||
|
|
||||||
|
/**
|
||||||
addRuntime=new Button("add runtime", VaadinIcon.PLUS.create());
|
addRuntime=new Button("add runtime", VaadinIcon.PLUS.create());
|
||||||
addRuntime.setClassName("leftMenu-global-button");
|
addRuntime.setClassName("leftMenu-global-button");
|
||||||
add(addRuntime);
|
add(addRuntime);
|
||||||
|
|
@ -30,7 +26,9 @@ public class RuntimesAction extends VerticalLayout {
|
||||||
|
|
||||||
dialog.open();
|
dialog.open();
|
||||||
});
|
});
|
||||||
|
**/
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isActive(Button button){
|
private boolean isActive(Button button){
|
||||||
return button.getClassNames().contains("active");
|
return button.getClassNames().contains("active");
|
||||||
}
|
}
|
||||||
|
|
@ -41,7 +39,7 @@ public class RuntimesAction extends VerticalLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void active(Button button){
|
private void active(Button button){
|
||||||
removeActive(addRuntime);
|
// removeActive(addRuntime);
|
||||||
button.getClassNames().add("active");
|
button.getClassNames().add("active");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,9 @@ package org.chtijbug.drools.console.vaadinComponent.menu;
|
||||||
|
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
||||||
import com.vaadin.flow.component.dependency.StyleSheet;
|
import com.vaadin.flow.component.dependency.StyleSheet;
|
||||||
import com.vaadin.flow.component.dialog.Dialog;
|
|
||||||
import com.vaadin.flow.component.icon.VaadinIcon;
|
import com.vaadin.flow.component.icon.VaadinIcon;
|
||||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
|
||||||
import org.chtijbug.drools.console.vaadinComponent.Squelette.SqueletteComposant;
|
import org.chtijbug.drools.console.vaadinComponent.Squelette.SqueletteComposant;
|
||||||
import org.chtijbug.drools.console.vaadinComponent.componentView.AddRuntime;
|
|
||||||
import org.chtijbug.drools.console.vaadinComponent.leftMenu.Action.DeploymentAction;
|
import org.chtijbug.drools.console.vaadinComponent.leftMenu.Action.DeploymentAction;
|
||||||
import org.chtijbug.drools.console.view.DeploymentView;
|
import org.chtijbug.drools.console.view.DeploymentView;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,9 @@ package org.chtijbug.drools.console.vaadinComponent.menu;
|
||||||
|
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
||||||
import com.vaadin.flow.component.dependency.StyleSheet;
|
import com.vaadin.flow.component.dependency.StyleSheet;
|
||||||
import com.vaadin.flow.component.dialog.Dialog;
|
|
||||||
import com.vaadin.flow.component.icon.VaadinIcon;
|
import com.vaadin.flow.component.icon.VaadinIcon;
|
||||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||||
import org.chtijbug.drools.console.vaadinComponent.Squelette.SqueletteComposant;
|
import org.chtijbug.drools.console.vaadinComponent.Squelette.SqueletteComposant;
|
||||||
import org.chtijbug.drools.console.vaadinComponent.componentView.AddRuntime;
|
|
||||||
import org.chtijbug.drools.console.vaadinComponent.leftMenu.Action.DeploymentAction;
|
|
||||||
import org.chtijbug.drools.console.vaadinComponent.leftMenu.Action.RuntimesAction;
|
import org.chtijbug.drools.console.vaadinComponent.leftMenu.Action.RuntimesAction;
|
||||||
import org.chtijbug.drools.console.view.DeploymentView;
|
import org.chtijbug.drools.console.view.DeploymentView;
|
||||||
import org.chtijbug.drools.console.view.RuntimesView;
|
import org.chtijbug.drools.console.view.RuntimesView;
|
||||||
|
|
|
||||||
|
|
@ -401,7 +401,7 @@ public class PackageResource {
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{organizationalUnitName}/{projectName}/asset/{assetName}/source")
|
@Path("{organizationalUnitName}/{projectName}/asset/{assetName:.+}}/source")
|
||||||
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN})
|
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN})
|
||||||
public void updateAssetSource(
|
public void updateAssetSource(
|
||||||
@PathParam("organizationalUnitName") String organizationalUnitName, @PathParam("projectName") String projectName, @PathParam("assetName") String assetName, String content) {
|
@PathParam("organizationalUnitName") String organizationalUnitName, @PathParam("projectName") String projectName, @PathParam("assetName") String assetName, String content) {
|
||||||
|
|
|
||||||
|
|
@ -137,8 +137,8 @@
|
||||||
<orderEntry type="library" name="Maven: com.google.guava:guava:13.0.1" level="project" />
|
<orderEntry type="library" name="Maven: com.google.guava:guava:13.0.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
|
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.7" level="project" />
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.7" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:7.16.0.Final" level="project" />
|
<orderEntry type="library" name="Maven: org.kie:kie-internal:7.17.0.Final" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.kie:kie-api:7.16.0.Final" level="project" />
|
<orderEntry type="library" name="Maven: org.kie:kie-api:7.17.0.Final" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.kie.soup:kie-soup-maven-support:7.16.0.Final" level="project" />
|
<orderEntry type="library" name="Maven: org.kie.soup:kie-soup-maven-support:7.17.0.Final" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
|
@ -92,8 +92,8 @@
|
||||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.google.guava:guava:13.0.1" level="project" />
|
<orderEntry type="library" name="Maven: com.google.guava:guava:13.0.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.1" level="project" />
|
<orderEntry type="library" name="Maven: commons-io:commons-io:2.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:7.16.0.Final" level="project" />
|
<orderEntry type="library" name="Maven: org.kie:kie-internal:7.17.0.Final" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.kie:kie-api:7.16.0.Final" level="project" />
|
<orderEntry type="library" name="Maven: org.kie:kie-api:7.17.0.Final" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.kie.soup:kie-soup-maven-support:7.16.0.Final" level="project" />
|
<orderEntry type="library" name="Maven: org.kie.soup:kie-soup-maven-support:7.17.0.Final" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
|
@ -56,7 +56,7 @@
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.pymmasoftware.jbpm</groupId>
|
<groupId>com.pymmasoftware.jbpm</groupId>
|
||||||
<artifactId>drools-framewwork-business-proxy-persistence</artifactId>
|
<artifactId>drools-framework-business-proxy-persistence</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Spring Boot -->
|
<!-- Spring Boot -->
|
||||||
|
|
@ -92,6 +92,10 @@
|
||||||
<groupId>org.apache.camel</groupId>
|
<groupId>org.apache.camel</groupId>
|
||||||
<artifactId>camel-jackson-starter</artifactId>
|
<artifactId>camel-jackson-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.camel</groupId>
|
||||||
|
<artifactId>camel-quartz2</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Test -->
|
<!-- Test -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package org.chtijbug.drools.proxy.camel;
|
||||||
|
|
||||||
|
import org.apache.camel.builder.RouteBuilder;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class AutodeployRouter extends RouteBuilder {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configure() throws Exception {
|
||||||
|
|
||||||
|
from("quartz2://myGroup/myTimerName?cron=0+0/1+*+?+*+MON-FRI").to("bean:kieService?method=updateConfig()");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -18,12 +18,13 @@ package org.chtijbug.drools.proxy.service;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.apache.camel.CamelContext;
|
import org.apache.camel.CamelContext;
|
||||||
import org.chtijbug.drools.proxy.camel.DroolsRouter;
|
import org.chtijbug.drools.proxy.camel.DroolsRouter;
|
||||||
import org.chtijbug.drools.proxy.persistence.repository.ContainerRepository;
|
|
||||||
import org.chtijbug.drools.proxy.persistence.model.ContainerPojoPersist;
|
import org.chtijbug.drools.proxy.persistence.model.ContainerPojoPersist;
|
||||||
|
import org.chtijbug.drools.proxy.persistence.model.RuntimePersist;
|
||||||
|
import org.chtijbug.drools.proxy.persistence.repository.ContainerRepository;
|
||||||
|
import org.chtijbug.drools.proxy.persistence.repository.RuntimeRepository;
|
||||||
import org.chtijbug.kieserver.services.drools.DroolsChtijbugKieServerExtension;
|
import org.chtijbug.kieserver.services.drools.DroolsChtijbugKieServerExtension;
|
||||||
import org.chtijbug.kieserver.services.drools.DroolsChtijbugRulesExecutionService;
|
import org.chtijbug.kieserver.services.drools.DroolsChtijbugRulesExecutionService;
|
||||||
import org.kie.server.api.model.*;
|
import org.kie.server.api.model.*;
|
||||||
import org.kie.server.services.api.KieContainerInstance;
|
|
||||||
import org.kie.server.services.api.KieServerExtension;
|
import org.kie.server.services.api.KieServerExtension;
|
||||||
import org.kie.server.services.api.KieServerRegistry;
|
import org.kie.server.services.api.KieServerRegistry;
|
||||||
import org.kie.server.services.impl.KieContainerInstanceImpl;
|
import org.kie.server.services.impl.KieContainerInstanceImpl;
|
||||||
|
|
@ -33,12 +34,15 @@ import org.kie.server.services.impl.marshal.MarshallerHelper;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.ws.rs.core.Context;
|
import javax.ws.rs.core.Context;
|
||||||
import javax.ws.rs.core.HttpHeaders;
|
import javax.ws.rs.core.HttpHeaders;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
@ -60,8 +64,12 @@ public class KieServiceCommon {
|
||||||
@Inject
|
@Inject
|
||||||
private ContainerRepository containerRepository;
|
private ContainerRepository containerRepository;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private RuntimeRepository runtimeRepository;
|
||||||
@Autowired
|
@Autowired
|
||||||
CamelContext camelContext;
|
CamelContext camelContext;
|
||||||
|
@Value("${server.port}")
|
||||||
|
private int serverPort;
|
||||||
|
|
||||||
public KieServiceCommon() {
|
public KieServiceCommon() {
|
||||||
// for now, if no server impl is passed as parameter, create one
|
// for now, if no server impl is passed as parameter, create one
|
||||||
|
|
@ -86,44 +94,68 @@ public class KieServiceCommon {
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
private void initCamelBusinessRoutes() {
|
private void initCamelBusinessRoutes() {
|
||||||
|
String serverName = System.getProperty("org.kie.server.id");
|
||||||
|
String sftpPort=System.getProperty("org.chtijbug.server.sftpPort");
|
||||||
|
List<RuntimePersist> itIsMes = runtimeRepository.findByServerName(serverName);
|
||||||
|
if (itIsMes.size()==0){
|
||||||
|
ServiceResponse<KieServerInfo> result = server.getInfo();
|
||||||
|
String version = result.getResult().getVersion();
|
||||||
|
String hostName="localhost";
|
||||||
|
try {
|
||||||
|
InetAddress inetAddress = InetAddress.getLocalHost();
|
||||||
|
hostName=inetAddress.getHostName();
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
logger.info("initCamelBusinessRoutes.getLocalHost", e);
|
||||||
|
}
|
||||||
|
//org.chtijbug.server.sftpPort
|
||||||
|
RuntimePersist runtimePersist = new RuntimePersist(serverName,version,"http://"+hostName+":"+serverPort,String.valueOf(serverPort),sftpPort);
|
||||||
|
runtimeRepository.save(runtimePersist);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
String serverName = System.getProperty("org.kie.server.id");
|
|
||||||
List<ContainerPojoPersist> containers = containerRepository.findByServerName(serverName);
|
List<ContainerPojoPersist> containers = containerRepository.findByServerName(serverName);
|
||||||
for (ContainerPojoPersist container : containers) {
|
for (ContainerPojoPersist container : containers) {
|
||||||
ClassLoader localClassLoader = null;
|
this.initCamelBusinessRoute(container);
|
||||||
String containerId = container.getContainerId();
|
|
||||||
KieContainerInstanceImpl kieContainerInstance = registry.getContainer(containerId);
|
|
||||||
if (kieContainerInstance != null) {
|
|
||||||
try {
|
|
||||||
localClassLoader = Thread.currentThread()
|
|
||||||
.getContextClassLoader();
|
|
||||||
} catch (ClassCastException e) {
|
|
||||||
logger.info("GenericResource.runSession", e);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Set<Class<?>> classes = kieContainerInstance.getExtraClasses();
|
|
||||||
String className = container.getClassName();
|
|
||||||
Class foundClass = this.getClassFromName(classes, className);
|
|
||||||
ClassLoader classLoader = foundClass.getClassLoader();
|
|
||||||
Class<?> theClass = classLoader.loadClass(className);
|
|
||||||
camelContext.setApplicationContextClassLoader(classLoader);
|
|
||||||
Thread.currentThread().setContextClassLoader(classLoader);
|
|
||||||
String projectName = container.getProjectName();
|
|
||||||
String processId = container.getProcessID();
|
|
||||||
DroolsRouter droolsRouter = new DroolsRouter(camelContext, theClass, projectName, kieContainerInstance, processId);
|
|
||||||
camelContext.addRoutes(droolsRouter);
|
|
||||||
} finally {
|
|
||||||
if (localClassLoader != null) {
|
|
||||||
Thread.currentThread().setContextClassLoader(localClassLoader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.info("CreationContainer", e);
|
logger.info("initCamelBusinessRoutes", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initCamelBusinessRoute(ContainerPojoPersist container) throws Exception {
|
||||||
|
ClassLoader localClassLoader = null;
|
||||||
|
String containerId = container.getContainerId();
|
||||||
|
KieContainerInstanceImpl kieContainerInstance = registry.getContainer(containerId);
|
||||||
|
if (kieContainerInstance != null) {
|
||||||
|
try {
|
||||||
|
localClassLoader = Thread.currentThread()
|
||||||
|
.getContextClassLoader();
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
logger.info("GenericResource.runSession", e);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Set<Class<?>> classes = kieContainerInstance.getExtraClasses();
|
||||||
|
String className = container.getClassName();
|
||||||
|
Class foundClass = this.getClassFromName(classes, className);
|
||||||
|
ClassLoader classLoader = foundClass.getClassLoader();
|
||||||
|
Class<?> theClass = classLoader.loadClass(className);
|
||||||
|
camelContext.setApplicationContextClassLoader(classLoader);
|
||||||
|
Thread.currentThread().setContextClassLoader(classLoader);
|
||||||
|
String projectName = container.getContainerId();
|
||||||
|
String processId = container.getProcessID();
|
||||||
|
DroolsRouter droolsRouter = new DroolsRouter(camelContext, theClass, projectName, kieContainerInstance, processId);
|
||||||
|
camelContext.addRoutes(droolsRouter);
|
||||||
|
} finally {
|
||||||
|
if (localClassLoader != null) {
|
||||||
|
Thread.currentThread().setContextClassLoader(localClassLoader);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public KieServerImpl getServer() {
|
public KieServerImpl getServer() {
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
@ -150,7 +182,25 @@ public class KieServiceCommon {
|
||||||
return result.getResult();
|
return result.getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateConfig() throws Exception {
|
||||||
|
String serverName = System.getProperty("org.kie.server.id");
|
||||||
|
List<ContainerPojoPersist> containers= containerRepository.findByServerNameAndStatus(serverName, ContainerPojoPersist.STATUS.TODEPLOY.toString());
|
||||||
|
for (ContainerPojoPersist element:containers){
|
||||||
|
//this.disposeContainer(element.getContainerId());
|
||||||
|
|
||||||
|
KieContainerResource newContainer = new KieContainerResource();
|
||||||
|
newContainer.setContainerId(element.getContainerId());
|
||||||
|
newContainer.setReleaseId(new ReleaseId());
|
||||||
|
newContainer.getReleaseId().setArtifactId(element.getArtifactId());
|
||||||
|
newContainer.getReleaseId().setGroupId(element.getGroupId());
|
||||||
|
newContainer.getReleaseId().setVersion(element.getVersion());
|
||||||
|
this.createContainer(element.getContainerId(),newContainer);
|
||||||
|
this.initCamelBusinessRoute(element);
|
||||||
|
element.setStatus(ContainerPojoPersist.STATUS.UP.toString());
|
||||||
|
containerRepository.save(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
public KieContainerResource createContainerWithRestBusinessService(String id, KieContainerResource container, String className, String processID) {
|
public KieContainerResource createContainerWithRestBusinessService(String id, KieContainerResource container, String className, String processID) {
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -167,39 +217,27 @@ public class KieServiceCommon {
|
||||||
logger.info("GenericResource.runSession", e);
|
logger.info("GenericResource.runSession", e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
KieContainerInstance kci = registry.getContainer(id);
|
String serverName = System.getProperty("org.kie.server.id");
|
||||||
Set<Class<?>> classes = kci.getExtraClasses();
|
ContainerPojoPersist containerPojoPersist = containerRepository.findByServerNameAndContainerId(serverName, id);
|
||||||
|
if (containerPojoPersist == null) {
|
||||||
|
containerPojoPersist = new ContainerPojoPersist();
|
||||||
|
containerPojoPersist.setId(UUID.randomUUID().toString());
|
||||||
|
containerPojoPersist.setContainerId(id);
|
||||||
|
containerPojoPersist.setClassName(className);
|
||||||
|
containerPojoPersist.setProjectName(id);
|
||||||
|
containerPojoPersist.setServerName(serverName);
|
||||||
|
containerPojoPersist.setProcessID(processID);
|
||||||
|
|
||||||
Class foundClass = this.getClassFromName(classes, className);
|
} else {
|
||||||
if (foundClass != null) {
|
containerPojoPersist.setContainerId(id);
|
||||||
ClassLoader classLoader = foundClass.getClassLoader();
|
containerPojoPersist.setClassName(className);
|
||||||
Class<?> theClass = classLoader.loadClass(className);
|
containerPojoPersist.setProjectName(id);
|
||||||
Thread.currentThread().setContextClassLoader(classLoader);
|
containerPojoPersist.setProcessID(processID);
|
||||||
camelContext.setApplicationContextClassLoader(classLoader);
|
containerPojoPersist.setServerName(serverName);
|
||||||
DroolsRouter droolsRouter = new DroolsRouter(camelContext, theClass, id, kci, processID);
|
|
||||||
camelContext.addRoutes(droolsRouter);
|
|
||||||
String serverName = System.getProperty("org.kie.server.id");
|
|
||||||
ContainerPojoPersist containerPojoPersist = containerRepository.findByServerNameAndContainerId(serverName, id);
|
|
||||||
if (containerPojoPersist == null) {
|
|
||||||
containerPojoPersist = new ContainerPojoPersist();
|
|
||||||
containerPojoPersist.setId(UUID.randomUUID().toString());
|
|
||||||
containerPojoPersist.setContainerId(id);
|
|
||||||
containerPojoPersist.setClassName(className);
|
|
||||||
containerPojoPersist.setProjectName(id);
|
|
||||||
containerPojoPersist.setServerName(serverName);
|
|
||||||
containerPojoPersist.setProcessID(processID);
|
|
||||||
containerRepository.save(containerPojoPersist);
|
|
||||||
} else {
|
|
||||||
containerPojoPersist.setContainerId(id);
|
|
||||||
containerPojoPersist.setClassName(className);
|
|
||||||
containerPojoPersist.setProjectName(id);
|
|
||||||
containerPojoPersist.setProcessID(processID);
|
|
||||||
containerPojoPersist.setServerName(serverName);
|
|
||||||
containerRepository.save(containerPojoPersist);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
this.initCamelBusinessRoute(containerPojoPersist);
|
||||||
|
containerRepository.save(containerPojoPersist);
|
||||||
|
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
logger.error("createContainerWithRestBusinessService", e);
|
logger.error("createContainerWithRestBusinessService", e);
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,6 @@
|
||||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>drools-framewwork-business-proxy-persistence</artifactId>
|
<artifactId>drools-framework-business-proxy-persistence</artifactId>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,11 @@ import org.springframework.data.mongodb.core.mapping.Document;
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
public class ContainerPojoPersist {
|
public class ContainerPojoPersist {
|
||||||
|
public enum STATUS {
|
||||||
|
UP,
|
||||||
|
DOWN,
|
||||||
|
TODEPLOY
|
||||||
|
}
|
||||||
@Id
|
@Id
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
|
|
@ -22,6 +26,14 @@ public class ContainerPojoPersist {
|
||||||
|
|
||||||
private String projectName;
|
private String projectName;
|
||||||
|
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
private String groupId;
|
||||||
|
|
||||||
|
private String artifactId;
|
||||||
|
|
||||||
|
private String version;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
@ -70,6 +82,38 @@ public class ContainerPojoPersist {
|
||||||
this.processID = processID;
|
this.processID = processID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGroupId() {
|
||||||
|
return groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupId(String groupId) {
|
||||||
|
this.groupId = groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getArtifactId() {
|
||||||
|
return artifactId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArtifactId(String artifactId) {
|
||||||
|
this.artifactId = artifactId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVersion(String version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final StringBuffer sb = new StringBuffer("ContainerPojoPersist{");
|
final StringBuffer sb = new StringBuffer("ContainerPojoPersist{");
|
||||||
|
|
@ -79,6 +123,10 @@ public class ContainerPojoPersist {
|
||||||
sb.append(", serverName='").append(serverName).append('\'');
|
sb.append(", serverName='").append(serverName).append('\'');
|
||||||
sb.append(", processID='").append(processID).append('\'');
|
sb.append(", processID='").append(processID).append('\'');
|
||||||
sb.append(", projectName='").append(projectName).append('\'');
|
sb.append(", projectName='").append(projectName).append('\'');
|
||||||
|
sb.append(", status=").append(status);
|
||||||
|
sb.append(", groupId='").append(groupId).append('\'');
|
||||||
|
sb.append(", artifactId='").append(artifactId).append('\'');
|
||||||
|
sb.append(", version='").append(version).append('\'');
|
||||||
sb.append('}');
|
sb.append('}');
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,16 @@ public class RuntimePersist {
|
||||||
|
|
||||||
private String hostname;
|
private String hostname;
|
||||||
|
|
||||||
public RuntimePersist(String serverName, String version, String hostname) {
|
private String serverPort;
|
||||||
|
|
||||||
|
private String sftpPort;
|
||||||
|
|
||||||
|
public RuntimePersist(String serverName, String version, String hostname,String serverPort,String sftpPort) {
|
||||||
this.serverName = serverName;
|
this.serverName = serverName;
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.hostname = hostname;
|
this.hostname = hostname;
|
||||||
|
this.serverPort = serverPort;
|
||||||
|
this.sftpPort = sftpPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
|
@ -55,4 +61,20 @@ public class RuntimePersist {
|
||||||
public void setHostname(String hostname) {
|
public void setHostname(String hostname) {
|
||||||
this.hostname = hostname;
|
this.hostname = hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSftpPort() {
|
||||||
|
return sftpPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSftpPort(String sftpPort) {
|
||||||
|
this.sftpPort = sftpPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerPort() {
|
||||||
|
return serverPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServerPort(String serverPort) {
|
||||||
|
this.serverPort = serverPort;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ public interface ContainerRepository extends MongoRepository<ContainerPojoPersis
|
||||||
List<ContainerPojoPersist> findByContainerId(String containerId);
|
List<ContainerPojoPersist> findByContainerId(String containerId);
|
||||||
|
|
||||||
List<ContainerPojoPersist> findByServerName(String serverName);
|
List<ContainerPojoPersist> findByServerName(String serverName);
|
||||||
|
List<ContainerPojoPersist> findByServerNameAndStatus(String serverName, String status);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
pom.xml
2
pom.xml
|
|
@ -19,7 +19,7 @@
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<jbpm.version>7.16.0.Final</jbpm.version>
|
<jbpm.version>7.17.0.Final</jbpm.version>
|
||||||
<spring.boot.version>1.5.12.RELEASE</spring.boot.version>
|
<spring.boot.version>1.5.12.RELEASE</spring.boot.version>
|
||||||
<spring.version>4.3.16.RELEASE</spring.version>
|
<spring.version>4.3.16.RELEASE</spring.version>
|
||||||
<version.thorntail>2.2.1.Final</version.thorntail>
|
<version.thorntail>2.2.1.Final</version.thorntail>
|
||||||
|
|
|
||||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue