Search in sources :

Example 1 with AnyTypeRestClient

use of org.apache.syncope.client.console.rest.AnyTypeRestClient 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 2 with AnyTypeRestClient

use of org.apache.syncope.client.console.rest.AnyTypeRestClient in project syncope by apache.

the class SAML2IdPsDirectoryPanel method getActions.

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

        private static final long serialVersionUID = -7978723352517770645L;

        @Override
        public void onClick(final AjaxRequestTarget target, final SAML2IdPTO ignore) {
            SAML2IdPTO object = restClient.read(model.getObject().getKey());
            metadataModal.header(Model.of(object.getName() + " - Metadata"));
            metadataModal.setContent(new XMLEditorPanel(metadataModal, Model.of(new String(Base64.decodeBase64(object.getMetadata()))), true, pageRef));
            metadataModal.show(true);
            target.add(metadataModal);
        }
    }, ActionLink.ActionType.HTML, SAML2SPEntitlement.IDP_READ);
    panel.add(new ActionLink<SAML2IdPTO>() {

        private static final long serialVersionUID = -3722207913631435501L;

        @Override
        public void onClick(final AjaxRequestTarget target, final SAML2IdPTO ignore) {
            SAML2IdPTO object = restClient.read(model.getObject().getKey());
            send(SAML2IdPsDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<>(object, target));
        }
    }, ActionLink.ActionType.EDIT, SAML2SPEntitlement.IDP_UPDATE);
    panel.add(new ActionLink<SAML2IdPTO>() {

        private static final long serialVersionUID = -3722207913631435501L;

        @Override
        public void onClick(final AjaxRequestTarget target, final SAML2IdPTO ignore) {
            final SAML2IdPTO object = restClient.read(model.getObject().getKey());
            UserTemplateWizardBuilder builder = new UserTemplateWizardBuilder(object.getUserTemplate(), new AnyTypeRestClient().read(AnyTypeKind.USER.name()).getClasses(), new UserFormLayoutInfo(), pageRef) {

                private static final long serialVersionUID = -7978723352517770634L;

                @Override
                protected Serializable onApplyInternal(final AnyWrapper<UserTO> modelObject) {
                    object.setUserTemplate(modelObject.getInnerObject());
                    restClient.update(object);
                    return modelObject;
                }
            };
            templateModal.header(Model.of(StringUtils.capitalize(new StringResourceModel("template.title", SAML2IdPsDirectoryPanel.this).getString())));
            templateModal.setContent(builder.build(BaseModal.CONTENT_ID));
            templateModal.show(true);
            target.add(templateModal);
        }
    }, ActionLink.ActionType.TEMPLATE, SAML2SPEntitlement.IDP_UPDATE);
    panel.add(new ActionLink<SAML2IdPTO>() {

        private static final long serialVersionUID = -5467832321897812767L;

        @Override
        public void onClick(final AjaxRequestTarget target, final SAML2IdPTO ignore) {
            try {
                restClient.delete(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);
        }
    }, ActionLink.ActionType.DELETE, SAML2SPEntitlement.IDP_DELETE, true);
    return panel;
}
Also used : SAML2IdPTO(org.apache.syncope.common.lib.to.SAML2IdPTO) XMLEditorPanel(org.apache.syncope.client.console.wicket.markup.html.form.XMLEditorPanel) Serializable(java.io.Serializable) AnyTypeRestClient(org.apache.syncope.client.console.rest.AnyTypeRestClient) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) UserTemplateWizardBuilder(org.apache.syncope.client.console.wizards.any.UserTemplateWizardBuilder) UserTO(org.apache.syncope.common.lib.to.UserTO) UserFormLayoutInfo(org.apache.syncope.client.console.layout.UserFormLayoutInfo) BasePage(org.apache.syncope.client.console.pages.BasePage) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Example 3 with AnyTypeRestClient

use of org.apache.syncope.client.console.rest.AnyTypeRestClient in project syncope by apache.

the class ProvisionAuxClassesPanel method onBeforeRender.

@Override
protected void onBeforeRender() {
    super.onBeforeRender();
    IModel<List<String>> model;
    List<String> choices;
    if (provision == null) {
        model = new ListModel<>(Collections.<String>emptyList());
        choices = Collections.emptyList();
    } else {
        model = new PropertyModel<>(provision, "auxClasses");
        choices = new ArrayList<>();
        AnyTypeTO anyType = null;
        try {
            anyType = new AnyTypeRestClient().read(provision.getAnyType());
        } catch (Exception e) {
            LOG.error("Could not read AnyType {}", provision.getAnyType(), e);
        }
        if (anyType != null) {
            for (AnyTypeClassTO aux : new AnyTypeClassRestClient().list()) {
                if (!anyType.getClasses().contains(aux.getKey())) {
                    choices.add(aux.getKey());
                }
            }
        }
    }
    addOrReplace(new AjaxPalettePanel.Builder<String>().build("auxClasses", model, new ListModel<>(choices)).hideLabel().setOutputMarkupId(true).setEnabled(provision != null));
}
Also used : AjaxPalettePanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxPalettePanel) AnyTypeRestClient(org.apache.syncope.client.console.rest.AnyTypeRestClient) AnyTypeTO(org.apache.syncope.common.lib.to.AnyTypeTO) ArrayList(java.util.ArrayList) List(java.util.List) AnyTypeClassTO(org.apache.syncope.common.lib.to.AnyTypeClassTO) AnyTypeClassRestClient(org.apache.syncope.client.console.rest.AnyTypeClassRestClient)

Example 4 with AnyTypeRestClient

use of org.apache.syncope.client.console.rest.AnyTypeRestClient in project syncope by apache.

the class RemediationDirectoryPanel method getActions.

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

        private static final long serialVersionUID = 6193210574968203299L;

        @Override
        public void onClick(final AjaxRequestTarget target, final RemediationTO ignore) {
            modal.header(new ResourceModel("error"));
            modal.setContent(new ExecMessageModal(model.getObject().getError()));
            modal.show(true);
            target.add(modal);
        }
    }, ActionLink.ActionType.VIEW_DETAILS, StandardEntitlement.REMEDIATION_READ);
    if (model.getObject().getOperation() == ResourceOperation.DELETE) {
        String entitlements = StringUtils.join(new String[] { StandardEntitlement.REMEDIATION_REMEDY, AnyTypeKind.USER.name().equals(model.getObject().getAnyType()) ? StandardEntitlement.USER_DELETE : AnyTypeKind.GROUP.name().equals(model.getObject().getAnyType()) ? StandardEntitlement.GROUP_DELETE : AnyEntitlement.DELETE.getFor(model.getObject().getAnyType()) }, ",");
        panel.add(new ActionLink<RemediationTO>() {

            private static final long serialVersionUID = 6193210574968203299L;

            @Override
            public void onClick(final AjaxRequestTarget target, final RemediationTO ignore) {
                try {
                    restClient.remedy(model.getObject().getKey(), model.getObject().getKeyPayload());
                    SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                    target.add(container);
                } catch (SyncopeClientException e) {
                    LOG.error("While performing remediation {}", model.getObject().getKey(), e);
                    SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
                }
                ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
            }
        }, ActionLink.ActionType.CLOSE, entitlements, true);
    } else {
        String entitlements = model.getObject().getOperation() == ResourceOperation.CREATE ? StringUtils.join(new String[] { StandardEntitlement.REMEDIATION_REMEDY, AnyTypeKind.USER.name().equals(model.getObject().getAnyType()) ? StandardEntitlement.USER_CREATE : AnyTypeKind.GROUP.name().equals(model.getObject().getAnyType()) ? StandardEntitlement.GROUP_CREATE : AnyEntitlement.CREATE.getFor(model.getObject().getAnyType()) }, ",") : StringUtils.join(new String[] { StandardEntitlement.REMEDIATION_REMEDY, AnyTypeKind.USER.name().equals(model.getObject().getAnyType()) ? StandardEntitlement.USER_UPDATE : AnyTypeKind.GROUP.name().equals(model.getObject().getAnyType()) ? StandardEntitlement.GROUP_UPDATE : AnyEntitlement.UPDATE.getFor(model.getObject().getAnyType()) }, ",");
        panel.add(new ActionLink<RemediationTO>() {

            private static final long serialVersionUID = 6193210574968203299L;

            @Override
            public void onClick(final AjaxRequestTarget target, final RemediationTO ignore) {
                modal.setFormModel(new CompoundPropertyModel<>(model.getObject()));
                RemediationTO remediationTO = model.getObject();
                switch(remediationTO.getAnyType()) {
                    case "USER":
                        UserTO newUserTO;
                        UserTO previousUserTO;
                        if (remediationTO.getAnyPatchPayload() == null) {
                            newUserTO = (UserTO) remediationTO.getAnyTOPayload();
                            previousUserTO = null;
                        } else {
                            previousUserTO = new UserRestClient().read(remediationTO.getAnyPatchPayload().getKey());
                            newUserTO = AnyOperations.patch(previousUserTO, (UserPatch) remediationTO.getAnyPatchPayload());
                        }
                        AjaxWizard.EditItemActionEvent<UserTO> userEvent = new AjaxWizard.EditItemActionEvent<>(newUserTO, target);
                        userEvent.forceModalPanel(new RemediationUserWizardBuilder(model.getObject(), previousUserTO, newUserTO, new AnyTypeRestClient().read(remediationTO.getAnyType()).getClasses(), FormLayoutInfoUtils.fetch(Arrays.asList(remediationTO.getAnyType())).getLeft(), pageRef).build(BaseModal.CONTENT_ID, AjaxWizard.Mode.EDIT));
                        send(RemediationDirectoryPanel.this, Broadcast.EXACT, userEvent);
                        break;
                    case "GROUP":
                        GroupTO newGroupTO;
                        GroupTO previousGroupTO;
                        if (remediationTO.getAnyPatchPayload() == null) {
                            newGroupTO = (GroupTO) remediationTO.getAnyTOPayload();
                            previousGroupTO = null;
                        } else {
                            previousGroupTO = new GroupRestClient().read(remediationTO.getAnyPatchPayload().getKey());
                            newGroupTO = AnyOperations.patch(previousGroupTO, (GroupPatch) remediationTO.getAnyPatchPayload());
                        }
                        AjaxWizard.EditItemActionEvent<GroupTO> groupEvent = new AjaxWizard.EditItemActionEvent<>(newGroupTO, target);
                        groupEvent.forceModalPanel(new RemediationGroupWizardBuilder(model.getObject(), previousGroupTO, newGroupTO, new AnyTypeRestClient().read(remediationTO.getAnyType()).getClasses(), FormLayoutInfoUtils.fetch(Arrays.asList(remediationTO.getAnyType())).getMiddle(), pageRef).build(BaseModal.CONTENT_ID, AjaxWizard.Mode.EDIT));
                        send(RemediationDirectoryPanel.this, Broadcast.EXACT, groupEvent);
                        break;
                    default:
                        AnyObjectTO newAnyObjectTO;
                        AnyObjectTO previousAnyObjectTO;
                        if (remediationTO.getAnyPatchPayload() == null) {
                            newAnyObjectTO = (AnyObjectTO) remediationTO.getAnyTOPayload();
                            previousAnyObjectTO = null;
                        } else {
                            previousAnyObjectTO = new AnyObjectRestClient().read(remediationTO.getAnyPatchPayload().getKey());
                            newAnyObjectTO = AnyOperations.patch(previousAnyObjectTO, (AnyObjectPatch) remediationTO.getAnyPatchPayload());
                        }
                        AjaxWizard.EditItemActionEvent<AnyObjectTO> anyObjectEvent = new AjaxWizard.EditItemActionEvent<>(newAnyObjectTO, target);
                        anyObjectEvent.forceModalPanel(new RemediationAnyObjectWizardBuilder(model.getObject(), previousAnyObjectTO, newAnyObjectTO, new AnyTypeRestClient().read(remediationTO.getAnyType()).getClasses(), FormLayoutInfoUtils.fetch(Arrays.asList(remediationTO.getAnyType())).getRight().values().iterator().next(), pageRef).build(BaseModal.CONTENT_ID, AjaxWizard.Mode.EDIT));
                        send(RemediationDirectoryPanel.this, Broadcast.EXACT, anyObjectEvent);
                }
            }
        }, ActionLink.ActionType.EDIT, entitlements);
    }
    panel.add(new ActionLink<RemediationTO>() {

        private static final long serialVersionUID = 6193210574968203299L;

        @Override
        public void onClick(final AjaxRequestTarget target, final RemediationTO ignore) {
            try {
                restClient.delete(model.getObject().getKey());
                SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                target.add(container);
            } catch (SyncopeClientException e) {
                LOG.error("While deleting {}", model.getObject().getKey(), e);
                SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
            }
            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
        }
    }, ActionLink.ActionType.DELETE, StandardEntitlement.REMEDIATION_DELETE, true);
    return panel;
}
Also used : AnyObjectTO(org.apache.syncope.common.lib.to.AnyObjectTO) ResourceModel(org.apache.wicket.model.ResourceModel) StringResourceModel(org.apache.wicket.model.StringResourceModel) GroupRestClient(org.apache.syncope.client.console.rest.GroupRestClient) AnyObjectRestClient(org.apache.syncope.client.console.rest.AnyObjectRestClient) BasePage(org.apache.syncope.client.console.pages.BasePage) 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) RemediationTO(org.apache.syncope.common.lib.to.RemediationTO) UserRestClient(org.apache.syncope.client.console.rest.UserRestClient) GroupTO(org.apache.syncope.common.lib.to.GroupTO) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) UserTO(org.apache.syncope.common.lib.to.UserTO)

Example 5 with AnyTypeRestClient

use of org.apache.syncope.client.console.rest.AnyTypeRestClient in project syncope by apache.

the class RoleDirectoryPanel method getActions.

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

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
            send(RoleDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<>(new RoleWrapper(new RoleRestClient().read(model.getObject().getKey())), target));
        }
    }, ActionLink.ActionType.EDIT, StandardEntitlement.ROLE_READ);
    panel.add(new ActionLink<RoleTO>() {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
            final RoleTO clone = SerializationUtils.clone(model.getObject());
            clone.setKey(null);
            send(RoleDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.NewItemActionEvent<>(new RoleWrapper(clone), target));
        }
    }, ActionLink.ActionType.CLONE, StandardEntitlement.ROLE_CREATE);
    panel.add(new ActionLink<RoleTO>() {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
            final String query = SyncopeClient.getUserSearchConditionBuilder().and(SyncopeClient.getUserSearchConditionBuilder().inRoles(model.getObject().getKey()), SyncopeClient.getUserSearchConditionBuilder().is("key").notNullValue()).query();
            final AnyTypeRestClient typeRestClient = new AnyTypeRestClient();
            final AnyTypeClassRestClient classRestClient = new AnyTypeClassRestClient();
            final AnyTypeTO anyTypeTO = typeRestClient.read(AnyTypeKind.USER.name());
            ModalPanel panel = new AnyPanel(BaseModal.CONTENT_ID, anyTypeTO, null, null, false, pageRef) {

                private static final long serialVersionUID = -7514498203393023415L;

                @Override
                protected Panel getDirectoryPanel(final String id) {
                    final Panel panel = new UserDirectoryPanel.Builder(classRestClient.list(anyTypeTO.getClasses()), anyTypeTO.getKey(), pageRef).setRealm("/").setFiltered(true).setFiql(query).disableCheckBoxes().addNewItemPanelBuilder(FormLayoutInfoUtils.instantiate(new UserTO(), anyTypeTO.getClasses(), FormLayoutInfoUtils.fetch(typeRestClient.list()).getLeft(), pageRef), false).setWizardInModal(false).build(id);
                    MetaDataRoleAuthorizationStrategy.authorize(panel, WebPage.RENDER, StandardEntitlement.USER_SEARCH);
                    return panel;
                }
            };
            membersModal.header(new StringResourceModel("role.members", RoleDirectoryPanel.this, model));
            membersModal.setContent(panel);
            membersModal.show(true);
            target.add(membersModal);
        }
    }, ActionLink.ActionType.MEMBERS, StandardEntitlement.USER_SEARCH);
    panel.add(new ActionLink<RoleTO>() {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
            final ConsoleLayoutInfo info = new ConsoleLayoutInfo(model.getObject().getKey());
            info.setContent(restClient.readConsoleLayoutInfo(model.getObject().getKey()));
            utilityModal.header(new ResourceModel("console.layout.info", "JSON Content"));
            utilityModal.setContent(new JsonEditorPanel(utilityModal, new PropertyModel<String>(info, "content"), false, pageRef) {

                private static final long serialVersionUID = -8927036362466990179L;

                @Override
                public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
                    try {
                        restClient.setConsoleLayoutInfo(info.getKey(), info.getContent());
                        SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                        modal.show(false);
                        modal.close(target);
                    } catch (Exception e) {
                        LOG.error("While updating console layout info for role {}", info.getKey(), e);
                        SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
                    }
                    ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
                }
            });
            utilityModal.show(true);
            target.add(utilityModal);
        }
    }, ActionLink.ActionType.LAYOUT_EDIT, StandardEntitlement.ROLE_UPDATE);
    panel.add(new ActionLink<RoleTO>() {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
            try {
                restClient.delete(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);
        }
    }, ActionLink.ActionType.DELETE, StandardEntitlement.ROLE_DELETE, true);
    return panel;
}
Also used : Form(org.apache.wicket.markup.html.form.Form) AnyTypeTO(org.apache.syncope.common.lib.to.AnyTypeTO) RoleRestClient(org.apache.syncope.client.console.rest.RoleRestClient) ConsoleLayoutInfo(org.apache.syncope.client.console.layout.ConsoleLayoutInfo) StringResourceModel(org.apache.wicket.model.StringResourceModel) ResourceModel(org.apache.wicket.model.ResourceModel) AnyTypeClassRestClient(org.apache.syncope.client.console.rest.AnyTypeClassRestClient) BasePage(org.apache.syncope.client.console.pages.BasePage) StringResourceModel(org.apache.wicket.model.StringResourceModel) AnyTypeRestClient(org.apache.syncope.client.console.rest.AnyTypeRestClient) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) RoleTO(org.apache.syncope.common.lib.to.RoleTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ActionsPanel(org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel) JsonEditorPanel(org.apache.syncope.client.console.wicket.markup.html.form.JsonEditorPanel) Panel(org.apache.wicket.markup.html.panel.Panel) WizardMgtPanel(org.apache.syncope.client.console.wizards.WizardMgtPanel) UserTO(org.apache.syncope.common.lib.to.UserTO) RoleWrapper(org.apache.syncope.client.console.wizards.role.RoleWrapper) JsonEditorPanel(org.apache.syncope.client.console.wicket.markup.html.form.JsonEditorPanel)

Aggregations

AnyTypeRestClient (org.apache.syncope.client.console.rest.AnyTypeRestClient)5 BasePage (org.apache.syncope.client.console.pages.BasePage)4 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)4 UserTO (org.apache.syncope.common.lib.to.UserTO)4 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)4 ResourceModel (org.apache.wicket.model.ResourceModel)3 StringResourceModel (org.apache.wicket.model.StringResourceModel)3 AnyTypeClassRestClient (org.apache.syncope.client.console.rest.AnyTypeClassRestClient)2 AjaxWizard (org.apache.syncope.client.console.wizards.AjaxWizard)2 AnyTypeTO (org.apache.syncope.common.lib.to.AnyTypeTO)2 CompoundPropertyModel (org.apache.wicket.model.CompoundPropertyModel)2 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ConsoleLayoutInfo (org.apache.syncope.client.console.layout.ConsoleLayoutInfo)1 UserFormLayoutInfo (org.apache.syncope.client.console.layout.UserFormLayoutInfo)1 AnyObjectRestClient (org.apache.syncope.client.console.rest.AnyObjectRestClient)1 GroupRestClient (org.apache.syncope.client.console.rest.GroupRestClient)1 RoleRestClient (org.apache.syncope.client.console.rest.RoleRestClient)1 UserRestClient (org.apache.syncope.client.console.rest.UserRestClient)1