Search in sources :

Example 1 with CompoundPropertyModel

use of org.apache.wicket.model.CompoundPropertyModel in project syncope by apache.

the class AnyObjectDirectoryPanel method getActions.

@Override
public ActionsPanel<AnyObjectTO> getActions(final IModel<AnyObjectTO> model) {
    final ActionsPanel<AnyObjectTO> panel = super.getActions(model);
    panel.add(new ActionLink<AnyObjectTO>() {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) {
            send(AnyObjectDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<>(new AnyWrapper<>(new AnyObjectRestClient().read(model.getObject().getKey())), target));
        }
    }, ActionType.EDIT, StringUtils.join(new String[] { AnyEntitlement.READ.getFor(type), AnyEntitlement.UPDATE.getFor(type) }, ",")).setRealm(realm);
    panel.add(new ActionLink<AnyObjectTO>() {

        private static final long serialVersionUID = -7978723352517770645L;

        @Override
        public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) {
            final AnyObjectTO clone = SerializationUtils.clone(model.getObject());
            clone.setKey(null);
            send(AnyObjectDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.NewItemActionEvent<>(new AnyWrapper<>(clone), target));
        }

        @Override
        protected boolean statusCondition(final AnyObjectTO modelObject) {
            return addAjaxLink.isVisibleInHierarchy() && realm.startsWith(SyncopeConstants.ROOT_REALM);
        }
    }, ActionType.CLONE, AnyEntitlement.CREATE.getFor(type)).setRealm(realm);
    if (wizardInModal) {
        panel.add(new ActionLink<AnyObjectTO>() {

            private static final long serialVersionUID = -7978723352517770645L;

            @Override
            public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) {
                final IModel<AnyWrapper<AnyObjectTO>> formModel = new CompoundPropertyModel<>(new AnyWrapper<>(model.getObject()));
                altDefaultModal.setFormModel(formModel);
                target.add(altDefaultModal.setContent(new AnyStatusModal<>(altDefaultModal, pageRef, formModel.getObject().getInnerObject(), "resource", false)));
                altDefaultModal.header(new Model<>(getString("any.edit", new Model<>(new AnyWrapper<>(model.getObject())))));
                altDefaultModal.show(true);
            }
        }, ActionType.MANAGE_RESOURCES, AnyEntitlement.UPDATE.getFor(type)).setRealm(realm);
        panel.add(new ActionLink<AnyObjectTO>() {

            private static final long serialVersionUID = -7978723352517770644L;

            @Override
            public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) {
                target.add(utilityModal.setContent(new AnyPropagationTasks(utilityModal, AnyTypeKind.ANY_OBJECT, model.getObject().getKey(), pageRef)));
                utilityModal.header(new StringResourceModel("any.propagation.tasks", model));
                utilityModal.show(true);
            }
        }, ActionType.PROPAGATION_TASKS, StandardEntitlement.TASK_LIST);
        panel.add(new ActionLink<AnyObjectTO>() {

            private static final long serialVersionUID = -7978723352517770644L;

            @Override
            public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) {
                target.add(utilityModal.setContent(new NotificationTasks(AnyTypeKind.ANY_OBJECT, model.getObject().getKey(), pageRef)));
                utilityModal.header(new StringResourceModel("any.notification.tasks", model));
                utilityModal.show(true);
                target.add(utilityModal);
            }
        }, ActionType.NOTIFICATION_TASKS, StandardEntitlement.TASK_LIST);
    }
    panel.add(new ActionLink<AnyObjectTO>() {

        private static final long serialVersionUID = -7978723352517770646L;

        @Override
        public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) {
            try {
                restClient.delete(model.getObject().getETagValue(), model.getObject().getKey());
                SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                target.add(container);
            } catch (SyncopeClientException e) {
                LOG.error("While deleting object {}", model.getObject().getKey(), e);
                SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
            }
            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
        }

        @Override
        protected boolean statusCondition(final AnyObjectTO modelObject) {
            return realm.startsWith(SyncopeConstants.ROOT_REALM);
        }
    }, ActionType.DELETE, AnyEntitlement.DELETE.getFor(type), true).setRealm(realm);
    return panel;
}
Also used : CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) AjaxWizard(org.apache.syncope.client.console.wizards.AjaxWizard) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) AnyWrapper(org.apache.syncope.client.console.wizards.any.AnyWrapper) NotificationTasks(org.apache.syncope.client.console.notifications.NotificationTasks) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AnyStatusModal(org.apache.syncope.client.console.status.AnyStatusModal) AnyObjectTO(org.apache.syncope.common.lib.to.AnyObjectTO) AnyPropagationTasks(org.apache.syncope.client.console.tasks.AnyPropagationTasks) AnyObjectRestClient(org.apache.syncope.client.console.rest.AnyObjectRestClient) StringResourceModel(org.apache.wicket.model.StringResourceModel) ActionLink(org.apache.syncope.client.console.wicket.markup.html.form.ActionLink)

Example 2 with CompoundPropertyModel

use of org.apache.wicket.model.CompoundPropertyModel in project syncope by apache.

the class ApprovalDirectoryPanel method getActions.

@Override
public ActionsPanel<WorkflowFormTO> getActions(final IModel<WorkflowFormTO> model) {
    final ActionsPanel<WorkflowFormTO> panel = super.getActions(model);
    panel.add(new ActionLink<WorkflowFormTO>() {

        private static final long serialVersionUID = -3722207913631435501L;

        @Override
        public void onClick(final AjaxRequestTarget target, final WorkflowFormTO ignore) {
            claimForm(model.getObject().getTaskId());
            SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
            target.add(container);
        }
    }, ActionLink.ActionType.CLAIM, StandardEntitlement.WORKFLOW_FORM_CLAIM);
    panel.add(new ActionLink<WorkflowFormTO>() {

        private static final long serialVersionUID = -3722207913631435501L;

        @Override
        public void onClick(final AjaxRequestTarget target, final WorkflowFormTO ignore) {
            manageApprovalModal.setFormModel(new CompoundPropertyModel<>(model.getObject()));
            target.add(manageApprovalModal.setContent(new ApprovalModal(manageApprovalModal, pageRef, model.getObject()) {

                private static final long serialVersionUID = 5546519445061007248L;

                @Override
                public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
                    try {
                        super.onSubmit(target, form);
                        ApprovalDirectoryPanel.this.getTogglePanel().close(target);
                    } catch (SyncopeClientException e) {
                        SyncopeConsoleSession.get().error(getString(Constants.ERROR) + ": " + e.getMessage());
                    }
                    ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
                }
            }));
            manageApprovalModal.header(new Model<>(getString("approval.manage", new Model<>(model.getObject()))));
            manageApprovalModal.show(true);
        }

        @Override
        protected boolean statusCondition(final WorkflowFormTO modelObject) {
            return SyncopeConsoleSession.get().getSelfTO().getUsername().equals(model.getObject().getOwner());
        }
    }, ActionLink.ActionType.MANAGE_APPROVAL, StandardEntitlement.WORKFLOW_FORM_READ);
    // SYNCOPE-1200 edit user while in approval state
    panel.add(new ActionLink<WorkflowFormTO>() {

        private static final long serialVersionUID = -3722207913631435501L;

        @Override
        public void onClick(final AjaxRequestTarget target, final WorkflowFormTO ignore) {
            modal.setFormModel(new CompoundPropertyModel<>(model.getObject()));
            WorkflowFormTO formTO = model.getObject();
            UserTO newUserTO;
            UserTO previousUserTO;
            if (formTO.getUserPatch() == null) {
                newUserTO = formTO.getUserTO();
                previousUserTO = null;
            } else if (formTO.getUserTO() == null) {
                // make it stronger by handling possible NPE
                previousUserTO = new UserTO();
                previousUserTO.setKey(formTO.getUserPatch().getKey());
                newUserTO = AnyOperations.patch(previousUserTO, formTO.getUserPatch());
            } else {
                previousUserTO = formTO.getUserTO();
                formTO.getUserTO().setKey(formTO.getUserPatch().getKey());
                formTO.getUserTO().setPassword(null);
                newUserTO = AnyOperations.patch(formTO.getUserTO(), formTO.getUserPatch());
            }
            AjaxWizard.EditItemActionEvent<UserTO> editItemActionEvent = new AjaxWizard.EditItemActionEvent<>(newUserTO, target);
            editItemActionEvent.forceModalPanel(new ApprovalUserWizardBuilder(model.getObject(), previousUserTO, newUserTO, new AnyTypeRestClient().read(AnyTypeKind.USER.name()).getClasses(), FormLayoutInfoUtils.fetch(Collections.singletonList(AnyTypeKind.USER.name())).getLeft(), pageRef).build(BaseModal.CONTENT_ID, AjaxWizard.Mode.EDIT));
            send(ApprovalDirectoryPanel.this, Broadcast.EXACT, editItemActionEvent);
        }

        @Override
        protected boolean statusCondition(final WorkflowFormTO modelObject) {
            return SyncopeConsoleSession.get().getSelfTO().getUsername().equals(model.getObject().getOwner());
        }
    }, ActionLink.ActionType.EDIT_APPROVAL, StandardEntitlement.WORKFLOW_FORM_SUBMIT);
    return panel;
}
Also used : CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) AjaxWizard(org.apache.syncope.client.console.wizards.AjaxWizard) AnyTypeRestClient(org.apache.syncope.client.console.rest.AnyTypeRestClient) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) WorkflowFormTO(org.apache.syncope.common.lib.to.WorkflowFormTO) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) UserTO(org.apache.syncope.common.lib.to.UserTO) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) ResourceModel(org.apache.wicket.model.ResourceModel) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) BasePage(org.apache.syncope.client.console.pages.BasePage)

Example 3 with CompoundPropertyModel

use of org.apache.wicket.model.CompoundPropertyModel in project syncope by apache.

the class TopologyTogglePanel method getResourceFragment.

private Fragment getResourceFragment(final TopologyNode node, final PageReference pageRef) {
    Fragment fragment = new Fragment("actions", "resourceActions", this);
    AjaxLink<String> delete = new IndicatingOnConfirmAjaxLink<String>("delete", true) {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            try {
                resourceRestClient.delete(node.getKey());
                target.appendJavaScript(String.format("jsPlumb.remove('%s');", node.getKey()));
                SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                toggle(target, false);
            } catch (SyncopeClientException e) {
                LOG.error("While deleting resource {}", node.getKey(), e);
                SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
            }
            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(delete, RENDER, StandardEntitlement.RESOURCE_DELETE);
    fragment.add(delete);
    AjaxLink<String> edit = new IndicatingAjaxLink<String>("edit") {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            ResourceTO resource = resourceRestClient.read(node.getKey());
            ConnInstanceTO connInstance = connectorRestClient.read(resource.getConnector());
            IModel<ResourceTO> model = new CompoundPropertyModel<>(resource);
            modal.setFormModel(model);
            target.add(modal.setContent(new ResourceWizardBuilder(resource, pageRef).build(BaseModal.CONTENT_ID, SyncopeConsoleSession.get().owns(StandardEntitlement.RESOURCE_UPDATE, connInstance.getAdminRealm()) ? AjaxWizard.Mode.EDIT : AjaxWizard.Mode.READONLY)));
            modal.header(new Model<>(MessageFormat.format(getString("resource.edit"), node.getKey())));
            modal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(edit, RENDER, StandardEntitlement.RESOURCE_READ);
    fragment.add(edit);
    AjaxLink<String> status = new IndicatingAjaxLink<String>("status") {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            ResourceTO modelObject = resourceRestClient.read(node.getKey());
            target.add(propTaskModal.setContent(new ResourceStatusModal(propTaskModal, pageRef, modelObject)));
            propTaskModal.header(new Model<>(MessageFormat.format(getString("resource.provisioning.status"), node.getKey())));
            propTaskModal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(status, RENDER, StandardEntitlement.USER_UPDATE);
    fragment.add(status);
    AjaxLink<String> provision = new IndicatingAjaxLink<String>("provision") {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            ResourceTO resource = resourceRestClient.read(node.getKey());
            ConnInstanceTO connInstance = connectorRestClient.read(resource.getConnector());
            if (SyncopeConsoleSession.get().owns(StandardEntitlement.RESOURCE_UPDATE, connInstance.getAdminRealm())) {
                provisionModal.addSubmitButton();
            } else {
                provisionModal.removeSubmitButton();
            }
            IModel<ResourceTO> model = new CompoundPropertyModel<>(resource);
            provisionModal.setFormModel(model);
            target.add(provisionModal.setContent(new ResourceProvisionPanel(provisionModal, resource, connInstance.getAdminRealm(), pageRef)));
            provisionModal.header(new Model<>(MessageFormat.format(getString("resource.edit"), node.getKey())));
            provisionModal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(edit, RENDER, StandardEntitlement.RESOURCE_READ);
    fragment.add(provision);
    AjaxLink<String> explore = new IndicatingAjaxLink<String>("explore") {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            ResourceTO resource = resourceRestClient.read(node.getKey());
            target.add(propTaskModal.setContent(new ConnObjects(resource, pageRef)));
            propTaskModal.header(new StringResourceModel("resource.explore.list", Model.of(node)));
            propTaskModal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(explore, RENDER, StandardEntitlement.RESOURCE_LIST_CONNOBJECT);
    fragment.add(explore);
    AjaxLink<String> propagation = new IndicatingAjaxLink<String>("propagation") {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        @SuppressWarnings("unchecked")
        public void onClick(final AjaxRequestTarget target) {
            target.add(propTaskModal.setContent(new PropagationTasks(propTaskModal, node.getKey(), pageRef)));
            propTaskModal.header(new Model<>(MessageFormat.format(getString("task.propagation.list"), node.getKey())));
            propTaskModal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(propagation, RENDER, StandardEntitlement.TASK_LIST);
    fragment.add(propagation);
    AjaxLink<String> pull = new IndicatingAjaxLink<String>("pull") {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            target.add(schedTaskModal.setContent(new PullTasks(schedTaskModal, pageRef, node.getKey())));
            schedTaskModal.header(new Model<>(MessageFormat.format(getString("task.pull.list"), node.getKey())));
            schedTaskModal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(pull, RENDER, StandardEntitlement.TASK_LIST);
    fragment.add(pull);
    AjaxLink<String> push = new IndicatingAjaxLink<String>("push") {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            target.add(schedTaskModal.setContent(new PushTasks(schedTaskModal, pageRef, node.getKey())));
            schedTaskModal.header(new Model<>(MessageFormat.format(getString("task.push.list"), node.getKey())));
            schedTaskModal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(push, RENDER, StandardEntitlement.TASK_LIST);
    fragment.add(push);
    AjaxLink<String> history = new IndicatingAjaxLink<String>("history") {

        private static final long serialVersionUID = -1876519166660008562L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            String resourceKey = String.class.cast(node.getKey());
            final ResourceTO modelObject = resourceRestClient.read(String.class.cast(node.getKey()));
            target.add(historyModal.setContent(new HistoryConfList<>(historyModal, resourceKey, pageRef, modelObject)));
            historyModal.header(new Model<>(MessageFormat.format(getString("resource.menu.history"), node.getDisplayName())));
            historyModal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(history, RENDER, StandardEntitlement.RESOURCE_HISTORY_LIST);
    fragment.add(history);
    // [SYNCOPE-1161] - Option to clone a resource
    AjaxLink<String> clone = new IndicatingOnConfirmAjaxLink<String>("clone", "confirmClone", true) {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            try {
                ResourceTO resource = resourceRestClient.read(node.getKey());
                resource.setKey("Copy of " + resource.getKey());
                // reset some resource objects keys
                if (resource.getOrgUnit() != null) {
                    resource.getOrgUnit().setKey(null);
                    for (ItemTO item : resource.getOrgUnit().getItems()) {
                        item.setKey(null);
                    }
                }
                for (ProvisionTO provision : resource.getProvisions()) {
                    provision.setKey(null);
                    if (provision.getMapping() != null) {
                        for (ItemTO item : provision.getMapping().getItems()) {
                            item.setKey(null);
                        }
                        provision.getMapping().getLinkingItems().clear();
                    }
                    provision.getVirSchemas().clear();
                }
                resourceRestClient.create(resource);
                // refresh Topology
                send(pageRef.getPage(), Broadcast.DEPTH, new AbstractResourceWizardBuilder.CreateEvent(resource.getKey(), resource.getKey(), TopologyNode.Kind.RESOURCE, resource.getConnector(), target));
                SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                toggle(target, false);
            } catch (SyncopeClientException e) {
                LOG.error("While cloning resource {}", node.getKey(), e);
                SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
            }
            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(clone, RENDER, StandardEntitlement.RESOURCE_CREATE);
    fragment.add(clone);
    return fragment;
}
Also used : ConnObjects(org.apache.syncope.client.console.panels.ConnObjects) ResourceProvisionPanel(org.apache.syncope.client.console.wizards.resources.ResourceProvisionPanel) HistoryConfList(org.apache.syncope.client.console.panels.HistoryConfList) ResourceStatusModal(org.apache.syncope.client.console.status.ResourceStatusModal) PushTasks(org.apache.syncope.client.console.tasks.PushTasks) Fragment(org.apache.wicket.markup.html.panel.Fragment) ItemTO(org.apache.syncope.common.lib.to.ItemTO) IndicatingAjaxLink(org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink) AbstractResourceWizardBuilder(org.apache.syncope.client.console.wizards.resources.AbstractResourceWizardBuilder) ResourceWizardBuilder(org.apache.syncope.client.console.wizards.resources.ResourceWizardBuilder) StringResourceModel(org.apache.wicket.model.StringResourceModel) PropagationTasks(org.apache.syncope.client.console.tasks.PropagationTasks) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) IndicatingOnConfirmAjaxLink(org.apache.syncope.client.console.wicket.markup.html.form.IndicatingOnConfirmAjaxLink) AbstractResourceWizardBuilder(org.apache.syncope.client.console.wizards.resources.AbstractResourceWizardBuilder) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) PullTasks(org.apache.syncope.client.console.tasks.PullTasks) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) ProvisionTO(org.apache.syncope.common.lib.to.ProvisionTO)

Example 4 with CompoundPropertyModel

use of org.apache.wicket.model.CompoundPropertyModel in project syncope by apache.

the class TopologyTogglePanel method getConnectorFragment.

private Fragment getConnectorFragment(final TopologyNode node, final PageReference pageRef) {
    Fragment fragment = new Fragment("actions", "connectorActions", this);
    AjaxLink<String> delete = new IndicatingOnConfirmAjaxLink<String>("delete", true) {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            try {
                connectorRestClient.delete(String.class.cast(node.getKey()));
                target.appendJavaScript(String.format("jsPlumb.remove('%s');", node.getKey()));
                SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                toggle(target, false);
            } catch (SyncopeClientException e) {
                LOG.error("While deleting resource {}", node.getKey(), e);
                SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
            }
            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(delete, RENDER, StandardEntitlement.CONNECTOR_DELETE);
    fragment.add(delete);
    AjaxLink<String> create = new IndicatingAjaxLink<String>("create") {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            final ResourceTO modelObject = new ResourceTO();
            modelObject.setConnector(String.class.cast(node.getKey()));
            modelObject.setConnectorDisplayName(node.getDisplayName());
            final IModel<ResourceTO> model = new CompoundPropertyModel<>(modelObject);
            modal.setFormModel(model);
            target.add(modal.setContent(new ResourceWizardBuilder(modelObject, pageRef).build(BaseModal.CONTENT_ID, AjaxWizard.Mode.CREATE)));
            modal.header(new Model<>(MessageFormat.format(getString("resource.new"), node.getKey())));
            modal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(create, RENDER, StandardEntitlement.RESOURCE_CREATE);
    fragment.add(create);
    AjaxLink<String> edit = new IndicatingAjaxLink<String>("edit") {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            ConnInstanceTO connInstance = connectorRestClient.read(String.class.cast(node.getKey()));
            final IModel<ConnInstanceTO> model = new CompoundPropertyModel<>(connInstance);
            modal.setFormModel(model);
            target.add(modal.setContent(new ConnectorWizardBuilder(connInstance, pageRef).build(BaseModal.CONTENT_ID, SyncopeConsoleSession.get().owns(StandardEntitlement.CONNECTOR_UPDATE, connInstance.getAdminRealm()) ? AjaxWizard.Mode.EDIT : AjaxWizard.Mode.READONLY)));
            modal.header(new Model<>(MessageFormat.format(getString("connector.edit"), connInstance.getDisplayName())));
            modal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(edit, RENDER, StandardEntitlement.CONNECTOR_READ);
    fragment.add(edit);
    AjaxLink<String> history = new IndicatingAjaxLink<String>("history") {

        private static final long serialVersionUID = -1876519166660008562L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            String connKey = String.class.cast(node.getKey());
            ConnInstanceTO connInstance = connectorRestClient.read(connKey);
            target.add(historyModal.setContent(new HistoryConfList<>(historyModal, connKey, pageRef, connInstance)));
            historyModal.header(new Model<>(MessageFormat.format(getString("connector.menu.history"), node.getDisplayName())));
            historyModal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    MetaDataRoleAuthorizationStrategy.authorize(history, RENDER, StandardEntitlement.CONNECTOR_HISTORY_LIST);
    fragment.add(history);
    return fragment;
}
Also used : HistoryConfList(org.apache.syncope.client.console.panels.HistoryConfList) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) IndicatingOnConfirmAjaxLink(org.apache.syncope.client.console.wicket.markup.html.form.IndicatingOnConfirmAjaxLink) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Fragment(org.apache.wicket.markup.html.panel.Fragment) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ConnectorWizardBuilder(org.apache.syncope.client.console.wizards.resources.ConnectorWizardBuilder) IndicatingAjaxLink(org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) AbstractResourceWizardBuilder(org.apache.syncope.client.console.wizards.resources.AbstractResourceWizardBuilder) ResourceWizardBuilder(org.apache.syncope.client.console.wizards.resources.ResourceWizardBuilder) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO)

Example 5 with CompoundPropertyModel

use of org.apache.wicket.model.CompoundPropertyModel in project syncope by apache.

the class TopologyTogglePanel method getLocationFragment.

private Fragment getLocationFragment(final TopologyNode node, final PageReference pageRef) {
    Fragment fragment = new Fragment("actions", "locationActions", this);
    AjaxLink<String> create = new IndicatingAjaxLink<String>("create") {

        private static final long serialVersionUID = 3776750333491622263L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            final ConnInstanceTO modelObject = new ConnInstanceTO();
            modelObject.setLocation(node.getKey());
            final IModel<ConnInstanceTO> model = new CompoundPropertyModel<>(modelObject);
            modal.setFormModel(model);
            target.add(modal.setContent(new ConnectorWizardBuilder(modelObject, pageRef).build(BaseModal.CONTENT_ID, AjaxWizard.Mode.CREATE)));
            modal.header(new Model<>(MessageFormat.format(getString("connector.new"), node.getKey())));
            modal.show(true);
        }

        @Override
        public String getAjaxIndicatorMarkupId() {
            return Constants.VEIL_INDICATOR_MARKUP_ID;
        }
    };
    fragment.add(create);
    MetaDataRoleAuthorizationStrategy.authorize(create, RENDER, StandardEntitlement.CONNECTOR_CREATE);
    return fragment;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) ConnectorWizardBuilder(org.apache.syncope.client.console.wizards.resources.ConnectorWizardBuilder) IndicatingAjaxLink(org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) Fragment(org.apache.wicket.markup.html.panel.Fragment)

Aggregations

CompoundPropertyModel (org.apache.wicket.model.CompoundPropertyModel)17 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)12 ArrayList (java.util.ArrayList)7 Form (org.apache.wicket.markup.html.form.Form)7 AjaxWizard (org.apache.syncope.client.console.wizards.AjaxWizard)5 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)5 StringResourceModel (org.apache.wicket.model.StringResourceModel)5 GitBlitException (com.gitblit.GitBlitException)4 SimpleAttributeModifier (org.apache.wicket.behavior.SimpleAttributeModifier)4 Button (org.apache.wicket.markup.html.form.Button)4 RegistrantAccessPermission (com.gitblit.models.RegistrantAccessPermission)3 StringChoiceRenderer (com.gitblit.wicket.StringChoiceRenderer)3 RegistrantPermissionsPanel (com.gitblit.wicket.panels.RegistrantPermissionsPanel)3 ConnInstanceTO (org.apache.syncope.common.lib.to.ConnInstanceTO)3 IndicatingAjaxLink (org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink)3 Label (org.apache.wicket.markup.html.basic.Label)3 Fragment (org.apache.wicket.markup.html.panel.Fragment)3 PropertyModel (org.apache.wicket.model.PropertyModel)3 RepositoryModel (com.gitblit.models.RepositoryModel)2 TeamModel (com.gitblit.models.TeamModel)2