You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by md...@apache.org on 2020/03/15 18:35:17 UTC
[syncope] branch 2_1_X updated: [SYNCOPE-1548] Better management
This is an automated email from the ASF dual-hosted git repository.
mdisabatino pushed a commit to branch 2_1_X
in repository https://gitbox.apache.org/repos/asf/syncope.git
The following commit(s) were added to refs/heads/2_1_X by this push:
new cc80886 [SYNCOPE-1548] Better management
cc80886 is described below
commit cc80886824f0b6ce66f2cf3c123e013cd4a74141
Author: Marco Di Sabatino Di Diodoro <ma...@tirasa.net>
AuthorDate: Sun Mar 15 17:24:42 2020 +0100
[SYNCOPE-1548] Better management
---
.../client/console/wizards/any/AbstractGroups.java | 78 ++++++++++++++++++++++
.../syncope/client/console/wizards/any/Groups.java | 72 +++++++-------------
2 files changed, 102 insertions(+), 48 deletions(-)
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AbstractGroups.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AbstractGroups.java
new file mode 100644
index 0000000..0ee9e7f
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AbstractGroups.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.wizards.any;
+
+import org.apache.commons.collections4.ListUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.client.console.wicket.ajax.markup.html.LabelInfo;
+import org.apache.syncope.common.lib.to.AnyTO;
+import org.apache.wicket.extensions.wizard.WizardStep;
+import org.apache.wicket.extensions.wizard.WizardModel.ICondition;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
+
+public abstract class AbstractGroups extends WizardStep implements ICondition {
+
+ private static final long serialVersionUID = -5211384197382796059L;
+
+ protected final AnyTO anyTO;
+
+ protected WebMarkupContainer dyngroupsContainer;
+
+ protected WebMarkupContainer dynrealmsContainer;
+
+ protected WebMarkupContainer groupsContainer;
+
+ public <T extends AnyTO> AbstractGroups(final AnyWrapper<T> modelObject) {
+ super();
+ this.anyTO = modelObject.getInnerObject();
+
+ setOutputMarkupId(true);
+
+ groupsContainer = new WebMarkupContainer("groupsContainer");
+ groupsContainer.setOutputMarkupId(true);
+ groupsContainer.setOutputMarkupPlaceholderTag(true);
+ add(groupsContainer);
+
+ // ------------------
+ // insert changed label if needed
+ // ------------------
+ if (modelObject instanceof UserWrapper
+ && UserWrapper.class.cast(modelObject).getPreviousUserTO() != null
+ && !ListUtils.isEqualList(
+ UserWrapper.class.cast(modelObject).getInnerObject().getMemberships(),
+ UserWrapper.class.cast(modelObject).getPreviousUserTO().getMemberships())) {
+ groupsContainer.add(new LabelInfo("changed", StringUtils.EMPTY));
+ } else {
+ groupsContainer.add(new Label("changed", StringUtils.EMPTY));
+ }
+ // ------------------
+ }
+
+ protected abstract void addGroupsPanel();
+
+ protected abstract void addDynamicRealmsContainer();
+
+ protected abstract void addDynamicGroupsContainer();
+
+ @Override
+ public boolean evaluate() {
+ return true;
+ }
+}
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 6caed6b..dd94e98 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
@@ -24,7 +24,6 @@ import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
-import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.cxf.jaxrs.ext.search.client.CompleteCondition;
import org.apache.syncope.client.console.SyncopeConsoleApplication;
@@ -32,7 +31,6 @@ import org.apache.syncope.client.console.SyncopeConsoleSession;
import org.apache.syncope.client.console.commons.Constants;
import org.apache.syncope.client.console.rest.DynRealmRestClient;
import org.apache.syncope.client.console.rest.GroupRestClient;
-import org.apache.syncope.client.console.wicket.ajax.markup.html.LabelInfo;
import org.apache.syncope.client.console.wicket.markup.html.form.AjaxPalettePanel;
import org.apache.syncope.client.lib.SyncopeClient;
import org.apache.syncope.common.lib.SyncopeConstants;
@@ -43,7 +41,6 @@ import org.apache.syncope.common.lib.to.EntityTO;
import org.apache.syncope.common.lib.to.GroupTO;
import org.apache.syncope.common.lib.to.MembershipTO;
import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
-import org.apache.wicket.extensions.wizard.WizardStep;
import org.apache.wicket.markup.html.form.IChoiceRenderer;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.util.ListModel;
@@ -51,18 +48,15 @@ import org.apache.syncope.common.lib.to.GroupableRelatableTO;
import org.apache.syncope.common.lib.types.StandardEntitlement;
import org.apache.wicket.authroles.authorization.strategies.role.metadata.ActionPermissions;
import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy;
-import org.apache.wicket.extensions.wizard.WizardModel.ICondition;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.PropertyModel;
-public class Groups extends WizardStep implements ICondition {
+public class Groups extends AbstractGroups {
private static final long serialVersionUID = 552437609667518888L;
- private final AnyTO anyTO;
-
- private boolean templateMode;
+ private final boolean templateMode;
protected final GroupRestClient groupRestClient = new GroupRestClient();
@@ -70,18 +64,9 @@ public class Groups extends WizardStep implements ICondition {
protected GroupsModel groupsModel;
- protected WebMarkupContainer dyngroupsContainer;
-
- protected WebMarkupContainer dynrealmsContainer;
-
- protected WebMarkupContainer groupsContainer;
-
public <T extends AnyTO> Groups(final AnyWrapper<T> modelObject, final boolean templateMode) {
- super();
+ super(modelObject);
this.templateMode = templateMode;
-
- this.anyTO = modelObject.getInnerObject();
-
groupsModel = new GroupsModel();
// -----------------------------------------------------------------
@@ -92,18 +77,13 @@ public class Groups extends WizardStep implements ICondition {
permissions.authorizeAll(RENDER);
// -----------------------------------------------------------------
- setOutputMarkupId(true);
-
- groupsContainer = new WebMarkupContainer("groupsContainer");
- groupsContainer.setOutputMarkupId(true);
- groupsContainer.setOutputMarkupPlaceholderTag(true);
- add(groupsContainer);
-
- dyngroupsContainer = new WebMarkupContainer("dyngroupsContainer");
- dyngroupsContainer.setOutputMarkupId(true);
- dyngroupsContainer.setOutputMarkupPlaceholderTag(true);
- add(dyngroupsContainer);
+ addDynamicGroupsContainer();
+ addGroupsPanel();
+ addDynamicRealmsContainer();
+ }
+ @Override
+ protected void addGroupsPanel() {
if (anyTO instanceof GroupTO) {
groupsContainer.add(new Label("groups").setVisible(false));
groupsContainer.setVisible(false);
@@ -180,9 +160,11 @@ public class Groups extends WizardStep implements ICondition {
}, new ListModel<>(groupsModel.getObject().stream().map(GroupTO::getName).collect(Collectors.toList()))).
hideLabel().setEnabled(false).setOutputMarkupId(true));
- // ---------------------------------
}
+ }
+ @Override
+ protected void addDynamicRealmsContainer() {
dynrealmsContainer = new WebMarkupContainer("dynrealmsContainer");
dynrealmsContainer.setOutputMarkupId(true);
dynrealmsContainer.setOutputMarkupPlaceholderTag(true);
@@ -191,20 +173,14 @@ public class Groups extends WizardStep implements ICondition {
new ListModel<>(allDynRealms.stream().map(EntityTO::getKey).collect(Collectors.toList()))).
hideLabel().setEnabled(false).setOutputMarkupId(true));
add(dynrealmsContainer);
+ }
- // ------------------
- // insert changed label if needed
- // ------------------
- if (modelObject instanceof UserWrapper
- && UserWrapper.class.cast(modelObject).getPreviousUserTO() != null
- && !ListUtils.isEqualList(
- UserWrapper.class.cast(modelObject).getInnerObject().getMemberships(),
- UserWrapper.class.cast(modelObject).getPreviousUserTO().getMemberships())) {
- groupsContainer.add(new LabelInfo("changed", StringUtils.EMPTY));
- } else {
- groupsContainer.add(new Label("changed", StringUtils.EMPTY));
- }
- // ------------------
+ @Override
+ protected void addDynamicGroupsContainer() {
+ dyngroupsContainer = new WebMarkupContainer("dyngroupsContainer");
+ dyngroupsContainer.setOutputMarkupId(true);
+ dyngroupsContainer.setOutputMarkupPlaceholderTag(true);
+ add(dyngroupsContainer);
}
@Override
@@ -216,7 +192,7 @@ public class Groups extends WizardStep implements ICondition {
isActionAuthorized(this, RENDER);
}
- protected class GroupsModel extends ListModel<GroupTO> {
+ public class GroupsModel extends ListModel<GroupTO> {
private static final long serialVersionUID = -4541954630939063927L;
@@ -237,7 +213,7 @@ public class Groups extends WizardStep implements ICondition {
/**
* Retrieve the first MAX_GROUP_LIST_SIZE assignable.
*/
- private void reloadObject() {
+ protected void reloadObject() {
groups = groupRestClient.search(
realm,
SyncopeClient.getGroupSearchConditionBuilder().isAssignable().query(),
@@ -255,7 +231,7 @@ public class Groups extends WizardStep implements ICondition {
/**
* Retrieve group memberships.
*/
- private void reloadMemberships() {
+ protected void reloadMemberships() {
// this is to be sure to have group names (required to see membership details in approval page)
GroupFiqlSearchConditionBuilder searchConditionBuilder = SyncopeClient.getGroupSearchConditionBuilder();
@@ -297,7 +273,7 @@ public class Groups extends WizardStep implements ICondition {
/**
* Retrieve dyn group memberships.
*/
- private void reloadDynMemberships() {
+ protected void reloadDynMemberships() {
GroupFiqlSearchConditionBuilder searchConditionBuilder = SyncopeClient.getGroupSearchConditionBuilder();
List<CompleteCondition> conditions = GroupableRelatableTO.class.cast(anyTO).getDynMemberships().
@@ -320,7 +296,7 @@ public class Groups extends WizardStep implements ICondition {
/**
* Reload data if the realm changes (see SYNCOPE-1135).
*/
- private void reload() {
+ protected void reload() {
boolean reload;
if (Groups.this.templateMode) {