Start some documentation
Refactor Admin-UI Finish the "drools-framewok-uberfire-security-service" module #97
This commit is contained in:
parent
3f1187921e
commit
13bd10561b
16 changed files with 270 additions and 101 deletions
|
|
@ -51,7 +51,7 @@ public class KieRepositoryService {
|
|||
logger.info("url updateAssetSource : {}", completeurl);
|
||||
|
||||
restTemplateKiewb
|
||||
.execute(completeurl, HttpMethod.POST, requestCallback(assetSource, username, password), clientHttpResponse -> {
|
||||
.execute(completeurl, HttpMethod.PUT, requestCallback(assetSource, username, password), clientHttpResponse -> {
|
||||
String extractedResponse = null;
|
||||
if (clientHttpResponse.getBody() != null) {
|
||||
Scanner s = new Scanner(clientHttpResponse.getBody()).useDelimiter("\\A");
|
||||
|
|
@ -125,12 +125,17 @@ public class KieRepositoryService {
|
|||
});
|
||||
UserConnected userConnected = new UserConnected();
|
||||
|
||||
UserLoginInformation responseBody = response.getBody();
|
||||
|
||||
userConnected.setUserName(username);
|
||||
userConnected.setUserPassword(password);
|
||||
userConnected.setUserPassword(password);
|
||||
userConnected.getProjectResponses().addAll(responseBody.getProjects());
|
||||
userConnected.getRoles().addAll(responseBody.getRoles());
|
||||
if (response!= null) {
|
||||
UserLoginInformation responseBody = response.getBody();
|
||||
if (responseBody!= null) {
|
||||
userConnected.getProjectResponses().addAll(responseBody.getProjects());
|
||||
userConnected.getRoles().addAll(responseBody.getRoles());
|
||||
}
|
||||
}
|
||||
userConnected.setUserName(username);
|
||||
userConnected.setKieWorkbenchName(workbenchName);
|
||||
return userConnected;
|
||||
|
|
@ -152,7 +157,7 @@ public class KieRepositoryService {
|
|||
logger.info("url moteur reco : {}" , completeurl);
|
||||
ResponseEntity<UserLoginInformation> response = restTemplateKiewb
|
||||
.execute(completeurl, HttpMethod.GET, requestCallback(null, username, password), clientHttpResponse -> {
|
||||
UserLoginInformation extractedResponse = null;
|
||||
UserLoginInformation extractedResponse =null;
|
||||
if (clientHttpResponse.getBody() != null) {
|
||||
Scanner s = new Scanner(clientHttpResponse.getBody()).useDelimiter("\\A");
|
||||
String result = s.hasNext() ? s.next() : "";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package org.chtijbug.drools.console.service.model.kie;
|
||||
|
||||
public class KieConfigurationData {
|
||||
import java.io.Serializable;
|
||||
|
||||
public class KieConfigurationData implements Serializable {
|
||||
|
||||
private String kiewbUrl;
|
||||
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public class GridRuntime extends Grid<RuntimePersist> {
|
|||
branch.addValueChangeListener(e -> {
|
||||
refreshtGrid(branch.getValue(), strBranch);
|
||||
});
|
||||
versionCo.setHeader(branch);
|
||||
statusCo.setHeader(branch);
|
||||
|
||||
Grid.Column<RuntimePersist> branchCo = addColumn(runtimePersist -> runtimePersist.getStatus());
|
||||
status = new TextField(strStatus);
|
||||
|
|
@ -156,13 +156,9 @@ public class GridRuntime extends Grid<RuntimePersist> {
|
|||
urlMap.put(runtimePersist.getServerName(), runtimePersist.getServerUrl());
|
||||
RuntimePersist runtimePersist1 = runtimePersist.duplicate();
|
||||
if (projectPersist != null) {
|
||||
runtimeToShow.add(runtimePersist1);
|
||||
if (projectPersist.getServerNames().contains(runtimePersist1.getServerName())) {
|
||||
runtimeToShow.add(runtimePersist1);
|
||||
getSelectionModel().select(runtimePersist1);
|
||||
} else {
|
||||
if (projectPersist.getServerNames().size() == 0){
|
||||
runtimeToShow.add(runtimePersist1);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
runtimeToShow.add(runtimePersist1);
|
||||
|
|
|
|||
|
|
@ -17,12 +17,13 @@ import org.springframework.data.domain.PageRequest;
|
|||
import java.util.List;
|
||||
|
||||
public class ActionLogging extends VerticalLayout {
|
||||
private static String active="active";
|
||||
|
||||
private Button viewAction;
|
||||
|
||||
private TextFieldPerso transactionIdSearch;
|
||||
|
||||
private IndexerService indexerService;
|
||||
private transient IndexerService indexerService;
|
||||
|
||||
public ActionLogging(LoggingView loggingView){
|
||||
|
||||
|
|
@ -78,17 +79,17 @@ public class ActionLogging extends VerticalLayout {
|
|||
|
||||
}
|
||||
private boolean isActive(Button button){
|
||||
return button.getClassNames().contains("active");
|
||||
return button.getClassNames().contains(active);
|
||||
}
|
||||
private void removeActive(Button button) {
|
||||
|
||||
if(button.getClassNames().contains("active")){
|
||||
button.getClassNames().remove("active");
|
||||
if(button.getClassNames().contains(active)){
|
||||
button.getClassNames().remove(active);
|
||||
}
|
||||
}
|
||||
private void active(Button button){
|
||||
removeActive(viewAction);
|
||||
button.getClassNames().add("active");
|
||||
button.getClassNames().add(active);
|
||||
}
|
||||
|
||||
public Button getViewAction() {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class MenuSecondaireAssets extends HorizontalLayout {
|
|||
TemplateView templateView=new TemplateView();
|
||||
TemplatesAction templatesAction=new TemplatesAction(templateView);
|
||||
templateView.setTemplatesAction(templatesAction);
|
||||
squeletteComposant.navigate(templateView,TemplateView.pageName,templatesAction);
|
||||
squeletteComposant.navigate(templateView,TemplateView.PAGE_NAME,templatesAction);
|
||||
});
|
||||
}
|
||||
private boolean isActive(Button button){
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import org.chtijbug.drools.console.view.LoggingView;
|
|||
|
||||
@StyleSheet("css/accueil.css")
|
||||
public class MenuSecondaireLogging extends HorizontalLayout {
|
||||
private static String active="active";
|
||||
|
||||
private Button logging;
|
||||
|
||||
|
|
@ -30,23 +31,23 @@ public class MenuSecondaireLogging extends HorizontalLayout {
|
|||
|
||||
ActionLogging actionLogging=new ActionLogging(loggingView);
|
||||
loggingView.setActionLogging(actionLogging);
|
||||
squeletteComposant.navigate(loggingView,LoggingView.pageName,actionLogging);
|
||||
squeletteComposant.navigate(loggingView,LoggingView.PAGE_NAME,actionLogging);
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isActive(Button button){
|
||||
return button.getClassNames().contains("active");
|
||||
return button.getClassNames().contains(active);
|
||||
}
|
||||
private void removeActive(Button button) {
|
||||
|
||||
if(button.getClassNames().contains("active")){
|
||||
button.getClassNames().remove("active");
|
||||
if(button.getClassNames().contains(active)){
|
||||
button.getClassNames().remove(active);
|
||||
}
|
||||
}
|
||||
private void active(Button button){
|
||||
removeActive(logging);
|
||||
|
||||
button.getClassNames().add("active");
|
||||
button.getClassNames().add(active);
|
||||
}
|
||||
|
||||
public Button getLogging() {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import org.chtijbug.drools.console.vaadincomponent.leftMenu.Action.ActionLogging
|
|||
@StyleSheet("css/accueil.css")
|
||||
public class LoggingView extends VerticalLayout {
|
||||
|
||||
public static final String pageName="Logging";
|
||||
public static final String PAGE_NAME = "Logging";
|
||||
|
||||
private Label title;
|
||||
|
||||
|
|
@ -17,29 +17,25 @@ public class LoggingView extends VerticalLayout {
|
|||
|
||||
private ActionLogging actionLogging;
|
||||
|
||||
public LoggingView(){
|
||||
public LoggingView() {
|
||||
|
||||
title=new Label("Logging : ");
|
||||
title = new Label("Logging : ");
|
||||
|
||||
add(title);
|
||||
|
||||
gridLogging=new GridLogging();
|
||||
gridLogging = new GridLogging();
|
||||
|
||||
add(gridLogging);
|
||||
|
||||
|
||||
gridLogging.addSelectionListener(selectionEvent -> {
|
||||
gridLogging.addSelectionListener(selectionEvent ->
|
||||
actionLogging.getViewAction().setEnabled(selectionEvent.getFirstSelectedItem().isPresent())
|
||||
|
||||
if(selectionEvent.getFirstSelectedItem().isPresent()) {
|
||||
actionLogging.getViewAction().setEnabled(true);
|
||||
}else {
|
||||
actionLogging.getViewAction().setEnabled(false);
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
public static String getPageName() {
|
||||
return pageName;
|
||||
return PAGE_NAME;
|
||||
}
|
||||
|
||||
public GridLogging getGridLogging() {
|
||||
|
|
|
|||
|
|
@ -30,19 +30,19 @@ import java.util.Set;
|
|||
@StyleSheet("css/accueil.css")
|
||||
public class TemplateView extends VerticalLayout {
|
||||
|
||||
public static final String pageName="Templates";
|
||||
public static final String PAGE_NAME = "Templates";
|
||||
|
||||
private KieConfigurationData config;
|
||||
private transient KieConfigurationData config;
|
||||
|
||||
private KieRepositoryService kieRepositoryService;
|
||||
private transient KieRepositoryService kieRepositoryService;
|
||||
|
||||
private UserConnected userConnected;
|
||||
private transient UserConnected userConnected;
|
||||
|
||||
private UserConnectedService userConnectedService;
|
||||
private transient UserConnectedService userConnectedService;
|
||||
|
||||
private UserGroupsRepository userGroupsRepository;
|
||||
private transient UserGroupsRepository userGroupsRepository;
|
||||
|
||||
private ProjectPersistService projectPersistService;
|
||||
private transient ProjectPersistService projectPersistService;
|
||||
|
||||
private ListDataProvider<Asset> dataProvider;
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ public class TemplateView extends VerticalLayout {
|
|||
|
||||
private TextField searchTemplate;
|
||||
|
||||
private ConfigurableFilterDataProvider<Asset,Void,SerializablePredicate<Asset>> filterDataProvider;
|
||||
private ConfigurableFilterDataProvider<Asset, Void, SerializablePredicate<Asset>> filterDataProvider;
|
||||
|
||||
private TemplatesAction templatesAction;
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ public class TemplateView extends VerticalLayout {
|
|||
|
||||
setClassName("template-content");
|
||||
|
||||
dataProvider=new ListDataProvider<>(new ArrayList<>());
|
||||
dataProvider = new ListDataProvider<>(new ArrayList<>());
|
||||
filterDataProvider = dataProvider.withConfigurableFilter();
|
||||
|
||||
this.kieRepositoryService = AppContext.getApplicationContext().getBean(KieRepositoryService.class);
|
||||
|
|
@ -68,31 +68,27 @@ public class TemplateView extends VerticalLayout {
|
|||
this.projectPersistService = AppContext.getApplicationContext().getBean(ProjectPersistService.class);
|
||||
this.config = AppContext.getApplicationContext().getBean(KieConfigurationData.class);
|
||||
|
||||
assetListGrid = new Grid();
|
||||
assetListGrid = new Grid<>();
|
||||
assetListGrid.setClassName("templates-grid-perso");
|
||||
assetListGrid.setSelectionMode(Grid.SelectionMode.SINGLE);
|
||||
|
||||
Grid.Column<Asset> assetColumn=assetListGrid.addColumn(asset -> asset.getTitle());
|
||||
searchTemplate=new TextField("title");
|
||||
Grid.Column<Asset> assetColumn = assetListGrid.addColumn(Asset::getTitle);
|
||||
searchTemplate = new TextField("title");
|
||||
searchTemplate.setValueChangeMode(ValueChangeMode.EAGER);
|
||||
searchTemplate.addValueChangeListener(e -> {
|
||||
refreshtGrid(searchTemplate.getValue(), "title");
|
||||
});
|
||||
searchTemplate.addValueChangeListener(e ->
|
||||
refreshtGrid(searchTemplate.getValue(), "title")
|
||||
);
|
||||
assetColumn.setHeader(searchTemplate);
|
||||
add(assetListGrid);
|
||||
|
||||
assetListGrid.addSelectionListener(selectionEvent -> {
|
||||
if(assetListGrid.getSelectedItems()==null){
|
||||
templatesAction.getEdit().setEnabled(false);
|
||||
}else {
|
||||
templatesAction.getEdit().setEnabled(true);
|
||||
}
|
||||
});
|
||||
assetListGrid.addSelectionListener(selectionEvent ->
|
||||
templatesAction.getEdit().setEnabled(assetListGrid.getSelectedItems() != null)
|
||||
);
|
||||
}
|
||||
|
||||
public void setDataProvider(ComboBox<ProjectPersist> spaceSelection){
|
||||
public void setDataProvider(ComboBox<ProjectPersist> spaceSelection) {
|
||||
ProjectPersist response = spaceSelection.getValue();
|
||||
if (response!= null) {
|
||||
if (response != null) {
|
||||
UserGroups projectGroups = userGroupsRepository.findUserGroupsByProjectPersist(response);
|
||||
String workspaceName = projectGroups.getWorkspaceUserGroup().getSpaceName();
|
||||
List<Asset> tmp = kieRepositoryService.getListAssets(config.getKiewbUrl(),
|
||||
|
|
@ -111,7 +107,7 @@ public class TemplateView extends VerticalLayout {
|
|||
filterDataProvider = dataProvider.withConfigurableFilter();
|
||||
assetListGrid.setDataProvider(filterDataProvider);
|
||||
reinitFilter();
|
||||
}else{
|
||||
} else {
|
||||
List<Asset> result = new ArrayList<>();
|
||||
dataProvider = new ListDataProvider<>(result);
|
||||
filterDataProvider = dataProvider.withConfigurableFilter();
|
||||
|
|
@ -123,17 +119,17 @@ public class TemplateView extends VerticalLayout {
|
|||
public void refreshList(ComboBox<ProjectPersist> spaceSelection) {
|
||||
spaceSelection.setItems(projectPersistService.findProjectsConnectedUser().values());
|
||||
}
|
||||
public void edit(ComboBox<ProjectPersist> spaceSelection){
|
||||
|
||||
public void edit(ComboBox<ProjectPersist> spaceSelection) {
|
||||
Set<Asset> selectedElements = assetListGrid.getSelectedItems();
|
||||
if (selectedElements.toArray().length > 0) {
|
||||
Optional<Asset> assetOptional = selectedElements.stream().findFirst();
|
||||
if (assetOptional.isPresent()) {
|
||||
String assetName = assetOptional.get().getTitle();
|
||||
if (assetName != null) {
|
||||
//latformProjectData response = spaceSelection.getValue();
|
||||
userConnectedService.addAssetToSession(assetName);
|
||||
UserGroups projectGroups = userGroupsRepository.findUserGroupsByProjectPersist(spaceSelection.getValue());
|
||||
String workspaceName=projectGroups.getWorkspaceUserGroup().getSpaceName();
|
||||
String workspaceName = projectGroups.getWorkspaceUserGroup().getSpaceName();
|
||||
userConnectedService.addProjectToSession(projectGroups.getProjectName());
|
||||
userConnectedService.addSpaceToSession(workspaceName);
|
||||
DialogPerso dialog = new DialogPerso();
|
||||
|
|
@ -144,16 +140,18 @@ public class TemplateView extends VerticalLayout {
|
|||
}
|
||||
}
|
||||
}
|
||||
private void refreshtGrid(String value,String type){
|
||||
|
||||
filterDataProvider.setFilter(filterGrid(value.toUpperCase(),type));
|
||||
private void refreshtGrid(String value, String type) {
|
||||
|
||||
filterDataProvider.setFilter(filterGrid(value.toUpperCase(), type));
|
||||
assetListGrid.getDataProvider().refreshAll();
|
||||
}
|
||||
private SerializablePredicate<Asset> filterGrid(String value, String type){
|
||||
|
||||
private SerializablePredicate<Asset> filterGrid(String value, String type) {
|
||||
SerializablePredicate<Asset> columnPredicate = null;
|
||||
if(value.equals(" ")||type.equals(" ")){
|
||||
if (value.equals(" ") || type.equals(" ")) {
|
||||
columnPredicate = asset -> (true);
|
||||
}else {
|
||||
} else {
|
||||
if (type.equals("Asset Title")) {
|
||||
columnPredicate = asset -> (asset.getTitle().contains(value));
|
||||
}
|
||||
|
|
@ -169,9 +167,11 @@ public class TemplateView extends VerticalLayout {
|
|||
this.userConnectedService = userConnectedService;
|
||||
}
|
||||
|
||||
public void duplicate(){}
|
||||
public void duplicate() {
|
||||
//NOP
|
||||
}
|
||||
|
||||
public void reinitFilter(){
|
||||
public void reinitFilter() {
|
||||
searchTemplate.setValue("");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
server.port=${port:8200}
|
||||
kie-wb.baseurl=${PYMMA_KIE_BASE_URL:http://localhost:18080/kie-wb/rest}
|
||||
kie-wb.mainwbintern=${PYMMA_KIE_MAINWBINTERN:http://localhost:8080/kie-wb}
|
||||
kie-wb.mainwbextern=${PYMMA_KIE_MAINWBEXTERN:http://localhost:8080/kie-wb}
|
||||
kie-wb.mainwbextern=${PYMMA_KIE_MAINWBEXTERN:http://localhost:18080/kie-wb}
|
||||
kie-wb.username=${PYMMA_KIE_USER:admin}
|
||||
kie-wb.password=${PYMMA_KIE_PASSWORD:admin}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@
|
|||
|
||||
package org.chtijbug.guvnor.uberfire.security;
|
||||
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.Block;
|
||||
import com.mongodb.client.FindIterable;
|
||||
import com.mongodb.client.MongoClient;
|
||||
import com.mongodb.client.MongoCollection;
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
|
|
@ -38,6 +40,8 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mongodb.client.model.Filters.eq;
|
||||
|
||||
/**
|
||||
* <p>Groups manager service provider implementation for Apache tomcat, when using default realm based on properties files.</p>
|
||||
*
|
||||
|
|
@ -85,14 +89,39 @@ public class KiePlatformRoleManager implements RoleManager, ContextualManager {
|
|||
|
||||
@Override
|
||||
public SearchResponse<Role> search(SearchRequest request) throws SecurityManagementException {
|
||||
SearchResponse<Role> roleSearchResponse = new SearchResponseImpl<>();
|
||||
return roleSearchResponse;
|
||||
MongoCollection<Document> roleCollection = database.getCollection("userRoles");
|
||||
BasicDBObject regexQuery = new BasicDBObject();
|
||||
regexQuery.put("name", new BasicDBObject("$regex", request.getSearchPattern() + ".*").append("$options", "i"));
|
||||
List<Role> roles = new ArrayList<>();
|
||||
long totalNumber = roleCollection.countDocuments(regexQuery);
|
||||
FindIterable<Document> documents = roleCollection.find(regexQuery).skip(request.getPageSize() * (request.getPage() - 1)).limit(request.getPageSize());
|
||||
documents.forEach((Block<? super Document>) document -> {
|
||||
String roleName = document.getString("name");
|
||||
Role role = new RoleImpl(roleName);
|
||||
roles.add(role);
|
||||
});
|
||||
boolean hasNextPage = true;
|
||||
if ((request.getPageSize() * (request.getPage()) > totalNumber)) {
|
||||
hasNextPage = false;
|
||||
}
|
||||
SearchResponse<Role> response = new SearchResponseImpl(roles, request.getPage(), request.getPageSize(), Long.valueOf(totalNumber).intValue(), hasNextPage);
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Role get(String identifier) throws SecurityManagementException {
|
||||
RoleImpl role = new RoleImpl(identifier);
|
||||
return role;
|
||||
MongoCollection<Document> userCollection = database.getCollection("userRoles");
|
||||
List<Role> roles = new ArrayList<>();
|
||||
userCollection.find(eq("name", identifier)).forEach((Block<? super Document>) document -> {
|
||||
String roleName = document.getString("name");
|
||||
Role role = new RoleImpl(roleName);
|
||||
roles.add(role);
|
||||
});
|
||||
if (roles.size() == 1) {
|
||||
return roles.get(0);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import com.mongodb.client.MongoCollection;
|
|||
import com.mongodb.client.MongoDatabase;
|
||||
import org.bson.Document;
|
||||
import org.bson.codecs.configuration.CodecRegistry;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.jboss.errai.security.shared.api.Group;
|
||||
import org.jboss.errai.security.shared.api.GroupImpl;
|
||||
import org.jboss.errai.security.shared.api.Role;
|
||||
|
|
@ -179,7 +178,7 @@ public class KiePlatformUserManager implements UserManager, ContextualManager {
|
|||
MongoCollection<Document> userRolesCollection = database.getCollection("userRoles");
|
||||
AtomicReference<ArrayList<DBRef>> roles = new AtomicReference<>(new ArrayList<>());
|
||||
AtomicReference<ArrayList<DBRef>> groups = new AtomicReference<>(new ArrayList<>());
|
||||
List<Document> users = new ArrayList<>();
|
||||
ArrayList<Document> users = new ArrayList<>();
|
||||
if (isCreated) {
|
||||
userCollection.find(eq("login", entity.getIdentifier())).forEach((Block<? super Document>) document -> {
|
||||
throw new SecurityManagementException("Existing identifier " + entity.getIdentifier());
|
||||
|
|
@ -211,15 +210,21 @@ public class KiePlatformUserManager implements UserManager, ContextualManager {
|
|||
roles.get().add(dbRef);
|
||||
});
|
||||
}
|
||||
Document userDocument = new Document("_id", new ObjectId());
|
||||
userDocument.append("login", entity.getIdentifier());
|
||||
userDocument.append("password", entity.getIdentifier());
|
||||
userDocument.append("userRoles", roles);
|
||||
userDocument.append("userGroups", groups);
|
||||
|
||||
if (isCreated) {
|
||||
Document userDocument = new Document();
|
||||
userDocument.append("login", entity.getIdentifier());
|
||||
userDocument.append("password", entity.getIdentifier());
|
||||
userDocument.append("userRoles", roles);
|
||||
userDocument.append("userGroups", groups);
|
||||
|
||||
userCollection.insertOne(userDocument);
|
||||
} else {
|
||||
userCollection.replaceOne(eq("login", entity.getIdentifier()), userDocument);
|
||||
userCollection.find(eq("login", entity.getIdentifier())).forEach((Block<? super Document>) document -> {
|
||||
document.append("userRoles", roles);
|
||||
document.append("userGroups", groups);
|
||||
userCollection.replaceOne(eq("login", entity.getIdentifier()), document);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@ import org.uberfire.io.IOService;
|
|||
import org.uberfire.java.nio.base.options.CommentedOption;
|
||||
import org.uberfire.java.nio.file.DirectoryStream;
|
||||
import org.uberfire.java.nio.file.Paths;
|
||||
import org.uberfire.security.authz.AuthorizationPolicy;
|
||||
import org.uberfire.security.authz.PermissionManager;
|
||||
import org.uberfire.security.impl.authz.AuthorizationPolicyBuilder;
|
||||
|
||||
import javax.enterprise.context.ApplicationScoped;
|
||||
import javax.inject.Inject;
|
||||
|
|
@ -461,4 +463,21 @@ public class PackageResource {
|
|||
}
|
||||
|
||||
}
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/auth")
|
||||
public AuthorizationPolicy getAuth() {
|
||||
|
||||
AuthorizationPolicy authorizationPolicy = this.permissionManager.getAuthorizationPolicy();
|
||||
return authorizationPolicy;
|
||||
}
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/auth2")
|
||||
public AuthorizationPolicy getAuth2() {
|
||||
AuthorizationPolicyBuilder tata = this.permissionManager.newAuthorizationPolicy();
|
||||
|
||||
AuthorizationPolicy authorizationPolicy = this.permissionManager.getAuthorizationPolicy();
|
||||
return authorizationPolicy;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class CustomMappingsProvider extends MappingsProvider {
|
|||
@Override
|
||||
public MappingProperties resolveMapping(String originUri, HttpServletRequest request) {
|
||||
|
||||
MappingProperties result = mappingPropertiesMap.get(originUri);
|
||||
MappingProperties result = mappingPropertiesMap.get(UpdateService.removeSlach(originUri));
|
||||
if (result!= null){
|
||||
return result;
|
||||
}else {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class UpdateService {
|
|||
public void store(ReverseProxyUpdate update) {
|
||||
boolean found = false;
|
||||
for (MappingProperties mappingProperties : mappingPropertiesMap.values()) {
|
||||
if (mappingProperties.getPath().equals(update.getPath())) {
|
||||
if (UpdateService.removeSlach(mappingProperties.getPath()).equals(UpdateService.removeSlach(update.getPath()))) {
|
||||
found = true;
|
||||
mappingProperties.getDestinations().clear();
|
||||
logger.info("Updating path {}",update.getPath());
|
||||
|
|
@ -69,7 +69,7 @@ public class UpdateService {
|
|||
newMappingProperties.getDestinations().add(destination);
|
||||
logger.info("for path {} adding server {} ",update.getPath(),destination);
|
||||
}
|
||||
mappingPropertiesMap.put(update.getPath(), newMappingProperties);
|
||||
mappingPropertiesMap.put(UpdateService.removeSlach(update.getPath()), newMappingProperties);
|
||||
}
|
||||
mappings.clear();
|
||||
mappings.addAll(mappingPropertiesMap.values());
|
||||
|
|
@ -81,6 +81,13 @@ public class UpdateService {
|
|||
return mappings;
|
||||
}
|
||||
|
||||
public static String removeSlach(String target){
|
||||
if (target!= null) {
|
||||
return target.replace("/", "");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void generateMappings() {
|
||||
projects.clear();
|
||||
mappingPropertiesMap.clear();
|
||||
|
|
@ -118,7 +125,7 @@ public class UpdateService {
|
|||
mappingProperties2.getCustomConfiguration().put("read", 2000);
|
||||
mappingProperties2.setStripPath(true);
|
||||
if (mappingProperties2.getDestinations().size() > 0) {
|
||||
mappingPropertiesMap.put(mappingProperties2.getPath(), mappingProperties2);
|
||||
mappingPropertiesMap.put(UpdateService.removeSlach(mappingProperties2.getPath()), mappingProperties2);
|
||||
paths.add(mappingProperties2);
|
||||
logger.info("Startup creating path {}",mappingProperties2.getPath());
|
||||
for (String serverName : mappingProperties2.getDestinations()){
|
||||
|
|
|
|||
16
readme.md
16
readme.md
|
|
@ -1,17 +1,5 @@
|
|||
|
||||
To run the platform, we ecourage you to use the docker containers build with maven
|
||||
To be able to build the docker container, active the profiles as follow
|
||||
mvn clean install -Pdev,docker-build
|
||||
|
||||
we have a docker-compose file.
|
||||
As we are using sso, you have in your /etc/hosts to add a line :
|
||||
YourHostIPnotLocalhost host.docker
|
||||
|
||||
then on the root
|
||||
docker-compose up -d
|
||||
This the Kie Platform.
|
||||
|
||||
|
||||
the workbench will be at the following url : htto://host.docker:8080/kie-wb
|
||||
|
||||
We need an ip visible from your browser when used as a callback once identified
|
||||
|
||||
[Extending the standard tooling](./wiki/Kie Platform extending standard drools Tooling.md)
|
||||
120
wiki/Kie Platform extending standard drools Tooling.md
Normal file
120
wiki/Kie Platform extending standard drools Tooling.md
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
# Kie Platform extending standard drools Tooling
|
||||
----
|
||||
## Kie standard tools
|
||||
The drools community is providing a certain numbers of tools :
|
||||
1. An api provided as a Apache Maven dependency. This is the classical approach used since drools exists
|
||||
2. An eclipse plugin to assist us in writing drools native language called « drl ». This plugin allows also to authors bpmn2 files for the jbpm library
|
||||
3. a web application called « Business Central » that allows to handle the complete lifecycle of a drools/jbpm project
|
||||
4. A runtime server, called « lie-server » that has a number of extension for standard components of the kielbasa’s community : drools, jbpm, optaplanner, etc.
|
||||
To use the kie-server there are two possibilities :
|
||||
1. use it as a standalone server
|
||||
2. link it to a business central and deploy components from the user interface
|
||||
In case 2, the connection only handles a set of kie-servers, this can be use in development mode and In case 1, you have to call the rest interfaces to start using components.
|
||||
The drools community is the the kie=knowledge is everything and has its own we site : [http://kie.org/][1]
|
||||
And by visiting it, you can see that there fours parts :
|
||||
- Kogito : it is called the next generation platform and targets the micro-profile approach by allowing to embed in your applications a cloud-native approach components that uses the
|
||||
- Quarkus : [https://quarkus.io/][2],
|
||||
- GrallVM virtual machine [https://www.graalvm.org/][3],
|
||||
- DMN notation [https://www.omg.org/dmn/][4]to model the business rules (it an OMG standard for modeling and running rules that is supported by most rule providers on the market),
|
||||
- and the DMN runtime with drools which is the reference implementation, it as a technology compatibility Kit [https://github.com/dmn-tck/tck][5]. You can see here the test results [https://dmn-tck.github.io/tck/index.html][6]and all supported and supporting tools.
|
||||
- Optaplanner : it is a constraint solver that offers an Api to use it. It uses drools as one possibility to implement business constraints.
|
||||
- Jbpm : bpmn2 implementation that allows to run Business processes.
|
||||
- Drools : rule engine that has a forward-chaining and backward-chaining inference algorithm to implement in an efficient way the business rules we want it to implement.
|
||||
Our Kie Platform is focusing exclusively on drools for the moment.
|
||||
## Apache Maven
|
||||
Starting with version 6.x of drools, Apache Maven is the only possiblility to compile and build a runtime jar for drools project (the same applies to jbpm, Optaplanner and Kogito).
|
||||
The drools compiler is provided as an Apache Maven plugin.
|
||||
A drools project is now an Apache Maven module and is adding a new packaging type: « Kjar ». This means a drools project can now be added to any other project as an Apache Maven dependency.
|
||||
The usage of standard Continuous Integration (CI) tools allows to build and deploy java applications using drools Apache Maven module/artefact :
|
||||
- git serveur to store the source code (Gitlab, Github, etc..)
|
||||
- jenkins to build the drools component
|
||||
- Nexus to store the constructed Kjar to make it available to other projects
|
||||
## Business Central
|
||||
Business Central is a web application that handles the complete lifecycle of a drools project (a maven module).
|
||||
- Authoring different rule artefact types : native drools rule, guided rules, guided rules template, Decision tables, etc..
|
||||
- multi-user management,
|
||||
- handles the history of all modifications using git behind,
|
||||
- allows to define git hooks to push every modification to an outside git server, in the near future, we shall provide a git Gerrit server ([https://en.wikipedia.org/wiki/Gerrit\_(software)][7] ) that would contain all rule modules as a copy of all modification done on Business central [https://github.com/pymma/pymma-kie-platform/issues/149][8]
|
||||
- exposes each module the git repository using git/http network protocol,
|
||||
- compiles and builds rule artefacts using Apache Maven behind,
|
||||
- stores all rule Apache Maven artefacts and all dependencies in its own Apache Maven repository,
|
||||
- exposes the Apache Maven repository behind http as a normal Apache Maven repository.
|
||||
|
||||
Business Central is a complete CI tools by itself and we shall use it for that.
|
||||
We have added some rest interfaces services to our Kie Plalform Business Central version to facilitate its integration with our platform/
|
||||
## Execution Server
|
||||
As already explained, Apache Maven is used to build a Kjar file that contains all artefacts of a drools project.
|
||||
We can integrate the Kjar in an application that will use it using the standard API of drools.
|
||||
The other way is to propose a runtime that can dynamically build and expose a Kjar. This is done out of the box by the KieServer proposed by the community as a standard Execution Server.
|
||||
The rest KieServer extension proposed by the community has the same interface as the API. You have to insert object by object, ask for fireallrules and all is then transmitted to the KieServer in JSON format. On the other side, all is unmarshall and transformed in java instances.
|
||||
If you have an instance A related to B and you transmit A and the B.
|
||||
The sequence is
|
||||
1. Insert A,
|
||||
2. Insert B that is an attribute of A ,
|
||||
3. execute fireAllrules.
|
||||
The JSON message will contain something like this :
|
||||
{ "commands":[
|
||||
{
|
||||
"insert":{
|
||||
"out-identifier":"CLASSA",
|
||||
"return-object":"true",
|
||||
"object": {
|
||||
"CLASSB":{
|
||||
"name" : "heron"
|
||||
|
||||
}
|
||||
},
|
||||
"insert":{
|
||||
"out-identifier":"CLASSB",
|
||||
"return-object":"true",
|
||||
"object": {
|
||||
"name" : "heron"
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"fire-all-rules":""
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
On the server side,
|
||||
1. instance A will be created with its attribute B and inserted to the working memory. This new A instance will be created with a B instance that is not inserted.
|
||||
2. Instance B will be created and inserted in the working memory.
|
||||
3. fireallrules command will be executed
|
||||
You can see here that when un-marshaling on the other side, there are going to be two instances of CLASSB.
|
||||
If some rules are using the relation between A and B, here the Object CLASSA has a relation with CLASSB but not for drools as another instance of CLASSB will be inserted which is not the instances linked to the object CLASSA.
|
||||
## Service Approach for execution server
|
||||
The standard rest interface obliges the client to insert one by one the java instances to insert into the drools runtime session.
|
||||
To avoid this, another approach is :
|
||||
1. use a service approach with java class as the top transmitted object
|
||||
2. insert all connected instance by reflection following all get/set object and Lists
|
||||
3. start a jbpm rule flow if needed
|
||||
4. we shall define an end point like follows :
|
||||
1. per project and branch
|
||||
2. a process to start (if needed)
|
||||
3. the top class to expose.
|
||||
In our Kie Platform our execution server exposes endpoint like this.
|
||||
## Missing features
|
||||
### logging rule execution
|
||||
The API proposed by drools allows the add callbacks to see what is happening in the engine during its execution.
|
||||
For many business areas, traceability is key feature that is mandatory. Our platform is offering that functionality : traceability and storing of all execution request. Over the user interface, it is possible to get details of all rule executed, fact inserted/updated/retracted and rule flow executions.
|
||||
### Logging deployment history
|
||||
In a production system, each time a deployment is done, informations about should be stored : date, time and git commit ID. It is then possible to create a branch with git from that commit and deploy that precise version. Within the logging feature, the Kie platform shall memorize the commit id of each Apache Maven artefact used to produce the logging.
|
||||
[errer]()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[1]: http://kie.org/
|
||||
[2]: https://quarkus.io/
|
||||
[3]: https://www.graalvm.org/
|
||||
[4]: https://www.omg.org/dmn/
|
||||
[5]: https://github.com/dmn-tck/tck
|
||||
[6]: https://dmn-tck.github.io/tck/index.html
|
||||
[7]: https://en.wikipedia.org/wiki/Gerrit_(software)
|
||||
[8]: https://github.com/pymma/pymma-kie-platform/issues/149
|
||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue