You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2016/03/31 17:29:03 UTC
[09/10] syncope git commit: [SYNCOPE-156] Internal refactoring
http://git-wip-us.apache.org/repos/asf/syncope/blob/3e8912c3/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyObjectSearchResultPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyObjectSearchResultPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyObjectSearchResultPanel.java
deleted file mode 100644
index af4dcd1..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyObjectSearchResultPanel.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * 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.panels;
-
-import java.io.Serializable;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import org.apache.commons.lang3.SerializationUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.syncope.client.console.SyncopeConsoleSession;
-import org.apache.syncope.client.console.commons.Constants;
-import org.apache.syncope.client.console.rest.AnyObjectRestClient;
-import org.apache.syncope.client.console.status.StatusModal;
-import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.ActionColumn;
-import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.AttrColumn;
-import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
-import org.apache.syncope.client.console.wicket.markup.html.form.ActionLinksPanel;
-import org.apache.syncope.client.console.wizards.AjaxWizard;
-import org.apache.syncope.client.console.wizards.WizardMgtPanel;
-import org.apache.syncope.client.console.wizards.any.AnyHandler;
-import org.apache.syncope.common.lib.SyncopeClientException;
-import org.apache.syncope.common.lib.to.AnyObjectTO;
-import org.apache.syncope.common.lib.to.AnyTypeClassTO;
-import org.apache.syncope.common.lib.types.AnyEntitlement;
-import org.apache.syncope.common.lib.types.SchemaType;
-import org.apache.syncope.common.lib.types.StandardEntitlement;
-import org.apache.wicket.PageReference;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.event.Broadcast;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
-import org.apache.wicket.model.CompoundPropertyModel;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.model.ResourceModel;
-import org.springframework.util.ReflectionUtils;
-
-public class AnyObjectSearchResultPanel extends AnySearchResultPanel<AnyObjectTO> {
-
- private static final long serialVersionUID = -1100228004207271270L;
-
- protected AnyObjectSearchResultPanel(final String id, final Builder builder) {
- super(id, builder);
- }
-
- @Override
- protected String paginatorRowsKey() {
- return Constants.PREF_ANYOBJECT_PAGINATOR_ROWS;
- }
-
- @Override
- protected List<IColumn<AnyObjectTO, String>> getColumns() {
- final List<IColumn<AnyObjectTO, String>> columns = new ArrayList<>();
-
- for (String name : prefMan.getList(
- getRequest(), String.format(Constants.PREF_ANY_OBJECT_DETAILS_VIEW, type))) {
-
- final Field field = ReflectionUtils.findField(AnyObjectTO.class, name);
-
- if (field != null && field.getType().equals(Date.class)) {
- columns.add(new PropertyColumn<AnyObjectTO, String>(new ResourceModel(name, name), name, name));
- } else {
- columns.add(new PropertyColumn<AnyObjectTO, String>(new ResourceModel(name, name), name, name));
- }
- }
-
- for (String name : prefMan.getList(
- getRequest(), String.format(Constants.PREF_ANY_OBJECT_PLAIN_ATTRS_VIEW, type))) {
-
- if (pSchemaNames.contains(name)) {
- columns.add(new AttrColumn<AnyObjectTO>(name, SchemaType.PLAIN));
- }
- }
-
- for (String name : prefMan.getList(
- getRequest(), String.format(Constants.PREF_ANY_OBJECT_DER_ATTRS_VIEW, type))) {
-
- if (dSchemaNames.contains(name)) {
- columns.add(new AttrColumn<AnyObjectTO>(name, SchemaType.DERIVED));
- }
- }
-
- // Add defaults in case of no selection
- if (columns.isEmpty()) {
- for (String name : AnyObjectDisplayAttributesModalPanel.DEFAULT_SELECTION) {
- columns.add(new PropertyColumn<AnyObjectTO, String>(new ResourceModel(name, name), name, name));
- }
-
- prefMan.setList(getRequest(), getResponse(),
- String.format(Constants.PREF_ANY_OBJECT_DETAILS_VIEW, type),
- Arrays.asList(AnyObjectDisplayAttributesModalPanel.DEFAULT_SELECTION));
- }
-
- setWindowClosedReloadCallback(displayAttributeModal);
-
- columns.add(new ActionColumn<AnyObjectTO, String>(new ResourceModel("actions")) {
-
- private static final long serialVersionUID = -3503023501954863131L;
-
- @Override
- public ActionLinksPanel<AnyObjectTO> getActions(final String componentId, final IModel<AnyObjectTO> model) {
- final ActionLinksPanel.Builder<AnyObjectTO> panel = ActionLinksPanel.builder();
-
- panel.add(new ActionLink<AnyObjectTO>() {
-
- private static final long serialVersionUID = -7978723352517770645L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) {
- final IModel<AnyHandler<AnyObjectTO>> formModel =
- new CompoundPropertyModel<>(new AnyHandler<>(model.getObject()));
- altDefaultModal.setFormModel(formModel);
-
- target.add(altDefaultModal.setContent(new StatusModal<>(
- altDefaultModal, pageRef, formModel.getObject().getInnerObject(), false)));
-
- altDefaultModal.header(new Model<>(
- getString("any.edit", new Model<>(new AnyHandler<>(model.getObject())))));
-
- altDefaultModal.show(true);
- }
- }, ActionLink.ActionType.MANAGE_RESOURCES, StandardEntitlement.USER_READ).
- add(new ActionLink<AnyObjectTO>() {
-
- private static final long serialVersionUID = -7978723352517770644L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) {
- send(AnyObjectSearchResultPanel.this, Broadcast.EXACT,
- new AjaxWizard.EditItemActionEvent<>(
- new AnyHandler<>(new AnyObjectRestClient().read(model.getObject().
- getKey())),
- target));
- }
- }, ActionLink.ActionType.EDIT, String.format("%s_%s", type, AnyEntitlement.READ)).
- add(new ActionLink<AnyObjectTO>() {
-
- private static final long serialVersionUID = -7978723352517770645L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) {
- final AnyObjectTO clone = SerializationUtils.clone(model.getObject());
- clone.setKey(0L);
- send(AnyObjectSearchResultPanel.this, Broadcast.EXACT,
- new AjaxWizard.NewItemActionEvent<>(new AnyHandler<>(clone), target));
- }
- }, ActionLink.ActionType.CLONE, StandardEntitlement.USER_CREATE).
- add(new ActionLink<AnyObjectTO>() {
-
- private static final long serialVersionUID = -7978723352517770646L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) {
- try {
- restClient.delete(model.getObject().getETagValue(), model.getObject().getKey());
- info(getString(Constants.OPERATION_SUCCEEDED));
- target.add(container);
- } catch (SyncopeClientException e) {
- LOG.error("While deleting object {}", model.getObject().getKey(), e);
- error(StringUtils.isBlank(e.getMessage())
- ? e.getClass().getName() : e.getMessage());
- }
- SyncopeConsoleSession.get().getNotificationPanel().refresh(target);
- }
- }, ActionLink.ActionType.DELETE, String.format("%s_%s", type, AnyEntitlement.DELETE));
-
- return panel.build(componentId, model.getObject());
- }
-
- @Override
- public ActionLinksPanel<Serializable> getHeader(final String componentId) {
- final ActionLinksPanel.Builder<Serializable> panel = ActionLinksPanel.builder();
-
- panel.add(new ActionLink<Serializable>() {
-
- private static final long serialVersionUID = -7978723352517770644L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
- target.add(displayAttributeModal.setContent(new AnyObjectDisplayAttributesModalPanel<>(
- displayAttributeModal, page.getPageReference(), pSchemaNames, dSchemaNames, type)));
- displayAttributeModal.addSumbitButton();
- displayAttributeModal.header(new ResourceModel("any.attr.display"));
- displayAttributeModal.show(true);
- }
- }, ActionLink.ActionType.CHANGE_VIEW, String.format("%s_%s", type, AnyEntitlement.READ)).add(
- new ActionLink<Serializable>() {
-
- private static final long serialVersionUID = -7978723352517770644L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
- if (target != null) {
- target.add(container);
- }
- }
- }, ActionLink.ActionType.RELOAD, String.format("%s_%s", type, AnyEntitlement.SEARCH));
-
- return panel.build(componentId);
- }
- }
- );
-
- return columns;
-
- }
-
- public static class Builder extends AnySearchResultPanel.Builder<AnyObjectTO> {
-
- private static final long serialVersionUID = -6828423611982275641L;
-
- public Builder(final List<AnyTypeClassTO> anyTypeClassTOs, final String type, final PageReference pageRef) {
- super(anyTypeClassTOs, new AnyObjectRestClient(), type, pageRef);
- setShowResultPage(true);
- }
-
- @Override
- protected WizardMgtPanel<AnyHandler<AnyObjectTO>> newInstance(final String id) {
- return new AnyObjectSearchResultPanel(id, this);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3e8912c3/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyPanel.java
index 3946357..57f6e42 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyPanel.java
@@ -75,7 +75,7 @@ public class AnyPanel extends Panel {
private AbstractSearchPanel searchPanel;
- private final Panel searchResultPanel;
+ private final Panel directoryPanel;
@SuppressWarnings({ "unchecked", "unchecked" })
public AnyPanel(
@@ -128,8 +128,8 @@ public class AnyPanel extends Panel {
accordion.setOutputMarkupId(true);
add(accordion);
- searchResultPanel = getSearchResultPanel("searchResult");
- add(searchResultPanel);
+ directoryPanel = getDirectoryPanel("searchResult");
+ add(directoryPanel);
// ------------------------
}
@@ -140,23 +140,23 @@ public class AnyPanel extends Panel {
switch (anyTypeTO.getKind()) {
case USER:
- UserSearchResultPanel.class.cast(AnyPanel.this.searchResultPanel).search(SearchUtils.buildFIQL(
+ UserDirectoryPanel.class.cast(AnyPanel.this.directoryPanel).search(SearchUtils.buildFIQL(
AnyPanel.this.searchPanel.getModel().getObject(),
SyncopeClient.getUserSearchConditionBuilder()), target);
break;
case GROUP:
- GroupSearchResultPanel.class.cast(AnyPanel.this.searchResultPanel).search(SearchUtils.buildFIQL(
+ GroupDirectoryPanel.class.cast(AnyPanel.this.directoryPanel).search(SearchUtils.buildFIQL(
AnyPanel.this.searchPanel.getModel().getObject(),
SyncopeClient.getGroupSearchConditionBuilder()), target);
break;
case ANY_OBJECT:
- AnyObjectSearchResultPanel.class.cast(AnyPanel.this.searchResultPanel).search(SearchUtils.buildFIQL(
+ AnyObjectDirectoryPanel.class.cast(AnyPanel.this.directoryPanel).search(SearchUtils.buildFIQL(
AnyPanel.this.searchPanel.getModel().getObject(),
SyncopeClient.getAnyObjectSearchConditionBuilder(anyTypeTO.getKey())), target);
break;
default:
}
- target.add(searchResultPanel);
+ target.add(directoryPanel);
} else {
super.onEvent(event);
}
@@ -187,7 +187,7 @@ public class AnyPanel extends Panel {
return panel;
}
- private Panel getSearchResultPanel(final String id) {
+ private Panel getDirectoryPanel(final String id) {
final Panel panel;
final String fiql;
switch (anyTypeTO.getKind()) {
@@ -195,7 +195,7 @@ public class AnyPanel extends Panel {
fiql = SyncopeClient.getUserSearchConditionBuilder().is("key").greaterThan(0).query();
final UserTO userTO = new UserTO();
userTO.setRealm(realmTO.getFullPath());
- panel = new UserSearchResultPanel.Builder(
+ panel = new UserDirectoryPanel.Builder(
anyTypeClassRestClient.list(anyTypeTO.getClasses()),
anyTypeTO.getKey(),
pageRef).setRealm(realmTO.getFullPath()).setFiltered(true).
@@ -207,7 +207,7 @@ public class AnyPanel extends Panel {
fiql = SyncopeClient.getGroupSearchConditionBuilder().is("key").greaterThan(0).query();
final GroupTO groupTO = new GroupTO();
groupTO.setRealm(realmTO.getFullPath());
- panel = new GroupSearchResultPanel.Builder(
+ panel = new GroupDirectoryPanel.Builder(
anyTypeClassRestClient.list(anyTypeTO.getClasses()),
anyTypeTO.getKey(),
pageRef).setRealm(realmTO.getFullPath()).setFiltered(true).
@@ -221,7 +221,7 @@ public class AnyPanel extends Panel {
final AnyObjectTO anyObjectTO = new AnyObjectTO();
anyObjectTO.setRealm(realmTO.getFullPath());
anyObjectTO.setType(anyTypeTO.getKey());
- panel = new AnyObjectSearchResultPanel.Builder(
+ panel = new AnyObjectDirectoryPanel.Builder(
anyTypeClassRestClient.list(anyTypeTO.getClasses()),
anyTypeTO.getKey(),
pageRef).setRealm(realmTO.getFullPath()).setFiltered(true).
http://git-wip-us.apache.org/repos/asf/syncope/blob/3e8912c3/client/console/src/main/java/org/apache/syncope/client/console/panels/AnySearchResultPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/AnySearchResultPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/AnySearchResultPanel.java
deleted file mode 100644
index 6791042..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/AnySearchResultPanel.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * 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.panels;
-
-import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.tuple.Pair;
-import org.apache.syncope.client.console.commons.AnyDataProvider;
-import org.apache.syncope.client.console.commons.SerializableTransformer;
-import org.apache.syncope.client.console.commons.status.ConnObjectWrapper;
-import org.apache.syncope.client.console.commons.status.StatusBean;
-import org.apache.syncope.client.console.rest.AbstractAnyRestClient;
-import org.apache.syncope.client.console.rest.SchemaRestClient;
-import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
-import org.apache.syncope.client.console.wizards.any.AnyHandler;
-import org.apache.syncope.client.console.wizards.any.StatusPanel;
-import org.apache.syncope.common.lib.to.AnyTO;
-import org.apache.syncope.common.lib.to.AnyTypeClassTO;
-import org.apache.syncope.common.lib.to.ConnObjectTO;
-import org.apache.syncope.common.lib.to.PropagationStatus;
-import org.apache.syncope.common.lib.to.ProvisioningResult;
-import org.apache.wicket.PageReference;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.markup.html.panel.Panel;
-import org.apache.wicket.model.util.ListModel;
-
-public abstract class AnySearchResultPanel<T extends AnyTO>
- extends AbstractSearchResultPanel<T, AnyHandler<T>, AnyDataProvider<T>, AbstractAnyRestClient<T>> {
-
- private static final long serialVersionUID = -1100228004207271270L;
-
- protected final SchemaRestClient schemaRestClient = new SchemaRestClient();
-
- protected final List<String> pSchemaNames;
-
- protected final List<String> dSchemaNames;
-
- /**
- * Filter used in case of filtered search.
- */
- protected String fiql;
-
- /**
- * Realm related to current panel.
- */
- protected final String realm;
-
- /**
- * Any type related to current panel.
- */
- protected final String type;
-
- protected AnySearchResultPanel(final String id, final Builder<T> builder) {
- super(id, builder);
- this.realm = builder.realm;
- this.type = builder.type;
- this.fiql = builder.fiql;
-
- modal.size(Modal.Size.Large);
- altDefaultModal.size(Modal.Size.Large);
-
- this.pSchemaNames = new ArrayList<>();
- for (AnyTypeClassTO anyTypeClassTO : AnySearchResultPanelBuilder.class.cast(builder).getAnyTypeClassTOs()) {
- this.pSchemaNames.addAll(anyTypeClassTO.getPlainSchemas());
- }
- this.dSchemaNames = new ArrayList<>();
- for (AnyTypeClassTO anyTypeClassTO : AnySearchResultPanelBuilder.class.cast(builder).getAnyTypeClassTOs()) {
- this.dSchemaNames.addAll(anyTypeClassTO.getDerSchemas());
- }
-
- initResultTable();
- }
-
- @Override
- protected AnyDataProvider<T> dataProvider() {
- final AnyDataProvider<T> dp = new AnyDataProvider<>(restClient, rows, filtered, realm, type);
- return dp.setFIQL(this.fiql);
- }
-
- public void search(final String fiql, final AjaxRequestTarget target) {
- this.fiql = fiql;
- dataProvider.setFIQL(fiql);
- super.search(target);
- }
-
- @Override
- protected Collection<ActionLink.ActionType> getBulkActions() {
- final List<ActionLink.ActionType> bulkActions = new ArrayList<>();
-
- bulkActions.add(ActionLink.ActionType.DELETE);
- bulkActions.add(ActionLink.ActionType.SUSPEND);
- bulkActions.add(ActionLink.ActionType.REACTIVATE);
-
- return bulkActions;
- }
-
- public interface AnySearchResultPanelBuilder extends Serializable {
-
- List<AnyTypeClassTO> getAnyTypeClassTOs();
- }
-
- public abstract static class Builder<T extends AnyTO>
- extends AbstractSearchResultPanel.Builder<T, AnyHandler<T>, AbstractAnyRestClient<T>>
- implements AnySearchResultPanelBuilder {
-
- private static final long serialVersionUID = -6828423611982275640L;
-
- /**
- * Realm related to current panel.
- */
- protected String realm = "/";
-
- /**
- * Any type related to current panel.
- */
- protected final String type;
-
- private final List<AnyTypeClassTO> anyTypeClassTOs;
-
- public Builder(
- final List<AnyTypeClassTO> anyTypeClassTOs,
- final AbstractAnyRestClient<T> restClient,
- final String type,
- final PageReference pageRef) {
-
- super(restClient, pageRef);
- this.anyTypeClassTOs = anyTypeClassTOs;
- this.type = type;
- }
-
- public Builder<T> setRealm(final String realm) {
- this.realm = realm;
- return this;
- }
-
- @Override
- public List<AnyTypeClassTO> getAnyTypeClassTOs() {
- return this.anyTypeClassTOs;
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- protected Panel customResultBody(final String panelId, final AnyHandler<T> item, final Serializable result) {
- if (!(result instanceof ProvisioningResult)) {
- throw new IllegalStateException("Unsupported result type");
- }
-
- return new StatusPanel(
- panelId,
- ((ProvisioningResult<T>) result).getAny(),
- new ListModel<>(new ArrayList<StatusBean>()),
- CollectionUtils.collect(
- ((ProvisioningResult<T>) result).getPropagationStatuses(),
- new SerializableTransformer<PropagationStatus, Pair<ConnObjectTO, ConnObjectWrapper>>() {
-
- private static final long serialVersionUID = -4931455531906427515L;
-
- @Override
- public Pair<ConnObjectTO, ConnObjectWrapper> transform(final PropagationStatus input) {
- ConnObjectTO before = input.getBeforeObj();
- ConnObjectWrapper afterObjWrapper = new ConnObjectWrapper(
- ((ProvisioningResult<T>) result).getAny(),
- input.getResource(),
- input.getAfterObj());
- return Pair.of(before, afterObjWrapper);
- }
-
- }, new ArrayList<Pair<ConnObjectTO, ConnObjectWrapper>>()),
- pageRef);
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3e8912c3/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyTypeClassesPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyTypeClassesPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyTypeClassesPanel.java
index d0f4b97..03005f9 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyTypeClassesPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyTypeClassesPanel.java
@@ -29,7 +29,7 @@ import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.client.console.SyncopeConsoleSession;
import org.apache.syncope.client.console.commons.Constants;
-import org.apache.syncope.client.console.commons.SearchableDataProvider;
+import org.apache.syncope.client.console.commons.DirectoryDataProvider;
import org.apache.syncope.client.console.commons.SortableDataProviderComparator;
import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.ActionColumn;
import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.BooleanPropertyColumn;
@@ -52,7 +52,7 @@ import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.ResourceModel;
-public class AnyTypeClassesPanel extends AbstractTypesPanel<AnyTypeClassTO, AnyTypeClassesPanel.AnyTypeClassProvider> {
+public class AnyTypeClassesPanel extends TypesDirectoryPanel<AnyTypeClassTO, AnyTypeClassesPanel.AnyTypeClassProvider> {
private static final long serialVersionUID = -2356760296223908382L;
@@ -212,7 +212,7 @@ public class AnyTypeClassesPanel extends AbstractTypesPanel<AnyTypeClassTO, AnyT
return columns;
}
- protected final class AnyTypeClassProvider extends SearchableDataProvider<AnyTypeClassTO> {
+ protected final class AnyTypeClassProvider extends DirectoryDataProvider<AnyTypeClassTO> {
private static final long serialVersionUID = -185944053385660794L;
http://git-wip-us.apache.org/repos/asf/syncope/blob/3e8912c3/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyTypesPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyTypesPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyTypesPanel.java
index 61535b4..f77654c 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyTypesPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/AnyTypesPanel.java
@@ -29,7 +29,7 @@ import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.client.console.SyncopeConsoleSession;
import org.apache.syncope.client.console.commons.Constants;
-import org.apache.syncope.client.console.commons.SearchableDataProvider;
+import org.apache.syncope.client.console.commons.DirectoryDataProvider;
import org.apache.syncope.client.console.commons.SortableDataProviderComparator;
import org.apache.syncope.client.console.panels.AnyTypesPanel.AnyTypeProvider;
import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.ActionColumn;
@@ -53,7 +53,7 @@ import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.ResourceModel;
-public class AnyTypesPanel extends AbstractTypesPanel<AnyTypeTO, AnyTypeProvider> {
+public class AnyTypesPanel extends TypesDirectoryPanel<AnyTypeTO, AnyTypeProvider> {
private static final long serialVersionUID = 3905038169553185171L;
@@ -216,7 +216,7 @@ public class AnyTypesPanel extends AbstractTypesPanel<AnyTypeTO, AnyTypeProvider
return columns;
}
- protected final class AnyTypeProvider extends SearchableDataProvider<AnyTypeTO> {
+ protected final class AnyTypeProvider extends DirectoryDataProvider<AnyTypeTO> {
private static final long serialVersionUID = -185944053385660794L;
http://git-wip-us.apache.org/repos/asf/syncope/blob/3e8912c3/client/console/src/main/java/org/apache/syncope/client/console/panels/DirectoryPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/DirectoryPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/DirectoryPanel.java
new file mode 100644
index 0000000..e4c8dad
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/DirectoryPanel.java
@@ -0,0 +1,367 @@
+/*
+ * 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.panels;
+
+import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.List;
+import org.apache.syncope.client.console.PreferenceManager;
+import org.apache.syncope.client.console.commons.Constants;
+import org.apache.syncope.client.console.commons.DirectoryDataProvider;
+import org.apache.syncope.client.console.pages.BasePage;
+import org.apache.syncope.client.console.rest.BaseRestClient;
+import org.apache.syncope.client.console.wicket.ajax.form.IndicatorAjaxFormComponentUpdatingBehavior;
+import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
+import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
+import org.apache.syncope.client.console.wizards.WizardMgtPanel;
+import org.apache.wicket.PageReference;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.event.Broadcast;
+import org.apache.wicket.event.IEvent;
+import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.form.DropDownChoice;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.model.PropertyModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class DirectoryPanel<
+ T extends Serializable, W extends Serializable, DP extends DirectoryDataProvider<T>, E extends BaseRestClient>
+ extends WizardMgtPanel<W> {
+
+ private static final long serialVersionUID = -9170191461250434024L;
+
+ protected static final Logger LOG = LoggerFactory.getLogger(DirectoryPanel.class);
+
+ /**
+ * Application preferences.
+ */
+ protected PreferenceManager prefMan = new PreferenceManager();
+
+ protected E restClient;
+
+ /**
+ * Number of rows per page.
+ */
+ protected int rows;
+
+ /**
+ * Container used to refresh table.
+ */
+ protected final WebMarkupContainer container;
+
+ /**
+ * Specify if results are about a filtered search or not. Using this attribute it is possible to use this panel to
+ * show results about user list and user search.
+ */
+ protected final boolean filtered;
+
+ private boolean checkBoxEnabled;
+
+ private boolean showPaginator;
+
+ /**
+ * Result table.
+ */
+ private AjaxDataTablePanel<T, String> resultTable;
+
+ /**
+ * Data provider used to search for users.
+ */
+ protected DP dataProvider;
+
+ /**
+ * Owner page.
+ */
+ protected final BasePage page;
+
+ protected String itemKeyFieldName = "key";
+
+ /**
+ * Create simple unfiltered search result panel.
+ * Use the available builder for powerfull configuration options.
+ *
+ * @param id panel id.
+ * @param pageRef page reference.
+ */
+ public DirectoryPanel(final String id, final PageReference pageRef) {
+ this(id, pageRef, true);
+ }
+
+ public DirectoryPanel(final String id, final PageReference pageRef, final boolean wizardInModal) {
+ this(id, new Builder<T, W, E>(null, pageRef) {
+
+ private static final long serialVersionUID = -8424727765826509309L;
+
+ @Override
+ protected WizardMgtPanel<W> newInstance(final String id) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+ }.setFiltered(false), wizardInModal);
+ setPageRef(pageRef);
+ }
+
+ protected DirectoryPanel(final String id, final Builder<T, W, E> builder) {
+ this(id, builder, true);
+ }
+
+ protected DirectoryPanel(final String id, final Builder<T, W, E> builder, final boolean wizardInModal) {
+ super(id, wizardInModal);
+ setOutputMarkupId(true);
+
+ this.page = (BasePage) builder.getPageRef().getPage();
+
+ this.filtered = builder.filtered;
+ this.checkBoxEnabled = builder.checkBoxEnabled;
+ this.showPaginator = builder.showPaginator;
+
+ this.restClient = builder.restClient;
+
+ // Container for user search result
+ container = new WebMarkupContainer("searchContainer");
+ container.setOutputMarkupId(true);
+ addInnerObject(container);
+
+ rows = prefMan.getPaginatorRows(getRequest(), paginatorRowsKey());
+
+ setWindowClosedReloadCallback(modal);
+ setWindowClosedReloadCallback(altDefaultModal);
+ setWindowClosedReloadCallback(displayAttributeModal);
+
+ altDefaultModal.size(Modal.Size.Medium);
+ displayAttributeModal.size(Modal.Size.Medium);
+ }
+
+ protected abstract DP dataProvider();
+
+ protected abstract String paginatorRowsKey();
+
+ protected abstract List<IColumn<T, String>> getColumns();
+
+ protected void initResultTable() {
+ // ---------------------------
+ // Result table initialization
+ // ---------------------------
+ updateResultTable(false);
+ // ---------------------------
+
+ // ---------------------------
+ // Rows-per-page selector
+ // ---------------------------
+ final Form<?> paginatorForm = new Form<>("paginator");
+ paginatorForm.setOutputMarkupPlaceholderTag(true);
+ paginatorForm.setVisible(showPaginator);
+ container.add(paginatorForm);
+
+ final DropDownChoice<Integer> rowsChooser = new DropDownChoice<>(
+ "rowsChooser", new PropertyModel<Integer>(this, "rows"), prefMan.getPaginatorChoices());
+
+ rowsChooser.add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
+
+ private static final long serialVersionUID = -1107858522700306810L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ prefMan.set(getRequest(), getResponse(), paginatorRowsKey(), String.valueOf(rows));
+
+ final EventDataWrapper data = new EventDataWrapper();
+ data.setTarget(target);
+ data.setRows(rows);
+
+ send(getParent(), Broadcast.BREADTH, data);
+ }
+ });
+ paginatorForm.add(rowsChooser);
+ // ---------------------------
+ }
+
+ public void search(final AjaxRequestTarget target) {
+ target.add(container);
+ }
+
+ private void updateResultTable(final boolean create) {
+ updateResultTable(create, rows);
+ }
+
+ private void updateResultTable(final boolean create, final int rows) {
+ dataProvider = dataProvider();
+
+ final int currentPage = resultTable != null
+ ? (create ? (int) resultTable.getPageCount() - 1 : (int) resultTable.getCurrentPage()) : 0;
+
+ // take care of restClient handle: maybe not useful to keep into
+ AjaxDataTablePanel.Builder<T, String> resultTableBuilder = new AjaxDataTablePanel.Builder<>(
+ dataProvider, page.getPageReference()).
+ setColumns(getColumns()).
+ setRowsPerPage(rows).
+ setBulkActions(getBulkActions(), restClient, itemKeyFieldName).
+ setContainer(container);
+
+ if (!checkBoxEnabled) {
+ resultTableBuilder.disableCheckBoxes();
+ }
+
+ resultTableCustomChanges(resultTableBuilder);
+ resultTable = resultTableBuilder.build("resultTable");
+
+ resultTable.setCurrentPage(currentPage);
+ resultTable.setOutputMarkupId(true);
+ container.addOrReplace(resultTable);
+ }
+
+ /**
+ * Caled before build. Override it to customize result table.
+ *
+ * @param resultTableBuilder result table builder.
+ */
+ protected void resultTableCustomChanges(final AjaxDataTablePanel.Builder<T, String> resultTableBuilder) {
+
+ }
+
+ public DirectoryPanel<T, W, DP, E> disableCheckBoxes() {
+ this.checkBoxEnabled = false;
+ return this;
+ }
+
+ @Override
+ public void onEvent(final IEvent<?> event) {
+ if (event.getPayload() instanceof EventDataWrapper) {
+ final EventDataWrapper data = (EventDataWrapper) event.getPayload();
+
+ if (data.getRows() < 1) {
+ updateResultTable(data.isCreate());
+ } else {
+ updateResultTable(data.isCreate(), data.getRows());
+ }
+
+ if (DirectoryPanel.this.container.isVisibleInHierarchy()) {
+ data.getTarget().add(DirectoryPanel.this.container);
+ }
+ }
+ super.onEvent(event);
+ }
+
+ protected void setWindowClosedReloadCallback(final BaseModal<?> modal) {
+ modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
+
+ private static final long serialVersionUID = 8804221891699487139L;
+
+ @Override
+ public void onClose(final AjaxRequestTarget target) {
+ modal.show(false);
+
+ final EventDataWrapper data = new EventDataWrapper();
+ data.setTarget(target);
+ data.setRows(rows);
+
+ send(getParent(), Broadcast.BREADTH, data);
+ }
+ });
+ }
+
+ public static class EventDataWrapper {
+
+ private AjaxRequestTarget target;
+
+ private boolean create;
+
+ private int rows;
+
+ public AjaxRequestTarget getTarget() {
+ return target;
+ }
+
+ public void setTarget(final AjaxRequestTarget target) {
+ this.target = target;
+ }
+
+ public boolean isCreate() {
+ return create;
+ }
+
+ public void setCreate(final boolean create) {
+ this.create = create;
+ }
+
+ public int getRows() {
+ return rows;
+ }
+
+ public void setRows(final int rows) {
+ this.rows = rows;
+ }
+ }
+
+ protected abstract Collection<ActionLink.ActionType> getBulkActions();
+
+ public abstract static class Builder<T extends Serializable, W extends Serializable, E extends BaseRestClient>
+ extends WizardMgtPanel.Builder<W> {
+
+ private static final long serialVersionUID = 5088962796986706805L;
+
+ /**
+ * Specify if results are about a filtered search or not.
+ * By using this attribute it is possible to force this panel to show results about user list and user search.
+ */
+ protected boolean filtered = false;
+
+ protected boolean checkBoxEnabled = true;
+
+ protected boolean showPaginator = true;
+
+ /**
+ * Filter used in case of filtered search.
+ */
+ protected String fiql;
+
+ protected final E restClient;
+
+ protected Builder(final E restClient, final PageReference pageRef) {
+ super(pageRef);
+ this.restClient = restClient;
+ }
+
+ public Builder<T, W, E> setFiltered(final boolean filtered) {
+ this.filtered = filtered;
+ return this;
+ }
+
+ public Builder<T, W, E> disableCheckBoxes() {
+ this.checkBoxEnabled = false;
+ return this;
+ }
+
+ public Builder<T, W, E> hidePaginator() {
+ this.showPaginator = false;
+ return this;
+ }
+
+ public Builder<T, W, E> setFiql(final String fiql) {
+ this.fiql = fiql;
+ return this;
+ }
+
+ private PageReference getPageRef() {
+ return this.pageRef;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3e8912c3/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupDirectoryPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupDirectoryPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupDirectoryPanel.java
new file mode 100644
index 0000000..29cb080
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupDirectoryPanel.java
@@ -0,0 +1,232 @@
+/*
+ * 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.panels;
+
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import org.apache.commons.lang3.SerializationUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.client.console.SyncopeConsoleSession;
+import org.apache.syncope.client.console.commons.Constants;
+import org.apache.syncope.client.console.rest.GroupRestClient;
+import org.apache.syncope.client.console.status.StatusModal;
+import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.ActionColumn;
+import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.AttrColumn;
+import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.DatePropertyColumn;
+import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
+import org.apache.syncope.client.console.wicket.markup.html.form.ActionLinksPanel;
+import org.apache.syncope.client.console.wizards.AjaxWizard;
+import org.apache.syncope.client.console.wizards.WizardMgtPanel;
+import org.apache.syncope.client.console.wizards.any.AnyHandler;
+import org.apache.syncope.client.console.wizards.any.GroupHandler;
+import org.apache.syncope.common.lib.SyncopeClientException;
+import org.apache.syncope.common.lib.to.AnyTypeClassTO;
+import org.apache.syncope.common.lib.to.GroupTO;
+import org.apache.syncope.common.lib.types.SchemaType;
+import org.apache.syncope.common.lib.types.StandardEntitlement;
+import org.apache.wicket.PageReference;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.event.Broadcast;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
+import org.apache.wicket.model.CompoundPropertyModel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.ResourceModel;
+import org.springframework.util.ReflectionUtils;
+
+public class GroupDirectoryPanel extends AnyDirectoryPanel<GroupTO> {
+
+ private static final long serialVersionUID = -1100228004207271270L;
+
+ protected GroupDirectoryPanel(final String id, final Builder builder) {
+ super(id, builder);
+ }
+
+ @Override
+ protected String paginatorRowsKey() {
+ return Constants.PREF_GROUP_PAGINATOR_ROWS;
+ }
+
+ @Override
+ protected List<IColumn<GroupTO, String>> getColumns() {
+ final List<IColumn<GroupTO, String>> columns = new ArrayList<>();
+
+ for (String name : prefMan.getList(getRequest(), Constants.PREF_GROUP_DETAILS_VIEW)) {
+ final Field field = ReflectionUtils.findField(GroupTO.class, name);
+
+ if (field != null && field.getType().equals(Date.class)) {
+ columns.add(new DatePropertyColumn<GroupTO>(new ResourceModel(name, name), name, name));
+ } else {
+ columns.add(new PropertyColumn<GroupTO, String>(new ResourceModel(name, name), name, name));
+ }
+ }
+
+ for (String name : prefMan.getList(getRequest(), Constants.PREF_GROUP_PLAIN_ATTRS_VIEW)) {
+ if (pSchemaNames.contains(name)) {
+ columns.add(new AttrColumn<GroupTO>(name, SchemaType.PLAIN));
+ }
+ }
+
+ for (String name : prefMan.getList(getRequest(), Constants.PREF_GROUP_DER_ATTRS_VIEW)) {
+ if (dSchemaNames.contains(name)) {
+ columns.add(new AttrColumn<GroupTO>(name, SchemaType.DERIVED));
+ }
+ }
+
+ // Add defaults in case of no selection
+ if (columns.isEmpty()) {
+ for (String name : GroupDisplayAttributesModalPanel.DEFAULT_SELECTION) {
+ columns.add(new PropertyColumn<GroupTO, String>(new ResourceModel(name, name), name, name));
+ }
+
+ prefMan.setList(getRequest(), getResponse(), Constants.PREF_GROUP_DETAILS_VIEW,
+ Arrays.asList(GroupDisplayAttributesModalPanel.DEFAULT_SELECTION));
+ }
+
+ setWindowClosedReloadCallback(displayAttributeModal);
+
+ columns.add(new ActionColumn<GroupTO, String>(new ResourceModel("actions")) {
+
+ private static final long serialVersionUID = -3503023501954863131L;
+
+ @Override
+ public ActionLinksPanel<GroupTO> getActions(final String componentId, final IModel<GroupTO> model) {
+ final ActionLinksPanel.Builder<GroupTO> panel = ActionLinksPanel.builder();
+
+ panel.
+ add(new ActionLink<GroupTO>() {
+
+ private static final long serialVersionUID = -7978723352517770645L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final GroupTO ignore) {
+ final IModel<AnyHandler<GroupTO>> formModel =
+ new CompoundPropertyModel<>(new AnyHandler<>(model.getObject()));
+ altDefaultModal.setFormModel(formModel);
+
+ target.add(altDefaultModal.setContent(new StatusModal<>(
+ altDefaultModal, pageRef, formModel.getObject().getInnerObject(), false)));
+
+ altDefaultModal.header(new Model<>(
+ getString("any.edit", new Model<>(new AnyHandler<>(model.getObject())))));
+
+ altDefaultModal.show(true);
+ }
+ }, ActionLink.ActionType.MANAGE_RESOURCES, StandardEntitlement.USER_READ).
+ add(new ActionLink<GroupTO>() {
+
+ private static final long serialVersionUID = -7978723352517770644L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final GroupTO ignore) {
+ send(GroupDirectoryPanel.this, Broadcast.EXACT,
+ new AjaxWizard.EditItemActionEvent<>(
+ new GroupHandler(new GroupRestClient().read(model.getObject().
+ getKey())), target));
+ }
+ }, ActionLink.ActionType.EDIT, StandardEntitlement.GROUP_READ).
+ add(new ActionLink<GroupTO>() {
+
+ private static final long serialVersionUID = -7978723352517770644L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final GroupTO ignore) {
+ final GroupTO clone = SerializationUtils.clone(model.getObject());
+ clone.setKey(0L);
+ send(GroupDirectoryPanel.this, Broadcast.EXACT,
+ new AjaxWizard.NewItemActionEvent<>(new GroupHandler(clone), target));
+ }
+ }, ActionLink.ActionType.CLONE, StandardEntitlement.GROUP_CREATE).
+ add(new ActionLink<GroupTO>() {
+
+ private static final long serialVersionUID = -7978723352517770644L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final GroupTO ignore) {
+ try {
+ restClient.delete(model.getObject().getETagValue(), model.getObject().getKey());
+ info(getString(Constants.OPERATION_SUCCEEDED));
+ target.add(container);
+ } catch (SyncopeClientException e) {
+ LOG.error("While deleting object {}", model.getObject().getKey(), e);
+ error(StringUtils.isBlank(e.getMessage())
+ ? e.getClass().getName() : e.getMessage());
+ }
+ SyncopeConsoleSession.get().getNotificationPanel().refresh(target);
+ }
+ }, ActionLink.ActionType.DELETE, StandardEntitlement.GROUP_DELETE);
+
+ return panel.build(componentId);
+ }
+
+ @Override
+ public ActionLinksPanel<Serializable> getHeader(final String componentId) {
+ final ActionLinksPanel.Builder<Serializable> panel = ActionLinksPanel.builder();
+
+ return panel.add(new ActionLink<Serializable>() {
+
+ private static final long serialVersionUID = -7978723352517770644L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
+ target.add(displayAttributeModal.setContent(new GroupDisplayAttributesModalPanel<>(
+ displayAttributeModal, page.getPageReference(), pSchemaNames, dSchemaNames)));
+ displayAttributeModal.addSumbitButton();
+ displayAttributeModal.header(new ResourceModel("any.attr.display"));
+ displayAttributeModal.show(true);
+ }
+ }, ActionLink.ActionType.CHANGE_VIEW, StandardEntitlement.GROUP_READ).add(
+ new ActionLink<Serializable>() {
+
+ private static final long serialVersionUID = -7978723352517770644L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
+ if (target != null) {
+ target.add(container);
+ }
+ }
+ }, ActionLink.ActionType.RELOAD, StandardEntitlement.GROUP_SEARCH).build(componentId);
+ }
+ });
+
+ return columns;
+ }
+
+ public static class Builder extends AnyDirectoryPanel.Builder<GroupTO>
+ implements AnyDirectoryPanelBuilder {
+
+ private static final long serialVersionUID = 3844281520756293159L;
+
+ public Builder(final List<AnyTypeClassTO> anyTypeClassTOs, final String type, final PageReference pageRef) {
+ super(anyTypeClassTOs, new GroupRestClient(), type, pageRef);
+ setShowResultPage(true);
+ }
+
+ @Override
+ protected WizardMgtPanel<AnyHandler<GroupTO>> newInstance(final String id) {
+ return new GroupDirectoryPanel(id, this);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3e8912c3/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupSearchResultPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupSearchResultPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupSearchResultPanel.java
deleted file mode 100644
index 50a92f5..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupSearchResultPanel.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * 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.panels;
-
-import java.io.Serializable;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import org.apache.commons.lang3.SerializationUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.syncope.client.console.SyncopeConsoleSession;
-import org.apache.syncope.client.console.commons.Constants;
-import org.apache.syncope.client.console.rest.GroupRestClient;
-import org.apache.syncope.client.console.status.StatusModal;
-import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.ActionColumn;
-import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.AttrColumn;
-import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.DatePropertyColumn;
-import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
-import org.apache.syncope.client.console.wicket.markup.html.form.ActionLinksPanel;
-import org.apache.syncope.client.console.wizards.AjaxWizard;
-import org.apache.syncope.client.console.wizards.WizardMgtPanel;
-import org.apache.syncope.client.console.wizards.any.AnyHandler;
-import org.apache.syncope.client.console.wizards.any.GroupHandler;
-import org.apache.syncope.common.lib.SyncopeClientException;
-import org.apache.syncope.common.lib.to.AnyTypeClassTO;
-import org.apache.syncope.common.lib.to.GroupTO;
-import org.apache.syncope.common.lib.types.SchemaType;
-import org.apache.syncope.common.lib.types.StandardEntitlement;
-import org.apache.wicket.PageReference;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.event.Broadcast;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
-import org.apache.wicket.model.CompoundPropertyModel;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.model.ResourceModel;
-import org.springframework.util.ReflectionUtils;
-
-public class GroupSearchResultPanel extends AnySearchResultPanel<GroupTO> {
-
- private static final long serialVersionUID = -1100228004207271270L;
-
- protected GroupSearchResultPanel(final String id, final Builder builder) {
- super(id, builder);
- }
-
- @Override
- protected String paginatorRowsKey() {
- return Constants.PREF_GROUP_PAGINATOR_ROWS;
- }
-
- @Override
- protected List<IColumn<GroupTO, String>> getColumns() {
- final List<IColumn<GroupTO, String>> columns = new ArrayList<>();
-
- for (String name : prefMan.getList(getRequest(), Constants.PREF_GROUP_DETAILS_VIEW)) {
- final Field field = ReflectionUtils.findField(GroupTO.class, name);
-
- if (field != null && field.getType().equals(Date.class)) {
- columns.add(new DatePropertyColumn<GroupTO>(new ResourceModel(name, name), name, name));
- } else {
- columns.add(new PropertyColumn<GroupTO, String>(new ResourceModel(name, name), name, name));
- }
- }
-
- for (String name : prefMan.getList(getRequest(), Constants.PREF_GROUP_PLAIN_ATTRS_VIEW)) {
- if (pSchemaNames.contains(name)) {
- columns.add(new AttrColumn<GroupTO>(name, SchemaType.PLAIN));
- }
- }
-
- for (String name : prefMan.getList(getRequest(), Constants.PREF_GROUP_DER_ATTRS_VIEW)) {
- if (dSchemaNames.contains(name)) {
- columns.add(new AttrColumn<GroupTO>(name, SchemaType.DERIVED));
- }
- }
-
- // Add defaults in case of no selection
- if (columns.isEmpty()) {
- for (String name : GroupDisplayAttributesModalPanel.DEFAULT_SELECTION) {
- columns.add(new PropertyColumn<GroupTO, String>(new ResourceModel(name, name), name, name));
- }
-
- prefMan.setList(getRequest(), getResponse(), Constants.PREF_GROUP_DETAILS_VIEW,
- Arrays.asList(GroupDisplayAttributesModalPanel.DEFAULT_SELECTION));
- }
-
- setWindowClosedReloadCallback(displayAttributeModal);
-
- columns.add(new ActionColumn<GroupTO, String>(new ResourceModel("actions")) {
-
- private static final long serialVersionUID = -3503023501954863131L;
-
- @Override
- public ActionLinksPanel<GroupTO> getActions(final String componentId, final IModel<GroupTO> model) {
- final ActionLinksPanel.Builder<GroupTO> panel = ActionLinksPanel.builder();
-
- panel.
- add(new ActionLink<GroupTO>() {
-
- private static final long serialVersionUID = -7978723352517770645L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final GroupTO ignore) {
- final IModel<AnyHandler<GroupTO>> formModel =
- new CompoundPropertyModel<>(new AnyHandler<>(model.getObject()));
- altDefaultModal.setFormModel(formModel);
-
- target.add(altDefaultModal.setContent(new StatusModal<>(
- altDefaultModal, pageRef, formModel.getObject().getInnerObject(), false)));
-
- altDefaultModal.header(new Model<>(
- getString("any.edit", new Model<>(new AnyHandler<>(model.getObject())))));
-
- altDefaultModal.show(true);
- }
- }, ActionLink.ActionType.MANAGE_RESOURCES, StandardEntitlement.USER_READ).
- add(new ActionLink<GroupTO>() {
-
- private static final long serialVersionUID = -7978723352517770644L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final GroupTO ignore) {
- send(GroupSearchResultPanel.this, Broadcast.EXACT,
- new AjaxWizard.EditItemActionEvent<>(
- new GroupHandler(new GroupRestClient().read(model.getObject().
- getKey())), target));
- }
- }, ActionLink.ActionType.EDIT, StandardEntitlement.GROUP_READ).
- add(new ActionLink<GroupTO>() {
-
- private static final long serialVersionUID = -7978723352517770644L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final GroupTO ignore) {
- final GroupTO clone = SerializationUtils.clone(model.getObject());
- clone.setKey(0L);
- send(GroupSearchResultPanel.this, Broadcast.EXACT,
- new AjaxWizard.NewItemActionEvent<>(new GroupHandler(clone), target));
- }
- }, ActionLink.ActionType.CLONE, StandardEntitlement.GROUP_CREATE).
- add(new ActionLink<GroupTO>() {
-
- private static final long serialVersionUID = -7978723352517770644L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final GroupTO ignore) {
- try {
- restClient.delete(model.getObject().getETagValue(), model.getObject().getKey());
- info(getString(Constants.OPERATION_SUCCEEDED));
- target.add(container);
- } catch (SyncopeClientException e) {
- LOG.error("While deleting object {}", model.getObject().getKey(), e);
- error(StringUtils.isBlank(e.getMessage())
- ? e.getClass().getName() : e.getMessage());
- }
- SyncopeConsoleSession.get().getNotificationPanel().refresh(target);
- }
- }, ActionLink.ActionType.DELETE, StandardEntitlement.GROUP_DELETE);
-
- return panel.build(componentId);
- }
-
- @Override
- public ActionLinksPanel<Serializable> getHeader(final String componentId) {
- final ActionLinksPanel.Builder<Serializable> panel = ActionLinksPanel.builder();
-
- return panel.add(new ActionLink<Serializable>() {
-
- private static final long serialVersionUID = -7978723352517770644L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
- target.add(displayAttributeModal.setContent(new GroupDisplayAttributesModalPanel<>(
- displayAttributeModal, page.getPageReference(), pSchemaNames, dSchemaNames)));
- displayAttributeModal.addSumbitButton();
- displayAttributeModal.header(new ResourceModel("any.attr.display"));
- displayAttributeModal.show(true);
- }
- }, ActionLink.ActionType.CHANGE_VIEW, StandardEntitlement.GROUP_READ).add(
- new ActionLink<Serializable>() {
-
- private static final long serialVersionUID = -7978723352517770644L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
- if (target != null) {
- target.add(container);
- }
- }
- }, ActionLink.ActionType.RELOAD, StandardEntitlement.GROUP_SEARCH).build(componentId);
- }
- });
-
- return columns;
- }
-
- public static class Builder extends AnySearchResultPanel.Builder<GroupTO>
- implements AnySearchResultPanelBuilder {
-
- private static final long serialVersionUID = 1L;
-
- public Builder(final List<AnyTypeClassTO> anyTypeClassTOs, final String type, final PageReference pageRef) {
- super(anyTypeClassTOs, new GroupRestClient(), type, pageRef);
- setShowResultPage(true);
- }
-
- @Override
- protected WizardMgtPanel<AnyHandler<GroupTO>> newInstance(final String id) {
- return new GroupSearchResultPanel(id, this);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3e8912c3/client/console/src/main/java/org/apache/syncope/client/console/panels/ParametersPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/ParametersPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/ParametersPanel.java
index d4099b8..67da08d 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/ParametersPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/ParametersPanel.java
@@ -27,7 +27,7 @@ import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.client.console.SyncopeConsoleSession;
import org.apache.syncope.client.console.commons.Constants;
-import org.apache.syncope.client.console.commons.SearchableDataProvider;
+import org.apache.syncope.client.console.commons.DirectoryDataProvider;
import org.apache.syncope.client.console.commons.SortableDataProviderComparator;
import org.apache.syncope.client.console.panels.ParametersPanel.ParametersProvider;
import org.apache.syncope.client.console.rest.BaseRestClient;
@@ -55,7 +55,7 @@ import org.apache.wicket.model.IModel;
import org.apache.wicket.model.ResourceModel;
import org.apache.wicket.model.StringResourceModel;
-public class ParametersPanel extends AbstractSearchResultPanel<
+public class ParametersPanel extends DirectoryPanel<
AttrTO, AttrTO, ParametersProvider, BaseRestClient> {
private static final long serialVersionUID = 2765863608539154422L;
@@ -206,7 +206,7 @@ public class ParametersPanel extends AbstractSearchResultPanel<
return columns;
}
- protected final class ParametersProvider extends SearchableDataProvider<AttrTO> {
+ protected final class ParametersProvider extends DirectoryDataProvider<AttrTO> {
private static final long serialVersionUID = -185944053385660794L;
http://git-wip-us.apache.org/repos/asf/syncope/blob/3e8912c3/client/console/src/main/java/org/apache/syncope/client/console/panels/RelationshipTypesPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/RelationshipTypesPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/RelationshipTypesPanel.java
index c148ea7..eea61bf 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/RelationshipTypesPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/RelationshipTypesPanel.java
@@ -29,7 +29,7 @@ import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.client.console.SyncopeConsoleSession;
import org.apache.syncope.client.console.commons.Constants;
-import org.apache.syncope.client.console.commons.SearchableDataProvider;
+import org.apache.syncope.client.console.commons.DirectoryDataProvider;
import org.apache.syncope.client.console.commons.SortableDataProviderComparator;
import org.apache.syncope.client.console.panels.RelationshipTypesPanel.RelationshipTypeProvider;
import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.ActionColumn;
@@ -53,7 +53,7 @@ import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.ResourceModel;
-public class RelationshipTypesPanel extends AbstractTypesPanel<RelationshipTypeTO, RelationshipTypeProvider> {
+public class RelationshipTypesPanel extends TypesDirectoryPanel<RelationshipTypeTO, RelationshipTypeProvider> {
private static final long serialVersionUID = -3731778000138547357L;
@@ -216,7 +216,7 @@ public class RelationshipTypesPanel extends AbstractTypesPanel<RelationshipTypeT
return columns;
}
- protected final class RelationshipTypeProvider extends SearchableDataProvider<RelationshipTypeTO> {
+ protected final class RelationshipTypeProvider extends DirectoryDataProvider<RelationshipTypeTO> {
private static final long serialVersionUID = -185944053385660794L;
http://git-wip-us.apache.org/repos/asf/syncope/blob/3e8912c3/client/console/src/main/java/org/apache/syncope/client/console/panels/RoleDirectoryPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/RoleDirectoryPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/RoleDirectoryPanel.java
new file mode 100644
index 0000000..cbb5809
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/RoleDirectoryPanel.java
@@ -0,0 +1,177 @@
+/*
+ * 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.panels;
+
+import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.apache.commons.lang3.SerializationUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.client.console.SyncopeConsoleSession;
+import org.apache.syncope.client.console.commons.Constants;
+import org.apache.syncope.client.console.commons.RoleDataProvider;
+import org.apache.syncope.client.console.rest.RoleRestClient;
+import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.ActionColumn;
+import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
+import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink.ActionType;
+import org.apache.syncope.client.console.wicket.markup.html.form.ActionLinksPanel;
+import org.apache.syncope.client.console.wizards.AjaxWizard;
+import org.apache.syncope.client.console.wizards.WizardMgtPanel;
+import org.apache.syncope.client.console.wizards.role.RoleHandler;
+import org.apache.syncope.common.lib.SyncopeClientException;
+import org.apache.syncope.common.lib.to.RoleTO;
+import org.apache.syncope.common.lib.types.StandardEntitlement;
+import org.apache.wicket.PageReference;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy;
+import org.apache.wicket.event.Broadcast;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.ResourceModel;
+
+public class RoleDirectoryPanel extends DirectoryPanel<RoleTO, RoleHandler, RoleDataProvider, RoleRestClient> {
+
+ private static final long serialVersionUID = -1100228004207271270L;
+
+ protected RoleDirectoryPanel(final String id, final Builder builder) {
+ super(id, builder);
+ setShowResultPage(true);
+
+ modal.size(Modal.Size.Large);
+ initResultTable();
+
+ MetaDataRoleAuthorizationStrategy.authorize(addAjaxLink, ENABLE, StandardEntitlement.ROLE_CREATE);
+ }
+
+ @Override
+ protected RoleDataProvider dataProvider() {
+ return new RoleDataProvider(rows);
+ }
+
+ @Override
+ protected String paginatorRowsKey() {
+ return Constants.PREF_ROLE_PAGINATOR_ROWS;
+ }
+
+ @Override
+ protected List<IColumn<RoleTO, String>> getColumns() {
+ final List<IColumn<RoleTO, String>> columns = new ArrayList<>();
+
+ columns.add(new PropertyColumn<RoleTO, String>(new ResourceModel("key"), "key", "key"));
+ columns.add(new PropertyColumn<RoleTO, String>(
+ new ResourceModel("entitlements", "Entitlements"), null, "entitlements"));
+ columns.add(new PropertyColumn<RoleTO, String>(
+ new ResourceModel("realms"), null, "realms"));
+
+ columns.add(new ActionColumn<RoleTO, String>(new ResourceModel("actions")) {
+
+ private static final long serialVersionUID = -3503023501954863131L;
+
+ @Override
+ public ActionLinksPanel<RoleTO> getActions(final String componentId, final IModel<RoleTO> model) {
+ final ActionLinksPanel.Builder<RoleTO> panel = ActionLinksPanel.builder();
+
+ panel.add(new ActionLink<RoleTO>() {
+
+ private static final long serialVersionUID = -7978723352517770644L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
+ send(RoleDirectoryPanel.this, Broadcast.EXACT,
+ new AjaxWizard.EditItemActionEvent<>(
+ new RoleHandler(new RoleRestClient().read(model.getObject().getKey())),
+ target));
+ }
+ }, ActionLink.ActionType.EDIT, StandardEntitlement.ROLE_READ).add(new ActionLink<RoleTO>() {
+
+ private static final long serialVersionUID = -7978723352517770644L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
+ final RoleTO clone = SerializationUtils.clone(model.getObject());
+ clone.setKey(null);
+ send(RoleDirectoryPanel.this, Broadcast.EXACT,
+ new AjaxWizard.NewItemActionEvent<>(new RoleHandler(clone), target));
+ }
+ }, ActionLink.ActionType.CLONE, StandardEntitlement.ROLE_CREATE).add(new ActionLink<RoleTO>() {
+
+ private static final long serialVersionUID = -7978723352517770644L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
+ try {
+ restClient.delete(model.getObject().getKey());
+ info(getString(Constants.OPERATION_SUCCEEDED));
+ target.add(container);
+ } catch (SyncopeClientException e) {
+ LOG.error("While deleting object {}", model.getObject().getKey(), e);
+ error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
+ }
+ SyncopeConsoleSession.get().getNotificationPanel().refresh(target);
+ }
+ }, ActionLink.ActionType.DELETE, StandardEntitlement.ROLE_DELETE);
+
+ return panel.build(componentId);
+ }
+
+ @Override
+ public ActionLinksPanel<RoleTO> getHeader(final String componentId) {
+ final ActionLinksPanel.Builder<RoleTO> panel = ActionLinksPanel.builder();
+
+ return panel.add(new ActionLink<RoleTO>() {
+
+ private static final long serialVersionUID = -7978723352517770644L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
+ if (target != null) {
+ target.add(container);
+ }
+ }
+ }, ActionLink.ActionType.RELOAD, StandardEntitlement.ROLE_LIST).build(componentId);
+ }
+ });
+
+ return columns;
+ }
+
+ @Override
+ protected Collection<ActionLink.ActionType> getBulkActions() {
+ final List<ActionType> bulkActions = new ArrayList<>();
+ bulkActions.add(ActionType.DELETE);
+ return bulkActions;
+ }
+
+ public abstract static class Builder
+ extends DirectoryPanel.Builder<RoleTO, RoleHandler, RoleRestClient> {
+
+ private static final long serialVersionUID = 5088962796986706805L;
+
+ public Builder(final PageReference pageRef) {
+ super(new RoleRestClient(), pageRef);
+ }
+
+ @Override
+ protected WizardMgtPanel<RoleHandler> newInstance(final String id) {
+ return new RoleDirectoryPanel(id, this);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3e8912c3/client/console/src/main/java/org/apache/syncope/client/console/panels/RoleSearchResultPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/RoleSearchResultPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/RoleSearchResultPanel.java
deleted file mode 100644
index fec8760..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/RoleSearchResultPanel.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * 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.panels;
-
-import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import org.apache.commons.lang3.SerializationUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.syncope.client.console.SyncopeConsoleSession;
-import org.apache.syncope.client.console.commons.Constants;
-import org.apache.syncope.client.console.commons.RoleDataProvider;
-import org.apache.syncope.client.console.rest.RoleRestClient;
-import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.ActionColumn;
-import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
-import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink.ActionType;
-import org.apache.syncope.client.console.wicket.markup.html.form.ActionLinksPanel;
-import org.apache.syncope.client.console.wizards.AjaxWizard;
-import org.apache.syncope.client.console.wizards.WizardMgtPanel;
-import org.apache.syncope.client.console.wizards.role.RoleHandler;
-import org.apache.syncope.common.lib.SyncopeClientException;
-import org.apache.syncope.common.lib.to.RoleTO;
-import org.apache.syncope.common.lib.types.StandardEntitlement;
-import org.apache.wicket.PageReference;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy;
-import org.apache.wicket.event.Broadcast;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.ResourceModel;
-
-public class RoleSearchResultPanel
- extends AbstractSearchResultPanel<RoleTO, RoleHandler, RoleDataProvider, RoleRestClient> {
-
- private static final long serialVersionUID = -1100228004207271270L;
-
- protected RoleSearchResultPanel(final String id, final Builder builder) {
- super(id, builder);
- setShowResultPage(true);
-
- modal.size(Modal.Size.Large);
- initResultTable();
-
- MetaDataRoleAuthorizationStrategy.authorize(addAjaxLink, ENABLE, StandardEntitlement.ROLE_CREATE);
- }
-
- @Override
- protected RoleDataProvider dataProvider() {
- return new RoleDataProvider(rows);
- }
-
- @Override
- protected String paginatorRowsKey() {
- return Constants.PREF_ROLE_PAGINATOR_ROWS;
- }
-
- @Override
- protected List<IColumn<RoleTO, String>> getColumns() {
- final List<IColumn<RoleTO, String>> columns = new ArrayList<>();
-
- columns.add(new PropertyColumn<RoleTO, String>(new ResourceModel("key"), "key", "key"));
- columns.add(new PropertyColumn<RoleTO, String>(
- new ResourceModel("entitlements", "Entitlements"), null, "entitlements"));
- columns.add(new PropertyColumn<RoleTO, String>(
- new ResourceModel("realms"), null, "realms"));
-
- columns.add(new ActionColumn<RoleTO, String>(new ResourceModel("actions")) {
-
- private static final long serialVersionUID = -3503023501954863131L;
-
- @Override
- public ActionLinksPanel<RoleTO> getActions(final String componentId, final IModel<RoleTO> model) {
- final ActionLinksPanel.Builder<RoleTO> panel = ActionLinksPanel.builder();
-
- panel.add(new ActionLink<RoleTO>() {
-
- private static final long serialVersionUID = -7978723352517770644L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
- send(RoleSearchResultPanel.this, Broadcast.EXACT,
- new AjaxWizard.EditItemActionEvent<>(
- new RoleHandler(new RoleRestClient().read(model.getObject().getKey())),
- target));
- }
- }, ActionLink.ActionType.EDIT, StandardEntitlement.ROLE_READ).add(new ActionLink<RoleTO>() {
-
- private static final long serialVersionUID = -7978723352517770644L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
- final RoleTO clone = SerializationUtils.clone(model.getObject());
- clone.setKey(null);
- send(RoleSearchResultPanel.this, Broadcast.EXACT,
- new AjaxWizard.NewItemActionEvent<>(new RoleHandler(clone), target));
- }
- }, ActionLink.ActionType.CLONE, StandardEntitlement.ROLE_CREATE).add(new ActionLink<RoleTO>() {
-
- private static final long serialVersionUID = -7978723352517770644L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
- try {
- restClient.delete(model.getObject().getKey());
- info(getString(Constants.OPERATION_SUCCEEDED));
- target.add(container);
- } catch (SyncopeClientException e) {
- LOG.error("While deleting object {}", model.getObject().getKey(), e);
- error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
- }
- SyncopeConsoleSession.get().getNotificationPanel().refresh(target);
- }
- }, ActionLink.ActionType.DELETE, StandardEntitlement.ROLE_DELETE);
-
- return panel.build(componentId);
- }
-
- @Override
- public ActionLinksPanel<RoleTO> getHeader(final String componentId) {
- final ActionLinksPanel.Builder<RoleTO> panel = ActionLinksPanel.builder();
-
- return panel.add(new ActionLink<RoleTO>() {
-
- private static final long serialVersionUID = -7978723352517770644L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
- if (target != null) {
- target.add(container);
- }
- }
- }, ActionLink.ActionType.RELOAD, StandardEntitlement.ROLE_LIST).build(componentId);
- }
- });
-
- return columns;
- }
-
- @Override
- protected Collection<ActionLink.ActionType> getBulkActions() {
- final List<ActionType> bulkActions = new ArrayList<>();
- bulkActions.add(ActionType.DELETE);
- return bulkActions;
- }
-
- public abstract static class Builder
- extends AbstractSearchResultPanel.Builder<RoleTO, RoleHandler, RoleRestClient> {
-
- private static final long serialVersionUID = 5088962796986706805L;
-
- public Builder(final PageReference pageRef) {
- super(new RoleRestClient(), pageRef);
- }
-
- @Override
- protected WizardMgtPanel<RoleHandler> newInstance(final String id) {
- return new RoleSearchResultPanel(id, this);
- }
- }
-}