http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/pages/Resources.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/Resources.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/Resources.java deleted file mode 100644 index 542cc82..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/pages/Resources.java +++ /dev/null @@ -1,723 +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.pages; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import org.apache.syncope.client.console.commons.Constants; -import org.apache.syncope.client.console.commons.PreferenceManager; -import org.apache.syncope.client.console.commons.SortableDataProviderComparator; -import org.apache.syncope.client.console.panels.AbstractSearchResultPanel; -import org.apache.syncope.client.console.panels.AjaxDataTablePanel; -import org.apache.syncope.client.console.rest.ConnectorRestClient; -import org.apache.syncope.client.console.wicket.ajax.markup.html.ClearIndicatingAjaxLink; -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.LinkPanel; -import org.apache.syncope.common.lib.SyncopeClientException; -import org.apache.syncope.common.lib.to.ConnInstanceTO; -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.AttributeModifier; -import org.apache.wicket.Component; -import org.apache.wicket.Page; -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.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.grid.ICellPopulator; -import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder; -import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn; -import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn; -import org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider; -import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn; -import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.html.form.DropDownChoice; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.markup.repeater.Item; -import org.apache.wicket.model.AbstractReadOnlyModel; -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.mapper.parameter.PageParameters; -import org.apache.wicket.spring.injection.annot.SpringBean; - -/** - * Resources WebPage. - */ -public class Resources extends BasePage { - - private static final long serialVersionUID = -3789252860990261728L; - - private static final int WIN_HEIGHT = 600; - - private static final int WIN_WIDTH = 1100; - - @SpringBean - private ConnectorRestClient connectorRestClient; - - @SpringBean - private PreferenceManager prefMan; - - private final ModalWindow createResourceWin; - - private final ModalWindow editResourceWin; - - private final ModalWindow createConnectorWin; - - private final ModalWindow editConnectorWin; - - private final int resourcePaginatorRows; - - private final int connectorPaginatorRows; - - private WebMarkupContainer resourceContainer; - - private WebMarkupContainer connectorContainer; - - /** - * Modal window to be used for user status management. - */ - protected final ModalWindow statusmodal = new ModalWindow("statusModal"); - - /** - * Schemas to be shown modal window height. - */ - private final static int STATUS_MODAL_WIN_HEIGHT = 500; - - /** - * Schemas to be shown modal window width. - */ - private final static int STATUS_MODAL_WIN_WIDTH = 700; - - public Resources(final PageParameters parameters) { - super(parameters); - - add(createResourceWin = new ModalWindow("createResourceWin")); - add(editResourceWin = new ModalWindow("editResourceWin")); - add(createConnectorWin = new ModalWindow("createConnectorWin")); - add(editConnectorWin = new ModalWindow("editConnectorWin")); - - statusmodal.setCssClassName(ModalWindow.CSS_CLASS_GRAY); - statusmodal.setInitialHeight(STATUS_MODAL_WIN_HEIGHT); - statusmodal.setInitialWidth(STATUS_MODAL_WIN_WIDTH); - statusmodal.setCookieName("status-modal"); - add(statusmodal); - - AjaxLink<Void> reloadLink = new ClearIndicatingAjaxLink<Void>("reloadLink", getPageReference()) { - - private static final long serialVersionUID = 3109256773218160485L; - - @Override - protected void onClickInternal(final AjaxRequestTarget target) { - try { - connectorRestClient.reload(); - info(getString(Constants.OPERATION_SUCCEEDED)); - } catch (Exception e) { - error(getString(Constants.ERROR) + ": " + e.getMessage()); - } - feedbackPanel.refresh(target); - target.add(connectorContainer); - } - - @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("confirmReloadConnectors") + "')) " - + "{return false;} else {return true;}"; - } - }; - attributes.getAjaxCallListeners().add(ajaxCallListener); - } - }; - MetaDataRoleAuthorizationStrategy.authorize(reloadLink, ENABLE, xmlRolesReader.getEntitlement( - "Connectors", "reload")); - add(reloadLink); - - resourcePaginatorRows = prefMan.getPaginatorRows(getRequest(), Constants.PREF_RESOURCES_PAGINATOR_ROWS); - connectorPaginatorRows = prefMan.getPaginatorRows(getRequest(), Constants.PREF_CONNECTORS_PAGINATOR_ROWS); - - setupResources(); - setupConnectors(); - } - - private void setupResources() { - List<IColumn<ResourceTO, String>> columns = new ArrayList<>(); - - columns.add(new PropertyColumn<ResourceTO, String>(new StringResourceModel("key", this, null), "key", "key")); - - columns.add(new AbstractColumn<ResourceTO, String>( - new StringResourceModel("connector", this, null, "connector")) { - - private static final long serialVersionUID = 8263694778917279290L; - - @Override - public void populateItem(final Item<ICellPopulator<ResourceTO>> cellItem, final String componentId, - final IModel<ResourceTO> rowModel) { - - final AjaxLink<String> editLink = - new ClearIndicatingAjaxLink<String>("link", getPageReference()) { - - private static final long serialVersionUID = -7978723352517770644L; - - @Override - protected void onClickInternal(final AjaxRequestTarget target) { - - editConnectorWin.setPageCreator(new ModalWindow.PageCreator() { - - private static final long serialVersionUID = -7834632442532690940L; - - @Override - public Page createPage() { - return new ConnectorModalPage(Resources.this.getPageReference(), - editConnectorWin, - connectorRestClient.read(rowModel.getObject().getConnectorId())); - } - }); - - editConnectorWin.show(target); - } - }; - editLink.add(new Label("linkTitle", rowModel.getObject().getConnectorDisplayName())); - - LinkPanel editConnPanel = new LinkPanel(componentId); - editConnPanel.add(editLink); - - cellItem.add(editConnPanel); - - MetaDataRoleAuthorizationStrategy.authorize(editConnPanel, ENABLE, xmlRolesReader. - getEntitlement( - "Connectors", "read")); - } - }); - - columns.add(new AbstractColumn<ResourceTO, String>( - new StringResourceModel("propagationPrimary", this, null)) { - - private static final long serialVersionUID = -3503023501954863131L; - - @Override - public void populateItem(final Item<ICellPopulator<ResourceTO>> item, - final String componentId, final IModel<ResourceTO> model) { - - item.add(new Label(componentId, "")); - item.add(new AttributeModifier("class", new Model<>( - Boolean.toString(model.getObject().isPropagationPrimary())))); - } - - @Override - public String getCssClass() { - return "narrowcolumn"; - } - }); - - columns.add(new PropertyColumn<ResourceTO, String>(new StringResourceModel( - "propagationPriority", this, null), "propagationPriority", "propagationPriority") { - - @Override - public String getCssClass() { - return "narrowcolumn"; - } - }); - - columns.add(new AbstractColumn<ResourceTO, String>(new StringResourceModel("actions", this, null, "")) { - - private static final long serialVersionUID = 2054811145491901166L; - - @Override - public String getCssClass() { - return "action"; - } - - @Override - public void populateItem(final Item<ICellPopulator<ResourceTO>> cellItem, final String componentId, - final IModel<ResourceTO> model) { - - final ResourceTO resourceTO = model.getObject(); - - final ActionLinksPanel panel = new ActionLinksPanel(componentId, model, getPageReference()); - panel.add(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - statusmodal.setPageCreator(new ModalWindow.PageCreator() { - - private static final long serialVersionUID = -7834632442532690940L; - - @Override - public Page createPage() { - return new ProvisioningModalPage<>( - getPageReference(), statusmodal, model.getObject(), UserTO.class); - } - }); - - statusmodal.show(target); - } - }, ActionLink.ActionType.MANAGE_USERS, "Resources"); - - panel.add(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - - statusmodal.setPageCreator(new ModalWindow.PageCreator() { - - private static final long serialVersionUID = -7834632442532690940L; - - @Override - public Page createPage() { - return new ProvisioningModalPage<>( - getPageReference(), statusmodal, model.getObject(), GroupTO.class); - } - }); - - statusmodal.show(target); - } - }, ActionLink.ActionType.MANAGE_GROUPS, "Resources"); - - panel.add(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - resourceTO.setUsyncToken(null); - resourceTO.setRsyncToken(null); - try { - resourceRestClient.update(resourceTO); - info(getString(Constants.OPERATION_SUCCEEDED)); - } catch (SyncopeClientException e) { - error(getString(Constants.ERROR) + ":" + e.getMessage()); - - LOG.error("While resetting sync token from " + resourceTO.getKey(), e); - } - - feedbackPanel.refresh(target); - target.add(resourceContainer); - } - }, ActionLink.ActionType.RESET, "Resources"); - - panel.add(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - editResourceWin.setPageCreator(new ModalWindow.PageCreator() { - - private static final long serialVersionUID = -7834632442532690940L; - - @Override - public Page createPage() { - return new ResourceModalPage(Resources.this.getPageReference(), - editResourceWin, resourceTO, false); - } - }); - - editResourceWin.show(target); - } - }, ActionLink.ActionType.EDIT, "Resources"); - - panel.add(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - try { - resourceRestClient.delete(resourceTO.getKey()); - info(getString(Constants.OPERATION_SUCCEEDED)); - } catch (SyncopeClientException e) { - error(getString(Constants.ERROR) + ": " + e.getMessage()); - - LOG.error("While deleting resource " + resourceTO.getKey(), e); - } - - feedbackPanel.refresh(target); - target.add(resourceContainer); - } - }, ActionLink.ActionType.DELETE, "Resources"); - - cellItem.add(panel); - } - }); - - final AjaxDataTablePanel<ResourceTO, String> table = new AjaxDataTablePanel<>( - "resourceDatatable", - columns, - (ISortableDataProvider<ResourceTO, String>) new ResourcesProvider(), - resourcePaginatorRows, - Arrays.asList(new ActionLink.ActionType[] { ActionLink.ActionType.DELETE }), - resourceRestClient, - "key", - "Resources", - getPageReference()); - - resourceContainer = new WebMarkupContainer("resourceContainer"); - resourceContainer.add(table); - resourceContainer.setOutputMarkupId(true); - - add(resourceContainer); - - setWindowClosedCallback(createResourceWin, resourceContainer); - setWindowClosedCallback(editResourceWin, resourceContainer); - - createResourceWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); - createResourceWin.setInitialHeight(WIN_HEIGHT); - createResourceWin.setInitialWidth(WIN_WIDTH); - createResourceWin.setCookieName("create-res-modal"); - - editResourceWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); - editResourceWin.setInitialHeight(WIN_HEIGHT); - editResourceWin.setInitialWidth(WIN_WIDTH); - editResourceWin.setCookieName("edit-res-modal"); - - AjaxLink<Void> createResourceLink = - new ClearIndicatingAjaxLink<Void>("createResourceLink", getPageReference()) { - - private static final long serialVersionUID = -7978723352517770644L; - - @Override - protected void onClickInternal(final AjaxRequestTarget target) { - createResourceWin.setPageCreator(new ModalWindow.PageCreator() { - - private static final long serialVersionUID = -7834632442532690940L; - - @Override - public Page createPage() { - final ResourceModalPage windows = new ResourceModalPage(Resources.this. - getPageReference(), - editResourceWin, new ResourceTO(), true); - return windows; - } - }); - - createResourceWin.show(target); - } - }; - - MetaDataRoleAuthorizationStrategy.authorize(createResourceLink, ENABLE, xmlRolesReader.getEntitlement( - "Resources", "create")); - - add(createResourceLink); - - @SuppressWarnings("rawtypes") - final Form paginatorForm = new Form("resourcePaginatorForm"); - - @SuppressWarnings({ "unchecked", "rawtypes" }) - final DropDownChoice rowsChooser = new DropDownChoice("rowsChooser", new PropertyModel(this, - "resourcePaginatorRows"), prefMan.getPaginatorChoices()); - - rowsChooser.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { - - private static final long serialVersionUID = -1107858522700306810L; - - @Override - protected void onUpdate(final AjaxRequestTarget target) { - prefMan.set(getRequest(), getResponse(), Constants.PREF_RESOURCES_PAGINATOR_ROWS, - String.valueOf(resourcePaginatorRows)); - - table.setItemsPerPage(resourcePaginatorRows); - target.add(resourceContainer); - } - }); - - paginatorForm.add(rowsChooser); - add(paginatorForm); - } - - private void setupConnectors() { - List<IColumn<ConnInstanceTO, String>> columns = new ArrayList<>(); - - columns.add(new PropertyColumn<ConnInstanceTO, String>( - new StringResourceModel("key", this, null), "key", "key")); - columns.add(new PropertyColumn<ConnInstanceTO, String>( - new StringResourceModel("name", this, null), "connectorName", "connectorName")); - columns.add(new PropertyColumn<ConnInstanceTO, String>( - new StringResourceModel("displayName", this, null), "displayName", "displayName")); - columns.add(new PropertyColumn<ConnInstanceTO, String>( - new StringResourceModel("bundleName", this, null), "bundleName", "bundleName")); - columns.add(new PropertyColumn<ConnInstanceTO, String>( - new StringResourceModel("version", this, null), "version", "version")); - columns.add(new AbstractColumn<ConnInstanceTO, String>(new StringResourceModel("actions", this, null, "")) { - - private static final long serialVersionUID = 2054811145491901166L; - - @Override - public String getCssClass() { - return "action"; - } - - @Override - public void populateItem(final Item<ICellPopulator<ConnInstanceTO>> cellItem, final String componentId, - final IModel<ConnInstanceTO> model) { - - final ConnInstanceTO connectorTO = model.getObject(); - - final ActionLinksPanel panel = new ActionLinksPanel(componentId, model, getPageReference()); - - panel.add(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - editConnectorWin.setPageCreator(new ModalWindow.PageCreator() { - - private static final long serialVersionUID = -7834632442532690940L; - - @Override - public Page createPage() { - return new ConnectorModalPage(Resources.this.getPageReference(), editConnectorWin, - connectorTO); - } - }); - - editConnectorWin.show(target); - } - }, ActionLink.ActionType.EDIT, "Connectors"); - - panel.add(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - try { - connectorRestClient.delete(connectorTO.getKey()); - info(getString(Constants.OPERATION_SUCCEEDED)); - } catch (SyncopeClientException e) { - error(getString(Constants.ERROR) + ": " + e.getMessage()); - - LOG.error("While deleting connector " + connectorTO.getKey(), e); - } - - target.add(connectorContainer); - feedbackPanel.refresh(target); - } - }, ActionLink.ActionType.DELETE, "Connectors"); - - cellItem.add(panel); - } - }); - - final AjaxDataTablePanel<ConnInstanceTO, String> table = new AjaxDataTablePanel<ConnInstanceTO, String>( - "connectorDatatable", - columns, - (ISortableDataProvider<ConnInstanceTO, String>) new ConnectorsProvider(), - connectorPaginatorRows, - Arrays.asList(new ActionLink.ActionType[] { ActionLink.ActionType.DELETE }), - connectorRestClient, - "key", - "Connectors", - getPageReference()); - - connectorContainer = new WebMarkupContainer("connectorContainer"); - connectorContainer.add(table); - connectorContainer.setOutputMarkupId(true); - - MetaDataRoleAuthorizationStrategy.authorize(connectorContainer, RENDER, xmlRolesReader.getEntitlement( - "Connectors", "list")); - - add(connectorContainer); - - setWindowClosedCallback(createConnectorWin, connectorContainer); - setWindowClosedCallback(editConnectorWin, connectorContainer); - - createConnectorWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); - createConnectorWin.setInitialHeight(WIN_HEIGHT); - createConnectorWin.setInitialWidth(WIN_WIDTH); - createConnectorWin.setCookieName("create-conn-modal"); - - editConnectorWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); - editConnectorWin.setInitialHeight(WIN_HEIGHT); - editConnectorWin.setInitialWidth(WIN_WIDTH); - editConnectorWin.setCookieName("edit-conn-modal"); - - AjaxLink<Void> createConnectorLink = - new ClearIndicatingAjaxLink<Void>("createConnectorLink", getPageReference()) { - - private static final long serialVersionUID = -7978723352517770644L; - - @Override - protected void onClickInternal(final AjaxRequestTarget target) { - createConnectorWin.setPageCreator(new ModalWindow.PageCreator() { - - private static final long serialVersionUID = -7834632442532690940L; - - @Override - public Page createPage() { - ConnectorModalPage form = new ConnectorModalPage(Resources.this.getPageReference(), - editConnectorWin, new ConnInstanceTO()); - return form; - } - }); - - createConnectorWin.show(target); - } - }; - - MetaDataRoleAuthorizationStrategy.authorize(createConnectorLink, ENABLE, xmlRolesReader.getEntitlement( - "Connectors", "create")); - - add(createConnectorLink); - - @SuppressWarnings("rawtypes") - Form paginatorForm = new Form("connectorPaginatorForm"); - - MetaDataRoleAuthorizationStrategy.authorize(paginatorForm, RENDER, xmlRolesReader.getEntitlement( - "Connectors", "list")); - - final DropDownChoice<Integer> rowsChooser = new DropDownChoice<Integer>( - "rowsChooser", - new PropertyModel<Integer>(this, - "connectorPaginatorRows"), - prefMan.getPaginatorChoices()); - - rowsChooser.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { - - private static final long serialVersionUID = -1107858522700306810L; - - @Override - protected void onUpdate(AjaxRequestTarget target) { - prefMan.set(getRequest(), getResponse(), Constants.PREF_CONNECTORS_PAGINATOR_ROWS, - String.valueOf(connectorPaginatorRows)); - table.setItemsPerPage(connectorPaginatorRows); - - target.add(connectorContainer); - } - }); - - paginatorForm.add(rowsChooser); - add(paginatorForm); - } - - class ResourcesProvider extends SortableDataProvider<ResourceTO, String> { - - private static final long serialVersionUID = -9055916672926643975L; - - private final SortableDataProviderComparator<ResourceTO> comparator; - - public ResourcesProvider() { - super(); - //Default sorting - setSort("key", SortOrder.ASCENDING); - comparator = new SortableDataProviderComparator<>(this); - } - - @Override - public Iterator<ResourceTO> iterator(final long first, final long count) { - List<ResourceTO> list = resourceRestClient.getAll(); - - Collections.sort(list, comparator); - - return list.subList((int) first, (int) first + (int) count).iterator(); - } - - @Override - public long size() { - return resourceRestClient.getAll().size(); - } - - @Override - public IModel<ResourceTO> model(final ResourceTO resource) { - return new AbstractReadOnlyModel<ResourceTO>() { - - private static final long serialVersionUID = 8952474152465381634L; - - @Override - public ResourceTO getObject() { - return resource; - } - }; - } - } - - private class ConnectorsProvider extends SortableDataProvider<ConnInstanceTO, String> { - - private static final long serialVersionUID = 4445909568349448518L; - - private final SortableDataProviderComparator<ConnInstanceTO> comparator; - - public ConnectorsProvider() { - super(); - //Default sorting - setSort("key", SortOrder.ASCENDING); - comparator = new SortableDataProviderComparator<>(this); - } - - @Override - public Iterator<ConnInstanceTO> iterator(long first, long count) { - List<ConnInstanceTO> list = connectorRestClient.getAllConnectors(); - - Collections.sort(list, comparator); - - return list.subList((int) first, (int) first + (int) count).iterator(); - } - - @Override - public long size() { - return connectorRestClient.getAllConnectors().size(); - } - - @Override - public IModel<ConnInstanceTO> model(final ConnInstanceTO connector) { - - return new AbstractReadOnlyModel<ConnInstanceTO>() { - - private static final long serialVersionUID = -6033068018293569398L; - - @Override - public ConnInstanceTO getObject() { - return connector; - } - }; - } - } - - @Override - public void onEvent(final IEvent<?> event) { - if (event.getPayload() instanceof AbstractSearchResultPanel.EventDataWrapper) { - ((AbstractSearchResultPanel.EventDataWrapper) event.getPayload()).getTarget().add(resourceContainer); - ((AbstractSearchResultPanel.EventDataWrapper) event.getPayload()).getTarget().add(connectorContainer); - } - } -}
http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/pages/ResultStatusModalPage.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/ResultStatusModalPage.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/ResultStatusModalPage.java deleted file mode 100644 index e5017e3..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/pages/ResultStatusModalPage.java +++ /dev/null @@ -1,424 +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.pages; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.apache.commons.lang3.StringUtils; -import org.apache.syncope.client.console.commons.ConnIdSpecialAttributeName; -import org.apache.syncope.client.console.commons.Constants; -import org.apache.syncope.client.console.commons.Mode; -import org.apache.syncope.client.console.commons.status.Status; -import org.apache.syncope.client.console.commons.status.StatusUtils; -import org.apache.syncope.common.lib.to.AbstractSubjectTO; -import org.apache.syncope.common.lib.to.AttrTO; -import org.apache.syncope.common.lib.to.ConnObjectTO; -import org.apache.syncope.common.lib.to.PropagationStatus; -import org.apache.syncope.common.lib.to.GroupTO; -import org.apache.syncope.common.lib.to.UserTO; -import org.apache.syncope.common.lib.types.PropagationTaskExecStatus; -import org.apache.wicket.Component; -import org.apache.wicket.Page; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.markup.html.AjaxLink; -import org.apache.wicket.behavior.Behavior; -import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; -import org.apache.wicket.markup.ComponentTag; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.html.image.Image; -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.model.ResourceModel; -import org.apache.wicket.request.resource.ContextRelativeResource; - -/** - * Show user or group status after performing a successful operation. - */ -public class ResultStatusModalPage extends BaseModalPage { - - private static final long serialVersionUID = 2646115294319713723L; - - private static final String IMG_PREFIX = "/img/statuses/"; - - private final AbstractSubjectTO subject; - - private final Mode mode; - - /** - * Status management utilities. - */ - private final StatusUtils statusUtils; - - public static class Builder implements Serializable { - - private static final long serialVersionUID = 220361441802274899L; - - private ModalWindow window; - - private Mode mode; - - private AbstractSubjectTO subject; - - public Builder(final ModalWindow window, final AbstractSubjectTO attributable) { - this.window = window; - this.subject = attributable; - } - - public ResultStatusModalPage.Builder mode(final Mode mode) { - this.mode = mode; - return this; - } - - public ResultStatusModalPage build() { - return new ResultStatusModalPage(this); - } - } - - private ResultStatusModalPage(final Builder builder) { - super(); - this.subject = builder.subject; - statusUtils = new StatusUtils(this.userRestClient); - if (builder.mode == null) { - this.mode = Mode.ADMIN; - } else { - this.mode = builder.mode; - } - - final BaseModalPage page = this; - - final WebMarkupContainer container = new WebMarkupContainer("container"); - container.setOutputMarkupId(true); - add(container); - - final Fragment fragment = new Fragment("resultFrag", mode == Mode.SELF - ? "userSelfResultFrag" - : "propagationResultFrag", this); - fragment.setOutputMarkupId(true); - container.add(fragment); - - if (mode == Mode.ADMIN) { - // add Syncope propagation status - PropagationStatus syncope = new PropagationStatus(); - syncope.setResource("Syncope"); - syncope.setStatus(PropagationTaskExecStatus.SUCCESS); - - List<PropagationStatus> propagations = new ArrayList<PropagationStatus>(); - propagations.add(syncope); - propagations.addAll(subject.getPropagationStatusTOs()); - - fragment.add(new Label("info", - ((subject instanceof UserTO) && ((UserTO) subject).getUsername() != null) - ? ((UserTO) subject).getUsername() - : ((subject instanceof GroupTO) && ((GroupTO) subject).getName() != null) - ? ((GroupTO) subject).getName() - : String.valueOf(subject.getKey()))); - - final ListView<PropagationStatus> propRes = new ListView<PropagationStatus>("resources", - propagations) { - - private static final long serialVersionUID = -1020475259727720708L; - - @Override - protected void populateItem(final ListItem<PropagationStatus> item) { - final PropagationStatus propTO = (PropagationStatus) item.getDefaultModelObject(); - - final ListView attributes = getConnObjectView(propTO); - - final Fragment attrhead; - if (attributes.getModelObject() == null || attributes.getModelObject().isEmpty()) { - attrhead = new Fragment("attrhead", "emptyAttrHeadFrag", page); - } else { - attrhead = new Fragment("attrhead", "attrHeadFrag", page); - } - - item.add(attrhead); - item.add(attributes); - - attrhead.add(new Label("resource", propTO.getResource())); - - attrhead.add(new Label("propagation", propTO.getStatus() == null - ? "UNDEFINED" : propTO.getStatus().toString())); - - final Image image; - final String alt, title; - final ModalWindow failureWindow = new ModalWindow("failureWindow"); - final AjaxLink<?> failureWindowLink = new AjaxLink<Void>("showFailureWindow") { - - private static final long serialVersionUID = -7978723352517770644L; - - @Override - public void onClick(AjaxRequestTarget target) { - failureWindow.show(target); - } - }; - - switch (propTO.getStatus()) { - - case SUCCESS: - case SUBMITTED: - case CREATED: - image = new Image("icon", - new ContextRelativeResource(IMG_PREFIX + Status.ACTIVE.toString() - + Constants.PNG_EXT)); - alt = "success icon"; - title = "success"; - failureWindow.setVisible(false); - failureWindowLink.setEnabled(false); - break; - - default: - image = new Image("icon", - new ContextRelativeResource(IMG_PREFIX + Status.SUSPENDED.toString() - + Constants.PNG_EXT)); - alt = "failure icon"; - title = "failure"; - } - - image.add(new Behavior() { - - private static final long serialVersionUID = 1469628524240283489L; - - @Override - public void onComponentTag(final Component component, final ComponentTag tag) { - tag.put("alt", alt); - tag.put("title", title); - } - }); - final FailureMessageModalPage executionFailureMessagePage; - if (propTO.getFailureReason() == null) { - executionFailureMessagePage = - new FailureMessageModalPage(failureWindow.getContentId(), StringUtils.EMPTY); - } else { - executionFailureMessagePage = - new FailureMessageModalPage(failureWindow.getContentId(), propTO.getFailureReason()); - } - - failureWindow.setPageCreator(new ModalWindow.PageCreator() { - - private static final long serialVersionUID = -7834632442532690940L; - - @Override - public Page createPage() { - return executionFailureMessagePage; - } - }); - failureWindow.setCookieName("failureWindow"); - failureWindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY); - failureWindowLink.add(image); - attrhead.add(failureWindowLink); - attrhead.add(failureWindow); - } - }; - fragment.add(propRes); - } - - final AjaxLink<Void> close = new IndicatingAjaxLink<Void>("close") { - - private static final long serialVersionUID = -7978723352517770644L; - - @Override - public void onClick(final AjaxRequestTarget target) { - builder.window.close(target); - } - }; - container.add(close); - - setOutputMarkupId(true); - } - - /** - * Get remote attributes list view. - * - * @param propTO propagation TO. - * @return list view. - */ - private ListView<String> getConnObjectView(final PropagationStatus propTO) { - final ConnObjectTO before = propTO.getBeforeObj(); - final ConnObjectTO after = propTO.getAfterObj(); - - // sorted in reversed presentation order - final List<String> head = new ArrayList<String>(); - if (subject instanceof UserTO) { - head.add(ConnIdSpecialAttributeName.PASSWORD); - head.add(ConnIdSpecialAttributeName.ENABLE); - } - head.add(ConnIdSpecialAttributeName.UID); - head.add(ConnIdSpecialAttributeName.NAME); - - final Map<String, AttrTO> beforeAttrMap = before == null - ? Collections.<String, AttrTO>emptyMap() - : before.getPlainAttrMap(); - - final Map<String, AttrTO> afterAttrMap = after == null - ? Collections.<String, AttrTO>emptyMap() - : after.getPlainAttrMap(); - - final Set<String> attributes = new HashSet<String>(); - attributes.addAll(beforeAttrMap.keySet()); - attributes.addAll(afterAttrMap.keySet()); - - if (!(subject instanceof UserTO)) { - attributes.remove(ConnIdSpecialAttributeName.PASSWORD); - attributes.remove(ConnIdSpecialAttributeName.ENABLE); - } - - final List<String> profile = new ArrayList<String>(); - profile.addAll(attributes); - profile.removeAll(head); - Collections.sort(profile); - - for (String attr : head) { - if (attributes.contains(attr)) { - profile.add(0, attr); - } - } - - return new ListView<String>("attrs", profile) { - - private static final long serialVersionUID = 4949588177564901031L; - - @Override - protected void populateItem(final ListItem<String> item) { - String name = item.getModelObject(); - - final Fragment beforeValue; - final Fragment afterValue; - if (ConnIdSpecialAttributeName.ENABLE.equals(name)) { - beforeValue = getStatusIcon("beforeValue", propTO.getResource(), before); - afterValue = getStatusIcon("afterValue", propTO.getResource(), after); - } else { - beforeValue = getLabelValue("beforeValue", name, beforeAttrMap); - afterValue = getLabelValue("afterValue", name, afterAttrMap); - } - - item.add(new Label("attrName", new ResourceModel(name, name))); - - item.add(beforeValue); - item.add(afterValue); - } - }; - } - - /** - * Get fragment for attribute value (not remote status). - * - * @param id component id to be replaced with the fragment content. - * @param attrName remote attribute name - * @param attrMap remote attributes map. - * @return fragment. - */ - private Fragment getLabelValue(final String id, final String attrName, final Map<String, AttrTO> attrMap) { - final String value; - - final AttrTO attr = attrMap.get(attrName); - - if (attr == null || attr.getValues() == null || attr.getValues().isEmpty()) { - value = ""; - } else { - if (ConnIdSpecialAttributeName.PASSWORD.equals(attrName)) { - value = "********"; - } else { - value = attr.getValues().size() > 1 - ? attr.getValues().toString() - : attr.getValues().get(0); - } - } - - Component label = new Label("value", value.length() > 50 ? value.substring(0, 50) + "..." : value). - add(new Behavior() { - - private static final long serialVersionUID = 1469628524240283489L; - - @Override - public void onComponentTag(final Component component, final ComponentTag tag) { - tag.put("title", value); - } - }); - - final Fragment frag = new Fragment(id, "attrValueFrag", this); - frag.add(label); - - return frag; - } - - /** - * Get fragment for user status icon. - * - * @param id component id to be replaced with the fragment content - * @param resourceName resource name - * @param objectTO connector object TO - * @return fragment. - */ - private Fragment getStatusIcon(final String id, final String resourceName, final ConnObjectTO objectTO) { - final Image image; - final String alt, title; - switch (statusUtils.getStatusBean(subject, resourceName, objectTO, this.subject instanceof GroupTO).getStatus()) { - - case ACTIVE: - image = new Image("status", - new ContextRelativeResource(IMG_PREFIX + Status.ACTIVE.toString() + Constants.PNG_EXT)); - alt = "active icon"; - title = "Enabled"; - break; - - case SUSPENDED: - image = new Image("status", - new ContextRelativeResource(IMG_PREFIX + Status.SUSPENDED.toString() + Constants.PNG_EXT)); - alt = "inactive icon"; - title = "Disabled"; - break; - - default: - image = null; - alt = null; - title = null; - } - - final Fragment frag; - if (image == null) { - frag = new Fragment(id, "emptyFrag", this); - } else { - image.add(new Behavior() { - - private static final long serialVersionUID = 1469628524240283489L; - - @Override - public void onComponentTag(final Component component, final ComponentTag tag) { - tag.put("alt", alt); - tag.put("title", title); - tag.put("width", "12px"); - tag.put("height", "12px"); - } - }); - - frag = new Fragment(id, "remoteStatusFrag", this); - frag.add(image); - } - - return frag; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/pages/SchedTaskModalPage.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/SchedTaskModalPage.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/SchedTaskModalPage.java deleted file mode 100644 index 6222717..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/pages/SchedTaskModalPage.java +++ /dev/null @@ -1,68 +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.pages; - -import java.util.List; -import org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel; -import org.apache.syncope.common.lib.to.SchedTaskTO; -import org.apache.wicket.PageReference; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.LoadableDetachableModel; -import org.apache.wicket.model.PropertyModel; - -/** - * Modal window with Task form (to stop and start execution). - */ -public class SchedTaskModalPage extends AbstractSchedTaskModalPage { - - private static final long serialVersionUID = -2501860242590060867L; - - public SchedTaskModalPage(final ModalWindow window, final SchedTaskTO taskTO, final PageReference callerPageRef) { - - super(window, taskTO, callerPageRef); - - final IModel<List<String>> classNames = new LoadableDetachableModel<List<String>>() { - - private static final long serialVersionUID = 5275935387613157437L; - - @Override - protected List<String> load() { - return taskRestClient.getJobClasses(); - } - }; - - final AjaxDropDownChoicePanel<String> className = new AjaxDropDownChoicePanel<String>("jobClassName", - getString("class"), new PropertyModel<String>(taskTO, "jobClassName")); - className.setChoices(classNames.getObject()); - className.addRequiredLabel(); - className.setEnabled(taskTO.getKey() == 0); - className.setStyleSheet("ui-widget-content ui-corner-all long_dynamicsize"); - profile.add(className); - } - - @Override - public void submitAction(final SchedTaskTO taskTO) { - if (taskTO.getKey() > 0) { - taskRestClient.updateSchedTask(taskTO); - } else { - taskRestClient.createSchedTask(taskTO); - } - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/pages/Schema.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/Schema.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/Schema.java deleted file mode 100644 index cffb7cd..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/pages/Schema.java +++ /dev/null @@ -1,468 +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.pages; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.Pair; -import org.apache.syncope.client.console.commons.Constants; -import org.apache.syncope.client.console.commons.PreferenceManager; -import org.apache.syncope.client.console.commons.SchemaModalPageFactory; -import org.apache.syncope.client.console.commons.SelectChoiceRenderer; -import org.apache.syncope.client.console.commons.SortableDataProviderComparator; -import org.apache.syncope.client.console.panels.JQueryUITabbedPanel; -import org.apache.syncope.client.console.rest.SchemaRestClient; -import org.apache.syncope.client.console.wicket.ajax.markup.html.ClearIndicatingAjaxLink; -import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink; -import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink.ActionType; -import org.apache.syncope.client.console.wicket.markup.html.form.ActionLinksPanel; -import org.apache.syncope.common.lib.to.AbstractSchemaTO; -import org.apache.syncope.common.lib.types.AttributableType; -import org.apache.syncope.common.lib.types.SchemaType; -import org.apache.wicket.AttributeModifier; -import org.apache.wicket.Page; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; -import org.apache.wicket.ajax.markup.html.AjaxLink; -import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; -import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable; -import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator; -import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder; -import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn; -import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn; -import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn; -import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider; -import org.apache.wicket.extensions.markup.html.tabs.AbstractTab; -import org.apache.wicket.extensions.markup.html.tabs.ITab; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.html.form.DropDownChoice; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.markup.html.panel.Panel; -import org.apache.wicket.markup.repeater.Item; -import org.apache.wicket.model.CompoundPropertyModel; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.Model; -import org.apache.wicket.model.PropertyModel; -import org.apache.wicket.model.ResourceModel; -import org.apache.wicket.spring.injection.annot.SpringBean; -import org.springframework.beans.BeanWrapper; -import org.springframework.beans.BeanWrapperImpl; -import org.springframework.util.ReflectionUtils; - -/** - * Schema WebPage. - */ -@SuppressWarnings({ "unchecked", "rawtypes" }) -public class Schema extends BasePage { - - private static final long serialVersionUID = 8091922398776299403L; - - private static final Map<SchemaType, List<String>> COL_NAMES = new HashMap<SchemaType, List<String>>() { - - private static final long serialVersionUID = 3109256773218160485L; - - { - put(SchemaType.PLAIN, Arrays.asList(new String[] { "key", "type", - "mandatoryCondition", "uniqueConstraint", "multivalue", "readonly" })); - put(SchemaType.DERIVED, Arrays.asList(new String[] { "key", "expression" })); - put(SchemaType.VIRTUAL, Arrays.asList(new String[] { "key", "readonly" })); - } - }; - - private static final Map<Pair<AttributableType, SchemaType>, String> PAGINATOR_ROWS_KEYS = - new HashMap<Pair<AttributableType, SchemaType>, String>() { - - private static final long serialVersionUID = 3109256773218160485L; - - { - put(new ImmutablePair<>(AttributableType.CONFIGURATION, SchemaType.PLAIN), - Constants.PREF_CONF_SCHEMA_PAGINATOR_ROWS); - put(new ImmutablePair<>(AttributableType.USER, SchemaType.PLAIN), - Constants.PREF_USER_PLAIN_SCHEMA_PAGINATOR_ROWS); - put(new ImmutablePair<>(AttributableType.USER, SchemaType.DERIVED), - Constants.PREF_USER_DER_SCHEMA_PAGINATOR_ROWS); - put(new ImmutablePair<>(AttributableType.USER, SchemaType.VIRTUAL), - Constants.PREF_USER_VIR_SCHEMA_PAGINATOR_ROWS); - put(new ImmutablePair<>(AttributableType.MEMBERSHIP, SchemaType.PLAIN), - Constants.PREF_MEMBERSHIP_PLAIN_SCHEMA_PAGINATOR_ROWS); - put(new ImmutablePair<>(AttributableType.MEMBERSHIP, SchemaType.DERIVED), - Constants.PREF_MEMBERSHIP_DER_SCHEMA_PAGINATOR_ROWS); - put(new ImmutablePair<>(AttributableType.MEMBERSHIP, SchemaType.VIRTUAL), - Constants.PREF_MEMBERSHIP_VIR_SCHEMA_PAGINATOR_ROWS); - put(new ImmutablePair<>(AttributableType.GROUP, SchemaType.PLAIN), - Constants.PREF_GROUP_PLAIN_SCHEMA_PAGINATOR_ROWS); - put(new ImmutablePair<>(AttributableType.GROUP, SchemaType.DERIVED), - Constants.PREF_GROUP_DER_SCHEMA_PAGINATOR_ROWS); - put(new ImmutablePair<>(AttributableType.GROUP, SchemaType.VIRTUAL), - Constants.PREF_GROUP_VIR_SCHEMA_PAGINATOR_ROWS); - } - }; - - private static final int WIN_WIDTH = 600; - - private static final int WIN_HEIGHT = 200; - - private static final int PLAIN_WIN_HEIGHT = 500; - - @SpringBean - private SchemaRestClient restClient; - - @SpringBean - private PreferenceManager prefMan; - - private final String allowedCreateRoles = xmlRolesReader.getEntitlement("Schema", "create"); - - private final String allowedReadRoles = xmlRolesReader.getEntitlement("Schema", "read"); - - private final String allowedDeleteRoles = xmlRolesReader.getEntitlement("Schema", "delete"); - - public Schema() { - super(); - - for (final AttributableType attrType : AttributableType.values()) { - final String attrTypeAsString = attrType.name().toLowerCase(); - - List<ITab> tabs = new ArrayList<>(); - - for (final SchemaType schemaType : SchemaType.values()) { - if (attrType != AttributableType.CONFIGURATION || schemaType == SchemaType.PLAIN) { - final String schemaTypeAsString = schemaType.name().toLowerCase(); - - tabs.add(new AbstractTab(new Model<>(getString(schemaTypeAsString))) { - - private static final long serialVersionUID = -5861786415855103549L; - - @Override - public WebMarkupContainer getPanel(final String panelId) { - return new SchemaTypePanel(panelId, attrType, schemaType); - } - }); - } - } - - add(new JQueryUITabbedPanel(attrTypeAsString + "Tabs", tabs)); - } - } - - private <T extends AbstractSchemaModalPage> List<IColumn> getColumns( - final WebMarkupContainer webContainer, final ModalWindow modalWindow, - final AttributableType attributableType, final SchemaType schemaType, - final Collection<String> fields) { - - List<IColumn> columns = new ArrayList<IColumn>(); - - for (final String field : fields) { - final Field clazzField = ReflectionUtils.findField(schemaType.getToClass(), field); - - if (clazzField != null) { - if (clazzField.getType().equals(Boolean.class) || clazzField.getType().equals(boolean.class)) { - columns.add(new AbstractColumn<AbstractSchemaTO, String>(new ResourceModel(field)) { - - private static final long serialVersionUID = 8263694778917279290L; - - @Override - public void populateItem(final Item<ICellPopulator<AbstractSchemaTO>> item, - final String componentId, final IModel<AbstractSchemaTO> model) { - - BeanWrapper bwi = new BeanWrapperImpl(model.getObject()); - Object obj = bwi.getPropertyValue(field); - - item.add(new Label(componentId, "")); - item.add(new AttributeModifier("class", new Model<String>(obj.toString()))); - } - - @Override - public String getCssClass() { - return "small_fixedsize"; - } - }); - } else { - IColumn column = new PropertyColumn(new ResourceModel(field), field, field) { - - private static final long serialVersionUID = 3282547854226892169L; - - @Override - public String getCssClass() { - String css = super.getCssClass(); - if ("key".equals(field)) { - css = StringUtils.isBlank(css) - ? "medium_fixedsize" - : css + " medium_fixedsize"; - } - return css; - } - }; - columns.add(column); - } - } - } - - columns.add(new AbstractColumn<AbstractSchemaTO, String>(new ResourceModel("actions", "")) { - - private static final long serialVersionUID = 2054811145491901166L; - - @Override - public String getCssClass() { - return "action"; - } - - @Override - public void populateItem(final Item<ICellPopulator<AbstractSchemaTO>> item, final String componentId, - final IModel<AbstractSchemaTO> model) { - - final AbstractSchemaTO schemaTO = model.getObject(); - - final ActionLinksPanel panel = new ActionLinksPanel(componentId, model, getPageReference()); - - panel.addWithRoles(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - modalWindow.setPageCreator(new ModalWindow.PageCreator() { - - private static final long serialVersionUID = -7834632442532690940L; - - @Override - public Page createPage() { - AbstractSchemaModalPage page = SchemaModalPageFactory.getSchemaModalPage( - attributableType, schemaType); - - page.setSchemaModalPage(Schema.this.getPageReference(), modalWindow, schemaTO, false); - - return page; - } - }); - - modalWindow.show(target); - } - }, ActionType.EDIT, allowedReadRoles); - - panel.addWithRoles(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - - switch (schemaType) { - case DERIVED: - restClient.deleteDerSchema(attributableType, schemaTO.getKey()); - break; - - case VIRTUAL: - restClient.deleteVirSchema(attributableType, schemaTO.getKey()); - break; - - default: - restClient.deletePlainSchema(attributableType, schemaTO.getKey()); - break; - } - - info(getString(Constants.OPERATION_SUCCEEDED)); - feedbackPanel.refresh(target); - - target.add(webContainer); - } - }, ActionType.DELETE, allowedDeleteRoles); - - item.add(panel); - } - }); - - return columns; - } - - private Form<Void> getPaginatorForm(final WebMarkupContainer webContainer, - final AjaxFallbackDefaultDataTable dataTable, - final String formname, final SchemaTypePanel schemaTypePanel, final String rowsPerPagePrefName) { - - Form<Void> form = new Form<>(formname); - - final DropDownChoice<Integer> rowChooser = new DropDownChoice<Integer>("rowsChooser", - new PropertyModel<Integer>(schemaTypePanel, "pageRows"), prefMan.getPaginatorChoices(), - new SelectChoiceRenderer<Integer>()); - - rowChooser.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { - - private static final long serialVersionUID = -1107858522700306810L; - - @Override - protected void onUpdate(final AjaxRequestTarget target) { - prefMan.set(getRequest(), getResponse(), rowsPerPagePrefName, rowChooser.getInput()); - dataTable.setItemsPerPage(rowChooser.getModelObject()); - - target.add(webContainer); - } - }); - - form.add(rowChooser); - - return form; - } - - private <T extends AbstractSchemaModalPage> AjaxLink<Void> getCreateSchemaLink(final ModalWindow modalWindow, - final AttributableType attrType, final SchemaType schemaType, final String winLinkName) { - - AjaxLink<Void> link = new ClearIndicatingAjaxLink<Void>(winLinkName, getPageReference()) { - - private static final long serialVersionUID = -7978723352517770644L; - - @Override - protected void onClickInternal(final AjaxRequestTarget target) { - modalWindow.setPageCreator(new ModalWindow.PageCreator() { - - private static final long serialVersionUID = -7834632442532690940L; - - @Override - public Page createPage() { - T page = SchemaModalPageFactory.getSchemaModalPage(attrType, schemaType); - page.setSchemaModalPage(Schema.this.getPageReference(), modalWindow, null, true); - - return page; - } - }); - - modalWindow.show(target); - } - }; - - MetaDataRoleAuthorizationStrategy.authorize(link, ENABLE, allowedCreateRoles); - - return link; - - } - - private class SchemaProvider extends SortableDataProvider<AbstractSchemaTO, String> { - - private static final long serialVersionUID = -185944053385660794L; - - private final SortableDataProviderComparator<AbstractSchemaTO> comparator; - - private final AttributableType attrType; - - private final SchemaType schemaType; - - public SchemaProvider(final AttributableType attrType, final SchemaType schemaType) { - super(); - - this.attrType = attrType; - this.schemaType = schemaType; - - // Default sorting - setSort("key", SortOrder.ASCENDING); - - comparator = new SortableDataProviderComparator<>(this); - } - - @Override - public Iterator<AbstractSchemaTO> iterator(final long first, final long count) { - @SuppressWarnings("unchecked") - List<AbstractSchemaTO> list = - (List<AbstractSchemaTO>) restClient.getSchemas(this.attrType, this.schemaType); - - Collections.sort(list, comparator); - - return list.subList((int) first, (int) first + (int) count).iterator(); - } - - @Override - public long size() { - return restClient.getSchemas(this.attrType, this.schemaType).size(); - } - - @Override - public IModel<AbstractSchemaTO> model(final AbstractSchemaTO object) { - return new CompoundPropertyModel<AbstractSchemaTO>(object); - } - } - - private class SchemaTypePanel extends Panel { - - private static final long serialVersionUID = 2854050613688773575L; - - private int pageRows; - - private final AttributableType attrType; - - private final SchemaType schemaType; - - public SchemaTypePanel(final String id, final AttributableType attrType, final SchemaType schemaType) { - super(id); - - this.attrType = attrType; - this.schemaType = schemaType; - - setup(); - } - - private void setup() { - ModalWindow editSchemaWin = new ModalWindow("editSchemaWin"); - editSchemaWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); - editSchemaWin.setInitialWidth(WIN_WIDTH); - if (schemaType == SchemaType.PLAIN) { - editSchemaWin.setInitialHeight(PLAIN_WIN_HEIGHT); - } else { - editSchemaWin.setInitialHeight(WIN_HEIGHT); - } - editSchemaWin.setCookieName("editSchemaWin"); - editSchemaWin.setMarkupId("editSchemaWin"); - add(editSchemaWin); - - WebMarkupContainer schemaWrapContainer = new WebMarkupContainer("schemaWrapContainer"); - schemaWrapContainer.setOutputMarkupId(true); - if (schemaType != SchemaType.VIRTUAL) { - schemaWrapContainer.add(new AttributeModifier("style", "width:auto;")); - } - add(schemaWrapContainer); - - WebMarkupContainer schemaContainer = new WebMarkupContainer("schemaContainer"); - schemaContainer.setOutputMarkupId(true); - schemaWrapContainer.add(schemaContainer); - setWindowClosedCallback(editSchemaWin, schemaContainer); - - final String paginatorRowsKey = PAGINATOR_ROWS_KEYS.get( - new ImmutablePair<AttributableType, SchemaType>(attrType, schemaType)); - pageRows = prefMan.getPaginatorRows(getRequest(), paginatorRowsKey); - - List<IColumn> tableCols = getColumns(schemaContainer, editSchemaWin, attrType, - schemaType, COL_NAMES.get(schemaType)); - final AjaxFallbackDefaultDataTable table = new AjaxFallbackDefaultDataTable("datatable", tableCols, - new SchemaProvider(attrType, schemaType), pageRows); - table.setOutputMarkupId(true); - schemaContainer.add(table); - - schemaWrapContainer.add(getPaginatorForm(schemaContainer, table, "paginatorForm", this, paginatorRowsKey)); - - add(getCreateSchemaLink(editSchemaWin, attrType, schemaType, "createSchemaLink")); - } - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/pages/SecurityQuestionModalPage.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/SecurityQuestionModalPage.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/SecurityQuestionModalPage.java deleted file mode 100644 index 12bfc2b..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/pages/SecurityQuestionModalPage.java +++ /dev/null @@ -1,111 +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.pages; - -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.AjaxTextFieldPanel; -import org.apache.syncope.common.lib.SyncopeClientException; -import org.apache.syncope.common.lib.to.SecurityQuestionTO; -import org.apache.wicket.PageReference; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.markup.html.form.AjaxButton; -import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy; -import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.model.CompoundPropertyModel; -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; - -class SecurityQuestionModalPage extends BaseModalPage { - - private static final long serialVersionUID = -6709838862698327502L; - - @SpringBean - private SecurityQuestionRestClient restClient; - - public SecurityQuestionModalPage(final PageReference pageRef, final ModalWindow window, - final SecurityQuestionTO securityQuestionTO, final boolean createFlag) { - - final Form<SecurityQuestionTO> form = - new Form<SecurityQuestionTO>(FORM, new CompoundPropertyModel<SecurityQuestionTO>(securityQuestionTO)); - - final AjaxTextFieldPanel contentFieldPanel = - new AjaxTextFieldPanel("content", "content", new PropertyModel<String>(securityQuestionTO, "content")); - contentFieldPanel.setRequired(true); - form.add(contentFieldPanel); - - AjaxButton submit = new IndicatingAjaxButton(APPLY, new Model<String>(getString(SUBMIT))) { - - private static final long serialVersionUID = -958724007591692537L; - - @Override - protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { - try { - if (createFlag) { - restClient.create(securityQuestionTO); - } else { - restClient.update(securityQuestionTO); - } - info(getString(Constants.OPERATION_SUCCEEDED)); - - Configuration callerPage = (Configuration) pageRef.getPage(); - callerPage.setModalResult(true); - - window.close(target); - } catch (SyncopeClientException scee) { - error(getString(Constants.ERROR) + ": " + scee.getMessage()); - feedbackPanel.refresh(target); - } - } - - @Override - protected void onError(final AjaxRequestTarget target, final Form<?> form) { - feedbackPanel.refresh(target); - } - }; - - final AjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) { - - private static final long serialVersionUID = -958724007591692537L; - - @Override - protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { - window.close(target); - } - }; - - cancel.setDefaultFormProcessing(false); - - String allowedRoles = createFlag - ? xmlRolesReader.getEntitlement("SecurityQuestion", "create") - : xmlRolesReader.getEntitlement("SecurityQuestion", "update"); - MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, allowedRoles); - - form.add(submit); - form.setDefaultButton(submit); - - form.add(cancel); - - add(form); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/pages/SignOut.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/SignOut.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/SignOut.java new file mode 100644 index 0000000..1b0ab30 --- /dev/null +++ b/client/console/src/main/java/org/apache/syncope/client/console/pages/SignOut.java @@ -0,0 +1,35 @@ +/* + * 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.pages; + +import org.apache.syncope.client.console.SyncopeConsoleSession; +import org.apache.wicket.markup.html.WebPage; +import org.apache.wicket.request.mapper.parameter.PageParameters; + +public class SignOut extends WebPage { + + private static final long serialVersionUID = -6497270741904509673L; + + public SignOut(final PageParameters parameters) { + super(parameters); + + SyncopeConsoleSession.get().invalidate(); + } + +}
