http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/pages/StatusModalPage.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/StatusModalPage.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/StatusModalPage.java deleted file mode 100644 index cab0e04..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/pages/StatusModalPage.java +++ /dev/null @@ -1,641 +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.Collection; -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.syncope.client.console.commons.status.AbstractStatusBeanProvider; -import org.apache.syncope.client.console.commons.status.ConnObjectWrapper; -import org.apache.syncope.client.console.commons.status.Status; -import org.apache.syncope.client.console.commons.status.StatusBean; -import org.apache.syncope.client.console.commons.status.StatusUtils; -import org.apache.syncope.client.console.panels.ActionDataTablePanel; -import org.apache.syncope.client.console.wicket.ajax.markup.html.ClearIndicatingAjaxButton; -import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink; -import org.apache.syncope.client.console.wicket.markup.html.form.AjaxCheckBoxPanel; -import org.apache.syncope.common.lib.to.AbstractSubjectTO; -import org.apache.syncope.common.lib.to.BulkActionResult; -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.syncope.common.lib.types.ResourceAssociationActionType; -import org.apache.wicket.PageReference; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; -import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator; -import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn; -import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn; -import org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider; -import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn; -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.form.Form; -import org.apache.wicket.markup.html.form.PasswordTextField; -import org.apache.wicket.markup.html.panel.Fragment; -import org.apache.wicket.markup.repeater.Item; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.Model; -import org.apache.wicket.model.ResourceModel; -import org.apache.wicket.model.StringResourceModel; - -public class StatusModalPage<T extends AbstractSubjectTO> extends AbstractStatusModalPage { - - private static final long serialVersionUID = -9148734710505211261L; - - private final AbstractSubjectTO subjectTO; - - private int rowsPerPage = 10; - - final StatusUtils statusUtils; - - final boolean statusOnly; - - // -------------------------------- - // password management fields .. - // -------------------------------- - final ClearIndicatingAjaxButton cancel; - - final WebMarkupContainer pwdMgt; - - final Form<?> pwdMgtForm; - - final AjaxCheckBoxPanel changepwd; - - final PasswordTextField password; - - final PasswordTextField confirm; - // -------------------------------- - - final PageReference pageRef; - - final ModalWindow window; - - final ActionDataTablePanel<StatusBean, String> table; - - final List<IColumn<StatusBean, String>> columns; - - public StatusModalPage( - final PageReference pageRef, - final ModalWindow window, - final AbstractSubjectTO attributableTO) { - - this(pageRef, window, attributableTO, false); - } - - public StatusModalPage( - final PageReference pageRef, - final ModalWindow window, - final AbstractSubjectTO subjectTO, - final boolean statusOnly) { - - super(); - - this.pageRef = pageRef; - this.window = window; - this.statusOnly = statusOnly; - this.subjectTO = subjectTO; - - statusUtils = new StatusUtils(subjectTO instanceof UserTO ? userRestClient : groupRestClient); - - add(new Label("displayName", subjectTO.getKey() + " " - + (subjectTO instanceof UserTO ? ((UserTO) subjectTO).getUsername() : ((GroupTO) subjectTO).getName()))); - - columns = new ArrayList<>(); - columns.add(new AbstractColumn<StatusBean, String>( - new StringResourceModel("resourceName", this, null, "Resource name"), "resourceName") { - - private static final long serialVersionUID = 2054811145491901166L; - - @Override - public void populateItem( - final Item<ICellPopulator<StatusBean>> cellItem, - final String componentId, - final IModel<StatusBean> model) { - - cellItem.add(new Label(componentId, model.getObject().getResourceName()) { - - private static final long serialVersionUID = 8432079838783825801L; - - @Override - protected void onComponentTag(final ComponentTag tag) { - if (model.getObject().isLinked()) { - super.onComponentTag(tag); - } else { - tag.put("style", "color: #DDDDDD"); - } - } - }); - } - }); - - columns.add(new PropertyColumn<StatusBean, String>( - new StringResourceModel("accountLink", this, null, "Account link"), "accountLink", "accountLink")); - - columns.add(new AbstractColumn<StatusBean, String>( - new StringResourceModel("status", this, null, "")) { - - private static final long serialVersionUID = -3503023501954863131L; - - @Override - public String getCssClass() { - return "action"; - } - - @Override - public void populateItem( - final Item<ICellPopulator<StatusBean>> cellItem, - final String componentId, - final IModel<StatusBean> model) { - - if (model.getObject().isLinked()) { - cellItem.add(statusUtils.getStatusImagePanel(componentId, model.getObject(). - getStatus())); - } else { - cellItem.add(new Label(componentId, "")); - } - } - }); - - table = new ActionDataTablePanel<StatusBean, String>( - "resourceDatatable", - columns, - (ISortableDataProvider<StatusBean, String>) new AttributableStatusProvider(), - rowsPerPage, - pageRef) { - - private static final long serialVersionUID = 6510391461033818316L; - - @Override - public boolean isElementEnabled(final StatusBean element) { - return !statusOnly || element.getStatus() != Status.OBJECT_NOT_FOUND; - } - }; - table.setOutputMarkupId(true); - - final String pageId = subjectTO instanceof GroupTO ? "Groups" : "Users"; - - final Fragment pwdMgtFragment = new Fragment("pwdMgtFields", "pwdMgtFragment", this); - addOrReplace(pwdMgtFragment); - - pwdMgt = new WebMarkupContainer("pwdMgt"); - pwdMgtFragment.add(pwdMgt.setOutputMarkupId(true)); - - pwdMgtForm = new Form("pwdMgtForm"); - pwdMgtForm.setVisible(false).setEnabled(false); - pwdMgt.add(pwdMgtForm); - - password = new PasswordTextField("password", new Model<String>()); - pwdMgtForm.add(password.setRequired(false).setEnabled(false)); - - confirm = new PasswordTextField("confirm", new Model<String>()); - pwdMgtForm.add(confirm.setRequired(false).setEnabled(false)); - - changepwd = new AjaxCheckBoxPanel("changepwd", "changepwd", new Model<Boolean>(false)); - pwdMgtForm.add(changepwd.setModelObject(false)); - pwdMgtForm.add(new Label("changePwdLabel", new ResourceModel("changePwdLabel", "Password propagation"))); - - changepwd.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { - - private static final long serialVersionUID = -1107858522700306810L; - - @Override - protected void onUpdate(final AjaxRequestTarget target) { - password.setEnabled(changepwd.getModelObject()); - confirm.setEnabled(changepwd.getModelObject()); - target.add(pwdMgt); - } - }); - - cancel = new ClearIndicatingAjaxButton("cancel", new ResourceModel("cancel"), pageRef) { - - private static final long serialVersionUID = -2341391430136818026L; - - @Override - protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) { - // ignore - window.close(target); - } - }.feedbackPanelAutomaticReload(false); - - pwdMgtForm.add(cancel); - - final ClearIndicatingAjaxButton goon = - new ClearIndicatingAjaxButton("continue", new ResourceModel("continue"), pageRef) { - - private static final long serialVersionUID = -2341391430136818027L; - - @Override - protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) { - // none - } - }; - - pwdMgtForm.add(goon); - - if (statusOnly) { - table.addAction(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - try { - userRestClient.reactivate( - subjectTO.getETagValue(), - subjectTO.getKey(), - new ArrayList<>(table.getModelObject())); - - ((BasePage) pageRef.getPage()).setModalResult(true); - - window.close(target); - } catch (Exception e) { - LOG.error("Error enabling resources", e); - error(getString(Constants.ERROR) + ": " + e.getMessage()); - feedbackPanel.refresh(target); - } - } - }, ActionLink.ActionType.REACTIVATE, pageId); - - table.addAction(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - try { - userRestClient.suspend( - subjectTO.getETagValue(), - subjectTO.getKey(), - new ArrayList<>(table.getModelObject())); - - if (pageRef.getPage() instanceof BasePage) { - ((BasePage) pageRef.getPage()).setModalResult(true); - } - - window.close(target); - } catch (Exception e) { - LOG.error("Error disabling resources", e); - error(getString(Constants.ERROR) + ": " + e.getMessage()); - feedbackPanel.refresh(target); - } - } - }, ActionLink.ActionType.SUSPEND, pageId); - } else { - table.addAction(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - try { - if (subjectTO instanceof UserTO) { - userRestClient.unlink( - subjectTO.getETagValue(), - subjectTO.getKey(), - new ArrayList<>(table.getModelObject())); - } else { - groupRestClient.unlink( - subjectTO.getETagValue(), - subjectTO.getKey(), - new ArrayList<>(table.getModelObject())); - } - - ((BasePage) pageRef.getPage()).setModalResult(true); - window.close(target); - } catch (Exception e) { - LOG.error("Error unlinking resources", e); - error(getString(Constants.ERROR) + ": " + e.getMessage()); - feedbackPanel.refresh(target); - } - } - }, ActionLink.ActionType.UNLINK, pageId); - - table.addAction(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - try { - if (subjectTO instanceof UserTO) { - userRestClient.link( - subjectTO.getETagValue(), - subjectTO.getKey(), - new ArrayList<>(table.getModelObject())); - } else { - groupRestClient.link( - subjectTO.getETagValue(), - subjectTO.getKey(), - new ArrayList<>(table.getModelObject())); - } - - ((BasePage) pageRef.getPage()).setModalResult(true); - window.close(target); - } catch (Exception e) { - LOG.error("Error linking resources", e); - error(getString(Constants.ERROR) + ": " + e.getMessage()); - feedbackPanel.refresh(target); - } - } - }, ActionLink.ActionType.LINK, pageId); - - table.addAction(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - try { - BulkActionResult bulkActionResult; - if (subjectTO instanceof UserTO) { - bulkActionResult = userRestClient.deprovision( - subjectTO.getETagValue(), - subjectTO.getKey(), - new ArrayList<>(table.getModelObject())); - } else { - bulkActionResult = groupRestClient.deprovision( - subjectTO.getETagValue(), - subjectTO.getKey(), - new ArrayList<>(table.getModelObject())); - } - - ((BasePage) pageRef.getPage()).setModalResult(true); - loadBulkActionResultPage(table.getModelObject(), bulkActionResult); - } catch (Exception e) { - LOG.error("Error de-provisioning user", e); - error(getString(Constants.ERROR) + ": " + e.getMessage()); - feedbackPanel.refresh(target); - } - } - }, ActionLink.ActionType.DEPROVISION, pageId); - - table.addAction(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - - if (subjectTO instanceof UserTO) { - StatusModalPage.this.passwordManagement( - target, ResourceAssociationActionType.PROVISION, table.getModelObject()); - } else { - try { - final BulkActionResult bulkActionResult = groupRestClient.provision( - subjectTO.getETagValue(), - subjectTO.getKey(), - new ArrayList<>(table.getModelObject())); - - ((BasePage) pageRef.getPage()).setModalResult(true); - loadBulkActionResultPage(table.getModelObject(), bulkActionResult); - } catch (Exception e) { - LOG.error("Error provisioning user", e); - error(getString(Constants.ERROR) + ": " + e.getMessage()); - feedbackPanel.refresh(target); - } - } - } - }.feedbackPanelAutomaticReload(!(subjectTO instanceof UserTO)), ActionLink.ActionType.PROVISION, pageId); - - table.addAction(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - try { - final BulkActionResult bulkActionResult; - if (subjectTO instanceof UserTO) { - bulkActionResult = userRestClient.unassign( - subjectTO.getETagValue(), - subjectTO.getKey(), - new ArrayList<>(table.getModelObject())); - } else { - bulkActionResult = groupRestClient.unassign( - subjectTO.getETagValue(), - subjectTO.getKey(), - new ArrayList<>(table.getModelObject())); - } - - ((BasePage) pageRef.getPage()).setModalResult(true); - loadBulkActionResultPage(table.getModelObject(), bulkActionResult); - } catch (Exception e) { - LOG.error("Error unassigning resources", e); - error(getString(Constants.ERROR) + ": " + e.getMessage()); - feedbackPanel.refresh(target); - } - } - }, ActionLink.ActionType.UNASSIGN, pageId); - - table.addAction(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - if (subjectTO instanceof UserTO) { - StatusModalPage.this.passwordManagement( - target, ResourceAssociationActionType.ASSIGN, table.getModelObject()); - } else { - try { - final BulkActionResult bulkActionResult = groupRestClient.assign( - subjectTO.getETagValue(), - subjectTO.getKey(), - new ArrayList<>(table.getModelObject())); - - ((BasePage) pageRef.getPage()).setModalResult(true); - loadBulkActionResultPage(table.getModelObject(), bulkActionResult); - } catch (Exception e) { - LOG.error("Error assigning resources", e); - error(getString(Constants.ERROR) + ": " + e.getMessage()); - feedbackPanel.refresh(target); - } - } - } - }.feedbackPanelAutomaticReload(!(subjectTO instanceof UserTO)), ActionLink.ActionType.ASSIGN, pageId); - } - - table.addCancelButton(window); - add(table); - } - - private class AttributableStatusProvider extends AbstractStatusBeanProvider { - - private static final long serialVersionUID = 4586969457669796621L; - - public AttributableStatusProvider() { - super(statusOnly ? "resourceName" : "accountLink"); - } - - @SuppressWarnings("unchecked") - @Override - public List<StatusBean> getStatusBeans() { - final List<String> resources = new ArrayList<>(); - for (ResourceTO resourceTO : resourceRestClient.getAll()) { - resources.add(resourceTO.getKey()); - } - - final List<ConnObjectWrapper> connObjects = statusUtils.getConnectorObjects(subjectTO); - - final List<StatusBean> statusBeans = new ArrayList<StatusBean>(connObjects.size() + 1); - - for (ConnObjectWrapper entry : connObjects) { - final StatusBean statusBean = statusUtils.getStatusBean(subjectTO, - entry.getResourceName(), - entry.getConnObjectTO(), - subjectTO instanceof GroupTO); - - statusBeans.add(statusBean); - resources.remove(entry.getResourceName()); - } - - if (statusOnly) { - final StatusBean syncope = new StatusBean(subjectTO, "Syncope"); - - syncope.setAccountLink(((UserTO) subjectTO).getUsername()); - - Status syncopeStatus = Status.UNDEFINED; - if (((UserTO) subjectTO).getStatus() != null) { - try { - syncopeStatus = Status.valueOf(((UserTO) subjectTO).getStatus().toUpperCase()); - } catch (IllegalArgumentException e) { - LOG.warn("Unexpected status found: {}", ((UserTO) subjectTO).getStatus(), e); - } - } - syncope.setStatus(syncopeStatus); - - statusBeans.add(syncope); - } else { - for (String resource : resources) { - final StatusBean statusBean = statusUtils.getStatusBean(subjectTO, - resource, - null, - subjectTO instanceof GroupTO); - - statusBean.setLinked(false); - statusBeans.add(statusBean); - } - } - - return statusBeans; - } - } - - private void passwordManagement( - final AjaxRequestTarget target, - final ResourceAssociationActionType type, - final Collection<StatusBean> selection) { - - final ClearIndicatingAjaxButton goon = - new ClearIndicatingAjaxButton("continue", new ResourceModel("continue", "Continue"), pageRef) { - - private static final long serialVersionUID = -2341391430136818027L; - - @Override - protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) { - try { - if (StringUtils.isNotBlank(password.getModelObject()) - && !password.getModelObject().equals(confirm.getModelObject())) { - throw new Exception(getString("passwordMismatch")); - } - - final BulkActionResult bulkActionResult; - switch (type) { - case ASSIGN: - bulkActionResult = userRestClient.assign( - subjectTO.getETagValue(), - subjectTO.getKey(), - new ArrayList<>(selection), - changepwd.getModelObject(), - password.getModelObject()); - break; - case PROVISION: - bulkActionResult = userRestClient.provision( - subjectTO.getETagValue(), - subjectTO.getKey(), - new ArrayList<>(selection), - changepwd.getModelObject(), - password.getModelObject()); - break; - default: - bulkActionResult = null; - // ignore - } - - ((BasePage) pageRef.getPage()).setModalResult(true); - - if (bulkActionResult != null) { - loadBulkActionResultPage(selection, bulkActionResult); - } else { - - target.add(((BasePage) pageRef.getPage()).getFeedbackPanel()); - window.close(target); - } - } catch (Exception e) { - LOG.error("Error provisioning resources", e); - error(getString(Constants.ERROR) + ": " + e.getMessage()); - feedbackPanel.refresh(target); - } - } - }.feedbackPanelAutomaticReload(false); - - pwdMgtForm.addOrReplace(goon); - - table.setVisible(false); - pwdMgtForm.setVisible(true).setEnabled(true); - - target.add(table); - target.add(pwdMgt); - } - - private void loadBulkActionResultPage( - final Collection<StatusBean> selection, final BulkActionResult bulkActionResult) { - final List<String> resources = new ArrayList<String>(selection.size()); - for (StatusBean statusBean : selection) { - resources.add(statusBean.getResourceName()); - } - - final List<ConnObjectWrapper> connObjects = - statusUtils.getConnectorObjects(Collections.singletonList(subjectTO), resources); - - final List<StatusBean> statusBeans = new ArrayList<StatusBean>(connObjects.size()); - - for (ConnObjectWrapper entry : connObjects) { - final StatusBean statusBean = statusUtils.getStatusBean(subjectTO, - entry.getResourceName(), - entry.getConnObjectTO(), - subjectTO instanceof GroupTO); - - statusBeans.add(statusBean); - } - - setResponsePage(new BulkActionResultModalPage<StatusBean, String>( - window, - statusBeans, - columns, - bulkActionResult, - "resourceName")); - } -}
http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/pages/SyncTaskModalPage.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/SyncTaskModalPage.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/SyncTaskModalPage.java deleted file mode 100644 index 544f670..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/pages/SyncTaskModalPage.java +++ /dev/null @@ -1,73 +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.AjaxCheckBoxPanel; -import org.apache.syncope.common.lib.to.SchedTaskTO; -import org.apache.syncope.common.lib.to.SyncTaskTO; -import org.apache.syncope.common.lib.types.MatchingRule; -import org.apache.syncope.common.lib.types.UnmatchingRule; -import org.apache.wicket.PageReference; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; -import org.apache.wicket.markup.html.form.DropDownChoice; -import org.apache.wicket.model.PropertyModel; - -/** - * Modal window with Sync Task form. - */ -public class SyncTaskModalPage extends AbstractSyncTaskModalPage { - - private static final long serialVersionUID = 2148403203517274669L; - - public SyncTaskModalPage(final ModalWindow window, final SyncTaskTO taskTO, final PageReference pageRef) { - - super(window, taskTO, pageRef); - - // set default Matching rule - ((DropDownChoice) matchingRule.getField()).setDefaultModelObject(taskTO.getMatchingRule() == null - ? MatchingRule.UPDATE - : taskTO.getMatchingRule()); - profile.add(matchingRule); - - // set default Unmatching rule - ((DropDownChoice) unmatchingRule.getField()).setDefaultModelObject(taskTO.getUnmatchingRule() == null - ? UnmatchingRule.PROVISION - : taskTO.getUnmatchingRule()); - profile.add(unmatchingRule); - - final AjaxCheckBoxPanel fullReconciliation = new AjaxCheckBoxPanel("fullReconciliation", - getString("fullReconciliation"), new PropertyModel<Boolean>(taskTO, "fullReconciliation")); - profile.add(fullReconciliation); - } - - @Override - protected List<String> getSyncActions() { - return taskRestClient.getSyncActionsClasses(); - } - - @Override - public void submitAction(final SchedTaskTO taskTO) { - if (taskTO.getKey() > 0) { - taskRestClient.updateSyncTask((SyncTaskTO) taskTO); - } else { - taskRestClient.createSyncTask((SyncTaskTO) taskTO); - } - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/pages/TaskModalPage.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/TaskModalPage.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/TaskModalPage.java deleted file mode 100644 index c251d87..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/pages/TaskModalPage.java +++ /dev/null @@ -1,253 +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.Collections; -import java.util.Iterator; -import java.util.List; -import org.apache.syncope.client.console.commons.Constants; -import org.apache.syncope.client.console.commons.SortableDataProviderComparator; -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.client.console.wicket.markup.html.form.AjaxTextFieldPanel; -import org.apache.syncope.common.lib.SyncopeClientException; -import org.apache.syncope.common.lib.to.AbstractTaskTO; -import org.apache.syncope.common.lib.to.NotificationTaskTO; -import org.apache.syncope.common.lib.to.PropagationTaskTO; -import org.apache.syncope.common.lib.to.SchedTaskTO; -import org.apache.syncope.common.lib.to.SyncTaskTO; -import org.apache.syncope.common.lib.to.TaskExecTO; -import org.apache.wicket.Component; -import org.apache.wicket.Page; -import org.apache.wicket.ajax.AjaxRequestTarget; -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.sort.SortOrder; -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.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.model.AbstractReadOnlyModel; -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.springframework.util.StringUtils; - -/** - * Modal window with Task form (to stop and start execution). - */ -public abstract class TaskModalPage extends BaseModalPage { - - private static final long serialVersionUID = -4110576026663173545L; - - protected WebMarkupContainer profile; - - protected WebMarkupContainer executions; - - protected Form<AbstractTaskTO> form; - - public TaskModalPage(final AbstractTaskTO taskTO) { - final ModalWindow taskExecMessageWin = new ModalWindow("taskExecMessageWin"); - taskExecMessageWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); - taskExecMessageWin.setCookieName("task-exec-message-win-modal"); - add(taskExecMessageWin); - - form = new Form<>(FORM); - form.setModel(new CompoundPropertyModel<>(taskTO)); - add(form); - - profile = new WebMarkupContainer("profile"); - profile.setOutputMarkupId(true); - form.add(profile); - - executions = new WebMarkupContainer("executionContainer"); - executions.setOutputMarkupId(true); - form.add(executions); - - final Label idLabel = new Label("idLabel", new ResourceModel("key")); - profile.add(idLabel); - - final AjaxTextFieldPanel id = - new AjaxTextFieldPanel("key", getString("key"), new PropertyModel<String>(taskTO, "key")); - - id.setEnabled(false); - profile.add(id); - - final List<IColumn<TaskExecTO, String>> columns = new ArrayList<>(); - - final int paginatorRows = 10; - - columns.add(new PropertyColumn<TaskExecTO, String>(new ResourceModel("key"), "key", "key")); - columns.add(new DatePropertyColumn<TaskExecTO>(new ResourceModel("startDate"), "startDate", "startDate")); - columns.add(new DatePropertyColumn<TaskExecTO>(new ResourceModel("endDate"), "endDate", "endDate")); - columns.add(new PropertyColumn<TaskExecTO, String>(new ResourceModel("status"), "status", "status")); - columns.add(new ActionColumn<TaskExecTO, String>(new ResourceModel("actions", "")) { - - private static final long serialVersionUID = 2054811145491901166L; - - @Override - public ActionLinksPanel getActions(final String componentId, final IModel<TaskExecTO> model) { - - final TaskExecTO taskExecutionTO = 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) { - taskExecMessageWin.setPageCreator(new ModalWindow.PageCreator() { - - private static final long serialVersionUID = -7834632442532690940L; - - @Override - public Page createPage() { - return new ExecMessageModalPage(model.getObject().getMessage()); - } - }); - taskExecMessageWin.show(target); - } - }, ActionLink.ActionType.EDIT, TASKS, StringUtils.hasText(model.getObject().getMessage())); - - panel.add(new ActionLink() { - - private static final long serialVersionUID = -3722207913631435501L; - - @Override - public void onClick(final AjaxRequestTarget target) { - try { - taskRestClient.deleteExecution(taskExecutionTO.getKey()); - - taskTO.getExecutions().remove(taskExecutionTO); - - info(getString(Constants.OPERATION_SUCCEEDED)); - } catch (SyncopeClientException scce) { - error(scce.getMessage()); - } - - feedbackPanel.refresh(target); - target.add(executions); - } - }, ActionLink.ActionType.DELETE, TASKS); - - return panel; - } - - @Override - public Component getHeader(final String componentId) { - final ActionLinksPanel panel = new ActionLinksPanel(componentId, new Model(), getPageReference()); - - panel.add(new ActionLink() { - - private static final long serialVersionUID = -7978723352517770644L; - - @Override - public void onClick(final AjaxRequestTarget target) { - if (target != null) { - final AjaxFallbackDefaultDataTable<TaskExecTO, String> currentTable = - new AjaxFallbackDefaultDataTable<TaskExecTO, String>("executionsTable", columns, - new TaskExecutionsProvider(getCurrentTaskExecution(taskTO)), paginatorRows); - currentTable.setOutputMarkupId(true); - target.add(currentTable); - executions.addOrReplace(currentTable); - } - } - }, ActionLink.ActionType.RELOAD, TASKS, "list"); - - return panel; - } - }); - - final AjaxFallbackDefaultDataTable<TaskExecTO, String> table = - new AjaxFallbackDefaultDataTable<TaskExecTO, String>("executionsTable", columns, - new TaskExecutionsProvider(getCurrentTaskExecution(taskTO)), paginatorRows); - - executions.add(table); - } - - protected static class TaskExecutionsProvider extends SortableDataProvider<TaskExecTO, String> { - - private static final long serialVersionUID = 8943636537120648961L; - - private SortableDataProviderComparator<TaskExecTO> comparator; - - private AbstractTaskTO taskTO; - - public TaskExecutionsProvider(final AbstractTaskTO taskTO) { - //Default sorting - this.taskTO = taskTO; - setSort("startDate", SortOrder.DESCENDING); - comparator = new SortableDataProviderComparator<TaskExecTO>(this); - } - - @Override - public Iterator<TaskExecTO> iterator(final long first, final long count) { - - List<TaskExecTO> list = taskTO.getExecutions(); - - Collections.sort(list, comparator); - - return list.subList((int) first, (int) first + (int) count).iterator(); - } - - @Override - public long size() { - return taskTO.getExecutions().size(); - } - - @Override - public IModel<TaskExecTO> model(final TaskExecTO taskExecution) { - - return new AbstractReadOnlyModel<TaskExecTO>() { - - private static final long serialVersionUID = 7485475149862342421L; - - @Override - public TaskExecTO getObject() { - return taskExecution; - } - }; - } - } - - private AbstractTaskTO getCurrentTaskExecution(final AbstractTaskTO taskTO) { - final AbstractTaskTO currentTask = taskTO.getKey() == 0 - ? taskTO - : taskTO instanceof PropagationTaskTO - ? taskRestClient.readPropagationTask(taskTO.getKey()) - : taskTO instanceof NotificationTaskTO - ? taskRestClient.readNotificationTask(taskTO.getKey()) - : taskTO instanceof SyncTaskTO - ? taskRestClient.readSchedTask(SyncTaskTO.class, taskTO.getKey()) - : taskRestClient.readSchedTask(SchedTaskTO.class, taskTO.getKey()); - - taskTO.getExecutions().clear(); - taskTO.getExecutions().addAll(currentTask.getExecutions()); - return taskTO; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/pages/Tasks.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/Tasks.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/Tasks.java deleted file mode 100644 index 296c365..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/pages/Tasks.java +++ /dev/null @@ -1,230 +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.Comparator; -import java.util.Iterator; -import java.util.List; -import org.apache.syncope.client.console.commons.SortableDataProviderComparator; -import org.apache.syncope.client.console.panels.AjaxDataTablePanel; -import org.apache.syncope.client.console.panels.NotificationTasks; -import org.apache.syncope.client.console.panels.PropagationTasks; -import org.apache.syncope.client.console.panels.PushTasksPanel; -import org.apache.syncope.client.console.panels.SchedTasks; -import org.apache.syncope.client.console.panels.SyncTasksPanel; -import org.apache.syncope.client.console.rest.BaseRestClient; -import org.apache.syncope.client.console.rest.TaskRestClient; -import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink; -import org.apache.syncope.common.lib.to.AbstractTaskTO; -import org.apache.syncope.common.lib.to.SchedTaskTO; -import org.apache.syncope.common.lib.to.TaskExecTO; -import org.apache.wicket.PageReference; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; -import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder; -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.util.SortableDataProvider; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.model.AbstractReadOnlyModel; -import org.apache.wicket.model.CompoundPropertyModel; -import org.apache.wicket.model.IModel; - -public class Tasks extends BasePage { - - private static final long serialVersionUID = 5289215853622289061L; - - public Tasks() { - super(); - - add(new PropagationTasks("propagation", getPageReference())); - add(new NotificationTasks("notification", getPageReference())); - add(new SchedTasks("sched", getPageReference())); - add(new SyncTasksPanel("sync", getPageReference())); - add(new PushTasksPanel("push", getPageReference())); - - getPageReference(); - } - - @Override - public void setWindowClosedCallback(final ModalWindow window, final WebMarkupContainer container) { - - super.setWindowClosedCallback(window, container); - } - - public static class TaskExecutionsProvider extends SortableDataProvider<TaskExecTO, String> { - - private static final long serialVersionUID = -5401263348984206145L; - - private SortableDataProviderComparator<TaskExecTO> comparator; - - private AbstractTaskTO taskTO; - - public TaskExecutionsProvider(final AbstractTaskTO taskTO) { - super(); - - //Default sorting - this.taskTO = taskTO; - setSort("startDate", SortOrder.DESCENDING); - comparator = new SortableDataProviderComparator<TaskExecTO>(this); - } - - @Override - public Iterator<TaskExecTO> iterator(final long first, final long count) { - - List<TaskExecTO> list = getTaskDB(); - - Collections.sort(list, comparator); - - return list.subList((int) first, (int) first + (int) count).iterator(); - } - - @Override - public long size() { - return getTaskDB().size(); - } - - @Override - public IModel<TaskExecTO> model(final TaskExecTO taskExecution) { - - return new AbstractReadOnlyModel<TaskExecTO>() { - - private static final long serialVersionUID = 7485475149862342421L; - - @Override - public TaskExecTO getObject() { - return taskExecution; - } - }; - } - - public List<TaskExecTO> getTaskDB() { - return taskTO.getExecutions(); - } - } - - public static class TasksProvider<T extends AbstractTaskTO> extends SortableDataProvider<T, String> { - - private static final long serialVersionUID = -20112718133295756L; - - private SortableDataProviderComparator<T> comparator; - - private TaskRestClient restClient; - - private int paginatorRows; - - private String id; - - private Class<T> reference; - - public TasksProvider( - final TaskRestClient restClient, final int paginatorRows, final String id, final Class<T> reference) { - - super(); - - //Default sorting - setSort("key", SortOrder.DESCENDING); - comparator = new SortableDataProviderComparator<>(this); - this.paginatorRows = paginatorRows; - this.restClient = restClient; - this.id = id; - this.reference = reference; - } - - @Override - public Iterator<T> iterator(final long first, final long count) { - final List<T> tasks = new ArrayList<>(); - - final int page = ((int) first / paginatorRows); - - for (T task : restClient.list(reference, (page < 0 ? 0 : page) + 1, paginatorRows, getSort())) { - if (task instanceof SchedTaskTO && ((SchedTaskTO) task).getLastExec() == null - && task.getExecutions() != null && !task.getExecutions().isEmpty()) { - - Collections.sort(task.getExecutions(), new Comparator<TaskExecTO>() { - - @Override - public int compare(final TaskExecTO left, final TaskExecTO right) { - return left.getStartDate().compareTo(right.getStartDate()); - } - }); - - ((SchedTaskTO) task).setLastExec(task.getExecutions().get(task.getExecutions().size() - 1). - getStartDate()); - } - tasks.add(task); - } - - Collections.sort(tasks, comparator); - return tasks.iterator(); - } - - @Override - public long size() { - return restClient.count(id); - } - - @Override - public IModel<T> model(final T object) { - return new CompoundPropertyModel<>(object); - } - } - - /** - * Update task table. - * - * @param columns columns. - * @param dataProvider data provider. - * @param container container. - * @param currentPage current page index. - * @param pageRef page reference - * @param restClient syncope base rest client - * @return data table. - */ - public static AjaxDataTablePanel<AbstractTaskTO, String> updateTaskTable( - final List<IColumn<AbstractTaskTO, String>> columns, - final TasksProvider<? extends AbstractTaskTO> dataProvider, - final WebMarkupContainer container, - final int currentPage, - final PageReference pageRef, - final BaseRestClient restClient) { - - @SuppressWarnings("unchecked") - final AjaxDataTablePanel<AbstractTaskTO, String> table = new AjaxDataTablePanel<>( - "datatable", - columns, - (ISortableDataProvider<AbstractTaskTO, String>) dataProvider, - dataProvider.paginatorRows, - Arrays.asList(new ActionLink.ActionType[] { - ActionLink.ActionType.DELETE, ActionLink.ActionType.DRYRUN, ActionLink.ActionType.EXECUTE }), - restClient, - "key", - TASKS, - pageRef); - - table.setCurrentPage(currentPage); - table.setOutputMarkupId(true); - - container.addOrReplace(table); - - return table; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/pages/Todo.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/Todo.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/Todo.java deleted file mode 100644 index 1329fe4..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/pages/Todo.java +++ /dev/null @@ -1,245 +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.Collections; -import java.util.Iterator; -import java.util.List; -import org.apache.syncope.client.console.SyncopeSession; -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.rest.ApprovalRestClient; -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.WorkflowFormTO; -import org.apache.wicket.Page; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; -import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy; -import org.apache.wicket.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.markup.html.WebMarkupContainer; -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.PropertyModel; -import org.apache.wicket.model.ResourceModel; -import org.apache.wicket.request.mapper.parameter.PageParameters; -import org.apache.wicket.spring.injection.annot.SpringBean; - -public class Todo extends BasePage { - - private static final long serialVersionUID = -7122136682275797903L; - - @SpringBean - private ApprovalRestClient restClient; - - @SpringBean - private PreferenceManager prefMan; - - private final ModalWindow window; - - private static final int WIN_HEIGHT = 400; - - private static final int WIN_WIDTH = 600; - - private WebMarkupContainer container; - - private int paginatorRows; - - public Todo(final PageParameters parameters) { - super(parameters); - - add(window = new ModalWindow("editApprovalWin")); - - container = new WebMarkupContainer("approvalContainer"); - - MetaDataRoleAuthorizationStrategy.authorize( - container, RENDER, xmlRolesReader.getEntitlement("Approval", "list")); - - paginatorRows = prefMan.getPaginatorRows(getRequest(), Constants.PREF_TODO_PAGINATOR_ROWS); - - List<IColumn<WorkflowFormTO, String>> columns = new ArrayList<IColumn<WorkflowFormTO, String>>(); - columns.add(new PropertyColumn<WorkflowFormTO, String>( - new ResourceModel("taskId"), "taskId", "taskId")); - columns.add(new PropertyColumn<WorkflowFormTO, String>( - new ResourceModel("key"), "key", "key")); - columns.add(new PropertyColumn<WorkflowFormTO, String>( - new ResourceModel("description"), "description", "description")); - columns.add(new DatePropertyColumn<WorkflowFormTO>( - new ResourceModel("createTime"), "createTime", "createTime")); - columns.add(new DatePropertyColumn<WorkflowFormTO>( - new ResourceModel("dueDate"), "dueDate", "dueDate")); - columns.add(new PropertyColumn<WorkflowFormTO, String>(new ResourceModel("owner"), "owner", "owner")); - columns.add(new AbstractColumn<WorkflowFormTO, String>(new ResourceModel("actions", "")) { - - private static final long serialVersionUID = 2054811145491901166L; - - @Override - public String getCssClass() { - return "action"; - } - - @Override - public void populateItem(final Item<ICellPopulator<WorkflowFormTO>> cellItem, final String componentId, - final IModel<WorkflowFormTO> model) { - - final WorkflowFormTO formTO = 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) { - try { - restClient.claimForm(formTO.getTaskId()); - info(getString(Constants.OPERATION_SUCCEEDED)); - } catch (SyncopeClientException scee) { - error(getString(Constants.ERROR) + ": " + scee.getMessage()); - } - feedbackPanel.refresh(target); - target.add(container); - } - }, ActionLink.ActionType.CLAIM, "Approval"); - - 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 ApprovalModalPage(Todo.this.getPageReference(), window, formTO); - } - }); - - window.show(target); - } - }, ActionLink.ActionType.EDIT, "Approval", - SyncopeSession.get().getUsername().equals(formTO.getOwner())); - - cellItem.add(panel); - } - }); - - final AjaxFallbackDefaultDataTable<WorkflowFormTO, String> approvalTable = - new AjaxFallbackDefaultDataTable<WorkflowFormTO, String>( - "approvalTable", columns, new ApprovalProvider(), paginatorRows); - container.add(approvalTable); - - container.setOutputMarkupId(true); - add(container); - - @SuppressWarnings("rawtypes") - Form approvalPaginatorForm = new Form("paginatorForm"); - - MetaDataRoleAuthorizationStrategy.authorize(approvalPaginatorForm, RENDER, - xmlRolesReader.getEntitlement("Approval", "list")); - - @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(getRequest(), getResponse(), Constants.PREF_TODO_PAGINATOR_ROWS, - String.valueOf(paginatorRows)); - approvalTable.setItemsPerPage(paginatorRows); - - target.add(container); - } - }); - - approvalPaginatorForm.add(rowsChooser); - add(approvalPaginatorForm); - - window.setCssClassName(ModalWindow.CSS_CLASS_GRAY); - window.setInitialHeight(WIN_HEIGHT); - window.setInitialWidth(WIN_WIDTH); - window.setCookieName("edit-approval-modal"); - - setWindowClosedCallback(window, container); - } - - private class ApprovalProvider extends SortableDataProvider<WorkflowFormTO, String> { - - private static final long serialVersionUID = -2311716167583335852L; - - private final SortableDataProviderComparator<WorkflowFormTO> comparator; - - public ApprovalProvider() { - super(); - //Default sorting - setSort("key", SortOrder.ASCENDING); - comparator = new SortableDataProviderComparator<WorkflowFormTO>(this); - } - - @Override - public Iterator<WorkflowFormTO> iterator(final long first, final long count) { - final List<WorkflowFormTO> list = restClient.getForms(); - - Collections.sort(list, comparator); - - return list.subList((int) first, (int) first + (int) count).iterator(); - } - - @Override - public long size() { - return restClient.getForms().size(); - } - - @Override - public IModel<WorkflowFormTO> model(final WorkflowFormTO configuration) { - return new AbstractReadOnlyModel<WorkflowFormTO>() { - - private static final long serialVersionUID = -2566070996511906708L; - - @Override - public WorkflowFormTO getObject() { - return configuration; - } - }; - } - } - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/pages/UserModalPage.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/UserModalPage.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/UserModalPage.java deleted file mode 100644 index 0835ca2..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/pages/UserModalPage.java +++ /dev/null @@ -1,229 +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.commons.lang3.StringUtils; -import org.apache.syncope.client.console.commons.Constants; -import org.apache.syncope.client.console.commons.Mode; -import org.apache.syncope.client.console.panels.DerAttrsPanel; -import org.apache.syncope.client.console.panels.MembershipsPanel; -import org.apache.syncope.client.console.panels.PlainAttrsPanel; -import org.apache.syncope.client.console.panels.ResourcesPanel; -import org.apache.syncope.client.console.panels.SecurityQuestionPanel; -import org.apache.syncope.client.console.panels.UserDetailsPanel; -import org.apache.syncope.client.console.panels.VirAttrsPanel; -import org.apache.syncope.client.console.wicket.markup.html.form.AjaxCheckBoxPanel; -import org.apache.syncope.common.lib.to.UserTO; -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.basic.Label; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.markup.html.panel.Fragment; -import org.apache.wicket.model.CompoundPropertyModel; -import org.apache.wicket.model.Model; -import org.apache.wicket.model.ResourceModel; - -/** - * Modal window with User form. - */ -public abstract class UserModalPage extends BaseModalPage { - - private static final long serialVersionUID = 5002005009737457667L; - - protected final PageReference pageRef; - - protected final ModalWindow window; - - protected UserTO userTO; - - protected final Mode mode; - - private Fragment fragment = null; - - private final boolean resetPassword; - - protected final AjaxCheckBoxPanel storePassword; - - public UserModalPage(final PageReference callerPageRef, final ModalWindow window, final UserTO userTO, - final Mode mode, final boolean resetPassword) { - - super(); - - this.pageRef = callerPageRef; - this.window = window; - this.userTO = userTO; - this.mode = mode; - this.resetPassword = resetPassword; - - fragment = new Fragment("userModalFrag", "userModalEditFrag", this); - fragment.setOutputMarkupId(true); - add(fragment); - - storePassword = new AjaxCheckBoxPanel("storePassword", "storePassword", - new Model<Boolean>(Boolean.TRUE)); - } - - public UserTO getUserTO() { - return userTO; - } - - public void setUserTO(final UserTO userTO) { - this.userTO = userTO; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - protected Form setupEditPanel() { - fragment.add(new Label("id", userTO.getKey() == 0 - ? StringUtils.EMPTY - : userTO.getUsername())); - - fragment.add(new Label("new", userTO.getKey() == 0 - ? new ResourceModel("new") - : new Model(StringUtils.EMPTY))); - - final Form form = new Form("UserForm"); - form.setModel(new CompoundPropertyModel(userTO)); - - //-------------------------------- - // User details - //-------------------------------- - form.add(new UserDetailsPanel("details", userTO, form, resetPassword, mode == Mode.TEMPLATE)); - - form.add(new Label("statuspanel", "")); - - form.add(new Label("pwdChangeInfo", "")); - - form.add(new Label("securityQuestion", "")); - form.addOrReplace(new SecurityQuestionPanel("securityQuestion", userTO)); - - form.add(new Label("accountinformation", "")); - //-------------------------------- - - //-------------------------------- - // Store password internally checkbox - //-------------------------------- - final Fragment storePwdFragment = new Fragment("storePwdFrag", "storePwdCheck", form); - storePwdFragment.setOutputMarkupId(true); - final Label storePasswordLabel = new Label("storePasswordLabel", new ResourceModel("storePassword")); - storePwdFragment.add(storePasswordLabel); - storePwdFragment.add(storePassword); - form.add(userTO.getKey() == 0 && mode != Mode.TEMPLATE - ? storePwdFragment : new Fragment("storePwdFrag", "emptyFragment", form)); - //-------------------------------- - - //-------------------------------- - // Attributes panel - //-------------------------------- - form.add(new PlainAttrsPanel("plainAttrs", userTO, form, mode)); - //-------------------------------- - - //-------------------------------- - // Derived attributes panel - //-------------------------------- - form.add(new DerAttrsPanel("derAttrs", userTO)); - //-------------------------------- - - //-------------------------------- - // Virtual attributes panel - //-------------------------------- - form.add(new VirAttrsPanel("virAttrs", userTO, mode == Mode.TEMPLATE)); - //-------------------------------- - - //-------------------------------- - // Resources panel - //-------------------------------- - form.add(new ResourcesPanel.Builder("resources").attributableTO(userTO).build()); - //-------------------------------- - - //-------------------------------- - // Groups panel - //-------------------------------- - form.add(new MembershipsPanel("memberships", userTO, mode, null, getPageReference())); - //-------------------------------- - - final AjaxButton submit = getOnSubmit(); - - if (mode == Mode.ADMIN) { - String allowedRoles = userTO.getKey() == 0 - ? xmlRolesReader.getEntitlement("Users", "create") - : xmlRolesReader.getEntitlement("Users", "update"); - MetaDataRoleAuthorizationStrategy.authorize(submit, RENDER, allowedRoles); - } - - fragment.add(form); - form.add(submit); - form.setDefaultButton(submit); - - final AjaxButton cancel = new AjaxButton(CANCEL, new ResourceModel(CANCEL)) { - - private static final long serialVersionUID = 530608535790823587L; - - @Override - protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { - window.close(target); - } - - @Override - protected void onError(final AjaxRequestTarget target, final Form<?> form) { - } - }; - - cancel.setDefaultFormProcessing(false); - form.add(cancel); - - return form; - } - - protected AjaxButton getOnSubmit() { - return new IndicatingAjaxButton(APPLY, new ResourceModel(SUBMIT)) { - - private static final long serialVersionUID = -958724007591692537L; - - @Override - protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { - try { - submitAction(target, form); - - if (pageRef.getPage() instanceof BasePage) { - ((BasePage) pageRef.getPage()).setModalResult(true); - } - - closeAction(target, form); - } catch (Exception e) { - LOG.error("While creating or updating user", e); - error(getString(Constants.ERROR) + ": " + e.getMessage()); - feedbackPanel.refresh(target); - } - } - - @Override - protected void onError(final AjaxRequestTarget target, final Form<?> form) { - feedbackPanel.refresh(target); - } - }; - } - - protected abstract void submitAction(AjaxRequestTarget target, Form<?> form); - - protected abstract void closeAction(AjaxRequestTarget target, Form<?> form); -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/pages/UserOwnerSelectModalPage.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/UserOwnerSelectModalPage.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/UserOwnerSelectModalPage.java deleted file mode 100644 index ae8a5da..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/pages/UserOwnerSelectModalPage.java +++ /dev/null @@ -1,81 +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.panels.AbstractSearchResultPanel; -import org.apache.syncope.client.console.panels.SelectOnlyUserSearchResultPanel; -import org.apache.syncope.client.console.panels.UserSearchPanel; -import org.apache.wicket.PageReference; -import org.apache.wicket.Session; -import org.apache.wicket.ajax.AjaxRequestTarget; -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.ResourceModel; - -public class UserOwnerSelectModalPage extends BaseModalPage { - - private static final long serialVersionUID = 2106489458494696439L; - - public UserOwnerSelectModalPage(final PageReference pageRef, final ModalWindow window) { - super(); - - final SelectOnlyUserSearchResultPanel searchResult = - new SelectOnlyUserSearchResultPanel("searchResult", true, null, pageRef, window, userRestClient); - add(searchResult); - - final Form<?> searchForm = new Form("searchForm"); - add(searchForm); - - final UserSearchPanel searchPanel = new UserSearchPanel.Builder("searchPanel").build(); - searchForm.add(searchPanel); - - searchForm.add(new IndicatingAjaxButton("search", new ResourceModel("search")) { - - private static final long serialVersionUID = -958724007591692537L; - - @Override - protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { - final String searchCond = searchPanel.buildFIQL(); - doSearch(target, searchCond, searchResult); - - Session.get().getFeedbackMessages().clear(); - searchPanel.getSearchFeedback().refresh(target); - } - - @Override - protected void onError(final AjaxRequestTarget target, final Form<?> form) { - searchPanel.getSearchFeedback().refresh(target); - } - }); - - } - - private void doSearch(final AjaxRequestTarget target, final String fiql, - final AbstractSearchResultPanel resultsetPanel) { - - if (fiql == null) { - error(getString(Constants.SEARCH_ERROR)); - return; - } - - resultsetPanel.search(fiql, target); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/pages/UserSelfModalPage.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/UserSelfModalPage.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/UserSelfModalPage.java deleted file mode 100644 index 087bd69..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/pages/UserSelfModalPage.java +++ /dev/null @@ -1,72 +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.commons.lang3.SerializationUtils; -import org.apache.syncope.client.console.commons.Mode; -import org.apache.syncope.client.console.rest.UserSelfRestClient; -import org.apache.syncope.common.lib.AttributableOperations; -import org.apache.syncope.common.lib.mod.UserMod; -import org.apache.syncope.common.lib.to.UserTO; -import org.apache.wicket.PageReference; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.spring.injection.annot.SpringBean; - -/** - * Modal window with User form. - */ -public class UserSelfModalPage extends UserModalPage { - - private static final long serialVersionUID = 603212869211672852L; - - @SpringBean - private UserSelfRestClient restClient; - - private final UserTO initialUserTO; - - public UserSelfModalPage(final PageReference callerPageRef, final ModalWindow window, final UserTO userTO) { - super(callerPageRef, window, userTO, Mode.SELF, userTO.getKey() != 0); - - this.initialUserTO = SerializationUtils.clone(userTO); - setupEditPanel(); - } - - @Override - protected void submitAction(final AjaxRequestTarget target, final Form<?> form) { - final UserTO updatedUserTO = (UserTO) form.getModelObject(); - - if (updatedUserTO.getKey() == 0) { - restClient.create(updatedUserTO, storePassword.getModelObject()); - } else { - final UserMod userMod = AttributableOperations.diff(updatedUserTO, initialUserTO); - - // update user only if it has changed - if (!userMod.isEmpty()) { - restClient.update(userMod); - } - } - } - - @Override - protected void closeAction(final AjaxRequestTarget target, final Form<?> form) { - setResponsePage(new ResultStatusModalPage.Builder(window, userTO).mode(mode).build()); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/pages/UserTemplateModalPage.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/UserTemplateModalPage.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/UserTemplateModalPage.java deleted file mode 100644 index 2b04035..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/pages/UserTemplateModalPage.java +++ /dev/null @@ -1,60 +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.Mode; -import org.apache.syncope.common.lib.to.SyncTaskTO; -import org.apache.syncope.common.lib.to.UserTO; -import org.apache.wicket.PageReference; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; -import org.apache.wicket.markup.html.form.Form; - -/** - * Modal window with User form. - */ -public class UserTemplateModalPage extends UserModalPage { - - private static final long serialVersionUID = 511003221213581368L; - - private final SyncTaskTO syncTaskTO; - - public UserTemplateModalPage(final PageReference callerPageRef, final ModalWindow window, - final SyncTaskTO syncTaskTO) { - - super(callerPageRef, window, syncTaskTO.getUserTemplate() == null - ? new UserTO() - : syncTaskTO.getUserTemplate(), Mode.TEMPLATE, true); - - this.syncTaskTO = syncTaskTO; - - setupEditPanel(); - } - - @Override - protected void submitAction(final AjaxRequestTarget target, final Form form) { - syncTaskTO.setUserTemplate((UserTO) form.getModelObject()); - taskRestClient.updateSyncTask(syncTaskTO); - } - - @Override - protected void closeAction(final AjaxRequestTarget target, final Form form) { - window.close(target); - } -}
