use of org.uberfire.ext.security.management.impl.SearchRequestImpl in project kie-wb-common by kiegroup.
the class DefaultAdminPageHelper method addSecurityPerspective.
private void addSecurityPerspective() {
if (hasAccessToPerspective(PerspectiveIds.SECURITY_MANAGEMENT)) {
adminPage.addTool("root", constants.Roles(), "fa-unlock-alt", "security", () -> {
final Command accessRoles = () -> {
Map<String, String> params = new HashMap<>();
params.put("activeTab", "RolesTab");
placeManager.goTo(new DefaultPlaceRequest(SECURITY_MANAGEMENT, params));
};
accessRoles.execute();
addAdminBreadcrumbs(SECURITY_MANAGEMENT, constants.SecurityManagement(), accessRoles);
}, command -> userSystemManager.roles((AbstractEntityManager.SearchResponse<Role> response) -> {
if (response != null) {
command.execute(response.getTotal());
}
}, (o, throwable) -> false).search(new SearchRequestImpl("", 1, 1, null)));
adminPage.addTool("root", constants.Groups(), "fa-users", "security", () -> {
final Command accessGroups = () -> {
Map<String, String> params = new HashMap<>();
params.put("activeTab", "GroupsTab");
placeManager.goTo(new DefaultPlaceRequest(SECURITY_MANAGEMENT, params));
};
accessGroups.execute();
addAdminBreadcrumbs(SECURITY_MANAGEMENT, constants.SecurityManagement(), accessGroups);
}, command -> userSystemManager.groups((AbstractEntityManager.SearchResponse<Group> response) -> {
if (response != null) {
command.execute(response.getTotal());
}
}, (o, throwable) -> false).search(new SearchRequestImpl("", 1, 1, null)));
adminPage.addTool("root", constants.Users(), "fa-user", "security", () -> {
final Command accessUsers = () -> {
Map<String, String> params = new HashMap<>();
params.put("activeTab", "UsersTab");
placeManager.goTo(new DefaultPlaceRequest(SECURITY_MANAGEMENT, params));
};
accessUsers.execute();
addAdminBreadcrumbs(SECURITY_MANAGEMENT, constants.SecurityManagement(), accessUsers);
}, command -> userSystemManager.users((AbstractEntityManager.SearchResponse<User> response) -> {
if (response != null) {
command.execute(response.getTotal());
}
}, (o, throwable) -> false).search(new SearchRequestImpl("", 1, 1, null)));
}
}
use of org.uberfire.ext.security.management.impl.SearchRequestImpl in project kie-wb-common by kiegroup.
the class AssigneeLiveSearchServiceTest method testSearchSingleUser.
@Test
public void testSearchSingleUser() {
assigneeLiveSearchService.init(AssigneeType.USER);
assigneeLiveSearchService.searchEntry("user", callback);
ArgumentCaptor<SearchRequestImpl> requestArgumentCaptor = ArgumentCaptor.forClass(SearchRequestImpl.class);
verify(userManager).search(requestArgumentCaptor.capture());
SearchRequestImpl request = requestArgumentCaptor.getValue();
assertEquals("user", request.getSearchPattern());
assertEquals(1, request.getPageSize());
ArgumentCaptor<RemoteCallback> callbackArgumentCaptor = ArgumentCaptor.forClass(RemoteCallback.class);
verify(userSystemManager).users(callbackArgumentCaptor.capture(), any());
RemoteCallback<AbstractEntityManager.SearchResponse<?>> successCallback = callbackArgumentCaptor.getValue();
successCallback.callback(prepareSingleUserResponse());
ArgumentCaptor<LiveSearchResults> resultsArgumentCaptor = ArgumentCaptor.forClass(LiveSearchResults.class);
verify(callback).afterSearch(resultsArgumentCaptor.capture());
LiveSearchResults<LiveSearchEntry<String>> result = resultsArgumentCaptor.getValue();
assertEquals(1, result.size());
assertEquals("user", result.get(0).getValue());
}
use of org.uberfire.ext.security.management.impl.SearchRequestImpl in project kie-wb-common by kiegroup.
the class AssigneeLiveSearchServiceTest method testSearchSingleGroup.
@Test
public void testSearchSingleGroup() {
assigneeLiveSearchService.init(AssigneeType.GROUP);
assigneeLiveSearchService.searchEntry("it", callback);
ArgumentCaptor<SearchRequestImpl> requestArgumentCaptor = ArgumentCaptor.forClass(SearchRequestImpl.class);
verify(groupManager).search(requestArgumentCaptor.capture());
SearchRequestImpl request = requestArgumentCaptor.getValue();
assertEquals("it", request.getSearchPattern());
assertEquals(1, request.getPageSize());
ArgumentCaptor<RemoteCallback> callbackArgumentCaptor = ArgumentCaptor.forClass(RemoteCallback.class);
verify(userSystemManager).groups(callbackArgumentCaptor.capture(), any());
RemoteCallback<AbstractEntityManager.SearchResponse<?>> successCallback = callbackArgumentCaptor.getValue();
successCallback.callback(prepareSingleGroupResponse());
ArgumentCaptor<LiveSearchResults> resultsArgumentCaptor = ArgumentCaptor.forClass(LiveSearchResults.class);
verify(callback).afterSearch(resultsArgumentCaptor.capture());
LiveSearchResults<LiveSearchEntry<String>> result = resultsArgumentCaptor.getValue();
assertEquals(1, result.size());
assertEquals("it", result.get(0).getValue());
}
use of org.uberfire.ext.security.management.impl.SearchRequestImpl in project kie-wb-common by kiegroup.
the class AssigneeLiveSearchService method search.
@Override
public void search(final String pattern, final int maxResults, final LiveSearchCallback<String> callback) {
final List<String> filteredCustomEntries;
if (pattern == null || pattern.isEmpty()) {
filteredCustomEntries = customEntries;
} else {
filteredCustomEntries = customEntries.stream().filter(entry -> entry.contains(pattern)).collect(Collectors.toList());
}
RemoteCallback<AbstractEntityManager.SearchResponse<?>> searchResponseRemoteCallback = response -> processFilterResponse(response, filteredCustomEntries, maxResults, callback);
ErrorCallback<Message> searchErrorCallback = (message, throwable) -> processError(callback);
SearchRequestImpl request = new SearchRequestImpl(pattern, 1, maxResults);
if (AssigneeType.USER.equals(type)) {
userSystemManager.users(searchResponseRemoteCallback, searchErrorCallback).search(request);
} else {
userSystemManager.groups(searchResponseRemoteCallback, searchErrorCallback).search(request);
}
}
use of org.uberfire.ext.security.management.impl.SearchRequestImpl in project kie-wb-common by kiegroup.
the class AssigneeLiveSearchService method searchEntry.
@Override
public void searchEntry(String key, LiveSearchCallback<String> callback) {
SearchRequestImpl request = new SearchRequestImpl(key, 1, 1);
ErrorCallback<Message> searchErrorCallback = (message, throwable) -> processError(callback);
RemoteCallback<AbstractEntityManager.SearchResponse<?>> searchResponseRemoteCallback = response -> searchEntry(key, response, callback);
if (AssigneeType.USER.equals(type)) {
userSystemManager.users(searchResponseRemoteCallback, searchErrorCallback).search(request);
} else {
userSystemManager.groups(searchResponseRemoteCallback, searchErrorCallback).search(request);
}
}
Aggregations