You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2015/04/22 15:52:05 UTC
[38/51] [partial] syncope git commit: [SYNCOPE-156] Preparing place
for new console
http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/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 406676f..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/ResourceMappingPanel.java
+++ /dev/null
@@ -1,644 +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.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.apache.syncope.client.console.commons.Constants;
-import org.apache.syncope.client.console.commons.JexlHelpUtils;
-import org.apache.syncope.client.console.panels.ResourceConnConfPanel.ConnConfModEvent;
-import org.apache.syncope.client.console.rest.ConnectorRestClient;
-import org.apache.syncope.client.console.rest.SchemaRestClient;
-import org.apache.syncope.client.console.wicket.markup.html.form.AjaxCheckBoxPanel;
-import org.apache.syncope.client.console.wicket.markup.html.form.AjaxDecoratedCheckbox;
-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.FieldPanel;
-import org.apache.syncope.client.console.wicket.markup.html.form.MappingPurposePanel;
-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.ResourceTO;
-import org.apache.syncope.common.lib.types.AttributableType;
-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.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.form.AjaxFormComponentUpdatingBehavior;
-import org.apache.wicket.ajax.markup.html.AjaxLink;
-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.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;
-import org.apache.wicket.spring.injection.annot.SpringBean;
-
-/**
- * Resource mapping panel.
- */
-public class ResourceMappingPanel extends Panel {
-
- private static final long serialVersionUID = -7982691107029848579L;
-
- /**
- * Mapping field style sheet.
- */
- private static final String FIELD_STYLE = "ui-widget-content ui-corner-all short_fixedsize";
-
- /**
- * Mapping field style sheet.
- */
- private static final String DEF_FIELD_STYLE = "ui-widget-content ui-corner-all";
-
- /**
- * Mapping field style sheet.
- */
- private static final String SHORT_FIELD_STYLE = "ui-widget-content ui-corner-all veryshort_fixedsize";
-
- /**
- * Schema rest client.
- */
- @SpringBean
- private SchemaRestClient schemaRestClient;
-
- /**
- * ConnInstance rest client.
- */
- @SpringBean
- private ConnectorRestClient connRestClient;
-
- /**
- * Resource schema name.
- */
- private final List<String> schemaNames;
-
- /**
- * Add mapping button.
- */
- private final AjaxButton addMappingBtn;
-
- /**
- * All mappings.
- */
- private final ListView<MappingItemTO> mappings;
-
- /**
- * External resource to be updated.
- */
- private final ResourceTO resourceTO;
-
- /**
- * User / group.
- */
- private final AttributableType attrType;
-
- /**
- * Mapping container.
- */
- private final WebMarkupContainer mappingContainer;
-
- /**
- * AccountLink container.
- */
- private final WebMarkupContainer accountLinkContainer;
-
- private final AjaxCheckBoxPanel accountLinkCheckbox;
-
- private MappingTO getMapping() {
- MappingTO result = null;
-
- if (AttributableType.USER == this.attrType) {
- if (this.resourceTO.getUmapping() == null) {
- this.resourceTO.setUmapping(new MappingTO());
- }
- result = this.resourceTO.getUmapping();
- }
- if (AttributableType.GROUP == this.attrType) {
- if (this.resourceTO.getGmapping() == null) {
- this.resourceTO.setGmapping(new MappingTO());
- }
- result = this.resourceTO.getGmapping();
- }
-
- return result;
- }
-
- /**
- * Attribute Mapping Panel.
- *
- * @param id panel id
- * @param resourceTO external resource
- * @param attrType USER / GROUP
- */
- public ResourceMappingPanel(final String id, final ResourceTO resourceTO, final AttributableType attrType) {
- super(id);
- setOutputMarkupId(true);
-
- this.resourceTO = resourceTO;
- this.attrType = attrType;
-
- this.mappingContainer = new WebMarkupContainer("mappingContainer");
- this.mappingContainer.setOutputMarkupId(true);
- add(this.mappingContainer);
-
- this.accountLinkContainer = new WebMarkupContainer("accountLinkContainer");
- this.accountLinkContainer.setOutputMarkupId(true);
- add(this.accountLinkContainer);
-
- if (this.resourceTO.getConnectorId() != null && this.resourceTO.getConnectorId() > 0) {
- schemaNames = getSchemaNames(this.resourceTO.getConnectorId(), this.resourceTO.getConnConfProperties());
-
- setEnabled();
- } else {
- schemaNames = Collections.<String>emptyList();
- }
-
- final WebMarkupContainer jexlHelp = JexlHelpUtils.getJexlHelpWebContainer("jexlHelp");
-
- AjaxLink<Void> questionMarkJexlHelp = JexlHelpUtils.getAjaxLink(jexlHelp, "questionMarkJexlHelp");
- mappingContainer.add(questionMarkJexlHelp);
- questionMarkJexlHelp.add(jexlHelp);
-
- final Label passwordLabel = new Label("passwordLabel", new ResourceModel("password"));
- mappingContainer.add(passwordLabel);
- if (AttributableType.USER != ResourceMappingPanel.this.attrType) {
- passwordLabel.setVisible(false);
- }
-
- 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.SYNCHRONIZATION || right.getPurpose()
- == MappingPurpose.NONE)) {
- compared = -1;
- } else if (left.getPurpose() == MappingPurpose.SYNCHRONIZATION
- && right.getPurpose() == MappingPurpose.PROPAGATION) {
- compared = 1;
- } else if (left.getPurpose() == MappingPurpose.SYNCHRONIZATION
- && right.getPurpose() == MappingPurpose.NONE) {
- compared = -1;
- } else if (left.getPurpose() == MappingPurpose.NONE
- && right.getPurpose() != MappingPurpose.NONE) {
- compared = 1;
- } else if (left.isAccountid()) {
- compared = -1;
- } else if (right.isAccountid()) {
- 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);
- }
-
- AttributableType entity = null;
- if (mapItem.getIntMappingType() != null) {
- entity = mapItem.getIntMappingType().getAttributableType();
- }
-
- final List<IntMappingType> attrTypes = new ArrayList<IntMappingType>(getAttributeTypes(entity));
-
- item.add(new AjaxDecoratedCheckbox("toRemove", new Model<Boolean>(Boolean.FALSE)) {
-
- private static final long serialVersionUID = 7170946748485726506L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- 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);
- }
- }
-
- @Override
- protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) {
- super.updateAjaxAttributes(attributes);
-
- final AjaxCallListener 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 AjaxDropDownChoicePanel<String> intAttrNames =
- new AjaxDropDownChoicePanel<String>("intAttrNames", getString("intAttrNames"),
- new PropertyModel<String>(mapItem, "intAttrName"), false);
- intAttrNames.setChoices(schemaNames);
- intAttrNames.setRequired(true);
- intAttrNames.setStyleSheet(FIELD_STYLE);
- intAttrNames.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- }
- });
- item.add(intAttrNames);
-
- final AjaxDropDownChoicePanel<IntMappingType> intMappingTypes =
- new AjaxDropDownChoicePanel<IntMappingType>("intMappingTypes",
- new ResourceModel("intMappingTypes", "intMappingTypes").getObject(),
- new PropertyModel<IntMappingType>(mapItem, "intMappingType"));
- intMappingTypes.setRequired(true);
- intMappingTypes.setChoices(attrTypes);
- intMappingTypes.setStyleSheet(FIELD_STYLE);
- item.add(intMappingTypes);
-
- final AjaxDropDownChoicePanel<AttributableType> entitiesPanel =
- new AjaxDropDownChoicePanel<AttributableType>("entities",
- new ResourceModel("entities", "entities").getObject(), new Model<AttributableType>(
- entity));
- entitiesPanel.setChoices(attrType == AttributableType.GROUP
- ? Collections.<AttributableType>singletonList(AttributableType.GROUP)
- : Arrays.asList(AttributableType.values()));
- entitiesPanel.setStyleSheet(DEF_FIELD_STYLE);
- entitiesPanel.getField().add(new AjaxFormComponentUpdatingBehavior(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.getField());
- target.add(intAttrNames.getField());
- }
- });
- item.add(entitiesPanel);
-
- final FieldPanel<String> extAttrNames = new AjaxTextFieldPanel("extAttrName",
- new ResourceModel("extAttrNames", "extAttrNames").getObject(),
- new PropertyModel<String>(mapItem, "extAttrName"));
- ((AjaxTextFieldPanel) extAttrNames).setChoices(schemaNames);
-
- boolean required = false;
- if (mapItem.isPassword()) {
- ((AjaxTextFieldPanel) extAttrNames).setModelObject(null);
- } else {
- required = true;
- }
- extAttrNames.setRequired(required);
- extAttrNames.setEnabled(required);
- extAttrNames.setStyleSheet(FIELD_STYLE);
- item.add(extAttrNames);
-
- final AjaxTextFieldPanel mandatory = new AjaxTextFieldPanel("mandatoryCondition",
- new ResourceModel("mandatoryCondition", "mandatoryCondition").getObject(),
- new PropertyModel<String>(mapItem, "mandatoryCondition"));
- mandatory.setChoices(Arrays.asList(new String[] { "true", "false" }));
- mandatory.setStyleSheet(SHORT_FIELD_STYLE);
- item.add(mandatory);
-
- final AjaxCheckBoxPanel accountId = new AjaxCheckBoxPanel("accountId",
- new ResourceModel("accountId", "accountId").getObject(),
- new PropertyModel<Boolean>(mapItem, "accountid"));
- accountId.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- if (accountId.getModelObject()) {
- mapItem.setMandatoryCondition("true");
- mandatory.setEnabled(false);
- } else {
- mapItem.setMandatoryCondition("false");
- mandatory.setEnabled(true);
- }
- target.add(mandatory);
- }
- });
- item.add(accountId);
-
- final AjaxCheckBoxPanel password = new AjaxCheckBoxPanel("password",
- new ResourceModel("password", "password").getObject(),
- new PropertyModel<Boolean>(mapItem, "password"));
- password.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- extAttrNames.setEnabled(!mapItem.isAccountid() && !password.getModelObject());
- extAttrNames.setModelObject(null);
- extAttrNames.setRequired(!password.getModelObject());
- target.add(extAttrNames);
-
- setAccountId(intMappingTypes.getModelObject(), accountId, password);
- target.add(accountId);
- }
- });
- item.add(password);
- if (AttributableType.USER != ResourceMappingPanel.this.attrType) {
- password.setVisible(false);
- }
-
- 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);
-
- item.add(purpose);
-
- intMappingTypes.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- setAttrNames(intMappingTypes.getModelObject(), intAttrNames);
- target.add(intAttrNames);
-
- setAccountId(intMappingTypes.getModelObject(), accountId, password);
- target.add(accountId);
- }
- });
-
- setAttrNames(mapItem.getIntMappingType(), intAttrNames);
- setAccountId(mapItem.getIntMappingType(), accountId, password);
- }
- };
-
- 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(this.resourceTO.getConnectorId() != null && this.resourceTO.getConnectorId() > 0);
- mappingContainer.add(addMappingBtn);
-
- boolean accountLinkEnabled = false;
- if (getMapping().getAccountLink() != null) {
- accountLinkEnabled = true;
- }
- accountLinkCheckbox = new AjaxCheckBoxPanel("accountLinkCheckbox",
- new ResourceModel("accountLinkCheckbox", "accountLinkCheckbox").getObject(),
- new Model<Boolean>(Boolean.valueOf(accountLinkEnabled)));
- accountLinkCheckbox.setEnabled(true);
-
- accountLinkContainer.add(accountLinkCheckbox);
-
- final AjaxTextFieldPanel accountLink = new AjaxTextFieldPanel("accountLink",
- new ResourceModel("accountLink", "accountLink").getObject(),
- new PropertyModel<String>(getMapping(), "accountLink"));
- accountLink.setEnabled(accountLinkEnabled);
- accountLinkContainer.add(accountLink);
-
- accountLinkCheckbox.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- if (accountLinkCheckbox.getModelObject()) {
- accountLink.setEnabled(Boolean.TRUE);
- accountLink.setModelObject("");
- } else {
- accountLink.setEnabled(Boolean.FALSE);
- accountLink.setModelObject("");
- }
-
- target.add(accountLink);
- }
- });
- }
-
- private List<String> getSchemaNames(final Long connectorId, final Set<ConnConfProperty> conf) {
- final ConnInstanceTO connInstanceTO = new ConnInstanceTO();
- connInstanceTO.setKey(connectorId);
- connInstanceTO.getConfiguration().addAll(conf);
-
- return connRestClient.getSchemaNames(connInstanceTO);
- }
-
- private void setEnabled() {
- final ConnInstanceTO connInstanceTO = new ConnInstanceTO();
- connInstanceTO.setKey(this.resourceTO.getConnectorId());
- connInstanceTO.getConfiguration().addAll(this.resourceTO.getConnConfProperties());
-
- List<ConnIdObjectClassTO> objectClasses = connRestClient.getSupportedObjectClasses(connInstanceTO);
-
- boolean enabled = objectClasses.isEmpty()
- || (AttributableType.USER == attrType && objectClasses.contains(ConnIdObjectClassTO.ACCOUNT))
- || (AttributableType.GROUP == attrType && objectClasses.contains(ConnIdObjectClassTO.GROUP));
- this.mappingContainer.setEnabled(enabled);
- this.mappingContainer.setVisible(enabled);
- this.accountLinkContainer.setEnabled(enabled);
- this.accountLinkContainer.setVisible(enabled);
-
- if (!enabled) {
- getMapping().getItems().clear();
- getMapping().setAccountLink(null);
- if (this.accountLinkCheckbox != null) {
- this.accountLinkCheckbox.setModelObject(null);
- }
- }
- }
-
- @Override
- public void onEvent(final IEvent<?> event) {
- if (event.getPayload() instanceof ConnConfModEvent) {
- final AjaxRequestTarget target = ((ConnConfModEvent) event.getPayload()).getTarget();
-
- final List<ConnConfProperty> conf = ((ConnConfModEvent) event.getPayload()).getConfiguration();
-
- mappings.removeAll();
-
- addMappingBtn.setEnabled(resourceTO.getConnectorId() != null && resourceTO.getConnectorId() > 0);
-
- schemaNames.clear();
- schemaNames.addAll(getSchemaNames(resourceTO.getConnectorId(), new HashSet<ConnConfProperty>(conf)));
-
- setEnabled();
-
- target.add(this);
- }
- }
-
- /**
- * 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.getAttributableType() == null) {
- toBeUpdated.setChoices(Collections.<String>emptyList());
- } else {
- switch (type) {
- // user attribute names
- case UserPlainSchema:
- case GroupPlainSchema:
- case MembershipPlainSchema:
- toBeUpdated.setChoices(schemaRestClient.getPlainSchemaNames(type.getAttributableType()));
- break;
-
- case UserDerivedSchema:
- case GroupDerivedSchema:
- case MembershipDerivedSchema:
- toBeUpdated.setChoices(schemaRestClient.getDerSchemaNames(type.getAttributableType()));
- break;
-
- case UserVirtualSchema:
- case GroupVirtualSchema:
- case MembershipVirtualSchema:
- toBeUpdated.setChoices(schemaRestClient.getVirSchemaNames(type.getAttributableType()));
- break;
-
- case UserId:
- case Password:
- case Username:
- case GroupId:
- case GroupName:
- default:
- toBeUpdated.setRequired(false);
- toBeUpdated.setEnabled(false);
- toBeUpdated.setChoices(Collections.<String>emptyList());
- }
- }
- }
-
- /**
- * Enable/Disable accountId checkbox.
- *
- * @param type attribute type.
- * @param accountId accountId checkbox.
- * @param password password checkbox.
- */
- private void setAccountId(final IntMappingType type, final AjaxCheckBoxPanel accountId,
- final AjaxCheckBoxPanel password) {
-
- if (type != null && type.getAttributableType() != null) {
- switch (type) {
- case UserVirtualSchema:
- case GroupVirtualSchema:
- case MembershipVirtualSchema:
- // Virtual accountId is not permitted
- case Password:
- // AccountId cannot be derived from password.
- accountId.setReadOnly(true);
- accountId.setModelObject(false);
- break;
-
- default:
- if (password.getModelObject()) {
- accountId.setReadOnly(true);
- accountId.setModelObject(false);
- } else {
- accountId.setReadOnly(false);
- }
- }
- }
- }
-
- /**
- * Get all attribute types from a selected attribute type.
- *
- * @param entity entity.
- * @return all attribute types.
- */
- private List<IntMappingType> getAttributeTypes(final AttributableType entity) {
- final List<IntMappingType> res = new ArrayList<IntMappingType>();
-
- if (entity != null) {
- res.addAll(IntMappingType.getAttributeTypes(AttributableType.valueOf(entity.name())));
- }
-
- return res;
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/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 40e031a..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/ResourceSecurityPanel.java
+++ /dev/null
@@ -1,189 +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.common.lib.to.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.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.model.ResourceModel;
-import org.apache.wicket.spring.injection.annot.SpringBean;
-
-public class ResourceSecurityPanel extends Panel {
-
- private static final long serialVersionUID = -7982691107029848579L;
-
- @SpringBean
- private PolicyRestClient policyRestClient;
-
- private IModel<Map<Long, String>> passwordPolicies = null;
-
- private IModel<Map<Long, String>> accountPolicies = null;
-
- private IModel<Map<Long, String>> syncPolicies = null;
-
- public ResourceSecurityPanel(final String id, final ResourceTO resourceTO) {
-
- 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;
- }
- };
-
- syncPolicies = 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.SYNC, 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",
- new ResourceModel("passwordPolicy", "passwordPolicy").getObject(), new PropertyModel<Long>(resourceTO,
- "passwordPolicy"));
-
- passwordPolicy.setChoiceRenderer(new PolicyRenderer(PolicyType.PASSWORD));
-
- passwordPolicy.setChoices(new ArrayList<>(passwordPolicies.getObject().keySet()));
-
- ((DropDownChoice<?>) passwordPolicy.getField()).setNullValid(true);
-
- securityContainer.add(passwordPolicy);
- // -------------------------------
-
- // -------------------------------
- // Account policy specification
- // -------------------------------
- final AjaxDropDownChoicePanel<Long> accountPolicy = new AjaxDropDownChoicePanel<Long>("accountPolicy",
- new ResourceModel("accountPolicy", "accountPolicy").getObject(), new PropertyModel<Long>(resourceTO,
- "accountPolicy"));
-
- accountPolicy.setChoiceRenderer(new PolicyRenderer(PolicyType.ACCOUNT));
-
- accountPolicy.setChoices(new ArrayList<Long>(accountPolicies.getObject().keySet()));
-
- ((DropDownChoice<?>) accountPolicy.getField()).setNullValid(true);
-
- securityContainer.add(accountPolicy);
- // -------------------------------
-
- // -------------------------------
- // Sync policy specification
- // -------------------------------
- final AjaxDropDownChoicePanel<Long> syncPolicy = new AjaxDropDownChoicePanel<Long>("syncPolicy",
- new ResourceModel("syncPolicy", "syncPolicy").getObject(), new PropertyModel<Long>(resourceTO,
- "syncPolicy"));
-
- syncPolicy.setChoiceRenderer(new PolicyRenderer(PolicyType.SYNC));
-
- syncPolicy.setChoices(new ArrayList<Long>(syncPolicies.getObject().keySet()));
-
- ((DropDownChoice<?>) syncPolicy.getField()).setNullValid(true);
-
- securityContainer.add(syncPolicy);
- // -------------------------------
- }
-
- 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) {
- switch (type) {
- case GLOBAL_ACCOUNT:
- case ACCOUNT:
- return accountPolicies.getObject().get(object);
- case GLOBAL_PASSWORD:
- case PASSWORD:
- return passwordPolicies.getObject().get(object);
- case GLOBAL_SYNC:
- case SYNC:
- return syncPolicies.getObject().get(object);
- default:
- return "";
- }
- }
-
- @Override
- public String getIdValue(final Long object, final 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/ResourcesPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/ResourcesPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/ResourcesPanel.java
deleted file mode 100644
index 028b3a0..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/ResourcesPanel.java
+++ /dev/null
@@ -1,177 +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.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.apache.syncope.client.console.commons.Constants;
-import org.apache.syncope.client.console.commons.GroupTreeBuilder;
-import org.apache.syncope.client.console.commons.SelectChoiceRenderer;
-import org.apache.syncope.client.console.commons.status.StatusUtils;
-import org.apache.syncope.client.console.rest.ResourceRestClient;
-import org.apache.syncope.client.console.wicket.markup.html.form.AjaxPalettePanel;
-import org.apache.syncope.client.console.wicket.markup.html.form.NonI18nPalette;
-import org.apache.syncope.common.lib.to.AbstractSubjectTO;
-import org.apache.syncope.common.lib.to.MembershipTO;
-import org.apache.syncope.common.lib.to.ResourceTO;
-import org.apache.syncope.common.lib.to.GroupTO;
-import org.apache.syncope.common.lib.to.UserTO;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
-import org.apache.wicket.extensions.markup.html.form.palette.Palette;
-import org.apache.wicket.extensions.markup.html.form.palette.component.Recorder;
-import org.apache.wicket.markup.html.form.IChoiceRenderer;
-import org.apache.wicket.markup.html.panel.Panel;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.PropertyModel;
-import org.apache.wicket.model.util.ListModel;
-import org.apache.wicket.spring.injection.annot.SpringBean;
-
-public class ResourcesPanel extends Panel {
-
- private static final long serialVersionUID = -8728071019777410008L;
-
- @SpringBean
- private ResourceRestClient resourceRestClient;
-
- @SpringBean
- private GroupTreeBuilder groupTreeBuilder;
-
- private final AbstractSubjectTO subjectTO;
-
- private final Set<String> previousResources;
-
- private final List<String> allResources;
-
- public static class Builder implements Serializable {
-
- private static final long serialVersionUID = 8644108944633025494L;
-
- private String id;
-
- private Object to;
-
- private StatusPanel statusPanel;
-
- public Builder(final String id) {
- this.id = id;
- }
-
- public Builder attributableTO(final Object to) {
- this.to = to;
- return this;
- }
-
- public Builder statusPanel(final StatusPanel statusPanel) {
- this.statusPanel = statusPanel;
- return this;
- }
-
- public ResourcesPanel build() {
- return new ResourcesPanel(this);
- }
- }
-
- private ResourcesPanel(final Builder builder) {
- super(builder.id);
- subjectTO = (AbstractSubjectTO) builder.to;
- previousResources = new HashSet<>(subjectTO.getResources());
- allResources = new ArrayList<>();
- for (ResourceTO resourceTO : resourceRestClient.getAll()) {
- allResources.add(resourceTO.getKey());
- }
- Collections.sort(allResources);
-
- AjaxPalettePanel<String> resourcesPalette = null;
-
- if (subjectTO instanceof UserTO) {
- resourcesPalette = new AjaxRecordingPalettePanel<>("resourcesPalette",
- new PropertyModel<List<String>>(subjectTO, "resources"),
- new ListModel<>(allResources), builder.statusPanel);
- } else if (subjectTO instanceof GroupTO) {
- resourcesPalette = new AjaxPalettePanel<>("resourcesPalette",
- new PropertyModel<List<String>>(subjectTO, "resources"), new ListModel<>(allResources));
- }
- add(resourcesPalette);
- }
-
- private class AjaxRecordingPalettePanel<T> extends AjaxPalettePanel<T> {
-
- private static final long serialVersionUID = -4215625881756021988L;
-
- private final StatusPanel statusPanel;
-
- public AjaxRecordingPalettePanel(final String id, final IModel<List<T>> model, final ListModel<T> choices,
- final StatusPanel statusPanel) {
-
- super(id, model, choices, new SelectChoiceRenderer<T>(), false, false);
- this.statusPanel = statusPanel;
- }
-
- @Override
- protected Palette<T> createPalette(final IModel<List<T>> model, final ListModel<T> choices,
- final IChoiceRenderer<T> renderer, final boolean allowOrder, final boolean allowMoveAll) {
-
- return new NonI18nPalette<T>("paletteField", model, choices, renderer, 8, allowOrder, false) {
-
- private static final long serialVersionUID = -3415146226879212841L;
-
- @Override
- protected Recorder<T> newRecorderComponent() {
- Recorder<T> recorder = super.newRecorderComponent();
- recorder.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = 5538299138211283825L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- if (subjectTO instanceof UserTO) {
- UserTO userTO = (UserTO) subjectTO;
-
- Set<String> resourcesToRemove = new HashSet<>(previousResources);
- resourcesToRemove.removeAll(userTO.getResources());
- if (!resourcesToRemove.isEmpty()) {
- Set<String> resourcesAssignedViaMembership = new HashSet<>();
- for (MembershipTO membTO : userTO.getMemberships()) {
- GroupTO groupTO = groupTreeBuilder.findGroup(membTO.getGroupKey());
- if (groupTO != null) {
- resourcesAssignedViaMembership.addAll(groupTO.getResources());
- }
- }
- resourcesToRemove.removeAll(resourcesAssignedViaMembership);
- }
-
- previousResources.clear();
- previousResources.addAll(userTO.getResources());
-
- StatusUtils.update(
- userTO, statusPanel, target, userTO.getResources(), resourcesToRemove);
- }
- }
- });
- return recorder;
- }
- };
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/panels/SchedTasks.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/SchedTasks.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/SchedTasks.java
deleted file mode 100644
index 205bfa5..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/SchedTasks.java
+++ /dev/null
@@ -1,286 +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.pages.SchedTaskModalPage;
-import org.apache.syncope.client.console.pages.Tasks;
-import org.apache.syncope.client.console.pages.Tasks.TasksProvider;
-import org.apache.syncope.client.console.wicket.ajax.markup.html.ClearIndicatingAjaxLink;
-import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.ActionColumn;
-import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.DatePropertyColumn;
-import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
-import org.apache.syncope.client.console.wicket.markup.html.form.ActionLinksPanel;
-import org.apache.syncope.common.lib.SyncopeClientException;
-import org.apache.syncope.common.lib.to.AbstractTaskTO;
-import org.apache.syncope.common.lib.to.SchedTaskTO;
-import org.apache.wicket.Component;
-import org.apache.wicket.Page;
-import org.apache.wicket.PageReference;
-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.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy;
-import org.apache.wicket.event.IEvent;
-import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.form.DropDownChoice;
-import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.model.PropertyModel;
-import org.apache.wicket.model.StringResourceModel;
-import org.apache.wicket.request.http.WebResponse;
-
-public class SchedTasks extends AbstractTasks {
-
- private static final long serialVersionUID = 525486152284253354L;
-
- private int paginatorRows;
-
- private WebMarkupContainer container;
-
- private ModalWindow window;
-
- private AjaxDataTablePanel<AbstractTaskTO, String> table;
-
- public SchedTasks(final String id, final PageReference pageRef) {
- super(id, pageRef);
-
- container = new WebMarkupContainer("container");
- container.setOutputMarkupId(true);
- add(container);
-
- window = new ModalWindow("taskWin");
- window.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
- window.setInitialHeight(WIN_HEIGHT);
- window.setInitialWidth(WIN_WIDTH);
- window.setCookieName(VIEW_TASK_WIN_COOKIE_NAME);
- add(window);
-
- ((Tasks) pageRef.getPage()).setWindowClosedCallback(window, container);
-
- paginatorRows = prefMan.getPaginatorRows(getWebRequest(), Constants.PREF_SCHED_TASKS_PAGINATOR_ROWS);
-
- table = Tasks.updateTaskTable(
- getColumns(),
- new TasksProvider<SchedTaskTO>(restClient, paginatorRows, getId(), SchedTaskTO.class),
- container,
- 0,
- pageRef,
- restClient);
-
- container.add(table);
-
- @SuppressWarnings("rawtypes")
- Form paginatorForm = new Form("PaginatorForm");
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- final DropDownChoice rowsChooser = new DropDownChoice("rowsChooser", new PropertyModel(this, "paginatorRows"),
- prefMan.getPaginatorChoices());
-
- rowsChooser.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- prefMan.set(getWebRequest(), (WebResponse) getResponse(), Constants.PREF_SCHED_TASKS_PAGINATOR_ROWS,
- String.valueOf(paginatorRows));
-
- table = Tasks.updateTaskTable(
- getColumns(),
- new TasksProvider<SchedTaskTO>(restClient, paginatorRows, getId(), SchedTaskTO.class),
- container,
- table == null ? 0 : (int) table.getCurrentPage(),
- pageRef,
- restClient);
-
- target.add(container);
- }
- });
-
- paginatorForm.add(rowsChooser);
- add(paginatorForm);
-
- AjaxLink createLink = new ClearIndicatingAjaxLink("createLink", pageRef) {
-
- private static final long serialVersionUID = -7978723352517770644L;
-
- @Override
- protected void onClickInternal(final AjaxRequestTarget target) {
- window.setPageCreator(new ModalWindow.PageCreator() {
-
- private static final long serialVersionUID = -7834632442532690940L;
-
- @Override
- public Page createPage() {
- return new SchedTaskModalPage(window, new SchedTaskTO(), pageRef);
- }
- });
-
- window.show(target);
- }
- };
-
- MetaDataRoleAuthorizationStrategy.authorize(
- createLink, RENDER, xmlRolesReader.getEntitlement(TASKS, "create"));
-
- add(createLink);
- }
-
- private List<IColumn<AbstractTaskTO, String>> getColumns() {
- final List<IColumn<AbstractTaskTO, String>> columns = new ArrayList<IColumn<AbstractTaskTO, String>>();
-
- columns.add(new PropertyColumn<AbstractTaskTO, String>(
- new StringResourceModel("key", this, null), "key", "key"));
- columns.add(new PropertyColumn<AbstractTaskTO, String>(
- new StringResourceModel("name", this, null), "name", "name"));
- columns.add(new PropertyColumn<AbstractTaskTO, String>(
- new StringResourceModel("description", this, null), "description", "description"));
- columns.add(new PropertyColumn<AbstractTaskTO, String>(
- new StringResourceModel("class", this, null), "jobClassName", "jobClassName"));
- columns.add(new DatePropertyColumn<AbstractTaskTO>(
- new StringResourceModel("lastExec", this, null), "lastExec", "lastExec"));
- columns.add(new DatePropertyColumn<AbstractTaskTO>(
- new StringResourceModel("nextExec", this, null), "nextExec", "nextExec"));
- columns.add(new PropertyColumn<AbstractTaskTO, String>(
- new StringResourceModel("latestExecStatus", this, null), "latestExecStatus", "latestExecStatus"));
-
- columns.add(new ActionColumn<AbstractTaskTO, String>(new StringResourceModel("actions", this, null, "")) {
-
- private static final long serialVersionUID = 2054811145491901166L;
-
- @Override
- public ActionLinksPanel getActions(final String componentId, final IModel<AbstractTaskTO> model) {
-
- final SchedTaskTO taskTO = (SchedTaskTO) model.getObject();
-
- final ActionLinksPanel panel = new ActionLinksPanel(componentId, model, pageRef);
-
- panel.add(new ActionLink() {
-
- private static final long serialVersionUID = -3722207913631435501L;
-
- @Override
- public void onClick(final AjaxRequestTarget target) {
- window.setPageCreator(new ModalWindow.PageCreator() {
-
- private static final long serialVersionUID = -7834632442532690940L;
-
- @Override
- public Page createPage() {
- return new SchedTaskModalPage(window, taskTO, pageRef);
- }
- });
-
- window.show(target);
- }
- }, ActionLink.ActionType.EDIT, TASKS);
-
- panel.add(new ActionLink() {
-
- private static final long serialVersionUID = -3722207913631435501L;
-
- @Override
- public void onClick(final AjaxRequestTarget target) {
- try {
- restClient.startExecution(taskTO.getKey(), false);
- getSession().info(getString(Constants.OPERATION_SUCCEEDED));
- } catch (SyncopeClientException scce) {
- error(scce.getMessage());
- }
-
- ((NotificationPanel) getPage().get(Constants.FEEDBACK)).refresh(target);
- target.add(container);
- }
- }, ActionLink.ActionType.EXECUTE, TASKS);
-
- panel.add(new ActionLink() {
-
- private static final long serialVersionUID = -3722207913631435501L;
-
- @Override
- public void onClick(final AjaxRequestTarget target) {
- try {
- restClient.startExecution(taskTO.getKey(), true);
- getSession().info(getString(Constants.OPERATION_SUCCEEDED));
- } catch (SyncopeClientException scce) {
- error(scce.getMessage());
- }
-
- ((NotificationPanel) getPage().get(Constants.FEEDBACK)).refresh(target);
- target.add(container);
- }
- }, ActionLink.ActionType.DRYRUN, TASKS);
-
- panel.add(new ActionLink() {
-
- private static final long serialVersionUID = -3722207913631435501L;
-
- @Override
- public void onClick(final AjaxRequestTarget target) {
- try {
- restClient.delete(taskTO.getKey(), SchedTaskTO.class);
- info(getString(Constants.OPERATION_SUCCEEDED));
- } catch (SyncopeClientException scce) {
- error(scce.getMessage());
- }
- target.add(container);
- ((NotificationPanel) getPage().get(Constants.FEEDBACK)).refresh(target);
- }
- }, ActionLink.ActionType.DELETE, TASKS);
-
- return panel;
- }
-
- @Override
- public Component getHeader(final String componentId) {
- @SuppressWarnings("rawtypes")
- final ActionLinksPanel panel = new ActionLinksPanel(componentId, new Model(), pageRef);
-
- panel.add(new ActionLink() {
-
- private static final long serialVersionUID = -7978723352517770644L;
-
- @Override
- public void onClick(final AjaxRequestTarget target) {
- if (target != null) {
- target.add(table);
- }
- }
- }, ActionLink.ActionType.RELOAD, TASKS, "list");
-
- return panel;
- }
- });
- return columns;
- }
-
- @Override
- public void onEvent(final IEvent<?> event) {
- if (event.getPayload() instanceof AbstractSearchResultPanel.EventDataWrapper) {
- ((AbstractSearchResultPanel.EventDataWrapper) event.getPayload()).getTarget().add(container);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/panels/SearchClause.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/SearchClause.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/SearchClause.java
deleted file mode 100644
index 488a2cf..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/SearchClause.java
+++ /dev/null
@@ -1,129 +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.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-
-public class SearchClause implements Serializable {
-
- private static final long serialVersionUID = 2010794463096110104L;
-
- public enum Operator {
-
- AND,
- OR;
-
- }
-
- public enum Type {
-
- ATTRIBUTE,
- MEMBERSHIP,
- RESOURCE,
- ENTITLEMENT;
-
- }
-
- public enum Comparator {
-
- IS_NULL,
- IS_NOT_NULL,
- EQUALS,
- NOT_EQUALS,
- GREATER_OR_EQUALS,
- GREATER_THAN,
- LESS_OR_EQUALS,
- LESS_THAN;
-
- }
-
- private Operator operator;
-
- private Type type;
-
- private String property;
-
- private Comparator comparator;
-
- private String value;
-
- public SearchClause() {
- setOperator(SearchClause.Operator.AND);
- setComparator(SearchClause.Comparator.EQUALS);
- }
-
- public Operator getOperator() {
- return operator;
- }
-
- public void setOperator(final Operator operator) {
- this.operator = operator;
- }
-
- public Type getType() {
- return type;
- }
-
- public void setType(final Type type) {
- this.type = type;
- }
-
- public String getProperty() {
- return property;
- }
-
- public void setProperty(final String property) {
- this.property = property;
- }
-
- public Comparator getComparator() {
- return comparator;
- }
-
- public void setComparator(final Comparator comparator) {
- this.comparator = comparator;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(final String value) {
- this.value = value;
- }
-
- @Override
- public boolean equals(final Object obj) {
- return EqualsBuilder.reflectionEquals(this, obj);
- }
-
- @Override
- public int hashCode() {
- return HashCodeBuilder.reflectionHashCode(this);
- }
-
- @Override
- public String toString() {
- return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/panels/SearchView.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/SearchView.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/SearchView.java
deleted file mode 100644
index c081cd3..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/SearchView.java
+++ /dev/null
@@ -1,461 +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.Arrays;
-import java.util.Collections;
-import java.util.List;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.syncope.client.console.commons.Constants;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
-import org.apache.wicket.ajax.markup.html.AjaxLink;
-import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.form.DropDownChoice;
-import org.apache.wicket.markup.html.form.IChoiceRenderer;
-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.model.IModel;
-import org.apache.wicket.model.LoadableDetachableModel;
-import org.apache.wicket.model.PropertyModel;
-
-public class SearchView extends ListView<SearchClause> {
-
- private static final long serialVersionUID = -527351923968737757L;
-
- private final WebMarkupContainer searchFormContainer;
-
- private final boolean required;
-
- private final IModel<List<SearchClause.Type>> types;
-
- private final IModel<List<String>> anames;
-
- private final IModel<List<String>> dnames;
-
- private final IModel<List<String>> groupNames;
-
- private final IModel<List<String>> resourceNames;
-
- private final IModel<List<String>> entitlements;
-
- public SearchView(final String id, final List<? extends SearchClause> list,
- final WebMarkupContainer searchFormContainer,
- final boolean required,
- final IModel<List<SearchClause.Type>> types,
- final IModel<List<String>> anames,
- final IModel<List<String>> dnames,
- final IModel<List<String>> groupNames,
- final IModel<List<String>> resourceNames,
- final IModel<List<String>> entitlements) {
-
- super(id, list);
-
- this.searchFormContainer = searchFormContainer;
- this.required = required;
- this.types = types;
- this.anames = anames;
- this.dnames = dnames;
- this.groupNames = groupNames;
- this.resourceNames = resourceNames;
- this.entitlements = entitlements;
- }
-
- @Override
- protected void populateItem(final ListItem<SearchClause> item) {
- final SearchClause searchClause = item.getModelObject();
-
- final DropDownChoice<SearchClause.Operator> operator = new DropDownChoice<SearchClause.Operator>("operator",
- new PropertyModel<SearchClause.Operator>(searchClause, "operator"),
- Arrays.asList(SearchClause.Operator.values()));
- operator.setOutputMarkupPlaceholderTag(true);
- operator.setNullValid(false);
- operator.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- }
- });
- item.add(operator);
- if (item.getIndex() == 0) {
- operator.setVisible(false);
- }
-
- final DropDownChoice<SearchClause.Type> type = new DropDownChoice<SearchClause.Type>("type",
- new PropertyModel<SearchClause.Type>(searchClause, "type"), types);
- type.setOutputMarkupId(true);
- type.setRequired(required);
- type.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- target.add(searchFormContainer);
- }
- });
- item.add(type);
-
- @SuppressWarnings("unchecked")
- final DropDownChoice<String> property = new DropDownChoice<String>("property",
- new PropertyModel<String>(searchClause, "property"), (IModel) null);
- property.setOutputMarkupId(true);
- property.setRequired(required);
- property.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- }
- });
- item.add(property);
-
- final TextField<String> value = new TextField<String>("value",
- new PropertyModel<String>(searchClause, "value"));
- value.setOutputMarkupId(true);
- value.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- }
- });
- item.add(value);
-
- final DropDownChoice<SearchClause.Comparator> comparator =
- new DropDownChoice<SearchClause.Comparator>("comparator",
- new PropertyModel<SearchClause.Comparator>(searchClause, "comparator"),
- Collections.<SearchClause.Comparator>emptyList());
- comparator.setOutputMarkupId(true);
- comparator.setNullValid(false);
- comparator.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- if (type.getModelObject() == SearchClause.Type.ATTRIBUTE) {
- if (comparator.getModelObject() == SearchClause.Comparator.IS_NULL
- || comparator.getModelObject() == SearchClause.Comparator.IS_NOT_NULL) {
-
- value.setModelObject(null);
- value.setEnabled(false);
- } else {
- value.setEnabled(true);
- }
- target.add(value);
- }
- }
- });
- comparator.setRequired(required);
- item.add(comparator);
-
- AjaxLink<Void> drop = new IndicatingAjaxLink<Void>("drop") {
-
- private static final long serialVersionUID = -7978723352517770644L;
-
- @Override
- public void onClick(final AjaxRequestTarget target) {
- SearchView.this.getModel().getObject().remove(item.getModelObject());
- target.add(searchFormContainer);
- }
- };
- item.add(drop);
- if (item.getIndex() == 0) {
- drop.setVisible(false);
- drop.setEnabled(false);
- } else {
- drop.setVisible(true);
- drop.setEnabled(true);
- }
-
- final AjaxLink<Void> add = new IndicatingAjaxLink<Void>("add") {
-
- private static final long serialVersionUID = -7978723352517770644L;
-
- @Override
- public void onClick(final AjaxRequestTarget target) {
- SearchClause clause = new SearchClause();
- SearchView.this.getModel().getObject().add(clause);
- target.add(searchFormContainer);
- }
- };
- item.add(add);
-
- if (searchClause == null || searchClause.getType() == null) {
- property.setChoices(Collections.<String>emptyList());
- } else {
- switch (searchClause.getType()) {
- case ATTRIBUTE:
- final List<String> names = new ArrayList<String>(dnames.getObject());
- if (anames.getObject() != null && !anames.getObject().isEmpty()) {
- names.addAll(anames.getObject());
- }
- Collections.sort(names);
- property.setChoices(names);
-
- comparator.setChoices(new LoadableDetachableModel<List<SearchClause.Comparator>>() {
-
- private static final long serialVersionUID = 5275935387613157437L;
-
- @Override
- protected List<SearchClause.Comparator> load() {
- return Arrays.asList(SearchClause.Comparator.values());
- }
- });
- comparator.setChoiceRenderer(new IChoiceRenderer<SearchClause.Comparator>() {
-
- private static final long serialVersionUID = -9086043750227867686L;
-
- @Override
- public Object getDisplayValue(final SearchClause.Comparator object) {
- String display;
-
- switch (object) {
- case IS_NULL:
- display = "NULL";
- break;
-
- case IS_NOT_NULL:
- display = "NOT NULL";
- break;
-
- case EQUALS:
- display = "==";
- break;
-
- case NOT_EQUALS:
- display = "!=";
- break;
-
- case LESS_THAN:
- display = "<";
- break;
-
- case LESS_OR_EQUALS:
- display = "<=";
- break;
-
- case GREATER_THAN:
- display = ">";
- break;
-
- case GREATER_OR_EQUALS:
- display = ">=";
- break;
-
- default:
- display = StringUtils.EMPTY;
- }
-
- return display;
- }
-
- @Override
- public String getIdValue(final SearchClause.Comparator object, int index) {
- return getDisplayValue(object).toString();
- }
- });
- if (!comparator.isEnabled()) {
- comparator.setEnabled(true);
- comparator.setRequired(true);
- }
-
- if (!value.isEnabled()) {
- value.setEnabled(true);
- }
- break;
-
- case MEMBERSHIP:
- property.setChoices(groupNames);
- property.setChoiceRenderer(new IChoiceRenderer<String>() {
-
- private static final long serialVersionUID = -4288397951948436434L;
-
- @Override
- public Object getDisplayValue(final String object) {
- return object;
- }
-
- @Override
- public String getIdValue(final String object, final int index) {
- return object;
- }
- });
-
- comparator.setChoices(new LoadableDetachableModel<List<SearchClause.Comparator>>() {
-
- private static final long serialVersionUID = 5275935387613157437L;
-
- @Override
- protected List<SearchClause.Comparator> load() {
- List<SearchClause.Comparator> comparators = new ArrayList<SearchClause.Comparator>();
- comparators.add(SearchClause.Comparator.EQUALS);
- comparators.add(SearchClause.Comparator.NOT_EQUALS);
- return comparators;
- }
- });
- comparator.setChoiceRenderer(new IChoiceRenderer<SearchClause.Comparator>() {
-
- private static final long serialVersionUID = -9086043750227867686L;
-
- @Override
- public Object getDisplayValue(final SearchClause.Comparator object) {
- String display;
-
- switch (object) {
- case EQUALS:
- display = "IN";
- break;
-
- case NOT_EQUALS:
- display = "NOT IN";
- break;
-
- default:
- display = StringUtils.EMPTY;
- }
-
- return display;
- }
-
- @Override
- public String getIdValue(final SearchClause.Comparator object, final int index) {
- return getDisplayValue(object).toString();
- }
- });
-
- value.setEnabled(false);
- value.setModelObject("");
-
- break;
-
- case RESOURCE:
- property.setChoices(resourceNames);
-
- comparator.setChoices(new LoadableDetachableModel<List<SearchClause.Comparator>>() {
-
- private static final long serialVersionUID = 5275935387613157437L;
-
- @Override
- protected List<SearchClause.Comparator> load() {
- List<SearchClause.Comparator> comparators = new ArrayList<SearchClause.Comparator>();
- comparators.add(SearchClause.Comparator.EQUALS);
- comparators.add(SearchClause.Comparator.NOT_EQUALS);
- return comparators;
- }
- });
- comparator.setChoiceRenderer(new IChoiceRenderer<SearchClause.Comparator>() {
-
- private static final long serialVersionUID = -9086043750227867686L;
-
- @Override
- public Object getDisplayValue(final SearchClause.Comparator object) {
- String display;
-
- switch (object) {
- case EQUALS:
- display = "HAS";
- break;
-
- case NOT_EQUALS:
- display = "HAS NOT";
- break;
-
- default:
- display = StringUtils.EMPTY;
- }
-
- return display;
- }
-
- @Override
- public String getIdValue(final SearchClause.Comparator object, final int index) {
- return getDisplayValue(object).toString();
- }
- });
-
- value.setEnabled(false);
- value.setModelObject("");
-
- break;
-
- case ENTITLEMENT:
- property.setChoices(entitlements);
-
- comparator.setChoices(new LoadableDetachableModel<List<SearchClause.Comparator>>() {
-
- private static final long serialVersionUID = 5275935387613157437L;
-
- @Override
- protected List<SearchClause.Comparator> load() {
- List<SearchClause.Comparator> comparators = new ArrayList<SearchClause.Comparator>();
- comparators.add(SearchClause.Comparator.EQUALS);
- comparators.add(SearchClause.Comparator.NOT_EQUALS);
- return comparators;
- }
- });
- comparator.setChoiceRenderer(new IChoiceRenderer<SearchClause.Comparator>() {
-
- private static final long serialVersionUID = -9086043750227867686L;
-
- @Override
- public Object getDisplayValue(final SearchClause.Comparator object) {
- String display;
-
- switch (object) {
- case EQUALS:
- display = "HAS";
- break;
-
- case NOT_EQUALS:
- display = "HAS NOT";
- break;
-
- default:
- display = StringUtils.EMPTY;
- }
-
- return display;
- }
-
- @Override
- public String getIdValue(final SearchClause.Comparator object, final int index) {
- return getDisplayValue(object).toString();
- }
- });
-
- value.setEnabled(false);
- value.setModelObject("");
-
- break;
-
- default:
- property.setChoices(Collections.<String>emptyList());
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/panels/SecurityQuestionPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/SecurityQuestionPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/SecurityQuestionPanel.java
deleted file mode 100644
index 8658cf6..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/SecurityQuestionPanel.java
+++ /dev/null
@@ -1,98 +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.Map;
-import java.util.TreeMap;
-import org.apache.syncope.client.console.commons.Constants;
-import org.apache.syncope.client.console.rest.SecurityQuestionRestClient;
-import org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel;
-import org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel;
-import org.apache.syncope.common.lib.to.SecurityQuestionTO;
-import org.apache.syncope.common.lib.to.UserTO;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
-import org.apache.wicket.markup.html.form.DropDownChoice;
-import org.apache.wicket.markup.html.form.IChoiceRenderer;
-import org.apache.wicket.markup.html.panel.Panel;
-import org.apache.wicket.model.PropertyModel;
-import org.apache.wicket.spring.injection.annot.SpringBean;
-
-public class SecurityQuestionPanel extends Panel {
-
- private static final long serialVersionUID = -790642213865180146L;
-
- private final Map<Long, String> questions = new TreeMap<Long, String>();
-
- @SpringBean
- private SecurityQuestionRestClient restClient;
-
- public SecurityQuestionPanel(final String id, final UserTO userTO) {
- super(id);
- setOutputMarkupId(true);
-
- for (SecurityQuestionTO secQues : restClient.list()) {
- questions.put(secQues.getKey(), secQues.getContent());
- }
-
- final AjaxTextFieldPanel securityAnswer = new AjaxTextFieldPanel("securityAnswer", "securityAnswer",
- new PropertyModel<String>(userTO, "securityAnswer"));
- securityAnswer.getField().setOutputMarkupId(true);
- securityAnswer.setEnabled(false);
- add(securityAnswer);
-
- final AjaxDropDownChoicePanel<Long> securityQuestion =
- new AjaxDropDownChoicePanel<>("securityQuestion", "securityQuestion",
- new PropertyModel<Long>(userTO, "securityQuestion"));
- ((DropDownChoice) securityQuestion.getField()).setNullValid(true);
- securityQuestion.setChoices(new ArrayList<>(questions.keySet()));
- securityQuestion.setStyleSheet("ui-widget-content ui-corner-all long_dynamicsize");
- securityQuestion.getField().setOutputMarkupId(true);
- securityQuestion.setChoiceRenderer(new IChoiceRenderer<Long>() {
-
- private static final long serialVersionUID = 2693996850376268294L;
-
- @Override
- public Object getDisplayValue(final Long object) {
- return questions.get(object);
- }
-
- @Override
- public String getIdValue(final Long object, final int index) {
- return questions.get(object);
- }
- });
- securityQuestion.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- if (securityQuestion.getModelObject() == null) {
- securityAnswer.setModelObject(null);
- } else {
- securityAnswer.setEnabled(true);
- }
- target.add(SecurityQuestionPanel.this);
- }
- });
- add(securityQuestion);
- }
-}