You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by fm...@apache.org on 2017/05/25 12:45:35 UTC
syncope git commit: [SYNCOPE-1098] improves user and anyobject edit
by improving performance in dealing with groups and memberships
Repository: syncope
Updated Branches:
refs/heads/2_0_X a7bf2af6d -> f5f489e2b
[SYNCOPE-1098] improves user and anyobject edit by improving performance in dealing with groups and memberships
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/f5f489e2
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/f5f489e2
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/f5f489e2
Branch: refs/heads/2_0_X
Commit: f5f489e2b6fa5b7443a6a1e78c96553be7603819
Parents: a7bf2af
Author: fmartelli <fa...@gmail.com>
Authored: Thu May 25 14:45:19 2017 +0200
Committer: fmartelli <fa...@gmail.com>
Committed: Thu May 25 14:45:19 2017 +0200
----------------------------------------------------------------------
.../client/console/wizards/any/Groups.java | 62 +++++++++++++++-----
.../console/wizards/any/Groups.properties | 1 +
.../console/wizards/any/Groups_it.properties | 1 +
.../console/wizards/any/Groups_pt_BR.properties | 1 +
.../console/wizards/any/Groups_ru.properties | 1 +
5 files changed, 52 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/f5f489e2/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/Groups.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/Groups.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/Groups.java
index 1cdafc8..184f657 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/Groups.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/Groups.java
@@ -19,17 +19,18 @@
package org.apache.syncope.client.console.wizards.any;
import java.util.ArrayList;
-import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Map;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.IterableUtils;
import org.apache.commons.collections4.Predicate;
import org.apache.commons.collections4.Transformer;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.cxf.jaxrs.ext.search.client.CompleteCondition;
import org.apache.syncope.client.console.SyncopeConsoleApplication;
import org.apache.syncope.client.console.rest.GroupRestClient;
import org.apache.syncope.client.console.wicket.markup.html.form.AjaxPalettePanel;
import org.apache.syncope.client.lib.SyncopeClient;
+import org.apache.syncope.common.lib.search.GroupFiqlSearchConditionBuilder;
import org.apache.syncope.common.lib.to.AnyObjectTO;
import org.apache.syncope.common.lib.to.AnyTO;
import org.apache.syncope.common.lib.to.GroupTO;
@@ -54,6 +55,8 @@ public class Groups extends WizardStep implements ICondition {
private final List<GroupTO> allGroups;
+ private static final int MAX_GROUP_LIST_CARDINALITY = 30;
+
public <T extends AnyTO> Groups(final T anyTO, final boolean templateMode) {
super();
@@ -100,6 +103,17 @@ public class Groups extends WizardStep implements ICondition {
}
});
+ allGroups = groupRestClient.search(
+ realm,
+ SyncopeClient.getGroupSearchConditionBuilder().isAssignable().query(),
+ 1,
+ MAX_GROUP_LIST_CARDINALITY,
+ new SortParam<>("name", true),
+ null);
+
+ // ---------------------------------
+ // Retrieve group memberships
+ // ---------------------------------
add(builder.setAllowOrder(true).withFilter().build("groups",
new ListModel<>(GroupableRelatableTO.class.cast(anyTO).getMemberships()),
new AjaxPalettePanel.Builder.Query<MembershipTO>() {
@@ -109,11 +123,13 @@ public class Groups extends WizardStep implements ICondition {
@Override
public List<MembershipTO> execute(final String filter) {
return CollectionUtils.collect(
- groupRestClient.search(
+ StringUtils.isEmpty(filter) || "*".equals(filter)
+ ? allGroups
+ : groupRestClient.search(
realm,
SyncopeClient.getGroupSearchConditionBuilder().
- isAssignable().and().is("name").equalTo(filter).query(),
- -1, -1,
+ isAssignable().and().is("name").equalTo(filter).query(),
+ 1, MAX_GROUP_LIST_CARDINALITY,
new SortParam<>("name", true),
null),
new Transformer<GroupTO, MembershipTO>() {
@@ -127,20 +143,36 @@ public class Groups extends WizardStep implements ICondition {
}, new ArrayList<MembershipTO>());
}
}).hideLabel().setOutputMarkupId(true));
+ // ---------------------------------
+
+ // ---------------------------------
+ // Retrieve dyn group memberships
+ // ---------------------------------
+ final GroupFiqlSearchConditionBuilder searchConditionBuilder = SyncopeClient.getGroupSearchConditionBuilder();
- allGroups = groupRestClient.search("/", null, -1, -1, new SortParam<>("name", true), null);
+ List<CompleteCondition> conditions = new ArrayList<>();
+ for (String groupKey : GroupableRelatableTO.class.cast(anyTO).getDynGroups()) {
+ conditions.add(searchConditionBuilder.is("key").equalTo(groupKey).wrap());
+ }
- final Map<String, GroupTO> allGroupsByKey = new LinkedHashMap<>(allGroups.size());
- for (GroupTO group : allGroups) {
- allGroupsByKey.put(group.getKey(), group);
+ final List<GroupTO> dynGroups = new ArrayList<>();
+ if (!conditions.isEmpty()) {
+ dynGroups.addAll(groupRestClient.search(
+ "/",
+ searchConditionBuilder.or(conditions).query(),
+ -1,
+ -1,
+ new SortParam<>("name", true),
+ null));
}
+
add(new AjaxPalettePanel.Builder<String>().setAllowOrder(true).build("dyngroups",
- new ListModel<>(CollectionUtils.collect(GroupableRelatableTO.class.cast(anyTO).getDynGroups(),
- new Transformer<String, String>() {
+ new ListModel<>(CollectionUtils.collect(dynGroups,
+ new Transformer<GroupTO, String>() {
@Override
- public String transform(final String input) {
- return allGroupsByKey.get(input).getName();
+ public String transform(final GroupTO input) {
+ return input.getName();
}
}, new ArrayList<String>())),
new ListModel<>(CollectionUtils.collect(allGroups, new Transformer<GroupTO, String>() {
@@ -151,12 +183,14 @@ public class Groups extends WizardStep implements ICondition {
}
}, new ArrayList<String>()))).
hideLabel().setEnabled(false).setOutputMarkupId(true));
+
+ // ---------------------------------
}
@Override
public boolean evaluate() {
return CollectionUtils.isNotEmpty(allGroups)
&& SyncopeConsoleApplication.get().getSecuritySettings().getAuthorizationStrategy().
- isActionAuthorized(this, RENDER);
+ isActionAuthorized(this, RENDER);
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/f5f489e2/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Groups.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Groups.properties b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Groups.properties
index c1cf4c4..295f1ac 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Groups.properties
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Groups.properties
@@ -16,3 +16,4 @@
# under the License.
groups.palette=Groups
dyngroups.palette=Dynamic groups
+palette.available=Available (limited to the first 30 results)
http://git-wip-us.apache.org/repos/asf/syncope/blob/f5f489e2/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Groups_it.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Groups_it.properties b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Groups_it.properties
index c345f38..aa56e3c 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Groups_it.properties
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Groups_it.properties
@@ -16,3 +16,4 @@
# under the License.
groups.palette=Gruppi
dyngroups.palette=Gruppi dinamici
+palette.available=Disponibili (limitato ai primi 30 risultati)
http://git-wip-us.apache.org/repos/asf/syncope/blob/f5f489e2/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Groups_pt_BR.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Groups_pt_BR.properties b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Groups_pt_BR.properties
index b4a0d34..b058c3d 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Groups_pt_BR.properties
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Groups_pt_BR.properties
@@ -16,3 +16,4 @@
# under the License.
groups.palette=Grupos
dyngroups.palette=Grupos din\u00e2micos
+palette.available=Available (limited to the first 30 results)
http://git-wip-us.apache.org/repos/asf/syncope/blob/f5f489e2/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Groups_ru.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Groups_ru.properties b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Groups_ru.properties
index aaa3ad3..4507518 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Groups_ru.properties
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/Groups_ru.properties
@@ -17,3 +17,4 @@
#
groups.palette=\u0413\u0440\u0443\u043f\u043f\u044b
dyngroups.palette=\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0433\u0440\u0443\u043f\u043f\u044b
+palette.available=Available (limited to the first 30 results)