You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by fm...@apache.org on 2016/04/18 10:05:58 UTC
[6/7] syncope git commit: [SYNCOPE-156,
SYNCOPE-817] provides wizard to manage resources and connectors
http://git-wip-us.apache.org/repos/asf/syncope/blob/1735c44c/client/console/src/main/java/org/apache/syncope/client/console/panels/ResourceMappingPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/ResourceMappingPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/ResourceMappingPanel.java
deleted file mode 100644
index 30188f9..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/ResourceMappingPanel.java
+++ /dev/null
@@ -1,642 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.client.console.panels;
-
-import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipConfig;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.apache.commons.collections4.IterableUtils;
-import org.apache.commons.collections4.Predicate;
-import org.apache.syncope.client.console.commons.ConnIdSpecialAttributeName;
-import org.apache.syncope.client.console.commons.Constants;
-import org.apache.syncope.client.console.rest.AnyTypeClassRestClient;
-import org.apache.syncope.client.console.rest.AnyTypeRestClient;
-import org.apache.syncope.client.console.rest.ConnectorRestClient;
-import org.apache.syncope.client.console.wicket.ajax.form.IndicatorAjaxFormComponentUpdatingBehavior;
-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.AjaxCheckBoxPanel;
-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.client.console.wicket.markup.html.form.MappingPurposePanel;
-import org.apache.syncope.common.lib.to.AnyTypeClassTO;
-import org.apache.syncope.common.lib.to.AnyTypeTO;
-import org.apache.syncope.common.lib.to.ConnIdObjectClassTO;
-import org.apache.syncope.common.lib.to.ConnInstanceTO;
-import org.apache.syncope.common.lib.to.MappingItemTO;
-import org.apache.syncope.common.lib.to.MappingTO;
-import org.apache.syncope.common.lib.to.ProvisionTO;
-import org.apache.syncope.common.lib.to.ResourceTO;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.common.lib.types.ConnConfProperty;
-import org.apache.syncope.common.lib.types.IntMappingType;
-import org.apache.syncope.common.lib.types.MappingPurpose;
-import org.apache.syncope.common.lib.types.StandardEntitlement;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.markup.html.form.AjaxButton;
-import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.form.Form;
-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.Model;
-import org.apache.wicket.model.PropertyModel;
-import org.apache.wicket.model.ResourceModel;
-
-/**
- * Resource mapping panel.
- */
-public class ResourceMappingPanel extends Panel {
-
- private static final long serialVersionUID = -7982691107029848579L;
-
- /**
- * Mapping field style sheet.
- */
- private static final String DEF_FIELD_STYLE = "";
-
- /**
- * Any type rest client.
- */
- private final AnyTypeRestClient anyTypeRestClient = new AnyTypeRestClient();
-
- /**
- * Any type class rest client.
- */
- private final AnyTypeClassRestClient anyTypeClassRestClient = new AnyTypeClassRestClient();
-
- /**
- * ConnInstance rest client.
- */
- private final ConnectorRestClient connRestClient = new ConnectorRestClient();
-
- /**
- * Resource schema name.
- */
- private final List<String> schemaNames;
-
- private final Label passwordLabel;
-
- /**
- * Add mapping button.
- */
- private final AjaxButton addMappingBtn;
-
- /**
- * All mappings.
- */
- private final ListView<MappingItemTO> mappings;
-
- /**
- * External resource to be updated.
- */
- private final ResourceTO resourceTO;
-
- /**
- * External resource provisioning configuration instance to be updated.
- */
- private final ProvisionTO provisionTO;
-
- /**
- * Mapping container.
- */
- private final WebMarkupContainer mappingContainer;
-
- private MappingTO getMapping() {
- if (provisionTO.getMapping() == null) {
- provisionTO.setMapping(new MappingTO());
- }
-
- return provisionTO.getMapping();
- }
-
- /**
- * Attribute Mapping Panel.
- *
- * @param id panel id
- * @param resourceTO external resource to be updated.
- * @param provisionTO external resource provisioning configuration instance.
- */
- public ResourceMappingPanel(final String id, final ResourceTO resourceTO, final ProvisionTO provisionTO) {
- super(id);
- setOutputMarkupId(true);
-
- this.resourceTO = resourceTO;
- this.provisionTO = provisionTO == null ? new ProvisionTO() : provisionTO;
-
- this.mappingContainer = new WebMarkupContainer("mappingContainer");
- this.mappingContainer.setOutputMarkupId(true);
- add(this.mappingContainer);
-
- if (resourceTO.getConnector() != null && resourceTO.getConnector() > 0) {
- schemaNames = getSchemaNames(resourceTO.getConnector(), resourceTO.getConfOverride());
- setEnabled();
- } else {
- schemaNames = Collections.<String>emptyList();
- }
-
- mappingContainer.add(Constants.getJEXLPopover(this, TooltipConfig.Placement.bottom));
-
- passwordLabel = new Label("passwordLabel", new ResourceModel("password"));
- mappingContainer.add(passwordLabel);
-
- Collections.sort(getMapping().getItems(), new Comparator<MappingItemTO>() {
-
- @Override
- public int compare(final MappingItemTO left, final MappingItemTO right) {
- int compared;
- if (left == null && right == null) {
- compared = 0;
- } else if (left == null) {
- compared = 1;
- } else if (right == null) {
- compared = -1;
- } else if (left.getPurpose() == MappingPurpose.BOTH && right.getPurpose() != MappingPurpose.BOTH) {
- compared = -1;
- } else if (left.getPurpose() != MappingPurpose.BOTH && right.getPurpose() == MappingPurpose.BOTH) {
- compared = 1;
- } else if (left.getPurpose() == MappingPurpose.PROPAGATION
- && (right.getPurpose() == MappingPurpose.PULL
- || right.getPurpose() == MappingPurpose.NONE)) {
- compared = -1;
- } else if (left.getPurpose() == MappingPurpose.PULL
- && right.getPurpose() == MappingPurpose.PROPAGATION) {
- compared = 1;
- } else if (left.getPurpose() == MappingPurpose.PULL
- && right.getPurpose() == MappingPurpose.NONE) {
- compared = -1;
- } else if (left.getPurpose() == MappingPurpose.NONE
- && right.getPurpose() != MappingPurpose.NONE) {
- compared = 1;
- } else if (left.isConnObjectKey()) {
- compared = -1;
- } else if (right.isConnObjectKey()) {
- compared = 1;
- } else if (left.isPassword()) {
- compared = -1;
- } else if (right.isPassword()) {
- compared = 1;
- } else {
- compared = left.getIntAttrName().compareTo(right.getIntAttrName());
- }
- return compared;
- }
- });
-
- mappings = new ListView<MappingItemTO>("mappings", getMapping().getItems()) {
-
- private static final long serialVersionUID = 4949588177564901031L;
-
- @Override
- protected void populateItem(final ListItem<MappingItemTO> item) {
- final MappingItemTO mapItem = item.getModelObject();
- if (mapItem.getPurpose() == null) {
- mapItem.setPurpose(MappingPurpose.BOTH);
- }
-
- AnyTypeKind entity = null;
- if (provisionTO.getAnyType().equals(AnyTypeKind.GROUP.name())) {
- // support for clone
- entity = AnyTypeKind.GROUP;
- } else if (mapItem.getIntMappingType() != null) {
- entity = mapItem.getIntMappingType().getAnyTypeKind();
- }
-
- // it will happen just in case of clone to create a new mapping for group object
- if (mapItem.getIntMappingType() != null && mapItem.getIntMappingType().getAnyTypeKind() != entity) {
- mapItem.setIntMappingType(null);
- mapItem.setIntAttrName(null);
- }
-
- //--------------------------------
- // Entity
- // -------------------------------
- final AjaxDropDownChoicePanel<AnyTypeKind> entitiesPanel = new AjaxDropDownChoicePanel<>(
- "entities",
- new ResourceModel("entities", "entities").getObject(),
- new Model<>(entity));
-
- entitiesPanel.hideLabel();
- entitiesPanel.setChoices(provisionTO.getAnyType().equals(AnyTypeKind.GROUP.name())
- ? Collections.<AnyTypeKind>singletonList(AnyTypeKind.GROUP)
- : Arrays.asList(AnyTypeKind.values()));
-
- entitiesPanel.setStyleSheet(false, DEF_FIELD_STYLE);
- item.add(entitiesPanel);
- // -------------------------------
-
- //--------------------------------
- // Internal attribute type
- // -------------------------------
- final List<IntMappingType> attrTypes = new ArrayList<>(getAttributeTypes(entity));
- final AjaxDropDownChoicePanel<IntMappingType> intMappingTypes = new AjaxDropDownChoicePanel<>(
- "intMappingTypes",
- new ResourceModel("intMappingTypes", "intMappingTypes").getObject(),
- new PropertyModel<IntMappingType>(mapItem, "intMappingType"),
- false);
- intMappingTypes.setNullValid(true).setRequired(true).hideLabel();
- intMappingTypes.setChoices(attrTypes);
- item.add(intMappingTypes);
- // -------------------------------
-
- //--------------------------------
- // Internal attribute
- // -------------------------------
- final AjaxDropDownChoicePanel<String> intAttrNames = new AjaxDropDownChoicePanel<>(
- "intAttrNames",
- getString("intAttrNames"),
- new PropertyModel<String>(mapItem, "intAttrName"),
- false);
- intAttrNames.setChoices(Collections.<String>emptyList());
- intAttrNames.setNullValid(true).setRequired(true).hideLabel();
- item.add(intAttrNames);
- // -------------------------------
-
- //--------------------------------
- // External attribute
- // -------------------------------
- final AjaxTextFieldPanel extAttrNames = new AjaxTextFieldPanel(
- "extAttrName",
- new ResourceModel("extAttrNames", "extAttrNames").getObject(),
- new PropertyModel<String>(mapItem, "extAttrName"));
- extAttrNames.setChoices(schemaNames);
-
- boolean required = !mapItem.isPassword();
- extAttrNames.setRequired(required).hideLabel();
- extAttrNames.setEnabled(required);
- item.add(extAttrNames);
- // -------------------------------
-
- //--------------------------------
- // Mandatory
- // -------------------------------
- final AjaxTextFieldPanel mandatory = new AjaxTextFieldPanel(
- "mandatoryCondition",
- new ResourceModel("mandatoryCondition", "mandatoryCondition").getObject(),
- new PropertyModel<String>(mapItem, "mandatoryCondition"));
- mandatory.hideLabel();
- mandatory.setChoices(Arrays.asList(new String[] { "true", "false" }));
- item.add(mandatory);
- // -------------------------------
-
- //--------------------------------
- // Connector object key
- // -------------------------------
- final AjaxCheckBoxPanel connObjectKey = new AjaxCheckBoxPanel(
- "connObjectKey",
- new ResourceModel("connObjectKey", "connObjectKey").getObject(),
- new PropertyModel<Boolean>(mapItem, "connObjectKey"), false);
- connObjectKey.hideLabel();
- item.add(connObjectKey);
- // -------------------------------
-
- //--------------------------------
- // Password
- // -------------------------------
- final AjaxCheckBoxPanel password = new AjaxCheckBoxPanel(
- "password",
- new ResourceModel("password", "password").getObject(),
- new PropertyModel<Boolean>(mapItem, "password"), false);
- item.add(password.hideLabel());
- // -------------------------------
-
- //--------------------------------
- // Purpose
- // -------------------------------
- final WebMarkupContainer purpose = new WebMarkupContainer("purpose");
- purpose.setOutputMarkupId(Boolean.TRUE);
-
- final MappingPurposePanel panel = new MappingPurposePanel(
- "purposeActions", new PropertyModel<MappingPurpose>(mapItem, "purpose"), purpose);
-
- purpose.add(panel.setRenderBodyOnly(true));
- item.add(purpose);
- // -------------------------------
-
- //--------------------------------
- // Remove
- // -------------------------------
- final ActionLinksPanel.Builder<Serializable> actions = ActionLinksPanel.builder();
- actions.add(new ActionLink<Serializable>() {
-
- private static final long serialVersionUID = -3722207913631435501L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
- int index = -1;
- for (int i = 0; i < getMapping().getItems().size() && index == -1; i++) {
- if (mapItem.equals(getMapping().getItems().get(i))) {
- index = i;
- }
- }
-
- if (index != -1) {
- getMapping().getItems().remove(index);
- item.getParent().removeAll();
- target.add(ResourceMappingPanel.this);
- }
- }
- }, ActionLink.ActionType.DELETE, StandardEntitlement.RESOURCE_UPDATE);
- item.add(actions.build("toRemove"));
- // -------------------------------
-
- entitiesPanel.getField().add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- attrTypes.clear();
- attrTypes.addAll(getAttributeTypes(entitiesPanel.getModelObject()));
- intMappingTypes.setChoices(attrTypes);
-
- intAttrNames.setChoices(Collections.<String>emptyList());
-
- target.add(intMappingTypes);
- target.add(intAttrNames);
- }
- });
-
- intMappingTypes.getField().add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- setAttrNames(intMappingTypes.getModelObject(), intAttrNames);
- target.add(intAttrNames);
-
- setConnObjectKey(intMappingTypes.getModelObject(), connObjectKey, password);
- target.add(connObjectKey);
- }
- });
-
- intAttrNames.getField().add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- }
- });
-
- connObjectKey.getField().add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- if (connObjectKey.getModelObject()) {
- mapItem.setMandatoryCondition("true");
- mandatory.setEnabled(false);
- } else {
- mapItem.setMandatoryCondition("false");
- mandatory.setEnabled(true);
- }
- target.add(mandatory);
- }
- });
-
- password.getField().add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- extAttrNames.setEnabled(!mapItem.isConnObjectKey() && !password.getModelObject());
- extAttrNames.setModelObject(password.getModelObject()
- ? ConnIdSpecialAttributeName.PASSWORD : extAttrNames.getModelObject());
- extAttrNames.setRequired(!password.getModelObject());
- target.add(extAttrNames);
-
- setConnObjectKey(intMappingTypes.getModelObject(), connObjectKey, password);
- target.add(connObjectKey);
- }
- });
-
- setAttrNames(mapItem.getIntMappingType(), intAttrNames);
- setConnObjectKey(mapItem.getIntMappingType(), connObjectKey, password);
-
- if (!AnyTypeKind.USER.name().equals(provisionTO.getAnyType())) {
- password.setVisible(false);
-
- // Changes required by clone ....
- extAttrNames.setEnabled(!mapItem.isConnObjectKey());
- if (mapItem.isPassword()) {
- // re-enable if and only if cloned objec mapping item was a password
- intAttrNames.setEnabled(true);
- }
- mapItem.setPassword(false);
- }
- }
- };
-
- mappings.setReuseItems(true);
- mappingContainer.add(mappings);
-
- addMappingBtn = new IndicatingAjaxButton("addMappingBtn", new ResourceModel("add")) {
-
- private static final long serialVersionUID = -4804368561204623354L;
-
- @Override
- protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
- getMapping().getItems().add(new MappingItemTO());
- target.add(ResourceMappingPanel.this);
- }
- };
- addMappingBtn.setDefaultFormProcessing(false);
- addMappingBtn.setEnabled(resourceTO.getConnector() != null && resourceTO.getConnector() > 0);
- mappingContainer.add(addMappingBtn);
- }
-
- @Override
- protected void onBeforeRender() {
- super.onBeforeRender();
- passwordLabel.setVisible(AnyTypeKind.USER.name().equals(this.provisionTO.getAnyType()));
- }
-
- private List<String> getSchemaNames(final Long connectorId, final Set<ConnConfProperty> conf) {
- final ConnInstanceTO connInstanceTO = new ConnInstanceTO();
- connInstanceTO.setKey(connectorId);
- connInstanceTO.getConf().addAll(conf);
-
- // SYNCOPE-156: use provided info to give schema names (and type!) by ObjectClass
- ConnIdObjectClassTO clazz = IterableUtils.find(
- connRestClient.buildObjectClassInfo(connInstanceTO, true), new Predicate<ConnIdObjectClassTO>() {
-
- @Override
- public boolean evaluate(final ConnIdObjectClassTO object) {
- return object.getType().equalsIgnoreCase(ResourceMappingPanel.this.provisionTO.getObjectClass());
- }
- });
-
- return clazz == null ? new ArrayList<String>()
- : IterableUtils.toList(IterableUtils.filteredIterable(clazz.getAttributes(), new Predicate<String>() {
-
- @Override
- public boolean evaluate(final String object) {
- return !(ConnIdSpecialAttributeName.NAME.equals(object)
- || ConnIdSpecialAttributeName.ENABLE.equals(object)
- || ConnIdSpecialAttributeName.PASSWORD.equals(object));
- }
- }));
- }
-
- private void setEnabled() {
- ConnInstanceTO connInstanceTO = new ConnInstanceTO();
- connInstanceTO.setKey(resourceTO.getConnector());
- connInstanceTO.getConf().addAll(resourceTO.getConfOverride());
-
- boolean enabled = provisionTO != null;
-
- this.mappingContainer.setEnabled(enabled);
- this.mappingContainer.setVisible(enabled);
-
- if (!enabled) {
- getMapping().getItems().clear();
- getMapping().setConnObjectLink(null);
- }
- }
-
- /**
- * Set attribute names for a drop down choice list.
- *
- * @param type attribute type.
- * @param toBeUpdated drop down choice to be updated.
- */
- private void setAttrNames(final IntMappingType type, final AjaxDropDownChoicePanel<String> toBeUpdated) {
- toBeUpdated.setRequired(true);
- toBeUpdated.setEnabled(true);
-
- if (type == null || type.getAnyTypeKind() == null) {
- toBeUpdated.setChoices(Collections.<String>emptyList());
- } else {
- AnyTypeTO anyTypeTO = anyTypeRestClient.read(provisionTO.getAnyType());
-
- List<AnyTypeClassTO> anyTypeClassTOs = new ArrayList<>();
- anyTypeClassTOs.addAll(anyTypeClassRestClient.list(anyTypeTO.getClasses()));
- for (String auxClass : provisionTO.getAuxClasses()) {
- anyTypeClassTOs.add(anyTypeClassRestClient.read(auxClass));
- }
-
- List<String> choices;
- switch (type) {
- case UserPlainSchema:
- case GroupPlainSchema:
- case AnyObjectPlainSchema:
- final Set<String> plains = new HashSet<>();
- for (AnyTypeClassTO anyTypeClassTO : anyTypeClassTOs) {
- plains.addAll(anyTypeClassTO.getPlainSchemas());
- }
- choices = new ArrayList<>(plains);
- break;
-
- case UserDerivedSchema:
- case GroupDerivedSchema:
- case AnyObjectDerivedSchema:
- final Set<String> deriveds = new HashSet<>();
- for (AnyTypeClassTO anyTypeClassTO : anyTypeClassTOs) {
- deriveds.addAll(anyTypeClassTO.getDerSchemas());
- }
- choices = new ArrayList<>(deriveds);
- break;
-
- case UserVirtualSchema:
- case GroupVirtualSchema:
- case AnyObjectVirtualSchema:
- final Set<String> virtuals = new HashSet<>();
- for (AnyTypeClassTO anyTypeClassTO : anyTypeClassTOs) {
- virtuals.addAll(anyTypeClassTO.getVirSchemas());
- }
- choices = new ArrayList<>(virtuals);
- break;
-
- case UserKey:
- case Password:
- case Username:
- case GroupKey:
- case GroupName:
- case AnyObjectKey:
- default:
- toBeUpdated.setRequired(false);
- toBeUpdated.setEnabled(false);
- choices = Collections.<String>emptyList();
- }
- Collections.sort(choices);
- toBeUpdated.setChoices(choices);
- }
- }
-
- /**
- * Enable/Disable connObjectKey checkbox.
- *
- * @param type attribute type.
- * @param connObjectKey connObjectKey checkbox.
- * @param password password checkbox.
- */
- private void setConnObjectKey(
- final IntMappingType type, final AjaxCheckBoxPanel connObjectKey, final AjaxCheckBoxPanel password) {
-
- if (type != null && type.getAnyTypeKind() != null) {
- switch (type) {
- case UserVirtualSchema:
- case GroupVirtualSchema:
- case AnyObjectVirtualSchema:
- // Virtual connObjectKey is not permitted
- case Password:
- // connObjectKey cannot be derived from password.
- connObjectKey.setReadOnly(true);
- connObjectKey.setModelObject(false);
- break;
-
- default:
- if (password.getModelObject()) {
- connObjectKey.setReadOnly(true);
- connObjectKey.setModelObject(false);
- } else {
- connObjectKey.setReadOnly(false);
- }
- }
- }
- }
-
- /**
- * Get all attribute types from a selected attribute type.
- *
- * @param kind entity.
- * @return all attribute types.
- */
- private List<IntMappingType> getAttributeTypes(final AnyTypeKind kind) {
- final List<IntMappingType> res = new ArrayList<>();
-
- if (kind != null) {
- res.addAll(IntMappingType.getAttributeTypes(kind));
- }
-
- return res;
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/1735c44c/client/console/src/main/java/org/apache/syncope/client/console/panels/ResourceModal.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/ResourceModal.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/ResourceModal.java
deleted file mode 100644
index 11c7468..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/ResourceModal.java
+++ /dev/null
@@ -1,304 +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.List;
-import org.apache.commons.collections4.IterableUtils;
-import org.apache.commons.collections4.IteratorUtils;
-import org.apache.commons.collections4.Predicate;
-import org.apache.commons.lang3.SerializationUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.syncope.client.console.SyncopeConsoleSession;
-import org.apache.syncope.client.console.commons.Constants;
-import org.apache.syncope.client.console.rest.ConnectorRestClient;
-import org.apache.syncope.client.console.rest.ResourceRestClient;
-import org.apache.syncope.client.console.topology.TopologyNode;
-import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
-import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
-import org.apache.syncope.client.console.wizards.AjaxWizard;
-import org.apache.syncope.client.console.wizards.provision.ProvisionWizardBuilder;
-import org.apache.syncope.common.lib.to.MappingItemTO;
-import org.apache.syncope.common.lib.to.ProvisionTO;
-import org.apache.syncope.common.lib.to.ResourceTO;
-import org.apache.syncope.common.lib.types.StandardEntitlement;
-import org.apache.wicket.PageReference;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy;
-import org.apache.wicket.event.Broadcast;
-import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;
-import org.apache.wicket.markup.ComponentTag;
-import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.markup.html.panel.Panel;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.ResourceModel;
-
-/**
- * Modal window with Resource form.
- *
- * @param <T>
- */
-public class ResourceModal<T extends Serializable> extends AbstractResourceModal<T> {
-
- private static final long serialVersionUID = 1734415311027284221L;
-
- private final ResourceRestClient resourceRestClient = new ResourceRestClient();
-
- private final ConnectorRestClient connectorRestClient = new ConnectorRestClient();
-
- private final boolean createFlag;
-
- public ResourceModal(
- final BaseModal<T> modal,
- final PageReference pageRef,
- final IModel<ResourceTO> model,
- final boolean createFlag) {
-
- super(modal, pageRef);
- this.createFlag = createFlag;
-
- //--------------------------------
- // Resource details panel
- //--------------------------------
- tabs.add(new AbstractTab(new ResourceModel("general")) {
-
- private static final long serialVersionUID = -5861786415855103549L;
-
- @Override
- public Panel getPanel(final String panelId) {
- return new ResourceDetailsPanel(panelId, model, createFlag);
- }
- });
- //--------------------------------
-
- //--------------------------------
- // Resource provision panels
- //--------------------------------
- final ListViewPanel.Builder<ProvisionTO> builder = new ListViewPanel.Builder<ProvisionTO>(ProvisionTO.class,
- pageRef) {
-
- private static final long serialVersionUID = 4907732721283972943L;
-
- @Override
- protected ProvisionTO getActualItem(final ProvisionTO item, final List<ProvisionTO> list) {
- return item == null
- ? null
- : IteratorUtils.find(list.iterator(), new Predicate<ProvisionTO>() {
-
- @Override
- public boolean evaluate(final ProvisionTO in) {
- return ((item.getKey() == null && in.getKey() == null)
- || (in.getKey() != null && in.getKey().equals(item.getKey())))
- && ((item.getAnyType() == null && in.getAnyType() == null)
- || (in.getAnyType() != null && in.getAnyType().equals(item.getAnyType())));
- }
- });
- }
- };
-
- builder.setItems(model.getObject().getProvisions());
- builder.includes("anyType", "objectClass", "auxClasses");
- builder.setReuseItem(false);
-
- builder.
- addAction(new ActionLink<ProvisionTO>() {
-
- private static final long serialVersionUID = -3722207913631435504L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final ProvisionTO provisionTO) {
- send(pageRef.getPage(), Broadcast.DEPTH,
- new AjaxWizard.NewItemActionEvent<>(provisionTO, 2, target));
- }
- }, ActionLink.ActionType.MAPPING, StandardEntitlement.RESOURCE_UPDATE).
- addAction(new ActionLink<ProvisionTO>() {
-
- private static final long serialVersionUID = -3722207913631435524L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final ProvisionTO provisionTO) {
- provisionTO.setSyncToken(null);
- send(pageRef.getPage(), Broadcast.DEPTH, new ListViewPanel.ListViewReload(target));
- }
- }, ActionLink.ActionType.RESET_TIME, StandardEntitlement.RESOURCE_UPDATE).
- addAction(new ActionLink<ProvisionTO>() {
-
- private static final long serialVersionUID = -3722207913631435534L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final ProvisionTO provisionTO) {
- final ProvisionTO clone = SerializationUtils.clone(provisionTO);
- clone.setKey(0L);
- clone.setAnyType(null);
- clone.setObjectClass(null);
- send(pageRef.getPage(), Broadcast.DEPTH, new AjaxWizard.NewItemActionEvent<>(clone, target));
- }
- }, ActionLink.ActionType.CLONE, StandardEntitlement.RESOURCE_CREATE).
- addAction(new ActionLink<ProvisionTO>() {
-
- private static final long serialVersionUID = -3722207913631435544L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final ProvisionTO provisionTO) {
- model.getObject().getProvisions().remove(provisionTO);
- send(pageRef.getPage(), Broadcast.DEPTH, new ListViewPanel.ListViewReload(target));
- }
- }, ActionLink.ActionType.DELETE, StandardEntitlement.RESOURCE_DELETE);
-
- builder.addNewItemPanelBuilder(new ProvisionWizardBuilder(model.getObject(), pageRef));
-
- tabs.add(new AbstractTab(new ResourceModel("provisions")) {
-
- private static final long serialVersionUID = -5861786415855103549L;
-
- @Override
- public Panel getPanel(final String panelId) {
- return builder.build(panelId);
- }
- });
- //--------------------------------
-
- //--------------------------------
- // Resource connector configuration panel
- //--------------------------------
- tabs.add(new AbstractTab(new ResourceModel("connectorProperties")) {
-
- private static final long serialVersionUID = -5861786415855103549L;
-
- @Override
- public Panel getPanel(final String panelId) {
- final ResourceConnConfPanel panel = new ResourceConnConfPanel(panelId, model, createFlag) {
-
- private static final long serialVersionUID = -1128269449868933504L;
-
- @Override
- protected void check(final AjaxRequestTarget target) {
- if (connectorRestClient.check(model.getObject())) {
- info(getString(Constants.OPERATION_SUCCEEDED));
- } else {
- error(getString("error_connection"));
- }
- SyncopeConsoleSession.get().getNotificationPanel().refresh(target);
- }
-
- @Override
- protected void onComponentTag(final ComponentTag tag) {
- tag.append("class", "scrollable-tab-content", " ");
- }
- };
- MetaDataRoleAuthorizationStrategy.authorize(panel, ENABLE, StandardEntitlement.CONNECTOR_READ);
- return panel;
- }
- });
- //--------------------------------
-
- //--------------------------------
- // Resource connector capabilities panel
- //--------------------------------
- tabs.add(new AbstractTab(new ResourceModel("connectorCapabilities")) {
-
- private static final long serialVersionUID = -6815067322125799251L;
-
- @Override
- public Panel getPanel(final String panelId) {
- ResourceConnCapabilitiesPanel panel = new ResourceConnCapabilitiesPanel(
- panelId,
- model,
- connectorRestClient.read(model.getObject().getConnector()).getCapabilities());
- MetaDataRoleAuthorizationStrategy.authorize(panel, ENABLE, StandardEntitlement.CONNECTOR_READ);
- return panel;
- }
- });
- //--------------------------------
-
- //--------------------------------
- // Resource security panel
- //--------------------------------
- tabs.add(new AbstractTab(new ResourceModel("security")) {
-
- private static final long serialVersionUID = -5861786415855103549L;
-
- @Override
- public Panel getPanel(final String panelId) {
- return new ResourceSecurityPanel(panelId, model);
- }
- });
- //--------------------------------
- }
-
- @Override
- public void onError(final AjaxRequestTarget target, final Form<?> form) {
- SyncopeConsoleSession.get().getNotificationPanel().refresh(target);
- }
-
- @Override
- public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
- final ResourceTO resourceTO = (ResourceTO) form.getDefaultModelObject();
-
- boolean connObjectKeyError = false;
-
- final Collection<ProvisionTO> provisions = new ArrayList<>(resourceTO.getProvisions());
-
- for (ProvisionTO provision : provisions) {
- if (provision != null) {
- if (provision.getMapping() == null || provision.getMapping().getItems().isEmpty()) {
- resourceTO.getProvisions().remove(provision);
- } else {
- long uConnObjectKeyCount = IterableUtils.countMatches(
- provision.getMapping().getItems(), new Predicate<MappingItemTO>() {
-
- @Override
- public boolean evaluate(final MappingItemTO item) {
- return item.isConnObjectKey();
- }
- });
-
- connObjectKeyError = uConnObjectKeyCount != 1;
- }
- }
- }
-
- if (connObjectKeyError) {
- error(getString("connObjectKeyValidation"));
- } else {
- try {
- if (createFlag) {
- final ResourceTO actual = resourceRestClient.create(resourceTO);
- send(pageRef.getPage(), Broadcast.BREADTH, new CreateEvent(
- actual.getKey(),
- actual.getKey(),
- TopologyNode.Kind.RESOURCE,
- actual.getConnector(),
- target));
- } else {
- resourceRestClient.update(resourceTO);
- }
-
- info(getString(Constants.OPERATION_SUCCEEDED));
- modal.close(target);
- } catch (Exception e) {
- LOG.error("Failure managing {}", resourceTO, e);
- error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
- }
- }
- SyncopeConsoleSession.get().getNotificationPanel().refresh(target);
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/1735c44c/client/console/src/main/java/org/apache/syncope/client/console/panels/ResourceSecurityPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/ResourceSecurityPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/ResourceSecurityPanel.java
deleted file mode 100644
index 25e22ce..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/ResourceSecurityPanel.java
+++ /dev/null
@@ -1,137 +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.rest.PolicyRestClient;
-import org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel;
-import org.apache.syncope.client.console.wicket.markup.html.form.PolicyRenderer;
-import org.apache.syncope.common.lib.policy.AbstractPolicyTO;
-import org.apache.syncope.common.lib.to.ResourceTO;
-import org.apache.syncope.common.lib.types.PolicyType;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-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.model.ResourceModel;
-
-public class ResourceSecurityPanel extends Panel {
-
- private static final long serialVersionUID = -7982691107029848579L;
-
- private final PolicyRestClient policyRestClient = new PolicyRestClient();
-
- private final IModel<Map<Long, String>> 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)) {
- res.put(policyTO.getKey(), policyTO.getDescription());
- }
- return res;
- }
- };
-
- private final IModel<Map<Long, String>> 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)) {
- res.put(policyTO.getKey(), policyTO.getDescription());
- }
- return res;
- }
- };
-
- private final IModel<Map<Long, String>> pullPolicies = 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.PULL)) {
- res.put(policyTO.getKey(), policyTO.getDescription());
- }
- return res;
- }
- };
-
- public ResourceSecurityPanel(final String id, final IModel<ResourceTO> model) {
- super(id);
- setOutputMarkupId(true);
-
- final WebMarkupContainer container = new WebMarkupContainer("container");
- container.setOutputMarkupId(true);
- container.setRenderBodyOnly(true);
- add(container);
-
- // -------------------------------
- // Password policy selection
- // -------------------------------
- AjaxDropDownChoicePanel<Long> passwordPolicy = new AjaxDropDownChoicePanel<>(
- "passwordPolicy",
- new ResourceModel("passwordPolicy", "passwordPolicy").getObject(),
- new PropertyModel<Long>(model, "passwordPolicy"),
- false);
- passwordPolicy.setChoiceRenderer(new PolicyRenderer(passwordPolicies));
- passwordPolicy.setChoices(new ArrayList<>(passwordPolicies.getObject().keySet()));
- ((DropDownChoice<?>) passwordPolicy.getField()).setNullValid(true);
- container.add(passwordPolicy);
- // -------------------------------
-
- // -------------------------------
- // Account policy selection
- // -------------------------------
- AjaxDropDownChoicePanel<Long> accountPolicy = new AjaxDropDownChoicePanel<>(
- "accountPolicy",
- new ResourceModel("accountPolicy", "accountPolicy").getObject(),
- new PropertyModel<Long>(model, "accountPolicy"),
- false);
- accountPolicy.setChoiceRenderer(new PolicyRenderer(accountPolicies));
- accountPolicy.setChoices(new ArrayList<>(accountPolicies.getObject().keySet()));
- ((DropDownChoice<?>) accountPolicy.getField()).setNullValid(true);
- container.add(accountPolicy);
- // -------------------------------
-
- // -------------------------------
- // Pull policy selection
- // -------------------------------
- AjaxDropDownChoicePanel<Long> pullPolicy = new AjaxDropDownChoicePanel<>(
- "pullPolicy",
- new ResourceModel("pullPolicy", "pullPolicy").getObject(),
- new PropertyModel<Long>(model, "pullPolicy"),
- false);
- pullPolicy.setChoiceRenderer(new PolicyRenderer(pullPolicies));
- pullPolicy.setChoices(new ArrayList<>(pullPolicies.getObject().keySet()));
- ((DropDownChoice<?>) pullPolicy.getField()).setNullValid(true);
- container.add(pullPolicy);
- // -------------------------------
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/1735c44c/client/console/src/main/java/org/apache/syncope/client/console/panels/RoleDirectoryPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/RoleDirectoryPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/RoleDirectoryPanel.java
index cbb5809..755ed04 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/RoleDirectoryPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/RoleDirectoryPanel.java
@@ -75,7 +75,8 @@ public class RoleDirectoryPanel extends DirectoryPanel<RoleTO, RoleHandler, Role
protected List<IColumn<RoleTO, String>> getColumns() {
final List<IColumn<RoleTO, String>> columns = new ArrayList<>();
- columns.add(new PropertyColumn<RoleTO, String>(new ResourceModel("key"), "key", "key"));
+ columns.add(new PropertyColumn<RoleTO, String>(
+ new ResourceModel("key"), "key", "key"));
columns.add(new PropertyColumn<RoleTO, String>(
new ResourceModel("entitlements", "Entitlements"), null, "entitlements"));
columns.add(new PropertyColumn<RoleTO, String>(
http://git-wip-us.apache.org/repos/asf/syncope/blob/1735c44c/client/console/src/main/java/org/apache/syncope/client/console/panels/TogglePanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/TogglePanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/TogglePanel.java
index 8280e58..84a4745 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/TogglePanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/TogglePanel.java
@@ -19,20 +19,15 @@
package org.apache.syncope.client.console.panels;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.client.console.commons.Constants;
+import org.apache.syncope.client.console.wizards.WizardMgtPanel;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxEventBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
-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.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,7 +36,7 @@ import org.slf4j.LoggerFactory;
*
* @param <T>
*/
-public abstract class TogglePanel<T extends Serializable> extends Panel {
+public abstract class TogglePanel<T extends Serializable> extends WizardMgtPanel<T> {
private static final long serialVersionUID = -2025535531121434056L;
@@ -59,15 +54,14 @@ public abstract class TogglePanel<T extends Serializable> extends Panel {
private final Label header;
- private List<Component> outerObjects = new ArrayList<>();
-
public TogglePanel(final String id) {
- super(id);
+ super(id, true);
setRenderBodyOnly(true);
setOutputMarkupId(true);
+ disableContainerAutoRefresh();
container = new WebMarkupContainer("togglePanelContainer");
- add(container.setMarkupId(id));
+ super.addInnerObject(container.setMarkupId(id));
header = new Label("label", StringUtils.EMPTY);
header.setOutputMarkupId(true);
@@ -96,31 +90,6 @@ public abstract class TogglePanel<T extends Serializable> extends Panel {
// do nothing
}
}));
-
- add(new ListView<Component>("outerObjectsRepeater", outerObjects) {
-
- private static final long serialVersionUID = -9180479401817023838L;
-
- @Override
- protected void populateItem(final ListItem<Component> item) {
- item.add(item.getModelObject());
- }
-
- });
-
- }
-
- /**
- * Add object outside the main container.
- * Use this method just to be not influenced by specific inner object css'.
- * Be sure to provide <tt>outer</tt> as id.
- *
- * @param childs components to be added.
- * @return the current panel instance.
- */
- public TogglePanel<T> addOuterObject(final Component... childs) {
- outerObjects.addAll(Arrays.asList(childs));
- return this;
}
/**
@@ -129,6 +98,7 @@ public abstract class TogglePanel<T extends Serializable> extends Panel {
* @param childs components to be added.
* @return the current panel instance.
*/
+ @Override
public TogglePanel<T> addInnerObject(final Component... childs) {
container.addOrReplace(childs);
return this;
http://git-wip-us.apache.org/repos/asf/syncope/blob/1735c44c/client/console/src/main/java/org/apache/syncope/client/console/topology/Topology.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/topology/Topology.java b/client/console/src/main/java/org/apache/syncope/client/console/topology/Topology.java
index 8a7e64e..6f7210a 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/topology/Topology.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/topology/Topology.java
@@ -32,7 +32,7 @@ import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.syncope.client.console.SyncopeConsoleSession;
import org.apache.syncope.client.console.commons.Constants;
import org.apache.syncope.client.console.pages.BasePage;
-import org.apache.syncope.client.console.panels.AbstractResourceModal.CreateEvent;
+import org.apache.syncope.client.console.wizards.resources.AbstractResourceWizardBuilder.CreateEvent;
import org.apache.syncope.client.console.rest.BaseRestClient;
import org.apache.syncope.client.console.rest.ConnectorRestClient;
import org.apache.syncope.client.console.rest.ResourceRestClient;
http://git-wip-us.apache.org/repos/asf/syncope/blob/1735c44c/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyNodePanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyNodePanel.java b/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyNodePanel.java
index b83fae2..7e82c3e 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyNodePanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyNodePanel.java
@@ -38,10 +38,7 @@ public class TopologyNodePanel extends Panel implements IAjaxIndicatorAware {
}
- public TopologyNodePanel(
- final String id,
- final TopologyNode node) {
-
+ public TopologyNodePanel(final String id, final TopologyNode node) {
super(id);
final String resourceName = node.getDisplayName().length() > 14
http://git-wip-us.apache.org/repos/asf/syncope/blob/1735c44c/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyTogglePanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyTogglePanel.java b/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyTogglePanel.java
index bb75836..0c83e9b 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyTogglePanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyTogglePanel.java
@@ -25,8 +25,8 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.client.console.SyncopeConsoleSession;
import org.apache.syncope.client.console.commons.Constants;
import org.apache.syncope.client.console.panels.ConnObjects;
-import org.apache.syncope.client.console.panels.ConnectorModal;
-import org.apache.syncope.client.console.panels.ResourceModal;
+import org.apache.syncope.client.console.wizards.resources.ConnectorWizardBuilder;
+import org.apache.syncope.client.console.wizards.resources.ResourceWizardBuilder;
import org.apache.syncope.client.console.panels.TogglePanel;
import org.apache.syncope.client.console.rest.ConnectorRestClient;
import org.apache.syncope.client.console.rest.ResourceRestClient;
@@ -36,6 +36,7 @@ import org.apache.syncope.client.console.tasks.SchedTasks;
import org.apache.syncope.client.console.tasks.PullTasks;
import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
import org.apache.syncope.client.console.wicket.markup.html.form.IndicatingOnConfirmAjaxLink;
+import org.apache.syncope.client.console.wizards.AjaxWizard;
import org.apache.syncope.common.lib.SyncopeClientException;
import org.apache.syncope.common.lib.to.ConnInstanceTO;
import org.apache.syncope.common.lib.to.ResourceTO;
@@ -63,20 +64,15 @@ public class TopologyTogglePanel extends TogglePanel<Serializable> {
private final WebMarkupContainer container;
- private final PageReference pageRef;
-
- protected final BaseModal<Serializable> resourceModal;
-
protected final BaseModal<Serializable> taskModal;
public TopologyTogglePanel(final String id, final PageReference pageRef) {
super(id);
this.pageRef = pageRef;
- resourceModal = new BaseModal<>("outer");
- resourceModal.addSumbitButton();
- resourceModal.size(Modal.Size.Large);
- addOuterObject(resourceModal);
+ modal.size(Modal.Size.Large);
+ setFooterVisibility(false);
+ setWindowClosedReloadCallback(modal);
taskModal = new BaseModal<>("outer");
taskModal.size(Modal.Size.Large);
@@ -155,16 +151,17 @@ public class TopologyTogglePanel extends TogglePanel<Serializable> {
modelObject.setLocation(node.getKey().toString());
final IModel<ConnInstanceTO> model = new CompoundPropertyModel<>(modelObject);
- resourceModal.setFormModel(model);
+ modal.setFormModel(model);
- target.add(resourceModal.setContent(new ConnectorModal(resourceModal, pageRef, model)));
+ target.add(modal.setContent(new ConnectorWizardBuilder(modelObject, pageRef).
+ build(BaseModal.CONTENT_ID, AjaxWizard.Mode.CREATE)));
- resourceModal.header(new Model<>(MessageFormat.format(getString("connector.new"), node.getKey())));
+ modal.header(new Model<>(MessageFormat.format(getString("connector.new"), node.getKey())));
MetaDataRoleAuthorizationStrategy.
- authorize(resourceModal.addSumbitButton(), ENABLE, StandardEntitlement.CONNECTOR_CREATE);
+ authorize(modal.getForm(), ENABLE, StandardEntitlement.CONNECTOR_CREATE);
- resourceModal.show(true);
+ modal.show(true);
}
};
fragment.add(create);
@@ -208,16 +205,17 @@ public class TopologyTogglePanel extends TogglePanel<Serializable> {
modelObject.setConnectorDisplayName(node.getDisplayName());
final IModel<ResourceTO> model = new CompoundPropertyModel<>(modelObject);
- resourceModal.setFormModel(model);
+ modal.setFormModel(model);
- target.add(resourceModal.setContent(new ResourceModal<>(resourceModal, pageRef, model, true)));
+ target.add(modal.setContent(new ResourceWizardBuilder(modelObject, pageRef).
+ build(BaseModal.CONTENT_ID, AjaxWizard.Mode.CREATE)));
- resourceModal.header(new Model<>(MessageFormat.format(getString("resource.new"), node.getKey())));
+ modal.header(new Model<>(MessageFormat.format(getString("resource.new"), node.getKey())));
MetaDataRoleAuthorizationStrategy.
- authorize(resourceModal.addSumbitButton(), ENABLE, StandardEntitlement.RESOURCE_CREATE);
+ authorize(modal.getForm(), ENABLE, StandardEntitlement.RESOURCE_CREATE);
- resourceModal.show(true);
+ modal.show(true);
}
};
MetaDataRoleAuthorizationStrategy.authorize(create, ENABLE, StandardEntitlement.RESOURCE_CREATE);
@@ -232,16 +230,17 @@ public class TopologyTogglePanel extends TogglePanel<Serializable> {
final ConnInstanceTO modelObject = connectorRestClient.read(Long.class.cast(node.getKey()));
final IModel<ConnInstanceTO> model = new CompoundPropertyModel<>(modelObject);
- resourceModal.setFormModel(model);
+ modal.setFormModel(model);
- target.add(resourceModal.setContent(new ConnectorModal(resourceModal, pageRef, model)));
+ target.add(modal.setContent(new ConnectorWizardBuilder(modelObject, pageRef).
+ build(BaseModal.CONTENT_ID, AjaxWizard.Mode.EDIT)));
- resourceModal.header(new Model<>(MessageFormat.format(getString("connector.edit"), node.getKey())));
+ modal.header(new Model<>(MessageFormat.format(getString("connector.edit"), node.getKey())));
MetaDataRoleAuthorizationStrategy.
- authorize(resourceModal.addSumbitButton(), ENABLE, StandardEntitlement.CONNECTOR_UPDATE);
+ authorize(modal.getForm(), ENABLE, StandardEntitlement.CONNECTOR_UPDATE);
- resourceModal.show(true);
+ modal.show(true);
}
};
MetaDataRoleAuthorizationStrategy.authorize(edit, ENABLE, StandardEntitlement.CONNECTOR_UPDATE);
@@ -282,16 +281,17 @@ public class TopologyTogglePanel extends TogglePanel<Serializable> {
ResourceTO modelObject = resourceRestClient.read(node.getKey().toString());
IModel<ResourceTO> model = new CompoundPropertyModel<>(modelObject);
- resourceModal.setFormModel(model);
+ modal.setFormModel(model);
- target.add(resourceModal.setContent(new ResourceModal<>(resourceModal, pageRef, model, false)));
+ target.add(modal.setContent(new ResourceWizardBuilder(modelObject, pageRef).
+ build(BaseModal.CONTENT_ID, AjaxWizard.Mode.EDIT)));
- resourceModal.header(new Model<>(MessageFormat.format(getString("resource.edit"), node.getKey())));
+ modal.header(new Model<>(MessageFormat.format(getString("resource.edit"), node.getKey())));
MetaDataRoleAuthorizationStrategy.
- authorize(resourceModal.addSumbitButton(), ENABLE, StandardEntitlement.RESOURCE_UPDATE);
+ authorize(modal.getForm(), ENABLE, StandardEntitlement.RESOURCE_UPDATE);
- resourceModal.show(true);
+ modal.show(true);
}
};
MetaDataRoleAuthorizationStrategy.authorize(edit, ENABLE, StandardEntitlement.RESOURCE_UPDATE);
http://git-wip-us.apache.org/repos/asf/syncope/blob/1735c44c/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/bootstrap/dialog/BaseModal.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/bootstrap/dialog/BaseModal.java b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/bootstrap/dialog/BaseModal.java
index 5041f1c..e49b1cf 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/bootstrap/dialog/BaseModal.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/bootstrap/dialog/BaseModal.java
@@ -229,7 +229,9 @@ public class BaseModal<T extends Serializable> extends Modal<T> {
/**
* Generic modal event.
*/
- public static class ModalEvent {
+ public static class ModalEvent implements Serializable {
+
+ private static final long serialVersionUID = 2668922412196063559L;
/**
* Request target.
http://git-wip-us.apache.org/repos/asf/syncope/blob/1735c44c/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/list/ConnConfPropertyListView.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/list/ConnConfPropertyListView.java b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/list/ConnConfPropertyListView.java
index 6710f73..1334bba 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/list/ConnConfPropertyListView.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/list/ConnConfPropertyListView.java
@@ -36,6 +36,8 @@ import org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel
import org.apache.syncope.common.lib.types.ConnConfProperty;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.markup.html.form.PasswordTextField;
@@ -184,4 +186,13 @@ public class ConnConfPropertyListView extends ListView<ConnConfProperty> {
}
};
}
+
+ @Override
+ public void renderHead(final IHeaderResponse response) {
+ super.renderHead(response);
+ if (getModelObject().isEmpty()) {
+ response.render(OnDomReadyHeaderItem.forScript(
+ String.format("$('#emptyPlaceholder').append(\"%s\")", getString("property.empty.list"))));
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/1735c44c/client/console/src/main/java/org/apache/syncope/client/console/wizards/AjaxWizard.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/AjaxWizard.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/AjaxWizard.java
index a03ccf5..94874b2 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/AjaxWizard.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/AjaxWizard.java
@@ -96,7 +96,7 @@ public abstract class AjaxWizard<T extends Serializable> extends Wizard implemen
protected abstract void onCancelInternal();
- protected abstract Serializable onApplyInternal();
+ protected abstract Serializable onApplyInternal(final AjaxRequestTarget target);
/**
* @see org.apache.wicket.extensions.wizard.Wizard#onCancel()
@@ -121,7 +121,7 @@ public abstract class AjaxWizard<T extends Serializable> extends Wizard implemen
public final void onFinish() {
final AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class);
try {
- final Serializable res = onApplyInternal();
+ final Serializable res = onApplyInternal(target);
send(AjaxWizard.this, Broadcast.BUBBLE, new NewItemFinishEvent<>(item, target).setResult(res));
} catch (Exception e) {
LOG.error("Wizard error on finish", e);
@@ -252,7 +252,7 @@ public abstract class AjaxWizard<T extends Serializable> extends Wizard implemen
@Override
public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
- onApplyInternal();
+ onApplyInternal(target);
}
@Override
http://git-wip-us.apache.org/repos/asf/syncope/blob/1735c44c/client/console/src/main/java/org/apache/syncope/client/console/wizards/AjaxWizardBuilder.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/AjaxWizardBuilder.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/AjaxWizardBuilder.java
index 3240a6b..050797d 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/AjaxWizardBuilder.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/AjaxWizardBuilder.java
@@ -20,12 +20,16 @@ package org.apache.syncope.client.console.wizards;
import java.io.Serializable;
import org.apache.wicket.PageReference;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.event.Broadcast;
import org.apache.wicket.extensions.wizard.WizardModel;
public abstract class AjaxWizardBuilder<T extends Serializable> extends AbstractModalPanelBuilder<T> {
private static final long serialVersionUID = 5241745929825564456L;
+ protected AjaxWizard.Mode mode = AjaxWizard.Mode.CREATE;
+
/**
* Construct.
*
@@ -66,6 +70,8 @@ public abstract class AjaxWizardBuilder<T extends Serializable> extends Abstract
* @return wizard.
*/
public AjaxWizard<T> build(final String id, final AjaxWizard.Mode mode) {
+ this.mode = mode;
+
// ge the specified item if available
final T modelObject = newModelObject();
@@ -79,11 +85,51 @@ public abstract class AjaxWizardBuilder<T extends Serializable> extends Abstract
}
@Override
- protected Serializable onApplyInternal() {
- return AjaxWizardBuilder.this.onApplyInternal(modelObject);
+ protected Serializable onApplyInternal(final AjaxRequestTarget target) {
+ final Serializable res = AjaxWizardBuilder.this.onApplyInternal(modelObject);
+
+ Serializable payload;
+ switch (mode) {
+ case CREATE:
+ payload = getCreateCustomPayloadEvent(res, target);
+ break;
+ case EDIT:
+ payload = getEditCustomPayloadEvent(res, target);
+ break;
+ default:
+ payload = null;
+ }
+
+ if (payload != null) {
+ send(pageRef.getPage(), Broadcast.BUBBLE, payload);
+ }
+
+ return res;
}
};
}
protected abstract WizardModel buildModelSteps(final T modelObject, final WizardModel wizardModel);
+
+ /**
+ * Override to send custom events after create.
+ *
+ * @param afterObject after applied changes object.
+ * @param target
+ * @return payload to be sent.
+ */
+ protected Serializable getCreateCustomPayloadEvent(final Serializable afterObject, final AjaxRequestTarget target) {
+ return null;
+ }
+
+ /**
+ * Override to send custom events after edit.
+ *
+ * @param afterObject after applied changes object.
+ * @param target
+ * @return payload to be sent.
+ */
+ protected Serializable getEditCustomPayloadEvent(final Serializable afterObject, final AjaxRequestTarget target) {
+ return null;
+ }
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/1735c44c/client/console/src/main/java/org/apache/syncope/client/console/wizards/WizardMgtPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/WizardMgtPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/WizardMgtPanel.java
index 49a1180..2a61de7 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/WizardMgtPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/WizardMgtPanel.java
@@ -19,6 +19,9 @@
package org.apache.syncope.client.console.wizards;
import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import org.apache.syncope.client.console.SyncopeConsoleSession;
import org.apache.syncope.client.console.commons.Constants;
import org.apache.syncope.client.console.panels.ModalPanel;
@@ -30,11 +33,13 @@ import org.apache.wicket.MarkupContainer;
import org.apache.wicket.PageReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
-import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.event.Broadcast;
import org.apache.wicket.event.IEvent;
import org.apache.wicket.event.IEventSource;
+import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.CompoundPropertyModel;
@@ -56,6 +61,8 @@ public abstract class WizardMgtPanel<T extends Serializable> extends Panel imple
private final boolean wizardInModal;
+ private boolean containerAutoRefresh = true;
+
protected PageReference pageRef;
protected final AjaxLink<?> addAjaxLink;
@@ -68,7 +75,9 @@ public abstract class WizardMgtPanel<T extends Serializable> extends Panel imple
protected boolean showResultPage = false;
- protected final BaseModal<T> modal = new BaseModal<T>("modal") {
+ private final List<Component> outerObjects = new ArrayList<>();
+
+ protected final BaseModal<T> modal = new BaseModal<T>("outer") {
private static final long serialVersionUID = 389935548143327858L;
@@ -80,12 +89,6 @@ public abstract class WizardMgtPanel<T extends Serializable> extends Panel imple
};
- protected final BaseModal<T> altDefaultModal = new BaseModal<>("alternativeDefaultModal");
-
- protected final BaseModal<T> displayAttributeModal = new BaseModal<>("displayAttributeModal");
-
- protected final BaseModal<Serializable> utilityModal = new BaseModal<>("utilityModal");
-
protected WizardMgtPanel(final String id) {
this(id, false);
}
@@ -97,14 +100,11 @@ public abstract class WizardMgtPanel<T extends Serializable> extends Panel imple
this.actualId = wizardInModal ? BaseModal.CONTENT_ID : WIZARD_ID;
this.wizardInModal = wizardInModal;
- super.add(modal);
- super.add(altDefaultModal);
- super.add(displayAttributeModal);
- super.add(utilityModal);
+ outerObjects.add(modal);
container = new WebMarkupContainer("container");
container.setOutputMarkupPlaceholderTag(true).setOutputMarkupId(true);
- super.add(container);
+ add(container);
initialFragment = new Fragment("content", "default", this);
container.addOrReplace(initialFragment);
@@ -122,6 +122,17 @@ public abstract class WizardMgtPanel<T extends Serializable> extends Panel imple
addAjaxLink.setEnabled(false);
addAjaxLink.setVisible(false);
initialFragment.addOrReplace(addAjaxLink);
+
+ add(new ListView<Component>("outerObjectsRepeater", outerObjects) {
+
+ private static final long serialVersionUID = -9180479401817023838L;
+
+ @Override
+ protected void populateItem(final ListItem<Component> item) {
+ item.add(item.getModelObject());
+ }
+
+ });
}
@Override
@@ -195,11 +206,18 @@ public abstract class WizardMgtPanel<T extends Serializable> extends Panel imple
}
}
- target.add(container);
+ if (containerAutoRefresh) {
+ target.add(container);
+ }
}
super.onEvent(event);
}
+ protected final WizardMgtPanel<T> disableContainerAutoRefresh() {
+ containerAutoRefresh = false;
+ return this;
+ }
+
/*
* Override this method to specify your custom result body panel.
*/
@@ -211,13 +229,27 @@ public abstract class WizardMgtPanel<T extends Serializable> extends Panel imple
};
}
- @Override
- public Component add(final Behavior... behaviors) {
- return super.add(behaviors);
+ /**
+ * Add object inside the main container.
+ *
+ * @param childs components to be added.
+ * @return the current panel instance.
+ */
+ public MarkupContainer addInnerObject(final Component... childs) {
+ return initialFragment.add(childs);
}
- public final MarkupContainer addInnerObject(final Component childs) {
- return initialFragment.add(childs);
+ /**
+ * Add object outside the main container.
+ * Use this method just to be not influenced by specific inner object css'.
+ * Be sure to provide <tt>outer</tt> as id.
+ *
+ * @param childs components to be added.
+ * @return the current panel instance.
+ */
+ public final WizardMgtPanel<T> addOuterObject(final Component... childs) {
+ outerObjects.addAll(Arrays.asList(childs));
+ return this;
}
public <B extends AbstractModalPanelBuilder<T>> WizardMgtPanel<T> setPageRef(final PageReference pageRef) {
@@ -253,6 +285,32 @@ public abstract class WizardMgtPanel<T extends Serializable> extends Panel imple
}
/**
+ * Set window close callback for the given modal.
+ *
+ * @param modal target modal.
+ */
+ protected final void setWindowClosedReloadCallback(final BaseModal<?> modal) {
+ modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
+
+ private static final long serialVersionUID = 8804221891699487139L;
+
+ @Override
+ public void onClose(final AjaxRequestTarget target) {
+ modal.show(false);
+ customActionOnCloseCallback(target);
+ }
+ });
+ }
+
+ /**
+ * Custom action to perform on close callback.
+ *
+ * @param target Ajax request target.
+ */
+ protected void customActionOnCloseCallback(final AjaxRequestTarget target) {
+ }
+
+ /**
* PanelInWizard abstract builder.
*
* @param <T> list item reference type.
http://git-wip-us.apache.org/repos/asf/syncope/blob/1735c44c/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AuxClasses.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AuxClasses.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AuxClasses.java
index 3d67497..5115a99 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AuxClasses.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AuxClasses.java
@@ -126,8 +126,7 @@ public class AuxClasses extends WizardStep {
}
}).hideLabel().setOutputMarkupId(true));
- final ArrayList<String> dynamics = CollectionUtils.collect(dyngroups,
- new Transformer<Long, String>() {
+ final ArrayList<String> dynamics = CollectionUtils.collect(dyngroups, new Transformer<Long, String>() {
@Override
public String transform(final Long input) {