http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/panels/AttrTemplatesPanel.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/AttrTemplatesPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/AttrTemplatesPanel.java deleted file mode 100644 index 98ada28..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/panels/AttrTemplatesPanel.java +++ /dev/null @@ -1,167 +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.util.Collection; -import java.util.Collections; -import java.util.List; -import org.apache.syncope.client.console.commons.Constants; -import org.apache.syncope.client.console.commons.SelectChoiceRenderer; -import org.apache.syncope.client.console.rest.SchemaRestClient; -import org.apache.syncope.client.console.wicket.markup.html.form.NonI18nPalette; -import org.apache.syncope.common.lib.to.GroupTO; -import org.apache.syncope.common.lib.types.AttributableType; -import org.apache.syncope.common.lib.types.SchemaType; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; -import org.apache.wicket.event.Broadcast; -import org.apache.wicket.extensions.markup.html.form.palette.component.Recorder; -import org.apache.wicket.markup.html.panel.Panel; -import org.apache.wicket.model.PropertyModel; -import org.apache.wicket.model.util.ListModel; -import org.apache.wicket.spring.injection.annot.SpringBean; - -public class AttrTemplatesPanel extends Panel { - - public enum Type { - - gPlainAttrTemplates, - gDerAttrTemplates, - gVirAttrTemplates, - mPlainAttrTemplates, - mDerAttrTemplates, - mVirAttrTemplates; - - } - - private static final long serialVersionUID = 1016028222120619000L; - - @SpringBean - private SchemaRestClient schemaRestClient; - - private final GroupTO groupTO; - - private final NonI18nPalette<String> rPlainAttrTemplates; - - private final NonI18nPalette<String> rDerAttrTemplates; - - private final NonI18nPalette<String> rVirAttrTemplates; - - public AttrTemplatesPanel(final String id, final GroupTO groupTO) { - super(id); - this.groupTO = groupTO; - - rPlainAttrTemplates = buildPalette(Type.gPlainAttrTemplates, - schemaRestClient.getSchemaNames(AttributableType.GROUP, SchemaType.PLAIN)); - this.add(rPlainAttrTemplates); - rDerAttrTemplates = buildPalette(Type.gDerAttrTemplates, - schemaRestClient.getSchemaNames(AttributableType.GROUP, SchemaType.DERIVED)); - this.add(rDerAttrTemplates); - rVirAttrTemplates = buildPalette(Type.gVirAttrTemplates, - schemaRestClient.getSchemaNames(AttributableType.GROUP, SchemaType.VIRTUAL)); - this.add(rVirAttrTemplates); - - this.add(buildPalette(Type.mPlainAttrTemplates, - schemaRestClient.getSchemaNames(AttributableType.MEMBERSHIP, SchemaType.PLAIN))); - this.add(buildPalette(Type.mDerAttrTemplates, - schemaRestClient.getSchemaNames(AttributableType.MEMBERSHIP, SchemaType.DERIVED))); - this.add(buildPalette(Type.mVirAttrTemplates, - schemaRestClient.getSchemaNames(AttributableType.MEMBERSHIP, SchemaType.VIRTUAL))); - } - - private NonI18nPalette<String> buildPalette(final Type type, final List<String> allSchemas) { - if (allSchemas != null && !allSchemas.isEmpty()) { - Collections.sort(allSchemas); - } - ListModel<String> availableSchemas = new ListModel<>(allSchemas); - - return new NonI18nPalette<String>(type.name(), new PropertyModel<List<String>>(groupTO, type.name()), - availableSchemas, new SelectChoiceRenderer<String>(), 8, false, true) { - - private static final long serialVersionUID = 2295567122085510330L; - - @Override - protected Recorder<String> newRecorderComponent() { - final Recorder<String> recorder = super.newRecorderComponent(); - - switch (type) { - case gPlainAttrTemplates: - case gDerAttrTemplates: - case gVirAttrTemplates: - recorder.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { - - private static final long serialVersionUID = -1107858522700306810L; - - @Override - protected void onUpdate(final AjaxRequestTarget target) { - send(getPage(), Broadcast.BREADTH, new GroupAttrTemplatesChange(type, target)); - } - }); - break; - - default: - } - - return recorder; - } - }; - } - - public Collection<String> getSelected(final Type type) { - Collection<String> selected; - switch (type) { - case gPlainAttrTemplates: - selected = this.rPlainAttrTemplates.getModelCollection(); - break; - - case gDerAttrTemplates: - selected = this.rDerAttrTemplates.getModelCollection(); - break; - - case gVirAttrTemplates: - selected = this.rVirAttrTemplates.getModelCollection(); - break; - - default: - selected = Collections.emptyList(); - } - - return selected; - } - - public static class GroupAttrTemplatesChange { - - private final Type type; - - private final AjaxRequestTarget target; - - public GroupAttrTemplatesChange(final Type type, final AjaxRequestTarget target) { - this.type = type; - this.target = target; - } - - public Type getType() { - return type; - } - - public AjaxRequestTarget getTarget() { - return target; - } - } -}
http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/panels/DataTablePanel.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/DataTablePanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/DataTablePanel.java deleted file mode 100644 index a5f6588..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/panels/DataTablePanel.java +++ /dev/null @@ -1,113 +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.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; -import org.apache.wicket.Component; -import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable; -import org.apache.wicket.extensions.markup.html.repeater.data.grid.DataGridView; -import org.apache.wicket.markup.html.form.CheckGroup; -import org.apache.wicket.markup.html.panel.Panel; -import org.apache.wicket.markup.repeater.Item; -import org.apache.wicket.model.IModel; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public abstract class DataTablePanel<T, S> extends Panel { - - private static final long serialVersionUID = -7264400471578272966L; - - /** - * Logger. - */ - private static final Logger LOG = LoggerFactory.getLogger(DataTablePanel.class); - - protected CheckGroup<T> group; - - protected AjaxFallbackDefaultDataTable<T, S> dataTable; - - protected IModel<Collection<T>> model; - - public DataTablePanel(final String id) { - super(id); - - model = new IModel<Collection<T>>() { - - private static final long serialVersionUID = 4886729136344643465L; - - private Collection<T> values = new HashSet<T>(); - - @Override - public Collection<T> getObject() { - // Someone or something call this method to change the model: this is not the right behavior. - // Return a copy of the model object in order to avoid SYNCOPE-465 - return new HashSet<T>(values); - } - - @Override - public void setObject(final Collection<T> selected) { - final Collection<T> all = getGroupModelObjects(); - values.removeAll(all); - values.addAll(selected); - } - - @Override - public void detach() { - } - }; - } - - public final void setCurrentPage(final long page) { - dataTable.setCurrentPage(page); - } - - public final long getRowCount() { - return dataTable.getRowCount(); - } - - public final long getCurrentPage() { - return dataTable.getCurrentPage(); - } - - public final long getPageCount() { - return dataTable.getPageCount(); - } - - public void setItemsPerPage(final int resourcePaginatorRows) { - dataTable.setItemsPerPage(resourcePaginatorRows); - } - - protected Collection<T> getGroupModelObjects() { - final Set<T> res = new HashSet<T>(); - - final Component rows = group.get("dataTable:body:rows"); - if (rows instanceof DataGridView) { - @SuppressWarnings("unchecked") - final Iterator<Item<T>> iter = ((DataGridView<T>) rows).getItems(); - - while (iter.hasNext()) { - res.add(iter.next().getModelObject()); - } - } - return res; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/panels/DerAttrsPanel.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/DerAttrsPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/DerAttrsPanel.java deleted file mode 100644 index 8be459a..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/panels/DerAttrsPanel.java +++ /dev/null @@ -1,206 +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.util.ArrayList; -import java.util.List; -import org.apache.syncope.client.console.commons.Constants; -import org.apache.syncope.client.console.panels.AttrTemplatesPanel.GroupAttrTemplatesChange; -import org.apache.syncope.client.console.rest.GroupRestClient; -import org.apache.syncope.client.console.rest.SchemaRestClient; -import org.apache.syncope.client.console.wicket.markup.html.form.AjaxDecoratedCheckbox; -import org.apache.syncope.common.lib.to.AbstractAttributableTO; -import org.apache.syncope.common.lib.to.AttrTO; -import org.apache.syncope.common.lib.to.MembershipTO; -import org.apache.syncope.common.lib.to.GroupTO; -import org.apache.syncope.common.lib.to.UserTO; -import org.apache.syncope.common.lib.types.AttributableType; -import org.apache.wicket.Component; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.attributes.AjaxCallListener; -import org.apache.wicket.ajax.attributes.AjaxRequestAttributes; -import org.apache.wicket.ajax.attributes.IAjaxCallListener; -import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; -import org.apache.wicket.ajax.markup.html.form.AjaxButton; -import org.apache.wicket.event.IEvent; -import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton; -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.markup.html.form.TextField; -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.LoadableDetachableModel; -import org.apache.wicket.model.Model; -import org.apache.wicket.model.PropertyModel; -import org.apache.wicket.model.ResourceModel; -import org.apache.wicket.spring.injection.annot.SpringBean; - -public class DerAttrsPanel extends Panel { - - private static final long serialVersionUID = -5387344116983102292L; - - @SpringBean - private SchemaRestClient schemaRestClient; - - @SpringBean - private GroupRestClient groupRestClient; - - private final AttrTemplatesPanel attrTemplates; - - public <T extends AbstractAttributableTO> DerAttrsPanel(final String id, final T entityTO) { - this(id, entityTO, null); - } - - public <T extends AbstractAttributableTO> DerAttrsPanel(final String id, final T entityTO, - final AttrTemplatesPanel attrTemplates) { - - super(id); - this.attrTemplates = attrTemplates; - setOutputMarkupId(true); - - final IModel<List<String>> derSchemas = new LoadableDetachableModel<List<String>>() { - - private static final long serialVersionUID = 5275935387613157437L; - - @Override - protected List<String> load() { - List<String> derSchemaNames; - - if (entityTO instanceof GroupTO) { - final GroupTO groupTO = (GroupTO) entityTO; - - if (attrTemplates == null) { - derSchemaNames = groupTO.getGDerAttrTemplates(); - } else { - derSchemaNames = new ArrayList<>( - attrTemplates.getSelected(AttrTemplatesPanel.Type.gDerAttrTemplates)); - if (groupTO.isInheritTemplates() && groupTO.getParent() != 0) { - derSchemaNames.addAll(groupRestClient.read(groupTO.getParent()).getGDerAttrTemplates()); - } - } - } else if (entityTO instanceof UserTO) { - derSchemaNames = schemaRestClient.getDerSchemaNames(AttributableType.USER); - } else { - derSchemaNames = groupRestClient.read(((MembershipTO) entityTO).getGroupKey()).getMDerAttrTemplates(); - } - - return derSchemaNames; - } - }; - - final WebMarkupContainer attributesContainer = new WebMarkupContainer("derAttrContainer"); - - attributesContainer.setOutputMarkupId(true); - add(attributesContainer); - - AjaxButton addAttributeBtn = new IndicatingAjaxButton("addAttributeBtn", new ResourceModel("addAttributeBtn")) { - - private static final long serialVersionUID = -4804368561204623354L; - - @Override - protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { - entityTO.getDerAttrs().add(new AttrTO()); - target.add(attributesContainer); - } - - @Override - protected void onError(final AjaxRequestTarget target, final Form<?> form) { - target.add(attributesContainer); - } - }; - add(addAttributeBtn.setDefaultFormProcessing(false)); - - ListView<AttrTO> attributes = new ListView<AttrTO>("attrs", - new PropertyModel<List<? extends AttrTO>>(entityTO, "derAttrs")) { - - private static final long serialVersionUID = 9101744072914090143L; - - @Override - protected void populateItem(final ListItem<AttrTO> item) { - final AttrTO attributeTO = item.getModelObject(); - - item.add(new AjaxDecoratedCheckbox("toRemove", new Model<>(Boolean.FALSE)) { - - private static final long serialVersionUID = 7170946748485726506L; - - @Override - protected void onUpdate(final AjaxRequestTarget target) { - entityTO.getDerAttrs().remove(attributeTO); - target.add(attributesContainer); - } - - @Override - protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) { - super.updateAjaxAttributes(attributes); - - IAjaxCallListener ajaxCallListener = new AjaxCallListener() { - - private static final long serialVersionUID = 7160235486520935153L; - - @Override - public CharSequence getPrecondition(final Component component) { - return "if (!confirm('" + getString("confirmDelete") + "')) return false;"; - } - }; - attributes.getAjaxCallListeners().add(ajaxCallListener); - } - }); - - final DropDownChoice<String> schemaChoice = new DropDownChoice<String>("schema", - new PropertyModel<String>(attributeTO, "schema"), derSchemas); - schemaChoice.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_BLUR) { - - private static final long serialVersionUID = -1107858522700306810L; - - @Override - protected void onUpdate(final AjaxRequestTarget target) { - attributeTO.setSchema(schemaChoice.getModelObject()); - } - }); - schemaChoice.setRequired(true); - schemaChoice.setOutputMarkupId(true); - schemaChoice.setRequired(true); - item.add(schemaChoice); - - final List<String> values = attributeTO.getValues(); - if (values == null || values.isEmpty()) { - item.add(new TextField<String>("value", - new Model<String>(null)).setVisible(false)); - } else { - item.add(new TextField<String>("value", - new Model<String>(values.get(0))).setEnabled(false)); - } - } - }; - attributesContainer.add(attributes); - } - - @Override - public void onEvent(final IEvent<?> event) { - if ((event.getPayload() instanceof GroupAttrTemplatesChange)) { - final GroupAttrTemplatesChange update = (GroupAttrTemplatesChange) event.getPayload(); - if (attrTemplates != null && update.getType() == AttrTemplatesPanel.Type.gDerAttrTemplates) { - update.getTarget().add(this); - } - } - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/panels/EventSelectionPanel.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/EventSelectionPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/EventSelectionPanel.java deleted file mode 100644 index 5332cb5..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/panels/EventSelectionPanel.java +++ /dev/null @@ -1,243 +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.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.markup.html.list.AltListView; -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<>(); - 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.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 AltListView<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 AltListView<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<>("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<>(); - 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()); - - final CheckGroupSelector failureSelector = new CheckGroupSelector("failureSelector", failureGroup); - failureSelector.setVisible(!events.isEmpty()); - add(failureSelector); - - final ListView<String> failureView = new AltListView<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<>("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.SYNCHRONIZATION == 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/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupDetailsPanel.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupDetailsPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupDetailsPanel.java deleted file mode 100644 index 7662e4a..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupDetailsPanel.java +++ /dev/null @@ -1,435 +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 org.apache.syncope.client.console.commons.Constants; -import org.apache.syncope.client.console.commons.JexlHelpUtils; -import org.apache.syncope.client.console.pages.GroupSelectModalPage; -import org.apache.syncope.client.console.pages.UserOwnerSelectModalPage; -import org.apache.syncope.client.console.panels.AttrTemplatesPanel.GroupAttrTemplatesChange; -import org.apache.syncope.client.console.panels.AttrTemplatesPanel.Type; -import org.apache.syncope.client.console.rest.GroupRestClient; -import org.apache.syncope.client.console.rest.UserRestClient; -import org.apache.syncope.client.console.wicket.markup.html.form.AjaxCheckBoxPanel; -import org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel; -import org.apache.syncope.common.lib.to.GroupTO; -import org.apache.syncope.common.lib.to.UserTO; -import org.apache.syncope.common.lib.types.AttributableType; -import org.apache.wicket.Page; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; -import org.apache.wicket.ajax.markup.html.AjaxLink; -import org.apache.wicket.event.Broadcast; -import org.apache.wicket.event.IEvent; -import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.panel.Fragment; -import org.apache.wicket.markup.html.panel.Panel; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.PropertyModel; -import org.apache.wicket.spring.injection.annot.SpringBean; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class GroupDetailsPanel extends Panel { - - private static final long serialVersionUID = 855618618337931784L; - - /** - * Logger. - */ - protected static final Logger LOG = LoggerFactory.getLogger(GroupDetailsPanel.class); - - @SpringBean - private UserRestClient userRestClient; - - @SpringBean - private GroupRestClient groupRestClient; - - private final Fragment parentFragment; - - private final WebMarkupContainer ownerContainer; - - private final OwnerModel userOwnerModel; - - private final OwnerModel groupOwnerModel; - - private ParentModel parentModel; - - public GroupDetailsPanel(final String id, final GroupTO groupTO, final boolean templateMode) { - super(id); - - ownerContainer = new WebMarkupContainer("ownerContainer"); - ownerContainer.setOutputMarkupId(true); - this.add(ownerContainer); - - final ModalWindow userOwnerSelectWin = new ModalWindow("userOwnerSelectWin"); - userOwnerSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); - userOwnerSelectWin.setCookieName("create-userOwnerSelect-modal"); - this.add(userOwnerSelectWin); - final ModalWindow groupOwnerSelectWin = new ModalWindow("groupOwnerSelectWin"); - groupOwnerSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); - groupOwnerSelectWin.setCookieName("create-groupOwnerSelect-modal"); - this.add(groupOwnerSelectWin); - final ModalWindow parentSelectWin = new ModalWindow("parentSelectWin"); - parentSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); - parentSelectWin.setCookieName("create-parentSelect-modal"); - this.add(parentSelectWin); - - if (templateMode) { - parentFragment = new Fragment("parent", "parentFragment", this); - - parentModel = new ParentModel(groupTO); - @SuppressWarnings("unchecked") - final AjaxTextFieldPanel parent = new AjaxTextFieldPanel("parent", "parent", parentModel); - parent.setReadOnly(true); - parent.setOutputMarkupId(true); - parentFragment.add(parent); - final AjaxLink<Void> parentSelect = new IndicatingAjaxLink<Void>("parentSelect") { - - private static final long serialVersionUID = -7978723352517770644L; - - @Override - public void onClick(final AjaxRequestTarget target) { - parentSelectWin.setPageCreator(new ModalWindow.PageCreator() { - - private static final long serialVersionUID = -7834632442532690940L; - - @Override - public Page createPage() { - return new GroupSelectModalPage(getPage().getPageReference(), parentSelectWin, - ParentSelectPayload.class); - } - }); - parentSelectWin.show(target); - } - }; - parentFragment.add(parentSelect); - final IndicatingAjaxLink<Void> parentReset = new IndicatingAjaxLink<Void>("parentReset") { - - private static final long serialVersionUID = -7978723352517770644L; - - @Override - public void onClick(final AjaxRequestTarget target) { - parentModel.setObject(null); - target.add(parent); - } - }; - parentFragment.add(parentReset); - } else { - parentFragment = new Fragment("parent", "emptyFragment", this); - } - parentFragment.setOutputMarkupId(true); - this.add(parentFragment); - - final AjaxTextFieldPanel name = - new AjaxTextFieldPanel("name", "name", new PropertyModel<String>(groupTO, "key")); - - final WebMarkupContainer jexlHelp = JexlHelpUtils.getJexlHelpWebContainer("jexlHelp"); - - final AjaxLink<Void> questionMarkJexlHelp = JexlHelpUtils.getAjaxLink(jexlHelp, "questionMarkJexlHelp"); - this.add(questionMarkJexlHelp); - questionMarkJexlHelp.add(jexlHelp); - - if (!templateMode) { - name.addRequiredLabel(); - questionMarkJexlHelp.setVisible(false); - } - this.add(name); - - userOwnerModel = new OwnerModel(groupTO, AttributableType.USER); - @SuppressWarnings("unchecked") - final AjaxTextFieldPanel userOwner = new AjaxTextFieldPanel("userOwner", "userOwner", userOwnerModel); - userOwner.setReadOnly(true); - userOwner.setOutputMarkupId(true); - ownerContainer.add(userOwner); - final AjaxLink<Void> userOwnerSelect = new IndicatingAjaxLink<Void>("userOwnerSelect") { - - private static final long serialVersionUID = -7978723352517770644L; - - @Override - public void onClick(final AjaxRequestTarget target) { - userOwnerSelectWin.setPageCreator(new ModalWindow.PageCreator() { - - private static final long serialVersionUID = -7834632442532690940L; - - @Override - public Page createPage() { - return new UserOwnerSelectModalPage(getPage().getPageReference(), userOwnerSelectWin); - } - }); - userOwnerSelectWin.show(target); - } - }; - ownerContainer.add(userOwnerSelect); - final IndicatingAjaxLink<Void> userOwnerReset = new IndicatingAjaxLink<Void>("userOwnerReset") { - - private static final long serialVersionUID = -7978723352517770644L; - - @Override - public void onClick(final AjaxRequestTarget target) { - userOwnerModel.setObject(null); - target.add(userOwner); - } - }; - ownerContainer.add(userOwnerReset); - - groupOwnerModel = new OwnerModel(groupTO, AttributableType.GROUP); - @SuppressWarnings("unchecked") - final AjaxTextFieldPanel groupOwner = new AjaxTextFieldPanel("groupOwner", "groupOwner", groupOwnerModel); - groupOwner.setReadOnly(true); - groupOwner.setOutputMarkupId(true); - ownerContainer.add(groupOwner); - final AjaxLink<Void> groupOwnerSelect = new IndicatingAjaxLink<Void>("groupOwnerSelect") { - - private static final long serialVersionUID = -7978723352517770644L; - - @Override - public void onClick(final AjaxRequestTarget target) { - parentSelectWin.setPageCreator(new ModalWindow.PageCreator() { - - private static final long serialVersionUID = -7834632442532690940L; - - @Override - public Page createPage() { - return new GroupSelectModalPage(getPage().getPageReference(), parentSelectWin, - GroupOwnerSelectPayload.class); - } - }); - parentSelectWin.show(target); - } - }; - ownerContainer.add(groupOwnerSelect); - final IndicatingAjaxLink<Void> groupOwnerReset = new IndicatingAjaxLink<Void>("groupOwnerReset") { - - private static final long serialVersionUID = -7978723352517770644L; - - @Override - public void onClick(final AjaxRequestTarget target) { - groupOwnerModel.setObject(null); - target.add(groupOwner); - } - }; - ownerContainer.add(groupOwnerReset); - - final AjaxCheckBoxPanel inhOwner = new AjaxCheckBoxPanel("inheritOwner", "inheritOwner", - new PropertyModel<Boolean>(groupTO, "inheritOwner")); - this.add(inhOwner); - - final AjaxCheckBoxPanel inhTemplates = new AjaxCheckBoxPanel("inheritTemplates", "inheritTemplates", - new PropertyModel<Boolean>(groupTO, "inheritTemplates")); - inhTemplates.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { - - private static final long serialVersionUID = -1107858522700306810L; - - @Override - protected void onUpdate(final AjaxRequestTarget target) { - send(getPage(), Broadcast.BREADTH, new GroupAttrTemplatesChange(Type.gPlainAttrTemplates, target)); - send(getPage(), Broadcast.BREADTH, new GroupAttrTemplatesChange(Type.gDerAttrTemplates, target)); - send(getPage(), Broadcast.BREADTH, new GroupAttrTemplatesChange(Type.gVirAttrTemplates, target)); - } - }); - this.add(inhTemplates); - } - - /** - * This is waiting for events from opened modal windows: first to get the selected user / group, then to update the - * respective text panel. - * - * {@inheritDoc } - */ - @Override - public void onEvent(final IEvent<?> event) { - super.onEvent(event); - - if (event.getPayload() instanceof ParentSelectPayload) { - parentModel.setObject(((ParentSelectPayload) event.getPayload()).getGroupId()); - } - if (event.getPayload() instanceof UserOwnerSelectPayload) { - userOwnerModel.setObject(((UserOwnerSelectPayload) event.getPayload()).getUserId()); - } - if (event.getPayload() instanceof GroupOwnerSelectPayload) { - groupOwnerModel.setObject(((GroupOwnerSelectPayload) event.getPayload()).getGroupId()); - } - - if (event.getPayload() instanceof AjaxRequestTarget) { - ((AjaxRequestTarget) event.getPayload()).add(parentFragment); - ((AjaxRequestTarget) event.getPayload()).add(ownerContainer); - } - } - - private class OwnerModel implements IModel { - - private static final long serialVersionUID = -3865621970810102714L; - - private final GroupTO groupTO; - - private final AttributableType type; - - public OwnerModel(final GroupTO groupTO, final AttributableType type) { - this.groupTO = groupTO; - this.type = type; - } - - @Override - public Object getObject() { - String object = null; - - switch (type) { - case USER: - if (groupTO.getUserOwner() != null) { - UserTO user = null; - try { - user = userRestClient.read(groupTO.getUserOwner()); - } catch (Exception e) { - LOG.warn("Could not find user with id {}, ignoring", groupTO.getUserOwner(), e); - } - if (user == null) { - groupTO.setUserOwner(null); - } else { - object = user.getKey() + " " + user.getUsername(); - } - } - break; - - case GROUP: - GroupTO group = null; - if (groupTO.getGroupOwner() != null) { - try { - group = groupRestClient.read(groupTO.getGroupOwner()); - } catch (Exception e) { - LOG.warn("Could not find group with id {}, ignoring", groupTO.getGroupOwner(), e); - } - if (group == null) { - groupTO.setGroupOwner(null); - } else { - object = group.getDisplayName(); - } - } - break; - - case MEMBERSHIP: - default: - } - - return object; - } - - @Override - public void setObject(final Object object) { - switch (type) { - case USER: - groupTO.setUserOwner((Long) object); - break; - - case GROUP: - groupTO.setGroupOwner((Long) object); - break; - - case MEMBERSHIP: - default: - } - } - - @Override - public void detach() { - // ignore - } - } - - private class ParentModel implements IModel { - - private static final long serialVersionUID = 1006546156848990721L; - - private final GroupTO groupTO; - - public ParentModel(final GroupTO groupTO) { - this.groupTO = groupTO; - } - - @Override - public Object getObject() { - Object object = null; - if (groupTO.getParent() != 0) { - GroupTO parent = null; - try { - parent = groupRestClient.read(groupTO.getParent()); - } catch (Exception e) { - LOG.warn("Could not find group with id {}, ignoring", groupTO.getParent(), e); - } - if (parent == null) { - groupTO.setParent(0); - } else { - object = parent.getDisplayName(); - } - } - return object; - } - - @Override - public void setObject(final Object object) { - groupTO.setParent((object instanceof Long) ? ((Long) object) : 0); - } - - @Override - public void detach() { - // ignore - } - } - - public static class UserOwnerSelectPayload { - - private final Long userId; - - public UserOwnerSelectPayload(final Long userId) { - this.userId = userId; - } - - public Long getUserId() { - return userId; - } - } - - public static class GroupOwnerSelectPayload { - - private final Long groupId; - - public GroupOwnerSelectPayload(final Long groupId) { - this.groupId = groupId; - } - - public Long getGroupId() { - return groupId; - } - } - - public static class ParentSelectPayload { - - private final Long groupId; - - public ParentSelectPayload(final Long groupId) { - this.groupId = groupId; - } - - public Long getGroupId() { - return groupId; - } - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupPanel.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupPanel.java deleted file mode 100644 index 7cbf47e..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupPanel.java +++ /dev/null @@ -1,187 +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.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import org.apache.syncope.client.console.commons.Mode; -import org.apache.syncope.client.console.commons.XMLRolesReader; -import org.apache.syncope.client.console.commons.status.StatusBean; -import org.apache.syncope.client.console.rest.AuthRestClient; -import org.apache.syncope.client.console.wicket.markup.html.form.AjaxCheckBoxPanel; -import org.apache.syncope.client.console.wicket.markup.html.form.AjaxPalettePanel; -import org.apache.syncope.common.lib.to.GroupTO; -import org.apache.wicket.PageReference; -import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy; -import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.markup.html.panel.Panel; -import org.apache.wicket.model.PropertyModel; -import org.apache.wicket.model.util.ListModel; -import org.apache.wicket.spring.injection.annot.SpringBean; - -public class GroupPanel extends Panel { - - private static final long serialVersionUID = 4216376097320768369L; - - @SpringBean - private AuthRestClient authRestClient; - - @SpringBean - private XMLRolesReader xmlRolesReader; - - private final AjaxPalettePanel<String> entitlements; - - public static class Builder implements Serializable { - - private static final long serialVersionUID = 8150440254654306070L; - - private String id; - - private Form form; - - private GroupTO groupTO; - - private Mode mode; - - private PageReference pageReference; - - public Builder(final String id) { - this.id = id; - } - - public Builder form(final Form form) { - this.form = form; - return this; - } - - public Builder groupTO(final GroupTO groupTO) { - this.groupTO = groupTO; - return this; - } - - public Builder groupModalPageMode(final Mode mode) { - this.mode = mode; - return this; - } - - public Builder pageRef(final PageReference pageReference) { - this.pageReference = pageReference; - return this; - } - - public GroupPanel build() { - return new GroupPanel(this); - } - } - - private GroupPanel(final Builder builder) { - super(builder.id); - - this.add(new GroupDetailsPanel("details", builder.groupTO, builder.mode == Mode.TEMPLATE)); - - if (builder.pageReference == null || builder.groupTO.getKey() == 0) { - this.add(new Label("statuspanel", "")); - } else { - StatusPanel statusPanel = new StatusPanel( - "statuspanel", builder.groupTO, new ArrayList<StatusBean>(), builder.pageReference); - statusPanel.setOutputMarkupId(true); - MetaDataRoleAuthorizationStrategy.authorize( - statusPanel, RENDER, xmlRolesReader.getEntitlement("Resources", "getConnectorObject")); - this.add(statusPanel); - } - - this.add(new AnnotatedBeanPanel("systeminformation", builder.groupTO)); - - //-------------------------------- - // Attribute templates panel - //-------------------------------- - AttrTemplatesPanel attrTemplates = new AttrTemplatesPanel("templates", builder.groupTO); - this.add(attrTemplates); - - //-------------------------------- - // Attributes panel - //-------------------------------- - this.add(new PlainAttrsPanel( - "plainAttrs", builder.groupTO, builder.form, builder.mode, attrTemplates)); - - final AjaxCheckBoxPanel inhAttributes = new AjaxCheckBoxPanel("inheritPlainAttrs", "inheritPlainAttrs", - new PropertyModel<Boolean>(builder.groupTO, "inheritPlainAttrs")); - inhAttributes.setOutputMarkupId(true); - this.add(inhAttributes); - //-------------------------------- - - //-------------------------------- - // Derived attributes panel - //-------------------------------- - this.add(new DerAttrsPanel("derAttrs", builder.groupTO, attrTemplates)); - - final AjaxCheckBoxPanel inhDerivedAttributes = new AjaxCheckBoxPanel("inheritDerAttrs", - "inheritDerAttrs", new PropertyModel<Boolean>(builder.groupTO, "inheritDerAttrs")); - inhDerivedAttributes.setOutputMarkupId(true); - this.add(inhDerivedAttributes); - //-------------------------------- - - //-------------------------------- - // Virtual attributes panel - //-------------------------------- - this.add(new VirAttrsPanel( - "virAttrs", builder.groupTO, builder.mode == Mode.TEMPLATE, attrTemplates)); - - final AjaxCheckBoxPanel inhVirtualAttributes = new AjaxCheckBoxPanel("inheritVirAttrs", - "inheritVirAttrs", new PropertyModel<Boolean>(builder.groupTO, "inheritVirAttrs")); - inhVirtualAttributes.setOutputMarkupId(true); - this.add(inhVirtualAttributes); - //-------------------------------- - - //-------------------------------- - // Resources panel - //-------------------------------- - this.add(new ResourcesPanel.Builder("resources").attributableTO(builder.groupTO).build(). - setOutputMarkupId(true)); - //-------------------------------- - - //-------------------------------- - // Entitlements - //-------------------------------- - ListModel<String> selectedEntitlements = new ListModel<String>(builder.groupTO.getEntitlements()); - - List<String> allEntitlements = authRestClient.getAllEntitlements(); - if (allEntitlements != null && !allEntitlements.isEmpty()) { - Collections.sort(allEntitlements); - } - ListModel<String> availableEntitlements = new ListModel<String>(allEntitlements); - - entitlements = new AjaxPalettePanel<String>("entitlements", selectedEntitlements, availableEntitlements); - this.add(entitlements); - - //-------------------------------- - // Security panel - //-------------------------------- - this.add(new GroupSecurityPanel("security", builder.groupTO).setOutputMarkupId(true)); - //-------------------------------- - } - - public Collection<String> getSelectedEntitlements() { - return this.entitlements.getModelCollection(); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupSearchPanel.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupSearchPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupSearchPanel.java deleted file mode 100644 index d13ab94..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupSearchPanel.java +++ /dev/null @@ -1,101 +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.util.ArrayList; -import java.util.Collections; -import java.util.List; -import org.apache.syncope.client.lib.SyncopeClient; -import org.apache.syncope.common.lib.search.AbstractFiqlSearchConditionBuilder; -import org.apache.syncope.common.lib.types.AttributableType; -import org.apache.wicket.model.LoadableDetachableModel; - -public class GroupSearchPanel extends AbstractSearchPanel { - - private static final long serialVersionUID = 5757183539269316263L; - - public static class Builder implements Serializable { - - private static final long serialVersionUID = 6308997285778809579L; - - private String id; - - private String fiql = null; - - private boolean required = true; - - public Builder(final String id) { - this.id = id; - } - - public Builder fiql(final String fiql) { - this.fiql = fiql; - return this; - } - - public Builder required(final boolean required) { - this.required = required; - return this; - } - - public GroupSearchPanel build() { - return new GroupSearchPanel(this); - } - } - - private GroupSearchPanel(final Builder builder) { - super(builder.id, AttributableType.GROUP, builder.fiql, builder.required); - } - - @Override - protected void populate() { - super.populate(); - - this.types = new LoadableDetachableModel<List<SearchClause.Type>>() { - - private static final long serialVersionUID = 5275935387613157437L; - - @Override - protected List<SearchClause.Type> load() { - final List<SearchClause.Type> result = new ArrayList<SearchClause.Type>(); - result.add(SearchClause.Type.ATTRIBUTE); - result.add(SearchClause.Type.ENTITLEMENT); - result.add(SearchClause.Type.RESOURCE); - return result; - } - }; - - this.groupNames = new LoadableDetachableModel<List<String>>() { - - private static final long serialVersionUID = 5275935387613157437L; - - @Override - protected List<String> load() { - return Collections.<String>emptyList(); - } - }; - } - - @Override - protected AbstractFiqlSearchConditionBuilder getSearchConditionBuilder() { - return SyncopeClient.getGroupSearchConditionBuilder(); - } - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/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 a7dac82..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupSearchResultPanel.java +++ /dev/null @@ -1,172 +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.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import org.apache.syncope.client.console.commons.Constants; -import org.apache.syncope.client.console.pages.ResultStatusModalPage; -import org.apache.syncope.client.console.pages.GroupModalPage; -import org.apache.syncope.client.console.pages.StatusModalPage; -import org.apache.syncope.client.console.rest.AbstractSubjectRestClient; -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.common.lib.SyncopeClientException; -import org.apache.syncope.common.lib.to.AbstractAttributableTO; -import org.apache.syncope.common.lib.to.GroupTO; -import org.apache.wicket.Page; -import org.apache.wicket.PageReference; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; -import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator; -import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn; -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.markup.repeater.Item; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.ResourceModel; - -public class GroupSearchResultPanel extends AbstractSearchResultPanel { - - private static final long serialVersionUID = -1180593361914008764L; - - private final static String PAGEID = "Groups"; - - public <T extends AbstractAttributableTO> GroupSearchResultPanel(final String id, final boolean filtered, - final String fiql, final PageReference callerRef, final AbstractSubjectRestClient restClient) { - - super(id, filtered, fiql, callerRef, restClient); - initResultTable(); - } - - @Override - protected List<IColumn<AbstractAttributableTO, String>> getColumns() { - final List<IColumn<AbstractAttributableTO, String>> columns = new ArrayList<>(); - - for (String item : new String[] { "key", "name", "entitlements" }) { - columns.add(new PropertyColumn<AbstractAttributableTO, String>(new ResourceModel(item, item), item, item)); - } - - columns.add(new AbstractColumn<AbstractAttributableTO, String>(new ResourceModel("actions", "")) { - - private static final long serialVersionUID = -3503023501954863131L; - - @Override - public String getCssClass() { - return "action"; - } - - @Override - public void populateItem(final Item<ICellPopulator<AbstractAttributableTO>> cellItem, - final String componentId, final IModel<AbstractAttributableTO> model) { - - final ActionLinksPanel panel = new ActionLinksPanel(componentId, model, page.getPageReference()); - - panel.add(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - statusmodal.setPageCreator(new ModalWindow.PageCreator() { - - private static final long serialVersionUID = -7834632442532690940L; - - @Override - public Page createPage() { - return new StatusModalPage<GroupTO>( - page.getPageReference(), statusmodal, (GroupTO) model.getObject()); - } - }); - - statusmodal.show(target); - } - }, ActionLink.ActionType.MANAGE_RESOURCES, PAGEID); - - panel.add(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - editmodal.setPageCreator(new ModalWindow.PageCreator() { - - private static final long serialVersionUID = -7834632442532690940L; - - @Override - public Page createPage() { - return new GroupModalPage( - page.getPageReference(), editmodal, (GroupTO) model.getObject()); - } - }); - - editmodal.show(target); - } - }, ActionLink.ActionType.EDIT, PAGEID); - - panel.add(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - try { - final GroupTO groupTO = (GroupTO) restClient. - delete(model.getObject().getETagValue(), model.getObject().getKey()); - - page.setModalResult(true); - - editmodal.setPageCreator(new ModalWindow.PageCreator() { - - private static final long serialVersionUID = -7834632442532690940L; - - @Override - public Page createPage() { - return new ResultStatusModalPage.Builder(editmodal, groupTO).build(); - } - }); - - editmodal.show(target); - } catch (SyncopeClientException scce) { - error(getString(Constants.OPERATION_ERROR) + ": " + scce.getMessage()); - feedbackPanel.refresh(target); - } - } - }, ActionLink.ActionType.DELETE, PAGEID); - - cellItem.add(panel); - } - }); - - return columns; - } - - @Override - protected Collection<ActionType> getBulkActions() { - return Collections.<ActionLink.ActionType>singletonList(ActionLink.ActionType.DELETE); - } - - @Override - protected String getPageId() { - return PAGEID; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupSecurityPanel.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupSecurityPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupSecurityPanel.java deleted file mode 100644 index 4e0e1f9..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupSecurityPanel.java +++ /dev/null @@ -1,198 +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.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import org.apache.syncope.client.console.commons.Constants; -import org.apache.syncope.client.console.rest.PolicyRestClient; -import org.apache.syncope.client.console.wicket.markup.html.form.AjaxCheckBoxPanel; -import org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel; -import org.apache.syncope.common.lib.to.AbstractAttributableTO; -import org.apache.syncope.common.lib.to.AbstractPolicyTO; -import org.apache.syncope.common.lib.types.PolicyType; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.form.ChoiceRenderer; -import org.apache.wicket.markup.html.form.DropDownChoice; -import org.apache.wicket.markup.html.panel.Panel; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.LoadableDetachableModel; -import org.apache.wicket.model.PropertyModel; -import org.apache.wicket.spring.injection.annot.SpringBean; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class GroupSecurityPanel extends Panel { - - /** - * Logger. - */ - protected static final Logger LOG = LoggerFactory.getLogger(GroupSecurityPanel.class); - - private static final long serialVersionUID = -7982691107029848579L; - - @SpringBean - private PolicyRestClient policyRestClient; - - private IModel<Map<Long, String>> passwordPolicies = null; - - private IModel<Map<Long, String>> accountPolicies = null; - - public <T extends AbstractAttributableTO> GroupSecurityPanel(final String id, final T entityTO) { - super(id); - - setOutputMarkupId(true); - - passwordPolicies = new LoadableDetachableModel<Map<Long, String>>() { - - private static final long serialVersionUID = 5275935387613157437L; - - @Override - protected Map<Long, String> load() { - Map<Long, String> res = new HashMap<>(); - for (AbstractPolicyTO policyTO : policyRestClient.getPolicies(PolicyType.PASSWORD, false)) { - res.put(policyTO.getKey(), policyTO.getDescription()); - } - return res; - } - }; - - accountPolicies = new LoadableDetachableModel<Map<Long, String>>() { - - private static final long serialVersionUID = -2012833443695917883L; - - @Override - protected Map<Long, String> load() { - Map<Long, String> res = new HashMap<>(); - for (AbstractPolicyTO policyTO : policyRestClient.getPolicies(PolicyType.ACCOUNT, false)) { - res.put(policyTO.getKey(), policyTO.getDescription()); - } - return res; - } - }; - - final WebMarkupContainer securityContainer = new WebMarkupContainer("security"); - - securityContainer.setOutputMarkupId(true); - add(securityContainer); - - // ------------------------------- - // Password policy specification - // ------------------------------- - final AjaxDropDownChoicePanel<Long> passwordPolicy = new AjaxDropDownChoicePanel<Long>("passwordPolicy", - "passwordPolicy", new PropertyModel<Long>(entityTO, "passwordPolicy")); - - passwordPolicy.setChoiceRenderer(new PolicyRenderer(PolicyType.PASSWORD)); - - passwordPolicy.setChoices(new ArrayList<Long>(passwordPolicies.getObject().keySet())); - - ((DropDownChoice<?>) passwordPolicy.getField()).setNullValid(true); - - securityContainer.add(passwordPolicy); - - final AjaxCheckBoxPanel inhPasswordPolicy = new AjaxCheckBoxPanel("inheritPasswordPolicy", - "inheritPasswordPolicy", new PropertyModel<Boolean>(entityTO, "inheritPasswordPolicy")); - - passwordPolicy.setReadOnly(inhPasswordPolicy.getModelObject()); - - inhPasswordPolicy.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { - - private static final long serialVersionUID = -1107858522700306810L; - - @Override - protected void onUpdate(final AjaxRequestTarget target) { - passwordPolicy.setReadOnly(inhPasswordPolicy.getModelObject()); - target.add(passwordPolicy); - } - }); - - securityContainer.add(inhPasswordPolicy); - // ------------------------------- - - // ------------------------------- - // Account policy specification - // ------------------------------- - final AjaxDropDownChoicePanel<Long> accountPolicy = new AjaxDropDownChoicePanel<Long>("accountPolicy", - "accountPolicy", new PropertyModel<Long>(entityTO, "accountPolicy")); - - accountPolicy.setChoiceRenderer(new PolicyRenderer(PolicyType.ACCOUNT)); - - accountPolicy.setChoices(new ArrayList<Long>(accountPolicies.getObject().keySet())); - - ((DropDownChoice<?>) accountPolicy.getField()).setNullValid(true); - - securityContainer.add(accountPolicy); - - final AjaxCheckBoxPanel inhAccountPolicy = new AjaxCheckBoxPanel("inheritAccountPolicy", - "inheritAccountPolicy", new PropertyModel<Boolean>(entityTO, "inheritAccountPolicy")); - accountPolicy.setReadOnly(inhAccountPolicy.getModelObject()); - - inhAccountPolicy.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { - - private static final long serialVersionUID = -1107858522700306810L; - - @Override - protected void onUpdate(final AjaxRequestTarget target) { - accountPolicy.setReadOnly(inhAccountPolicy.getModelObject()); - target.add(accountPolicy); - } - }); - - securityContainer.add(inhAccountPolicy); - // ------------------------------- - } - - private class PolicyRenderer extends ChoiceRenderer<Long> { - - private static final long serialVersionUID = 8060500161321947000L; - - private PolicyType type; - - public PolicyRenderer(final PolicyType type) { - super(); - this.type = type; - } - - @Override - public Object getDisplayValue(final Long object) { - Object displayValue; - switch (type) { - case ACCOUNT: - displayValue = accountPolicies.getObject().get(object); - break; - case PASSWORD: - displayValue = passwordPolicies.getObject().get(object); - break; - default: - displayValue = ""; - } - return displayValue; - } - - @Override - public String getIdValue(Long object, int index) { - return String.valueOf(object != null - ? object - : 0L); - } - }; -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupSummaryPanel.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupSummaryPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupSummaryPanel.java deleted file mode 100644 index f9a56e6..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/panels/GroupSummaryPanel.java +++ /dev/null @@ -1,153 +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 org.apache.syncope.client.console.commons.XMLRolesReader; -import org.apache.syncope.client.console.pages.GroupModalPage; -import org.apache.syncope.client.console.rest.GroupRestClient; -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.common.lib.SyncopeClientException; -import org.apache.syncope.common.lib.to.GroupTO; -import org.apache.wicket.Page; -import org.apache.wicket.PageReference; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; -import org.apache.wicket.markup.html.panel.Fragment; -import org.apache.wicket.markup.html.panel.Panel; -import org.apache.wicket.model.Model; -import org.apache.wicket.spring.injection.annot.SpringBean; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class GroupSummaryPanel extends Panel { - - private static final long serialVersionUID = 643769814985593156L; - - /** - * Logger. - */ - private static final Logger LOG = LoggerFactory.getLogger(GroupSummaryPanel.class); - - @SpringBean - private XMLRolesReader xmlRolesReader; - - @SpringBean - private GroupRestClient restClient; - - private GroupTO selectedNode; - - public static class Builder implements Serializable { - - private static final long serialVersionUID = 4164563358509351832L; - - private String id; - - private ModalWindow window; - - private PageReference callerPageRef; - - private Long selectedNodeId = null; - - public Builder(final String id) { - this.id = id; - } - - public GroupSummaryPanel.Builder window(final ModalWindow window) { - this.window = window; - return this; - } - - public GroupSummaryPanel.Builder callerPageRef(final PageReference callerPageRef) { - this.callerPageRef = callerPageRef; - return this; - } - - public GroupSummaryPanel.Builder selectedNodeId(final Long selectedNodeId) { - this.selectedNodeId = selectedNodeId; - return this; - } - - public GroupSummaryPanel build() { - return new GroupSummaryPanel(this); - } - } - - private GroupSummaryPanel(final Builder builder) { - super(builder.id); - - if (builder.selectedNodeId == null || builder.selectedNodeId == 0) { - selectedNode = null; - } else { - try { - selectedNode = restClient.read(builder.selectedNodeId); - } catch (SyncopeClientException e) { - LOG.error("Could not read {}", builder.selectedNodeId, e); - selectedNode = null; - builder.selectedNodeId = null; - } - } - - Fragment fragment = new Fragment("groupSummaryPanel", - builder.selectedNodeId == null - ? "fakerootFrag" - : (builder.selectedNodeId == 0 ? "rootPanel" : "groupViewPanel"), - this); - - if (builder.selectedNodeId != null) { - if (builder.selectedNodeId == 0) { - @SuppressWarnings("rawtypes") - final ActionLinksPanel links = new ActionLinksPanel("actionLinks", new Model(), builder.callerPageRef); - links.setOutputMarkupId(true); - fragment.add(links); - - links.addWithRoles(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - builder.window.setPageCreator(new ModalWindow.PageCreator() { - - private static final long serialVersionUID = -7834632442532690940L; - - @Override - public Page createPage() { - return new GroupModalPage(builder.callerPageRef, builder.window, new GroupTO()); - } - }); - - builder.window.show(target); - } - }, ActionLink.ActionType.CREATE, xmlRolesReader.getEntitlement("Groups", "create")); - } else { - GroupTabPanel groupTabPanel = - new GroupTabPanel("nodeViewPanel", selectedNode, builder.window, builder.callerPageRef); - groupTabPanel.setOutputMarkupId(true); - fragment.add(groupTabPanel); - } - } - add(fragment); - } - - public GroupTO getSelectedNode() { - return selectedNode; - } -}
