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/04/29 16:24:36 UTC
[5/5] syncope git commit: [SYNCOPE-745] Audit
[SYNCOPE-745] Audit
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/052cf6b1
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/052cf6b1
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/052cf6b1
Branch: refs/heads/master
Commit: 052cf6b16459b5f60838e35d4968d27c535bc3f1
Parents: 3b16483
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Fri Apr 29 16:24:09 2016 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Fri Apr 29 16:24:09 2016 +0200
----------------------------------------------------------------------
.../console/commons/TaskDataProvider.java | 3 +-
.../status/AbstractStatusBeanProvider.java | 2 +-
.../console/events/EventCategoryPanel.java | 498 ++++++++++++++++++
.../console/events/EventSelectionPanel.java | 220 ++++++++
.../console/events/SelectedEventsPanel.java | 172 +++++++
.../notifications/EventSelectionPanel.java | 240 ---------
.../notifications/LoggerCategoryPanel.java | 509 -------------------
.../MailTemplateDirectoryPanel.java | 4 +-
.../NotificationDirectoryPanel.java | 22 +-
.../notifications/NotificationHandler.java | 131 -----
.../NotificationWizardBuilder.java | 34 +-
.../notifications/NotificationWrapper.java | 131 +++++
.../notifications/SelectedEventsPanel.java | 172 -------
.../syncope/client/console/pages/Audit.java | 127 +++++
.../syncope/client/console/pages/BasePage.java | 6 +
.../syncope/client/console/pages/Roles.java | 4 +-
.../AnyObjectDisplayAttributesModalPanel.java | 2 +-
.../panels/DisplayAttributesModalPanel.java | 2 +-
.../GroupDisplayAttributesModalPanel.java | 2 +-
.../console/panels/RoleDirectoryPanel.java | 12 +-
.../client/console/panels/SchemaTypePanel.java | 3 +-
.../panels/TypeExtensionDirectoryPanel.java | 1 -
.../panels/UserDisplayAttributesModalPanel.java | 2 +-
.../console/reports/ReportDirectoryPanel.java | 12 +-
.../reports/ReportTemplateDirectoryPanel.java | 4 +-
.../console/reports/ReportWizardBuilder.java | 2 +-
.../console/rest/NotificationRestClient.java | 4 +-
.../client/console/rest/ReportRestClient.java | 2 +-
.../client/console/rest/TemplateRestClient.java | 2 +-
.../console/tasks/SchedTaskDirectoryPanel.java | 3 +-
.../console/tasks/TaskDirectoryPanel.java | 1 -
.../console/wizards/any/DynamicMemberships.java | 10 +-
.../client/console/wizards/any/Ownership.java | 26 +-
.../console/wizards/role/RoleHandler.java | 74 ---
.../console/wizards/role/RoleWizardBuilder.java | 16 +-
.../console/wizards/role/RoleWrapper.java | 74 +++
.../META-INF/resources/css/syncopeConsole.css | 47 +-
.../src/main/resources/console.properties | 1 +
.../SyncopeConsoleApplication.properties | 1 +
.../SyncopeConsoleApplication_it.properties | 1 +
.../SyncopeConsoleApplication_pt_BR.properties | 1 +
.../SyncopeConsoleApplication_ru.properties | 1 +
.../console/events/EventCategoryPanel.html | 53 ++
.../console/events/EventSelectionPanel.html | 125 +++++
.../console/events/SelectedEventsPanel.html | 25 +
.../notifications/EventSelectionPanel.html | 125 -----
.../notifications/LoggerCategoryPanel.html | 91 ----
.../notifications/SelectedEventsPanel.html | 33 --
.../syncope/client/console/pages/Audit.html | 38 ++
.../syncope/client/console/pages/BasePage.html | 11 +-
.../console/topology/TopologyTogglePanel.html | 2 +-
.../common/lib/types/AuditLoggerName.java | 1 -
.../syncope/common/rest/api/LoggerWrapper.java | 12 +-
.../common/rest/api/service/LoggerService.java | 1 -
.../src/main/resources/console.properties | 1 +
.../src/test/resources/console.properties | 1 +
56 files changed, 1619 insertions(+), 1481 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/052cf6b1/client/console/src/main/java/org/apache/syncope/client/console/commons/TaskDataProvider.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/TaskDataProvider.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/TaskDataProvider.java
index 9f6db89..6a57c2e 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/commons/TaskDataProvider.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/commons/TaskDataProvider.java
@@ -37,9 +37,8 @@ public abstract class TaskDataProvider<T extends AbstractTaskTO> extends Directo
public TaskDataProvider(final int paginatorRows, final TaskType taskType, final TaskRestClient taskRestClient) {
super(paginatorRows);
- this.taskRestClient = taskRestClient;
- //Default sorting
+ this.taskRestClient = taskRestClient;
setSort("key", SortOrder.DESCENDING);
comparator = new SortableDataProviderComparator<>(this);
this.taskType = taskType;
http://git-wip-us.apache.org/repos/asf/syncope/blob/052cf6b1/client/console/src/main/java/org/apache/syncope/client/console/commons/status/AbstractStatusBeanProvider.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/status/AbstractStatusBeanProvider.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/status/AbstractStatusBeanProvider.java
index 48227e0..7d9a688 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/commons/status/AbstractStatusBeanProvider.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/commons/status/AbstractStatusBeanProvider.java
@@ -35,7 +35,7 @@ public abstract class AbstractStatusBeanProvider extends DirectoryDataProvider<S
public AbstractStatusBeanProvider(final String sort) {
super(10);
- //Default sorting
+
setSort(sort, SortOrder.ASCENDING);
comparator = new SortableDataProviderComparator<>(this);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/052cf6b1/client/console/src/main/java/org/apache/syncope/client/console/events/EventCategoryPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/events/EventCategoryPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/events/EventCategoryPanel.java
new file mode 100644
index 0000000..9277212
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/events/EventCategoryPanel.java
@@ -0,0 +1,498 @@
+/*
+ * 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.events;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.commons.collections4.IterableUtils;
+import org.apache.commons.collections4.Predicate;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.syncope.client.console.commons.Constants;
+import org.apache.syncope.client.console.events.SelectedEventsPanel.EventSelectionChanged;
+import org.apache.syncope.client.console.events.SelectedEventsPanel.InspectSelectedEvent;
+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.wicket.markup.html.form.AjaxDropDownChoicePanel;
+import org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel;
+import org.apache.syncope.common.lib.to.EventCategoryTO;
+import org.apache.syncope.common.lib.types.AuditElements;
+import org.apache.syncope.common.lib.types.AuditElements.EventCategoryType;
+import org.apache.syncope.common.lib.types.AuditLoggerName;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
+import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy;
+import org.apache.wicket.event.Broadcast;
+import org.apache.wicket.event.IEvent;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.IChoiceRenderer;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.model.ResourceModel;
+
+public abstract class EventCategoryPanel extends Panel {
+
+ private static final long serialVersionUID = 6429053774964787734L;
+
+ private final List<EventCategoryTO> eventCategoryTOs;
+
+ private final EventCategoryTO eventCategoryTO = new EventCategoryTO();
+
+ private final WebMarkupContainer categoryContainer;
+
+ private final WebMarkupContainer eventsContainer;
+
+ private final SelectedEventsPanel selectedEventsPanel;
+
+ private final AjaxDropDownChoicePanel<EventCategoryType> type;
+
+ private final AjaxDropDownChoicePanel<String> category;
+
+ private final AjaxDropDownChoicePanel<String> subcategory;
+
+ private final AjaxTextFieldPanel custom;
+
+ private final ActionLinksPanel<EventCategoryTO> actionLinksPanel;
+
+ private final IModel<List<String>> model;
+
+ public EventCategoryPanel(
+ final String id,
+ final List<EventCategoryTO> eventCategoryTOs,
+ final IModel<List<String>> model) {
+
+ super(id);
+
+ this.model = model;
+ selectedEventsPanel = new SelectedEventsPanel("selectedEventsPanel", model);
+ add(selectedEventsPanel);
+
+ this.eventCategoryTOs = eventCategoryTOs;
+
+ categoryContainer = new WebMarkupContainer("categoryContainer");
+ categoryContainer.setOutputMarkupId(true);
+ add(categoryContainer);
+
+ eventsContainer = new WebMarkupContainer("eventsContainer");
+ eventsContainer.setOutputMarkupId(true);
+ add(eventsContainer);
+
+ authorizeList();
+ authorizeChanges();
+
+ type = new AjaxDropDownChoicePanel<>(
+ "type",
+ "type",
+ new PropertyModel<EventCategoryType>(eventCategoryTO, "type"),
+ false);
+ type.setChoices(Arrays.asList(EventCategoryType.values()));
+ type.setStyleSheet("ui-widget-content ui-corner-all");
+ type.setChoiceRenderer(new IChoiceRenderer<EventCategoryType>() {
+
+ private static final long serialVersionUID = 2317134950949778735L;
+
+ @Override
+ public String getDisplayValue(final EventCategoryType eventCategoryType) {
+ return eventCategoryType.name();
+ }
+
+ @Override
+ public String getIdValue(final EventCategoryType eventCategoryType, final int i) {
+ return eventCategoryType.name();
+ }
+
+ @Override
+ public EventCategoryType getObject(
+ final String id, final IModel<? extends List<? extends EventCategoryType>> choices) {
+ return IterableUtils.find(choices.getObject(), new Predicate<EventCategoryType>() {
+
+ @Override
+ public boolean evaluate(final EventCategoryType object) {
+ return object.name().equals(id);
+ }
+ });
+ }
+ });
+ categoryContainer.add(type);
+
+ type.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
+
+ private static final long serialVersionUID = -1107858522700306810L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ send(EventCategoryPanel.this, Broadcast.EXACT, new ChangeCategoryEvent(target, type));
+ }
+ });
+
+ category = new AjaxDropDownChoicePanel<>(
+ "category",
+ "category",
+ new PropertyModel<String>(eventCategoryTO, "category"),
+ false);
+ category.setChoices(filter(eventCategoryTOs, type.getModelObject()));
+ categoryContainer.add(category);
+
+ category.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
+
+ private static final long serialVersionUID = -1107858522700306811L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ send(EventCategoryPanel.this, Broadcast.EXACT, new ChangeCategoryEvent(target, category));
+ }
+ });
+
+ subcategory = new AjaxDropDownChoicePanel<>(
+ "subcategory",
+ "subcategory",
+ new PropertyModel<String>(eventCategoryTO, "subcategory"),
+ false);
+ subcategory.setChoices(filter(eventCategoryTOs, type.getModelObject(), category.getModelObject()));
+ categoryContainer.add(subcategory);
+
+ subcategory.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
+
+ private static final long serialVersionUID = -1107858522700306812L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ send(EventCategoryPanel.this, Broadcast.EXACT, new ChangeCategoryEvent(target, subcategory));
+ }
+ });
+
+ categoryContainer.add(new Label("customLabel", new ResourceModel("custom", "custom")).setVisible(false));
+
+ custom = new AjaxTextFieldPanel("custom", "custom", new Model<String>(null));
+ custom.setVisible(false);
+ custom.setEnabled(false);
+
+ categoryContainer.add(custom.hideLabel());
+
+ actionLinksPanel = ActionLinksPanel.<EventCategoryTO>builder().
+ add(new ActionLink<EventCategoryTO>() {
+
+ private static final long serialVersionUID = -3722207913631435501L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final EventCategoryTO modelObject) {
+ if (StringUtils.isNotBlank(custom.getModelObject())) {
+ Map.Entry<EventCategoryTO, AuditElements.Result> parsed =
+ AuditLoggerName.parseEventCategory(custom.getModelObject());
+
+ String eventString = AuditLoggerName.buildEvent(
+ parsed.getKey().getType(),
+ null,
+ null,
+ parsed.getKey().getEvents().isEmpty()
+ ? StringUtils.EMPTY : parsed.getKey().getEvents().iterator().next(),
+ parsed.getValue());
+
+ custom.setModelObject(StringUtils.EMPTY);
+ send(EventCategoryPanel.this.getPage(), Broadcast.BREADTH, new EventSelectionChanged(
+ target,
+ Collections.<String>singleton(eventString),
+ Collections.<String>emptySet()));
+ target.add(categoryContainer);
+ }
+ }
+ }, ActionLink.ActionType.CREATE).
+ add(new ActionLink<EventCategoryTO>() {
+
+ private static final long serialVersionUID = -3722207913631435501L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final EventCategoryTO modelObject) {
+ if (StringUtils.isNotBlank(custom.getModelObject())) {
+ Pair<EventCategoryTO, AuditElements.Result> parsed =
+ AuditLoggerName.parseEventCategory(custom.getModelObject());
+
+ String eventString = AuditLoggerName.buildEvent(
+ parsed.getKey().getType(),
+ null,
+ null,
+ parsed.getKey().getEvents().isEmpty()
+ ? StringUtils.EMPTY : parsed.getKey().getEvents().iterator().next(),
+ parsed.getValue());
+
+ custom.setModelObject(StringUtils.EMPTY);
+ send(EventCategoryPanel.this.getPage(), Broadcast.BREADTH, new EventSelectionChanged(
+ target,
+ Collections.<String>singleton(eventString),
+ Collections.<String>emptySet()));
+ target.add(categoryContainer);
+ }
+ }
+ }, ActionLink.ActionType.CREATE).
+ add(new ActionLink<EventCategoryTO>() {
+
+ private static final long serialVersionUID = -3722207913631435521L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target, final EventCategoryTO modelObject) {
+ if (StringUtils.isNotBlank(custom.getModelObject())) {
+ Pair<EventCategoryTO, AuditElements.Result> parsed =
+ AuditLoggerName.parseEventCategory(custom.getModelObject());
+
+ String eventString = AuditLoggerName.buildEvent(
+ parsed.getKey().getType(),
+ null,
+ null,
+ parsed.getKey().getEvents().isEmpty()
+ ? StringUtils.EMPTY : parsed.getKey().getEvents().iterator().next(),
+ parsed.getValue());
+
+ custom.setModelObject(StringUtils.EMPTY);
+ send(EventCategoryPanel.this.getPage(), Broadcast.BREADTH, new EventSelectionChanged(
+ target,
+ Collections.<String>emptySet(),
+ Collections.<String>singleton(eventString)));
+ target.add(categoryContainer);
+ }
+ }
+ }, ActionLink.ActionType.DELETE).build("customActions");
+
+ categoryContainer.add(actionLinksPanel);
+
+ actionLinksPanel.setVisible(false);
+ actionLinksPanel.setEnabled(false);
+
+ eventsContainer.add(new EventSelectionPanel("eventsPanel", eventCategoryTO, model) {
+
+ private static final long serialVersionUID = 3513194801190026082L;
+
+ @Override
+ protected void onEventAction(final IEvent<?> event) {
+ EventCategoryPanel.this.onEventAction(event);
+ }
+ });
+ }
+
+ private List<String> filter(final List<EventCategoryTO> eventCategoryTOs, final EventCategoryType type) {
+ Set<String> res = new HashSet<>();
+
+ for (EventCategoryTO eventCategory : eventCategoryTOs) {
+ if (type == eventCategory.getType() && StringUtils.isNotEmpty(eventCategory.getCategory())) {
+ res.add(eventCategory.getCategory());
+ }
+ }
+
+ List<String> filtered = new ArrayList<>(res);
+ Collections.sort(filtered);
+ return filtered;
+ }
+
+ private List<String> filter(
+ final List<EventCategoryTO> eventCategoryTOs, final EventCategoryType type, final String category) {
+
+ Set<String> res = new HashSet<>();
+
+ for (EventCategoryTO eventCategory : eventCategoryTOs) {
+ if (type == eventCategory.getType() && StringUtils.equals(category, eventCategory.getCategory())
+ && StringUtils.isNotEmpty(eventCategory.getSubcategory())) {
+ res.add(eventCategory.getSubcategory());
+ }
+ }
+
+ List<String> filtered = new ArrayList<>(res);
+ Collections.sort(filtered);
+ return filtered;
+ }
+
+ @Override
+ public void onEvent(final IEvent<?> event) {
+ if (event.getPayload() instanceof ChangeCategoryEvent) {
+ // update objects ....
+ eventCategoryTO.getEvents().clear();
+
+ final ChangeCategoryEvent change = (ChangeCategoryEvent) event.getPayload();
+
+ final Panel changedPanel = change.getChangedPanel();
+ if (null != changedPanel.getId()) {
+ switch (changedPanel.getId()) {
+ case "type":
+ eventCategoryTO.setType(type.getModelObject());
+ eventCategoryTO.setCategory(null);
+ eventCategoryTO.setSubcategory(null);
+ if (type.getModelObject() == EventCategoryType.CUSTOM) {
+ category.setChoices(Collections.<String>emptyList());
+ subcategory.setChoices(Collections.<String>emptyList());
+ category.setEnabled(false);
+ subcategory.setEnabled(false);
+ custom.setVisible(true);
+ custom.setEnabled(true);
+ actionLinksPanel.setVisible(true);
+ actionLinksPanel.setEnabled(true);
+ } else {
+ category.setChoices(filter(eventCategoryTOs, type.getModelObject()));
+ subcategory.setChoices(Collections.<String>emptyList());
+ category.setEnabled(true);
+ subcategory.setEnabled(true);
+ custom.setVisible(false);
+ custom.setEnabled(false);
+ actionLinksPanel.setVisible(false);
+ actionLinksPanel.setEnabled(false);
+ }
+ change.getTarget().add(categoryContainer);
+ break;
+
+ case "category":
+ subcategory.setChoices(
+ filter(eventCategoryTOs, type.getModelObject(), category.getModelObject()));
+ eventCategoryTO.setCategory(category.getModelObject());
+ eventCategoryTO.setSubcategory(null);
+ change.getTarget().add(categoryContainer);
+ break;
+
+ default:
+ eventCategoryTO.setSubcategory(subcategory.getModelObject());
+ break;
+ }
+ }
+
+ updateEventsContainer(change.getTarget());
+ } else if (event.getPayload() instanceof InspectSelectedEvent) {
+ // update objects ....
+ eventCategoryTO.getEvents().clear();
+
+ final InspectSelectedEvent inspectSelectedEvent = (InspectSelectedEvent) event.getPayload();
+
+ final Map.Entry<EventCategoryTO, AuditElements.Result> categoryEvent = AuditLoggerName.parseEventCategory(
+ inspectSelectedEvent.getEvent());
+
+ eventCategoryTO.setType(categoryEvent.getKey().getType());
+ category.setChoices(filter(eventCategoryTOs, type.getModelObject()));
+
+ eventCategoryTO.setCategory(categoryEvent.getKey().getCategory());
+ subcategory.setChoices(filter(eventCategoryTOs, type.getModelObject(), category.getModelObject()));
+
+ eventCategoryTO.setSubcategory(categoryEvent.getKey().getSubcategory());
+
+ if (categoryEvent.getKey().getType() == EventCategoryType.CUSTOM) {
+ custom.setModelObject(AuditLoggerName.buildEvent(
+ categoryEvent.getKey().getType(),
+ categoryEvent.getKey().getCategory(),
+ categoryEvent.getKey().getSubcategory(),
+ categoryEvent.getKey().getEvents().isEmpty()
+ ? StringUtils.EMPTY : categoryEvent.getKey().getEvents().iterator().next(),
+ categoryEvent.getValue()));
+
+ category.setEnabled(false);
+ subcategory.setEnabled(false);
+ custom.setVisible(true);
+ custom.setEnabled(true);
+ actionLinksPanel.setVisible(true);
+ actionLinksPanel.setEnabled(true);
+ } else {
+ category.setEnabled(true);
+ subcategory.setEnabled(true);
+ custom.setVisible(false);
+ custom.setEnabled(false);
+ actionLinksPanel.setVisible(false);
+ actionLinksPanel.setEnabled(false);
+ }
+
+ inspectSelectedEvent.getTarget().add(categoryContainer);
+ updateEventsContainer(inspectSelectedEvent.getTarget());
+ }
+ }
+
+ private void setEvents() {
+ final Iterator<EventCategoryTO> itor = eventCategoryTOs.iterator();
+ while (itor.hasNext() && eventCategoryTO.getEvents().isEmpty()) {
+ final EventCategoryTO eventCategory = itor.next();
+ if (eventCategory.getType() == eventCategoryTO.getType()
+ && StringUtils.equals(eventCategory.getCategory(), eventCategoryTO.getCategory())
+ && StringUtils.equals(eventCategory.getSubcategory(), eventCategoryTO.getSubcategory())) {
+ eventCategoryTO.getEvents().addAll(eventCategory.getEvents());
+
+ }
+ }
+ }
+
+ private class ChangeCategoryEvent {
+
+ private final AjaxRequestTarget target;
+
+ private final Panel changedPanel;
+
+ ChangeCategoryEvent(final AjaxRequestTarget target, final Panel changedPanel) {
+ this.target = target;
+ this.changedPanel = changedPanel;
+ }
+
+ public AjaxRequestTarget getTarget() {
+ return target;
+ }
+
+ public Panel getChangedPanel() {
+ return changedPanel;
+ }
+ }
+
+ /**
+ * To be extended in order to add actions on events.
+ *
+ * @param event event.
+ */
+ protected void onEventAction(final IEvent<?> event) {
+ // nothing by default
+ }
+
+ private void authorizeList() {
+ for (String role : getListAuthRoles()) {
+ MetaDataRoleAuthorizationStrategy.authorize(selectedEventsPanel, RENDER, role);
+ }
+ }
+
+ private void authorizeChanges() {
+ for (String role : getChangeAuthRoles()) {
+ MetaDataRoleAuthorizationStrategy.authorize(categoryContainer, RENDER, role);
+ MetaDataRoleAuthorizationStrategy.authorize(eventsContainer, RENDER, role);
+ }
+ }
+
+ private void updateEventsContainer(final AjaxRequestTarget target) {
+ setEvents();
+
+ eventsContainer.addOrReplace(new EventSelectionPanel("eventsPanel", eventCategoryTO, model) {
+
+ private static final long serialVersionUID = 3513194801190026082L;
+
+ @Override
+ public void onEventAction(final IEvent<?> event) {
+ EventCategoryPanel.this.onEventAction(event);
+ }
+ });
+ target.add(eventsContainer);
+ }
+
+ protected abstract List<String> getListAuthRoles();
+
+ protected abstract List<String> getChangeAuthRoles();
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/052cf6b1/client/console/src/main/java/org/apache/syncope/client/console/events/EventSelectionPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/events/EventSelectionPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/events/EventSelectionPanel.java
new file mode 100644
index 0000000..54a4506
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/events/EventSelectionPanel.java
@@ -0,0 +1,220 @@
+/*
+ * 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.events;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.client.console.wicket.ajax.form.IndicatorAjaxFormChoiceComponentUpdatingBehavior;
+import org.apache.syncope.common.lib.to.EventCategoryTO;
+import org.apache.syncope.common.lib.types.AuditElements;
+import org.apache.syncope.common.lib.types.AuditLoggerName;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.event.Broadcast;
+import org.apache.wicket.event.IEvent;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.Check;
+import org.apache.wicket.markup.html.form.CheckGroup;
+import org.apache.wicket.markup.html.form.CheckGroupSelector;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.ResourceModel;
+
+public abstract class EventSelectionPanel extends Panel {
+
+ private static final long serialVersionUID = 752233163798301002L;
+
+ private final Set<String> selected = new HashSet<>();
+
+ public EventSelectionPanel(
+ final String id, final EventCategoryTO eventCategoryTO, final IModel<List<String>> model) {
+ super(id);
+ setOutputMarkupId(true);
+
+ List<String> events = getEvents(eventCategoryTO);
+
+ // needed to avoid model reset: model have to be managed into SelectedEventsPanel
+ selected.addAll(model.getObject());
+
+ final CheckGroup<String> successGroup = new CheckGroup<>("successGroup", selected);
+ successGroup.add(new IndicatorAjaxFormChoiceComponentUpdatingBehavior() {
+
+ private static final long serialVersionUID = -151291731388673682L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+
+ final Set<String> toBeRemoved = new HashSet<>();
+ final Set<String> toBeAdded = new HashSet<>();
+
+ for (String event : getEvents(eventCategoryTO)) {
+ String eventString = AuditLoggerName.buildEvent(
+ eventCategoryTO.getType(),
+ eventCategoryTO.getCategory(),
+ eventCategoryTO.getSubcategory(),
+ event,
+ AuditElements.Result.SUCCESS);
+
+ if (successGroup.getModelObject().contains(eventString)) {
+ toBeAdded.add(eventString);
+ } else {
+ toBeRemoved.add(eventString);
+ }
+ }
+
+ send(EventSelectionPanel.this.getPage(), Broadcast.BREADTH,
+ new SelectedEventsPanel.EventSelectionChanged(target, toBeAdded, toBeRemoved));
+ }
+ });
+ successGroup.setVisible(!events.isEmpty());
+ add(successGroup);
+
+ add(new Label("successLabel", new ResourceModel("Success", "Success"))).setVisible(!events.isEmpty());
+
+ CheckGroupSelector successSelector = new CheckGroupSelector("successSelector", successGroup);
+ successSelector.setVisible(!events.isEmpty());
+ add(successSelector);
+
+ ListView<String> categoryView = new ListView<String>("categoryView", events) {
+
+ private static final long serialVersionUID = 4949588177564901031L;
+
+ @Override
+ protected void populateItem(final ListItem<String> item) {
+ final String subcategory = item.getModelObject();
+
+ item.add(new Label("subcategory", new ResourceModel(subcategory, subcategory)));
+ }
+ };
+ add(categoryView);
+
+ ListView<String> successView = new ListView<String>("successView", events) {
+
+ private static final long serialVersionUID = 4949588177564901031L;
+
+ @Override
+ protected void populateItem(final ListItem<String> item) {
+ item.add(new Check<>("successCheck",
+ new Model<>(AuditLoggerName.buildEvent(
+ eventCategoryTO.getType(),
+ eventCategoryTO.getCategory(),
+ eventCategoryTO.getSubcategory(),
+ item.getModelObject(),
+ AuditElements.Result.SUCCESS)),
+ successGroup));
+ }
+ };
+ successGroup.add(successView);
+
+ final CheckGroup<String> failureGroup = new CheckGroup<>("failureGroup", selected);
+ failureGroup.add(new IndicatorAjaxFormChoiceComponentUpdatingBehavior() {
+
+ private static final long serialVersionUID = -151291731388673682L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ final Set<String> toBeRemoved = new HashSet<>();
+ final Set<String> toBeAdded = new HashSet<>();
+
+ for (String event : getEvents(eventCategoryTO)) {
+ final String eventString = AuditLoggerName.buildEvent(
+ eventCategoryTO.getType(),
+ eventCategoryTO.getCategory(),
+ eventCategoryTO.getSubcategory(),
+ event,
+ AuditElements.Result.FAILURE);
+
+ if (failureGroup.getModelObject().contains(eventString)) {
+ toBeAdded.add(eventString);
+ } else {
+ toBeRemoved.add(eventString);
+ }
+ }
+
+ send(EventSelectionPanel.this.getPage(), Broadcast.BREADTH,
+ new SelectedEventsPanel.EventSelectionChanged(target, toBeAdded, toBeRemoved));
+ }
+ });
+ failureGroup.setVisible(!events.isEmpty());
+ add(failureGroup);
+
+ add(new Label("failureLabel", new ResourceModel("Failure", "Failure"))).setVisible(!events.isEmpty());
+
+ CheckGroupSelector failureSelector = new CheckGroupSelector("failureSelector", failureGroup);
+ failureSelector.setVisible(!events.isEmpty());
+ add(failureSelector);
+
+ ListView<String> failureView = new ListView<String>("failureView", events) {
+
+ private static final long serialVersionUID = 4949588177564901031L;
+
+ @Override
+ protected void populateItem(final ListItem<String> item) {
+ item.add(new Check<>("failureCheck",
+ new Model<>(AuditLoggerName.buildEvent(
+ eventCategoryTO.getType(),
+ eventCategoryTO.getCategory(),
+ eventCategoryTO.getSubcategory(),
+ item.getModelObject(),
+ AuditElements.Result.FAILURE)),
+ failureGroup));
+ }
+ };
+ failureGroup.add(failureView);
+ }
+
+ private List<String> getEvents(final EventCategoryTO eventCategoryTO) {
+ final List<String> res;
+
+ res = eventCategoryTO.getEvents();
+
+ if (res.isEmpty()) {
+ if ((AuditElements.EventCategoryType.PROPAGATION == eventCategoryTO.getType()
+ || AuditElements.EventCategoryType.PULL == eventCategoryTO.getType()
+ || AuditElements.EventCategoryType.PUSH == eventCategoryTO.getType())
+ && StringUtils.isEmpty(eventCategoryTO.getCategory())) {
+ res.add(eventCategoryTO.getType().toString());
+ } else if (AuditElements.EventCategoryType.TASK == eventCategoryTO.getType()
+ && StringUtils.isNotEmpty(eventCategoryTO.getCategory())) {
+ res.add(eventCategoryTO.getCategory());
+ }
+ } else {
+ Collections.sort(res);
+ }
+
+ return res;
+ }
+
+ /**
+ * To be extended in order to add actions on events.
+ *
+ * @param event event.
+ */
+ protected abstract void onEventAction(final IEvent<?> event);
+
+ @Override
+ public void onEvent(final IEvent<?> event) {
+ onEventAction(event);
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/052cf6b1/client/console/src/main/java/org/apache/syncope/client/console/events/SelectedEventsPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/events/SelectedEventsPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/events/SelectedEventsPanel.java
new file mode 100644
index 0000000..07c3854
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/events/SelectedEventsPanel.java
@@ -0,0 +1,172 @@
+/*
+ * 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.events;
+
+import java.util.List;
+import java.util.Set;
+import org.apache.syncope.client.console.commons.Constants;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
+import org.apache.wicket.event.Broadcast;
+import org.apache.wicket.event.IEvent;
+import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.form.IChoiceRenderer;
+import org.apache.wicket.markup.html.form.ListMultipleChoice;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.util.ListModel;
+
+public class SelectedEventsPanel extends Panel {
+
+ private static final long serialVersionUID = -4832450230348213500L;
+
+ private final WebMarkupContainer selectionContainer;
+
+ private ListMultipleChoice<String> selectedEvents;
+
+ private final IModel<List<String>> model;
+
+ public SelectedEventsPanel(final String id, final IModel<List<String>> model) {
+ super(id);
+
+ this.model = model;
+
+ selectionContainer = new WebMarkupContainer("selectionContainer");
+ selectionContainer.setOutputMarkupId(true);
+ add(selectionContainer);
+
+ selectedEvents = new ListMultipleChoice<String>("selectedEvents", new ListModel<String>(), model) {
+
+ private static final long serialVersionUID = 1226677544225737338L;
+
+ @Override
+ protected void onComponentTag(final ComponentTag tag) {
+ super.onComponentTag(tag);
+ tag.remove("size");
+ tag.remove("multiple");
+ tag.put("size", 5);
+ }
+ };
+
+ selectedEvents.setMaxRows(5);
+ selectedEvents.setChoiceRenderer(new IChoiceRenderer<String>() {
+
+ private static final long serialVersionUID = -4288397951948436434L;
+
+ @Override
+ public Object getDisplayValue(final String object) {
+ return object;
+ }
+
+ @Override
+ public String getIdValue(final String object, final int index) {
+ return object;
+ }
+
+ @Override
+ public String getObject(final String id, final IModel<? extends List<? extends String>> choices) {
+ return id;
+ }
+ });
+
+ selectedEvents.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
+
+ private static final long serialVersionUID = -151291731388673682L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ send(SelectedEventsPanel.this.getPage(),
+ Broadcast.BREADTH,
+ new InspectSelectedEvent(target, selectedEvents.getModelValue()));
+ }
+ });
+
+ selectionContainer.add(selectedEvents);
+ }
+
+ @Override
+ public void onEvent(final IEvent<?> event) {
+ if (event.getPayload() instanceof EventSelectionChanged) {
+ final EventSelectionChanged eventSelectionChanged = (EventSelectionChanged) event.getPayload();
+
+ for (String toBeRemoved : eventSelectionChanged.getToBeRemoved()) {
+ model.getObject().remove(toBeRemoved);
+ }
+
+ for (String toBeAdded : eventSelectionChanged.getToBeAdded()) {
+ if (!model.getObject().contains(toBeAdded)) {
+ model.getObject().add(toBeAdded);
+ }
+ }
+
+ eventSelectionChanged.getTarget().add(selectionContainer);
+ }
+ }
+
+ public static class InspectSelectedEvent {
+
+ private final AjaxRequestTarget target;
+
+ private final String event;
+
+ public InspectSelectedEvent(final AjaxRequestTarget target, final String event) {
+ this.target = target;
+ this.event = event;
+ }
+
+ public AjaxRequestTarget getTarget() {
+ return target;
+ }
+
+ public String getEvent() {
+ return event;
+ }
+ }
+
+ public static class EventSelectionChanged {
+
+ private final AjaxRequestTarget target;
+
+ private final Set<String> toBeRemoved;
+
+ private final Set<String> toBeAdded;
+
+ public EventSelectionChanged(
+ final AjaxRequestTarget target,
+ final Set<String> toBeAdded,
+ final Set<String> toBeRemoved) {
+ this.target = target;
+ this.toBeAdded = toBeAdded;
+ this.toBeRemoved = toBeRemoved;
+ }
+
+ public AjaxRequestTarget getTarget() {
+ return target;
+ }
+
+ public Set<String> getToBeRemoved() {
+ return toBeRemoved;
+ }
+
+ public Set<String> getToBeAdded() {
+ return toBeAdded;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/052cf6b1/client/console/src/main/java/org/apache/syncope/client/console/notifications/EventSelectionPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/notifications/EventSelectionPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/notifications/EventSelectionPanel.java
deleted file mode 100644
index 38d2dd9..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/notifications/EventSelectionPanel.java
+++ /dev/null
@@ -1,240 +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.notifications;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.syncope.common.lib.to.EventCategoryTO;
-import org.apache.syncope.common.lib.types.AuditElements;
-import org.apache.syncope.common.lib.types.AuditLoggerName;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior;
-import org.apache.wicket.event.Broadcast;
-import org.apache.wicket.event.IEvent;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.form.Check;
-import org.apache.wicket.markup.html.form.CheckGroup;
-import org.apache.wicket.markup.html.form.CheckGroupSelector;
-import org.apache.wicket.markup.html.list.ListItem;
-import org.apache.wicket.markup.html.list.ListView;
-import org.apache.wicket.markup.html.panel.Panel;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.model.ResourceModel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class EventSelectionPanel extends Panel {
-
- /**
- * Logger.
- */
- private static final Logger LOG = LoggerFactory.getLogger(EventSelectionPanel.class);
-
- private static final long serialVersionUID = 752233163798301002L;
-
- private final Set<String> selected = new HashSet<String>();
-
- public EventSelectionPanel(
- final String id, final EventCategoryTO eventCategoryTO, final IModel<List<String>> model) {
- super(id);
- setOutputMarkupId(true);
-
- final List<String> events = getEvents(eventCategoryTO);
-
- // needed to avoid model reset: model have to be managed into SelectedEventsPanel
- selected.addAll(model.getObject());
-
- final CheckGroup<String> successGroup = new CheckGroup<String>(
- "successGroup",
- selected);
-
- successGroup.add(new AjaxFormChoiceComponentUpdatingBehavior() {
-
- private static final long serialVersionUID = -151291731388673682L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
-
- final Set<String> toBeRemoved = new HashSet<String>();
- final Set<String> toBeAdded = new HashSet<String>();
-
- for (String event : getEvents(eventCategoryTO)) {
- final String eventString = AuditLoggerName.buildEvent(
- eventCategoryTO.getType(),
- eventCategoryTO.getCategory(),
- eventCategoryTO.getSubcategory(),
- event,
- AuditElements.Result.SUCCESS);
-
- if (successGroup.getModelObject().contains(eventString)) {
- toBeAdded.add(eventString);
- } else {
- toBeRemoved.add(eventString);
- }
- }
-
- send(EventSelectionPanel.this.getPage(), Broadcast.BREADTH,
- new SelectedEventsPanel.EventSelectionChanged(target, toBeAdded, toBeRemoved));
- }
- });
-
- successGroup.setVisible(!events.isEmpty());
- add(successGroup);
-
- add(new Label("successLabel", new ResourceModel("Success", "Success"))).setVisible(!events.isEmpty());
-
- final CheckGroupSelector successSelector = new CheckGroupSelector("successSelector", successGroup);
- successSelector.setVisible(!events.isEmpty());
- add(successSelector);
-
- final ListView<String> categoryView = new ListView<String>("categoryView", events) {
-
- private static final long serialVersionUID = 4949588177564901031L;
-
- @Override
- protected void populateItem(final ListItem<String> item) {
- final String subcategory = item.getModelObject();
-
- item.add(new Label("subcategory", new ResourceModel(subcategory, subcategory)));
- }
- };
- add(categoryView);
-
- final ListView<String> successView = new ListView<String>("successView", events) {
-
- private static final long serialVersionUID = 4949588177564901031L;
-
- @Override
- protected void populateItem(final ListItem<String> item) {
- final String event = item.getModelObject();
-
- final Check<String> successCheck = new Check<String>("successCheck",
- new Model<String>(AuditLoggerName.buildEvent(
- eventCategoryTO.getType(),
- eventCategoryTO.getCategory(),
- eventCategoryTO.getSubcategory(),
- event,
- AuditElements.Result.SUCCESS)),
- successGroup);
- item.add(successCheck);
- }
- };
- successGroup.add(successView);
-
- final CheckGroup<String> failureGroup = new CheckGroup<String>("failureGroup", selected);
-
- failureGroup.add(new AjaxFormChoiceComponentUpdatingBehavior() {
-
- private static final long serialVersionUID = -151291731388673682L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
-
- final Set<String> toBeRemoved = new HashSet<String>();
- final Set<String> toBeAdded = new HashSet<String>();
-
- for (String event : getEvents(eventCategoryTO)) {
- final String eventString = AuditLoggerName.buildEvent(
- eventCategoryTO.getType(),
- eventCategoryTO.getCategory(),
- eventCategoryTO.getSubcategory(),
- event,
- AuditElements.Result.FAILURE);
-
- if (failureGroup.getModelObject().contains(eventString)) {
- toBeAdded.add(eventString);
- } else {
- toBeRemoved.add(eventString);
- }
- }
-
- send(EventSelectionPanel.this.getPage(), Broadcast.BREADTH,
- new SelectedEventsPanel.EventSelectionChanged(target, toBeAdded, toBeRemoved));
- }
- });
-
- failureGroup.setVisible(!events.isEmpty());
- add(failureGroup);
-
- add(new Label("failureLabel", new ResourceModel("Failure", "Failure"))).setVisible(!events.isEmpty());
-
- final CheckGroupSelector failureSelector = new CheckGroupSelector("failureSelector", failureGroup);
- failureSelector.setVisible(!events.isEmpty());
- add(failureSelector);
-
- final ListView<String> failureView = new ListView<String>("failureView", events) {
-
- private static final long serialVersionUID = 4949588177564901031L;
-
- @Override
- protected void populateItem(final ListItem<String> item) {
- final String event = item.getModelObject();
-
- final Check<String> failureCheck = new Check<String>("failureCheck",
- new Model<String>(AuditLoggerName.buildEvent(
- eventCategoryTO.getType(),
- eventCategoryTO.getCategory(),
- eventCategoryTO.getSubcategory(),
- event,
- AuditElements.Result.FAILURE)),
- failureGroup);
- item.add(failureCheck);
- }
- };
- failureGroup.add(failureView);
- }
-
- private List<String> getEvents(final EventCategoryTO eventCategoryTO) {
- final List<String> res;
-
- res = eventCategoryTO.getEvents();
-
- if (res.isEmpty()) {
- if ((AuditElements.EventCategoryType.PROPAGATION == eventCategoryTO.getType()
- || AuditElements.EventCategoryType.PULL == eventCategoryTO.getType()
- || AuditElements.EventCategoryType.PUSH == eventCategoryTO.getType())
- && StringUtils.isEmpty(eventCategoryTO.getCategory())) {
- res.add(eventCategoryTO.getType().toString());
- } else if (AuditElements.EventCategoryType.TASK == eventCategoryTO.getType()
- && StringUtils.isNotEmpty(eventCategoryTO.getCategory())) {
- res.add(eventCategoryTO.getCategory());
- }
- } else {
- Collections.sort(res);
- }
-
- return res;
- }
-
- /**
- * To be extended in order to add actions on events.
- *
- * @param event event.
- */
- protected abstract void onEventAction(final IEvent<?> event);
-
- @Override
- public void onEvent(final IEvent<?> event) {
- onEventAction(event);
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/052cf6b1/client/console/src/main/java/org/apache/syncope/client/console/notifications/LoggerCategoryPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/notifications/LoggerCategoryPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/notifications/LoggerCategoryPanel.java
deleted file mode 100644
index d1715f1..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/notifications/LoggerCategoryPanel.java
+++ /dev/null
@@ -1,509 +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.notifications;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.apache.commons.collections4.IterableUtils;
-import org.apache.commons.collections4.Predicate;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.syncope.client.console.commons.Constants;
-import org.apache.syncope.client.console.notifications.SelectedEventsPanel.EventSelectionChanged;
-import org.apache.syncope.client.console.notifications.SelectedEventsPanel.InspectSelectedEvent;
-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.wicket.markup.html.form.AjaxDropDownChoicePanel;
-import org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel;
-import org.apache.syncope.common.lib.to.EventCategoryTO;
-import org.apache.syncope.common.lib.types.AuditElements;
-import org.apache.syncope.common.lib.types.AuditElements.EventCategoryType;
-import org.apache.syncope.common.lib.types.AuditLoggerName;
-import org.apache.syncope.common.lib.types.StandardEntitlement;
-import org.apache.wicket.PageReference;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
-import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy;
-import org.apache.wicket.event.Broadcast;
-import org.apache.wicket.event.IEvent;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.form.IChoiceRenderer;
-import org.apache.wicket.markup.html.panel.Panel;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.model.PropertyModel;
-import org.apache.wicket.model.ResourceModel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class LoggerCategoryPanel extends Panel {
-
- /**
- * Logger.
- */
- private static final Logger LOG = LoggerFactory.getLogger(LoggerCategoryPanel.class);
-
- private static final long serialVersionUID = 6429053774964787734L;
-
- private final List<EventCategoryTO> eventCategoryTOs;
-
- private final EventCategoryTO eventCategoryTO = new EventCategoryTO();
-
- private final WebMarkupContainer categoryContainer;
-
- private final WebMarkupContainer eventsContainer;
-
- private final SelectedEventsPanel selectedEventsPanel;
-
- private final AjaxDropDownChoicePanel<EventCategoryType> type;
-
- private final AjaxDropDownChoicePanel<String> category;
-
- private final AjaxDropDownChoicePanel<String> subcategory;
-
- private final AjaxTextFieldPanel custom;
-
- private final ActionLinksPanel actionPanel;
-
- private final IModel<List<String>> model;
-
- public LoggerCategoryPanel(
- final String id,
- final List<EventCategoryTO> eventCategoryTOs,
- final IModel<List<String>> model,
- final PageReference pageReference,
- final String pageId) {
- super(id);
-
- this.model = model;
- selectedEventsPanel = new SelectedEventsPanel("selectedEventsPanel", model);
- add(selectedEventsPanel);
-
- this.eventCategoryTOs = eventCategoryTOs;
-
- categoryContainer = new WebMarkupContainer("categoryContainer");
- categoryContainer.setOutputMarkupId(true);
- add(categoryContainer);
-
- eventsContainer = new WebMarkupContainer("eventsContainer");
- eventsContainer.setOutputMarkupId(true);
- add(eventsContainer);
-
- authorizeList();
- authorizeChanges();
-
- type = new AjaxDropDownChoicePanel<EventCategoryType>(
- "type",
- "type",
- new PropertyModel<EventCategoryType>(eventCategoryTO, "type"),
- false);
- type.setChoices(Arrays.asList(EventCategoryType.values()));
- type.setStyleSheet("ui-widget-content ui-corner-all");
- type.setChoiceRenderer(new IChoiceRenderer<EventCategoryType>() {
-
- private static final long serialVersionUID = 2317134950949778735L;
-
- @Override
- public String getDisplayValue(final EventCategoryType eventCategoryType) {
- return eventCategoryType.name();
- }
-
- @Override
- public String getIdValue(final EventCategoryType eventCategoryType, final int i) {
- return eventCategoryType.name();
- }
-
- @Override
- public EventCategoryType getObject(
- final String id, final IModel<? extends List<? extends EventCategoryType>> choices) {
- return IterableUtils.find(choices.getObject(), new Predicate<EventCategoryType>() {
-
- @Override
- public boolean evaluate(final EventCategoryType object) {
- return object.name().equals(id);
- }
- });
- }
- });
- categoryContainer.add(type);
-
- type.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- send(LoggerCategoryPanel.this, Broadcast.EXACT, new ChangeCategoryEvent(target, type));
- }
- });
-
- category = new AjaxDropDownChoicePanel<String>(
- "category",
- "category",
- new PropertyModel<String>(eventCategoryTO, "category"),
- false);
- category.setChoices(filter(eventCategoryTOs, type.getModelObject()));
-// category.setStyleSheet("ui-widget-content ui-corner-all");
- categoryContainer.add(category);
-
- category.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306811L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- send(LoggerCategoryPanel.this, Broadcast.EXACT, new ChangeCategoryEvent(target, category));
- }
- });
-
- subcategory = new AjaxDropDownChoicePanel<String>(
- "subcategory",
- "subcategory",
- new PropertyModel<String>(eventCategoryTO, "subcategory"),
- false);
- subcategory.setChoices(filter(eventCategoryTOs, type.getModelObject(), category.getModelObject()));
-// subcategory.setStyleSheet("ui-widget-content ui-corner-all");
- categoryContainer.add(subcategory);
-
- subcategory.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306812L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- send(LoggerCategoryPanel.this, Broadcast.EXACT, new ChangeCategoryEvent(target, subcategory));
- }
- });
-
- categoryContainer.add(new Label("customLabel", new ResourceModel("custom", "custom")).setVisible(false));
-
- custom = new AjaxTextFieldPanel("custom", "custom", new Model<String>(null));
-// custom.setStyleSheet("ui-widget-content ui-corner-all short_fixedsize");
- custom.setVisible(false);
- custom.setEnabled(false);
-
- categoryContainer.add(custom.hideLabel());
-
- actionPanel = ActionLinksPanel.<EventCategoryTO>builder().
- add(new ActionLink<EventCategoryTO>() {
-
- private static final long serialVersionUID = -3722207913631435501L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final EventCategoryTO modelObject) {
-
- if (StringUtils.isNotBlank(custom.getModelObject())) {
- final Map.Entry<EventCategoryTO, AuditElements.Result> parsed = AuditLoggerName.
- parseEventCategory(
- custom.getModelObject());
-
- final String eventString = AuditLoggerName.buildEvent(
- parsed.getKey().getType(),
- null,
- null,
- parsed.getKey().getEvents().isEmpty()
- ? StringUtils.EMPTY : parsed.getKey().getEvents().iterator().next(),
- parsed.getValue());
-
- custom.setModelObject(StringUtils.EMPTY);
- send(LoggerCategoryPanel.this.getPage(), Broadcast.BREADTH, new EventSelectionChanged(
- target,
- Collections.<String>singleton(eventString),
- Collections.<String>emptySet()));
- target.add(categoryContainer);
- }
- }
- }, ActionLink.ActionType.CREATE, StandardEntitlement.NOTIFICATION_UPDATE, true).
- add(new ActionLink<EventCategoryTO>() {
-
- private static final long serialVersionUID = -3722207913631435501L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final EventCategoryTO modelObject) {
- if (StringUtils.isNotBlank(custom.getModelObject())) {
- final Map.Entry<EventCategoryTO, AuditElements.Result> parsed = AuditLoggerName.
- parseEventCategory(
- custom.getModelObject());
-
- final String eventString = AuditLoggerName.buildEvent(
- parsed.getKey().getType(),
- null,
- null,
- parsed.getKey().getEvents().isEmpty()
- ? StringUtils.EMPTY : parsed.getKey().getEvents().iterator().next(),
- parsed.getValue());
-
- custom.setModelObject(StringUtils.EMPTY);
- send(LoggerCategoryPanel.this.getPage(), Broadcast.BREADTH, new EventSelectionChanged(
- target,
- Collections.<String>singleton(eventString),
- Collections.<String>emptySet()));
- target.add(categoryContainer);
- }
- }
- }, ActionLink.ActionType.CREATE, pageId, true).
- add(new ActionLink<EventCategoryTO>() {
-
- private static final long serialVersionUID = -3722207913631435521L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final EventCategoryTO modelObject) {
- if (StringUtils.isNotBlank(custom.getModelObject())) {
- final Map.Entry<EventCategoryTO, AuditElements.Result> parsed = AuditLoggerName.
- parseEventCategory(
- custom.getModelObject());
-
- final String eventString = AuditLoggerName.buildEvent(
- parsed.getKey().getType(),
- null,
- null,
- parsed.getKey().getEvents().isEmpty()
- ? StringUtils.EMPTY : parsed.getKey().getEvents().iterator().next(),
- parsed.getValue());
-
- custom.setModelObject(StringUtils.EMPTY);
- send(LoggerCategoryPanel.this.getPage(), Broadcast.BREADTH, new EventSelectionChanged(
- target,
- Collections.<String>emptySet(),
- Collections.<String>singleton(eventString)));
- target.add(categoryContainer);
- }
- }
- }, ActionLink.ActionType.DELETE, pageId, true).build("customActions");
-
- //, new Model(), pageReference);
- categoryContainer.add(actionPanel);
-
- actionPanel.setVisible(false);
- actionPanel.setEnabled(false);
-
- eventsContainer.add(new EventSelectionPanel("eventsPanel", eventCategoryTO, model) {
-
- private static final long serialVersionUID = 3513194801190026082L;
-
- @Override
- protected void onEventAction(final IEvent<?> event) {
- LoggerCategoryPanel.this.onEventAction(event);
- }
- });
- }
-
- private List<String> filter(
- final List<EventCategoryTO> eventCategoryTOs, final EventCategoryType type) {
- final Set<String> res = new HashSet<String>();
-
- for (EventCategoryTO eventCategory : eventCategoryTOs) {
- if (type == eventCategory.getType() && StringUtils.isNotEmpty(eventCategory.getCategory())) {
- res.add(eventCategory.getCategory());
- }
- }
-
- final List<String> filtered = new ArrayList<String>(res);
- Collections.sort(filtered);
- return filtered;
- }
-
- private List<String> filter(
- final List<EventCategoryTO> eventCategoryTOs, final EventCategoryType type, final String category) {
- final Set<String> res = new HashSet<String>();
-
- for (EventCategoryTO eventCategory : eventCategoryTOs) {
- if (type == eventCategory.getType() && StringUtils.equals(category, eventCategory.getCategory())
- && StringUtils.isNotEmpty(eventCategory.getSubcategory())) {
- res.add(eventCategory.getSubcategory());
- }
- }
-
- final List<String> filtered = new ArrayList<String>(res);
- Collections.sort(filtered);
- return filtered;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void onEvent(final IEvent<?> event) {
- if (event.getPayload() instanceof ChangeCategoryEvent) {
- // update objects ....
- eventCategoryTO.getEvents().clear();
-
- final ChangeCategoryEvent change = (ChangeCategoryEvent) event.getPayload();
-
- final Panel changedPanel = change.getChangedPanel();
- if ("type".equals(changedPanel.getId())) {
- eventCategoryTO.setType(type.getModelObject());
- eventCategoryTO.setCategory(null);
- eventCategoryTO.setSubcategory(null);
-
- if (type.getModelObject() == EventCategoryType.CUSTOM) {
- category.setChoices(Collections.<String>emptyList());
- subcategory.setChoices(Collections.<String>emptyList());
- category.setEnabled(false);
- subcategory.setEnabled(false);
- custom.setVisible(true);
- custom.setEnabled(true);
- actionPanel.setVisible(true);
- actionPanel.setEnabled(true);
-
- } else {
- category.setChoices(filter(eventCategoryTOs, type.getModelObject()));
- subcategory.setChoices(Collections.<String>emptyList());
- category.setEnabled(true);
- subcategory.setEnabled(true);
- custom.setVisible(false);
- custom.setEnabled(false);
- actionPanel.setVisible(false);
- actionPanel.setEnabled(false);
- }
- change.getTarget().add(categoryContainer);
- } else if ("category".equals(changedPanel.getId())) {
- subcategory.setChoices(filter(eventCategoryTOs, type.getModelObject(), category.getModelObject()));
- eventCategoryTO.setCategory(category.getModelObject());
- eventCategoryTO.setSubcategory(null);
- change.getTarget().add(categoryContainer);
- } else {
- eventCategoryTO.setSubcategory(subcategory.getModelObject());
- }
-
- updateEventsContainer(change.getTarget());
- } else if (event.getPayload() instanceof InspectSelectedEvent) {
- // update objects ....
- eventCategoryTO.getEvents().clear();
-
- final InspectSelectedEvent inspectSelectedEvent = (InspectSelectedEvent) event.getPayload();
-
- final Map.Entry<EventCategoryTO, AuditElements.Result> categoryEvent = AuditLoggerName.parseEventCategory(
- inspectSelectedEvent.getEvent());
-
- eventCategoryTO.setType(categoryEvent.getKey().getType());
- category.setChoices(filter(eventCategoryTOs, type.getModelObject()));
-
- eventCategoryTO.setCategory(categoryEvent.getKey().getCategory());
- subcategory.setChoices(filter(eventCategoryTOs, type.getModelObject(), category.getModelObject()));
-
- eventCategoryTO.setSubcategory(categoryEvent.getKey().getSubcategory());
-
- if (categoryEvent.getKey().getType() == EventCategoryType.CUSTOM) {
- custom.setModelObject(AuditLoggerName.buildEvent(
- categoryEvent.getKey().getType(),
- categoryEvent.getKey().getCategory(),
- categoryEvent.getKey().getSubcategory(),
- categoryEvent.getKey().getEvents().isEmpty()
- ? StringUtils.EMPTY : categoryEvent.getKey().getEvents().iterator().next(),
- categoryEvent.getValue()));
-
- category.setEnabled(false);
- subcategory.setEnabled(false);
- custom.setVisible(true);
- custom.setEnabled(true);
- actionPanel.setVisible(true);
- actionPanel.setEnabled(true);
- } else {
- category.setEnabled(true);
- subcategory.setEnabled(true);
- custom.setVisible(false);
- custom.setEnabled(false);
- actionPanel.setVisible(false);
- actionPanel.setEnabled(false);
- }
-
- inspectSelectedEvent.getTarget().add(categoryContainer);
- updateEventsContainer(inspectSelectedEvent.getTarget());
- }
- }
-
- private void setEvents() {
- final Iterator<EventCategoryTO> itor = eventCategoryTOs.iterator();
- while (itor.hasNext() && eventCategoryTO.getEvents().isEmpty()) {
- final EventCategoryTO eventCategory = itor.next();
- if (eventCategory.getType() == eventCategoryTO.getType()
- && StringUtils.equals(eventCategory.getCategory(), eventCategoryTO.getCategory())
- && StringUtils.equals(eventCategory.getSubcategory(), eventCategoryTO.getSubcategory())) {
- eventCategoryTO.getEvents().addAll(eventCategory.getEvents());
-
- }
- }
- }
-
- private class ChangeCategoryEvent {
-
- private final AjaxRequestTarget target;
-
- private final Panel changedPanel;
-
- ChangeCategoryEvent(final AjaxRequestTarget target, final Panel changedPanel) {
- this.target = target;
- this.changedPanel = changedPanel;
- }
-
- public AjaxRequestTarget getTarget() {
- return target;
- }
-
- public Panel getChangedPanel() {
- return changedPanel;
- }
- }
-
- /**
- * To be extended in order to add actions on events.
- *
- * @param event event.
- */
- protected void onEventAction(final IEvent<?> event) {
- // nothing by default
- }
-
- private void authorizeList() {
- for (String role : getListRoles()) {
- MetaDataRoleAuthorizationStrategy.authorize(selectedEventsPanel, RENDER, role);
- }
- }
-
- private void authorizeChanges() {
- for (String role : getChangeRoles()) {
- MetaDataRoleAuthorizationStrategy.authorize(categoryContainer, RENDER, role);
- MetaDataRoleAuthorizationStrategy.authorize(eventsContainer, RENDER, role);
- }
- }
-
- private void updateEventsContainer(final AjaxRequestTarget target) {
- setEvents();
-
- eventsContainer.addOrReplace(new EventSelectionPanel("eventsPanel", eventCategoryTO, model) {
-
- private static final long serialVersionUID = 3513194801190026082L;
-
- @Override
- public void onEventAction(final IEvent<?> event) {
- LoggerCategoryPanel.this.onEventAction(event);
- }
- });
- target.add(eventsContainer);
- }
-
- protected abstract String[] getListRoles();
-
- protected abstract String[] getChangeRoles();
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/052cf6b1/client/console/src/main/java/org/apache/syncope/client/console/notifications/MailTemplateDirectoryPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/notifications/MailTemplateDirectoryPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/notifications/MailTemplateDirectoryPanel.java
index 2b9d072..6b1796f 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/notifications/MailTemplateDirectoryPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/notifications/MailTemplateDirectoryPanel.java
@@ -203,14 +203,14 @@ public class MailTemplateDirectoryPanel
@Override
public Iterator<MailTemplateTO> iterator(final long first, final long count) {
- final List<MailTemplateTO> list = restClient.getAllAvailableTemplates();
+ final List<MailTemplateTO> list = restClient.listTemplates();
Collections.sort(list, comparator);
return list.subList((int) first, (int) first + (int) count).iterator();
}
@Override
public long size() {
- return restClient.getAllAvailableTemplates().size();
+ return restClient.listTemplates().size();
}
@Override
http://git-wip-us.apache.org/repos/asf/syncope/blob/052cf6b1/client/console/src/main/java/org/apache/syncope/client/console/notifications/NotificationDirectoryPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/notifications/NotificationDirectoryPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/notifications/NotificationDirectoryPanel.java
index 195c5ff..ba0e43a 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/notifications/NotificationDirectoryPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/notifications/NotificationDirectoryPanel.java
@@ -34,6 +34,7 @@ import org.apache.syncope.client.console.notifications.NotificationDirectoryPane
import org.apache.syncope.client.console.panels.DirectoryPanel;
import org.apache.syncope.client.console.rest.NotificationRestClient;
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;
import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.CollectionPropertyColumn;
import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.KeyPropertyColumn;
import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
@@ -56,23 +57,24 @@ import org.apache.wicket.model.ResourceModel;
import org.apache.wicket.model.StringResourceModel;
public class NotificationDirectoryPanel
- extends DirectoryPanel<NotificationTO, NotificationHandler, NotificationProvider, NotificationRestClient> {
+ extends DirectoryPanel<NotificationTO, NotificationWrapper, NotificationProvider, NotificationRestClient> {
private static final long serialVersionUID = -3789392431954221446L;
protected final BaseModal<Serializable> utilityModal = new BaseModal<>("outer");
- public NotificationDirectoryPanel(final String id, final PageReference pageReference) {
- super(id, pageReference, true);
+ public NotificationDirectoryPanel(final String id, final PageReference pageRef) {
+ super(id, pageRef, true);
disableCheckBoxes();
addOuterObject(utilityModal);
setWindowClosedReloadCallback(utilityModal);
+ utilityModal.size(Modal.Size.Large);
modal.size(Modal.Size.Large);
altDefaultModal.size(Modal.Size.Large);
- addNewItemPanelBuilder(new NotificationWizardBuilder(new NotificationTO(), pageReference), true);
+ addNewItemPanelBuilder(new NotificationWizardBuilder(new NotificationTO(), pageRef), true);
restClient = new NotificationRestClient();
@@ -83,7 +85,6 @@ public class NotificationDirectoryPanel
@Override
protected List<IColumn<NotificationTO, String>> getColumns() {
-
List<IColumn<NotificationTO, String>> columns = new ArrayList<>();
columns.add(new KeyPropertyColumn<NotificationTO>(
new StringResourceModel("key", this, null), "key", "key"));
@@ -95,7 +96,7 @@ public class NotificationDirectoryPanel
new StringResourceModel("template", this, null), "template", "template"));
columns.add(new PropertyColumn<NotificationTO, String>(
new StringResourceModel("traceLevel", this, null), "traceLevel", "traceLevel"));
- columns.add(new PropertyColumn<NotificationTO, String>(
+ columns.add(new BooleanPropertyColumn<NotificationTO>(
new StringResourceModel("active", this, null), "active", "active"));
columns.add(new ActionColumn<NotificationTO, String>(new ResourceModel("actions", "")) {
@@ -130,7 +131,7 @@ public class NotificationDirectoryPanel
public void onClick(final AjaxRequestTarget target, final NotificationTO ignore) {
send(NotificationDirectoryPanel.this, Broadcast.EXACT,
new AjaxWizard.EditItemActionEvent<>(
- new NotificationHandler(restClient.read(model.getObject().getKey())), target));
+ new NotificationWrapper(restClient.read(model.getObject().getKey())), target));
}
}, ActionLink.ActionType.EDIT, StandardEntitlement.NOTIFICATION_UPDATE);
@@ -173,7 +174,7 @@ public class NotificationDirectoryPanel
return Collections.<ActionLink.ActionType>emptyList();
}
- public class NotificationProvider extends DirectoryDataProvider<NotificationTO> {
+ protected class NotificationProvider extends DirectoryDataProvider<NotificationTO> {
private static final long serialVersionUID = -276043813563988590L;
@@ -181,20 +182,21 @@ public class NotificationDirectoryPanel
public NotificationProvider(final int paginatorRows) {
super(paginatorRows);
+
setSort("key", SortOrder.ASCENDING);
comparator = new SortableDataProviderComparator<>(this);
}
@Override
public Iterator<NotificationTO> iterator(final long first, final long count) {
- final List<NotificationTO> list = restClient.getAllNotifications();
+ List<NotificationTO> list = restClient.list();
Collections.sort(list, comparator);
return list.subList((int) first, (int) first + (int) count).iterator();
}
@Override
public long size() {
- return restClient.getAllNotifications().size();
+ return restClient.list().size();
}
@Override