work on login module
This commit is contained in:
parent
760ae20f49
commit
6c625e1edb
12 changed files with 151 additions and 46 deletions
|
|
@ -246,6 +246,25 @@ services:
|
||||||
command: mongod
|
command: mongod
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
|
kafka_manager:
|
||||||
|
image: hlebalbau/kafka-manager:stable
|
||||||
|
ports:
|
||||||
|
- "9000:9000"
|
||||||
|
hostname: kafka_manager.pymma
|
||||||
|
networks:
|
||||||
|
drools-network-dev:
|
||||||
|
ipv4_address: 172.27.1.89
|
||||||
|
links:
|
||||||
|
- zoo1:zoo1
|
||||||
|
- zoo2:zoo2
|
||||||
|
- zoo3:zoo3
|
||||||
|
environment:
|
||||||
|
ZK_HOSTS: "zoo1:2181, zoo2:2182, zoo3:2183"
|
||||||
|
KAFKA_MANAGER_AUTH_ENABLED: "true"
|
||||||
|
KAFKA_MANAGER_USERNAME: admin
|
||||||
|
KAFKA_MANAGER_PASSWORD: adminpymma
|
||||||
|
command: -Dpidfile.path=/dev/null
|
||||||
|
|
||||||
zoo1:
|
zoo1:
|
||||||
image: zookeeper:3.4.9
|
image: zookeeper:3.4.9
|
||||||
hostname: zoo1
|
hostname: zoo1
|
||||||
|
|
|
||||||
|
|
@ -68,12 +68,11 @@
|
||||||
<version>1</version>
|
<version>1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--dependency>
|
<dependency>
|
||||||
<groupId>org.mongodb</groupId>
|
<groupId>org.mongodb</groupId>
|
||||||
<artifactId>mongodb-driver</artifactId>
|
<artifactId>mongodb-driver</artifactId>
|
||||||
<version>${version.mongodb.driver}</version>
|
<version>${version.mongodb.driver}</version>
|
||||||
<scope>provided</scope>
|
</dependency>
|
||||||
</dependency-->
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
package org.chtijbug.guvnor.uberfire.security;
|
package org.chtijbug.guvnor.uberfire.security;
|
||||||
|
|
||||||
|
import com.mongodb.client.MongoClient;
|
||||||
|
import com.mongodb.client.MongoDatabase;
|
||||||
|
import org.bson.codecs.configuration.CodecRegistry;
|
||||||
import org.jboss.errai.security.shared.api.Group;
|
import org.jboss.errai.security.shared.api.Group;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
@ -45,6 +48,11 @@ public class KiePlatformGroupManager implements GroupManager, ContextualManager
|
||||||
|
|
||||||
IdentifierRuntimeSearchEngine<Group> groupsSearchEngine;
|
IdentifierRuntimeSearchEngine<Group> groupsSearchEngine;
|
||||||
|
|
||||||
|
private MongoClient mongoClient;
|
||||||
|
private CodecRegistry pojoCodecRegistry;
|
||||||
|
private MongoDatabase database;
|
||||||
|
|
||||||
|
|
||||||
public KiePlatformGroupManager() {
|
public KiePlatformGroupManager() {
|
||||||
this(new ConfigProperties(System.getProperties()));
|
this(new ConfigProperties(System.getProperties()));
|
||||||
}
|
}
|
||||||
|
|
@ -58,6 +66,12 @@ public class KiePlatformGroupManager implements GroupManager, ContextualManager
|
||||||
// loadConfig(gitPrefs);
|
// loadConfig(gitPrefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMongo (MongoClient mongoClient,CodecRegistry pojoCodecRegistry,MongoDatabase database){
|
||||||
|
this.mongoClient=mongoClient;
|
||||||
|
this.pojoCodecRegistry = pojoCodecRegistry;
|
||||||
|
this.database=database;
|
||||||
|
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void initialize(UserSystemManager userSystemManager) throws Exception {
|
public void initialize(UserSystemManager userSystemManager) throws Exception {
|
||||||
groupsSearchEngine = new GroupsIdentifierRuntimeSearchEngine();
|
groupsSearchEngine = new GroupsIdentifierRuntimeSearchEngine();
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2016 Red Hat, Inc. and/or its affiliates.
|
* Copyright 2016 Red Hat, Inc. and/or its affiliates.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
|
@ -16,52 +16,65 @@
|
||||||
|
|
||||||
package org.chtijbug.guvnor.uberfire.security;
|
package org.chtijbug.guvnor.uberfire.security;
|
||||||
|
|
||||||
import org.jboss.errai.security.shared.api.Group;
|
import com.mongodb.Block;
|
||||||
|
import com.mongodb.client.MongoClient;
|
||||||
|
import com.mongodb.client.MongoCollection;
|
||||||
|
import com.mongodb.client.MongoDatabase;
|
||||||
|
import org.bson.Document;
|
||||||
|
import org.bson.codecs.configuration.CodecRegistry;
|
||||||
import org.jboss.errai.security.shared.api.Role;
|
import org.jboss.errai.security.shared.api.Role;
|
||||||
|
import org.jboss.errai.security.shared.api.RoleImpl;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.uberfire.commons.config.ConfigProperties;
|
import org.uberfire.commons.config.ConfigProperties;
|
||||||
import org.uberfire.ext.security.management.api.*;
|
import org.uberfire.ext.security.management.api.*;
|
||||||
import org.uberfire.ext.security.management.api.exception.SecurityManagementException;
|
import org.uberfire.ext.security.management.api.exception.SecurityManagementException;
|
||||||
import org.uberfire.ext.security.management.api.exception.UnsupportedServiceCapabilityException;
|
|
||||||
import org.uberfire.ext.security.management.impl.RoleManagerSettingsImpl;
|
import org.uberfire.ext.security.management.impl.RoleManagerSettingsImpl;
|
||||||
import org.uberfire.ext.security.management.search.GroupsIdentifierRuntimeSearchEngine;
|
import org.uberfire.ext.security.management.impl.SearchResponseImpl;
|
||||||
import org.uberfire.ext.security.management.search.IdentifierRuntimeSearchEngine;
|
|
||||||
import org.uberfire.ext.security.management.util.SecurityManagementUtils;
|
import org.uberfire.ext.security.management.util.SecurityManagementUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Groups manager service provider implementation for Apache tomcat, when using default realm based on properties files.</p>
|
* <p>Groups manager service provider implementation for Apache tomcat, when using default realm based on properties files.</p>
|
||||||
|
*
|
||||||
* @since 0.8.0
|
* @since 0.8.0
|
||||||
*/
|
*/
|
||||||
public class KiePlatformRoleManager implements RoleManager,ContextualManager {
|
public class KiePlatformRoleManager implements RoleManager, ContextualManager {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(KiePlatformRoleManager.class);
|
private static final Logger LOG = LoggerFactory.getLogger(KiePlatformRoleManager.class);
|
||||||
|
|
||||||
|
|
||||||
|
private MongoClient mongoClient;
|
||||||
IdentifierRuntimeSearchEngine<Group> groupsSearchEngine;
|
private CodecRegistry pojoCodecRegistry;
|
||||||
|
private MongoDatabase database;
|
||||||
|
|
||||||
public KiePlatformRoleManager() {
|
public KiePlatformRoleManager() {
|
||||||
this(new ConfigProperties(System.getProperties()));
|
this(new ConfigProperties(System.getProperties()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public KiePlatformRoleManager(final Map<String, String> gitPrefs) {
|
public KiePlatformRoleManager(final Map<String, String> gitPrefs) {
|
||||||
this(new ConfigProperties(gitPrefs));
|
this(new ConfigProperties(gitPrefs));
|
||||||
}
|
}
|
||||||
|
|
||||||
public KiePlatformRoleManager(final ConfigProperties gitPrefs) {
|
public KiePlatformRoleManager(final ConfigProperties gitPrefs) {
|
||||||
// loadConfig(gitPrefs);
|
// loadConfig(gitPrefs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMongo(MongoClient mongoClient, CodecRegistry pojoCodecRegistry, MongoDatabase database) {
|
||||||
|
this.mongoClient = mongoClient;
|
||||||
|
this.pojoCodecRegistry = pojoCodecRegistry;
|
||||||
|
this.database = database;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(UserSystemManager userSystemManager) throws Exception {
|
public void initialize(UserSystemManager userSystemManager) throws Exception {
|
||||||
groupsSearchEngine = new GroupsIdentifierRuntimeSearchEngine();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -72,48 +85,58 @@ public class KiePlatformRoleManager implements RoleManager,ContextualManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SearchResponse<Role> search(SearchRequest request) throws SecurityManagementException {
|
public SearchResponse<Role> search(SearchRequest request) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_SEARCH_ROLES);
|
SearchResponse<Role> roleSearchResponse = new SearchResponseImpl<>();
|
||||||
|
return roleSearchResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Role get(String identifier) throws SecurityManagementException {
|
public Role get(String identifier) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_READ_ROLE);
|
RoleImpl role = new RoleImpl(identifier);
|
||||||
|
return role;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Role> getAll() throws SecurityManagementException {
|
public List<Role> getAll() throws SecurityManagementException {
|
||||||
return null;
|
|
||||||
|
MongoCollection<Document> userRolesCollection = database.getCollection("userRoles");
|
||||||
|
List<Role> roles = new ArrayList<>();
|
||||||
|
userRolesCollection.find().forEach((Block<? super Document>) document -> {
|
||||||
|
String roleName = document.getString("name");
|
||||||
|
RoleImpl role = new RoleImpl(roleName);
|
||||||
|
roles.add(role);
|
||||||
|
});
|
||||||
|
|
||||||
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Role create(Role entity) throws SecurityManagementException {
|
public Role create(Role entity) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_ADD_ROLE);
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Role update(Role entity) throws SecurityManagementException {
|
public Role update(Role entity) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_UPDATE_ROLE);
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(String... identifiers) throws SecurityManagementException {
|
public void delete(String... identifiers) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_DELETE_ROLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleManagerSettings getSettings() {
|
public RoleManagerSettings getSettings() {
|
||||||
final Map<Capability, CapabilityStatus> capabilityStatusMap = new HashMap<Capability, CapabilityStatus>(8);
|
final Map<Capability, CapabilityStatus> capabilityStatusMap = new HashMap<>(8);
|
||||||
for (final Capability capability : SecurityManagementUtils.ROLES_CAPABILITIES) {
|
for (final Capability capability : SecurityManagementUtils.ROLES_CAPABILITIES) {
|
||||||
capabilityStatusMap.put(capability,
|
capabilityStatusMap.put(capability,
|
||||||
getCapabilityStatus(capability));
|
getCapabilityStatus(capability));
|
||||||
}
|
}
|
||||||
return new RoleManagerSettingsImpl(capabilityStatusMap);
|
return new RoleManagerSettingsImpl(capabilityStatusMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CapabilityStatus getCapabilityStatus(Capability capability) {
|
protected CapabilityStatus getCapabilityStatus(Capability capability) {
|
||||||
/**
|
|
||||||
if (capability != null) {
|
if (capability != null) {
|
||||||
switch (capability) {
|
switch (capability) {
|
||||||
case CAN_SEARCH_ROLES:
|
case CAN_SEARCH_ROLES:
|
||||||
|
|
@ -124,7 +147,7 @@ public class KiePlatformRoleManager implements RoleManager,ContextualManager {
|
||||||
return CapabilityStatus.ENABLED;
|
return CapabilityStatus.ENABLED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
**/
|
|
||||||
return CapabilityStatus.UNSUPPORTED;
|
return CapabilityStatus.UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
package org.chtijbug.guvnor.uberfire.security;
|
package org.chtijbug.guvnor.uberfire.security;
|
||||||
|
|
||||||
|
|
||||||
|
import com.mongodb.MongoClientSettings;
|
||||||
|
import com.mongodb.client.MongoClient;
|
||||||
|
import com.mongodb.client.MongoClients;
|
||||||
|
import com.mongodb.client.MongoDatabase;
|
||||||
|
import org.bson.codecs.configuration.CodecRegistry;
|
||||||
|
import org.bson.codecs.pojo.PojoCodecProvider;
|
||||||
import org.uberfire.ext.security.management.api.GroupManager;
|
import org.uberfire.ext.security.management.api.GroupManager;
|
||||||
import org.uberfire.ext.security.management.api.RoleManager;
|
import org.uberfire.ext.security.management.api.RoleManager;
|
||||||
import org.uberfire.ext.security.management.api.UserManagementService;
|
import org.uberfire.ext.security.management.api.UserManagementService;
|
||||||
|
|
@ -10,6 +16,9 @@ import javax.enterprise.context.Dependent;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import static org.bson.codecs.configuration.CodecRegistries.fromProviders;
|
||||||
|
import static org.bson.codecs.configuration.CodecRegistries.fromRegistries;
|
||||||
|
|
||||||
@Dependent
|
@Dependent
|
||||||
@Named(value = "PymmaKieSecurityService")
|
@Named(value = "PymmaKieSecurityService")
|
||||||
public class KiePlatformSecurityService implements UserManagementService {
|
public class KiePlatformSecurityService implements UserManagementService {
|
||||||
|
|
@ -20,30 +29,32 @@ public class KiePlatformSecurityService implements UserManagementService {
|
||||||
|
|
||||||
private String connectionString;
|
private String connectionString;
|
||||||
private String databaseName;
|
private String databaseName;
|
||||||
// private MongoClient mongoClient;
|
private MongoClient mongoClient;
|
||||||
// private CodecRegistry pojoCodecRegistry;
|
private CodecRegistry pojoCodecRegistry;
|
||||||
//private MongoDatabase database;
|
private MongoDatabase database;
|
||||||
|
|
||||||
|
|
||||||
public KiePlatformSecurityService() {
|
|
||||||
System.out.println("KiePlatformSecurityService initialized with databaseName = " + connectionString );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public KiePlatformSecurityService(KiePlatformUserManager userManager,
|
public KiePlatformSecurityService(KiePlatformUserManager userManager,
|
||||||
KiePlatformGroupManager groupManager,
|
KiePlatformGroupManager groupManager,
|
||||||
KiePlatformRoleManager roleManager) {
|
KiePlatformRoleManager roleManager) {
|
||||||
|
//-DconnectionString=localhost:28017 -Ddatabase=businessProxyDB
|
||||||
|
|
||||||
connectionString = System.getProperty("connectionString");
|
connectionString = System.getProperty("connectionString");
|
||||||
databaseName=System.getProperty("name");
|
databaseName=System.getProperty("database");
|
||||||
System.out.println("KiePlatformSecurityService initialized with databaseName = " + connectionString );
|
System.out.println("KiePlatformSecurityService initialized with databaseName = " + connectionString );
|
||||||
//mongoClient = MongoClients.create(connectionString);
|
mongoClient = MongoClients.create(connectionString);
|
||||||
//pojoCodecRegistry = fromRegistries(MongoClientSettings.getDefaultCodecRegistry(),
|
pojoCodecRegistry = fromRegistries(MongoClientSettings.getDefaultCodecRegistry(),
|
||||||
// fromProviders(PojoCodecProvider.builder().automatic(true).build()));
|
fromProviders(PojoCodecProvider.builder().automatic(true).build()));
|
||||||
// database = mongoClient.getDatabase(databaseName).withCodecRegistry(pojoCodecRegistry);
|
database = mongoClient.getDatabase(databaseName).withCodecRegistry(pojoCodecRegistry);
|
||||||
System.out.println("All setup");
|
System.out.println("All setup");
|
||||||
this.userManager = userManager;
|
this.userManager = userManager;
|
||||||
this.groupManager = groupManager;
|
this.groupManager = groupManager;
|
||||||
this.roleManager = roleManager;
|
this.roleManager = roleManager;
|
||||||
|
this.userManager.setMongo(mongoClient,pojoCodecRegistry,database);
|
||||||
|
this.groupManager.setMongo(mongoClient,pojoCodecRegistry,database);
|
||||||
|
this.roleManager.setMongo(mongoClient,pojoCodecRegistry,database);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
package org.chtijbug.guvnor.uberfire.security;
|
package org.chtijbug.guvnor.uberfire.security;
|
||||||
|
|
||||||
|
import com.mongodb.client.MongoClient;
|
||||||
|
import com.mongodb.client.MongoDatabase;
|
||||||
|
import org.bson.codecs.configuration.CodecRegistry;
|
||||||
import org.jboss.errai.security.shared.api.identity.User;
|
import org.jboss.errai.security.shared.api.identity.User;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
@ -42,7 +45,9 @@ public class KiePlatformUserManager implements UserManager, ContextualManager {
|
||||||
UserSystemManager userSystemManager;
|
UserSystemManager userSystemManager;
|
||||||
IdentifierRuntimeSearchEngine<User> usersSearchEngine;
|
IdentifierRuntimeSearchEngine<User> usersSearchEngine;
|
||||||
|
|
||||||
|
private MongoClient mongoClient;
|
||||||
|
private CodecRegistry pojoCodecRegistry;
|
||||||
|
private MongoDatabase database;
|
||||||
|
|
||||||
public KiePlatformUserManager() {
|
public KiePlatformUserManager() {
|
||||||
this(new ConfigProperties(System.getProperties()));
|
this(new ConfigProperties(System.getProperties()));
|
||||||
|
|
@ -56,7 +61,12 @@ public class KiePlatformUserManager implements UserManager, ContextualManager {
|
||||||
//loadConfig(gitPrefs);
|
//loadConfig(gitPrefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMongo (MongoClient mongoClient,CodecRegistry pojoCodecRegistry,MongoDatabase database){
|
||||||
|
this.mongoClient=mongoClient;
|
||||||
|
this.pojoCodecRegistry = pojoCodecRegistry;
|
||||||
|
this.database=database;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(final UserSystemManager userSystemManager) throws Exception {
|
public void initialize(final UserSystemManager userSystemManager) throws Exception {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
org.jboss.weld.level=DEBUG
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
<jboss-deployment-structure>
|
||||||
|
|
||||||
|
<deployment>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<module name="com.pymmasoftware.pymma-kie-loginmodule" export="TRUE" />
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</deployment>
|
||||||
|
|
||||||
|
</jboss-deployment-structure>
|
||||||
|
|
@ -77,7 +77,7 @@
|
||||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest:2.1" level="project" />
|
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest:2.1" 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: io.github.kostaskougios:cloning:1.10.3" level="project" />
|
<orderEntry type="module" module-name="cloning" />
|
||||||
<orderEntry type="library" name="Maven: org.objenesis:objenesis:3.0.1" level="project" />
|
<orderEntry type="library" name="Maven: org.objenesis:objenesis:3.0.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.3" level="project" />
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.3" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.3" level="project" />
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.3" level="project" />
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
|
||||||
import org.springframework.kafka.core.*;
|
import org.springframework.kafka.core.*;
|
||||||
import org.springframework.kafka.support.serializer.JsonDeserializer;
|
import org.springframework.kafka.support.serializer.JsonDeserializer;
|
||||||
import org.springframework.kafka.support.serializer.JsonSerializer;
|
import org.springframework.kafka.support.serializer.JsonSerializer;
|
||||||
|
import org.springframework.kafka.transaction.KafkaTransactionManager;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
@ -104,13 +105,21 @@ public class DroolsBusinessProxyServer {
|
||||||
configProps.put(
|
configProps.put(
|
||||||
ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,
|
ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,
|
||||||
JsonSerializer.class);
|
JsonSerializer.class);
|
||||||
return new DefaultKafkaProducerFactory<>(configProps);
|
DefaultKafkaProducerFactory<String, KieContainerResponse> producer = new DefaultKafkaProducerFactory<>(configProps);
|
||||||
|
producer.transactionCapable();
|
||||||
|
producer.setTransactionIdPrefix("trans");
|
||||||
|
return producer;
|
||||||
|
}
|
||||||
|
@Bean
|
||||||
|
public KafkaTransactionManager transactionManager(ProducerFactory producerFactory) {
|
||||||
|
KafkaTransactionManager manager = new KafkaTransactionManager(producerKieContainerResponseactory());
|
||||||
|
return manager;
|
||||||
}
|
}
|
||||||
@Bean
|
@Bean
|
||||||
public KafkaTemplate<String, KieContainerResponse> kafkaKieContainerUpdateResponsableTemplate() {
|
public KafkaTemplate<String, KieContainerResponse> kafkaKieContainerUpdateResponsableTemplate() {
|
||||||
return new KafkaTemplate<>(producerKieContainerResponseactory());
|
return new KafkaTemplate<>(producerKieContainerResponseactory());
|
||||||
}
|
}
|
||||||
@Bean
|
@Bean(name="deployFinish")
|
||||||
public NewTopic actionDeployResponseTopic() {
|
public NewTopic actionDeployResponseTopic() {
|
||||||
return new NewTopic(KafkaTopicConstants.RESPONSE_DEPLOY_TOPIC, 1, (short) 1);
|
return new NewTopic(KafkaTopicConstants.RESPONSE_DEPLOY_TOPIC, 1, (short) 1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ 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.apache.camel.Route;
|
import org.apache.camel.Route;
|
||||||
|
import org.apache.kafka.clients.admin.NewTopic;
|
||||||
import org.chtijbug.drools.KieContainerResponse;
|
import org.chtijbug.drools.KieContainerResponse;
|
||||||
import org.chtijbug.drools.KieContainerUpdate;
|
import org.chtijbug.drools.KieContainerUpdate;
|
||||||
import org.chtijbug.drools.common.KafkaTopicConstants;
|
import org.chtijbug.drools.common.KafkaTopicConstants;
|
||||||
|
|
@ -40,6 +41,7 @@ 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.Qualifier;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.kafka.annotation.KafkaListener;
|
import org.springframework.kafka.annotation.KafkaListener;
|
||||||
|
|
@ -91,6 +93,10 @@ public class KieServiceCommon {
|
||||||
@Autowired
|
@Autowired
|
||||||
KafkaTemplate<String, KieContainerResponse> kafkaKieContainerUpdateResponseTemplate;
|
KafkaTemplate<String, KieContainerResponse> kafkaKieContainerUpdateResponseTemplate;
|
||||||
|
|
||||||
|
@Qualifier("deployFinish")
|
||||||
|
@Autowired
|
||||||
|
NewTopic responseTopic;
|
||||||
|
|
||||||
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
|
||||||
// this.server = KieServerLocator.getInstance();
|
// this.server = KieServerLocator.getInstance();
|
||||||
|
|
@ -333,8 +339,8 @@ public class KieServiceCommon {
|
||||||
}
|
}
|
||||||
KieContainerResponse kieContainerResponse = new KieContainerResponse();
|
KieContainerResponse kieContainerResponse = new KieContainerResponse();
|
||||||
kieContainerResponse.setStatus(KieContainerResponse.STATUS.SUCCESS);
|
kieContainerResponse.setStatus(KieContainerResponse.STATUS.SUCCESS);
|
||||||
|
kafkaKieContainerUpdateResponseTemplate.executeInTransaction(kt ->
|
||||||
kafkaKieContainerUpdateResponseTemplate.send(KafkaTopicConstants.RESPONSE_DEPLOY_TOPIC,kieContainerResponse);
|
kt.send(KafkaTopicConstants.RESPONSE_DEPLOY_TOPIC,kieContainerResponse));
|
||||||
|
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
KieContainerResponse kieContainerResponse = new KieContainerResponse();
|
KieContainerResponse kieContainerResponse = new KieContainerResponse();
|
||||||
|
|
@ -344,7 +350,9 @@ public class KieServiceCommon {
|
||||||
for (StackTraceElement stackTraceElement : e.getStackTrace()){
|
for (StackTraceElement stackTraceElement : e.getStackTrace()){
|
||||||
kieContainerResponse.getErrorMessages().add(stackTraceElement.toString());
|
kieContainerResponse.getErrorMessages().add(stackTraceElement.toString());
|
||||||
}
|
}
|
||||||
kafkaKieContainerUpdateResponseTemplate.send(KafkaTopicConstants.RESPONSE_DEPLOY_TOPIC,kieContainerResponse);
|
kafkaKieContainerUpdateResponseTemplate.executeInTransaction(kt ->
|
||||||
|
kt.send(KafkaTopicConstants.RESPONSE_DEPLOY_TOPIC,kieContainerResponse));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:2.1" level="project" />
|
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:2.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest:2.1" level="project" />
|
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest:2.1" 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: io.github.kostaskougios:cloning:1.10.3" level="project" />
|
<orderEntry type="module" module-name="cloning" />
|
||||||
<orderEntry type="library" name="Maven: org.objenesis:objenesis:3.0.1" level="project" />
|
<orderEntry type="library" name="Maven: org.objenesis:objenesis:3.0.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.3" level="project" />
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.3" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.3" level="project" />
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.3" level="project" />
|
||||||
|
|
|
||||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue