Search in sources :

Example 1 with UserTemplateWizardBuilder

use of org.apache.syncope.client.console.wizards.any.UserTemplateWizardBuilder 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)

Aggregations

Serializable (java.io.Serializable)1 UserFormLayoutInfo (org.apache.syncope.client.console.layout.UserFormLayoutInfo)1 BasePage (org.apache.syncope.client.console.pages.BasePage)1 AnyTypeRestClient (org.apache.syncope.client.console.rest.AnyTypeRestClient)1 XMLEditorPanel (org.apache.syncope.client.console.wicket.markup.html.form.XMLEditorPanel)1 UserTemplateWizardBuilder (org.apache.syncope.client.console.wizards.any.UserTemplateWizardBuilder)1 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)1 SAML2IdPTO (org.apache.syncope.common.lib.to.SAML2IdPTO)1 UserTO (org.apache.syncope.common.lib.to.UserTO)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 StringResourceModel (org.apache.wicket.model.StringResourceModel)1