Search in sources :

Example 1 with XMLEditorPanel

use of org.apache.syncope.client.console.wicket.markup.html.form.XMLEditorPanel in project syncope by apache.

the class WorkflowDirectoryPanel method getActions.

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

        private static final long serialVersionUID = -184018732772021627L;

        @Override
        public void onClick(final AjaxRequestTarget target, final WorkflowDefinitionTO ignore) {
            final IModel<String> wfDefinition = new Model<>();
            try {
                wfDefinition.setObject(IOUtils.toString(restClient.getDefinition(MediaType.APPLICATION_XML_TYPE, model.getObject().getKey())));
            } catch (IOException e) {
                LOG.error("Could not get workflow definition", e);
            }
            utility.header(Model.of(model.getObject().getKey()));
            utility.setContent(new XMLEditorPanel(utility, wfDefinition, false, pageRef) {

                private static final long serialVersionUID = -7688359318035249200L;

                @Override
                public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
                    if (StringUtils.isNotBlank(wfDefinition.getObject())) {
                        try {
                            restClient.setDefinition(MediaType.APPLICATION_XML_TYPE, model.getObject().getKey(), wfDefinition.getObject());
                            SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                            target.add(container);
                            utility.show(false);
                            utility.close(target);
                        } catch (SyncopeClientException e) {
                            SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
                        }
                        ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
                    }
                }
            });
            utility.show(target);
            target.add(utility);
        }
    }, ActionLink.ActionType.EDIT, StandardEntitlement.WORKFLOW_DEF_SET);
    panel.add(new ActionLink<WorkflowDefinitionTO>() {

        private static final long serialVersionUID = 3109256773218160485L;

        @Override
        public void onClick(final AjaxRequestTarget target, final WorkflowDefinitionTO ignore) {
            modal.header(Model.of(model.getObject().getKey()));
            modal.setContent(new ImageModalPanel<>(modal, restClient.getDiagram(model.getObject().getKey()), pageRef));
            modal.show(target);
            target.add(modal);
        }
    }, ActionLink.ActionType.VIEW, StandardEntitlement.WORKFLOW_DEF_GET);
    panel.add(new ActionLink<WorkflowDefinitionTO>() {

        private static final long serialVersionUID = -184018732772021627L;

        @Override
        public Class<? extends Page> getPageClass() {
            return ModelerPopupPage.class;
        }

        @Override
        public PageParameters getPageParameters() {
            PageParameters parameters = new PageParameters();
            if (modelerCtx != null) {
                parameters.add(Constants.MODELER_CONTEXT, modelerCtx);
            }
            parameters.add(Constants.MODEL_ID_PARAM, model.getObject().getModelId());
            return parameters;
        }

        @Override
        protected boolean statusCondition(final WorkflowDefinitionTO modelObject) {
            return modelerCtx != null;
        }

        @Override
        public void onClick(final AjaxRequestTarget target, final WorkflowDefinitionTO ignore) {
        // do nothing
        }
    }, ActionLink.ActionType.WORKFLOW_MODELER, StandardEntitlement.WORKFLOW_DEF_SET);
    panel.add(new ActionLink<WorkflowDefinitionTO>() {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        protected boolean statusCondition(final WorkflowDefinitionTO modelObject) {
            return !modelObject.isMain();
        }

        @Override
        public void onClick(final AjaxRequestTarget target, final WorkflowDefinitionTO ignore) {
            try {
                restClient.deleteDefinition(model.getObject().getKey());
                SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                target.add(container);
            } catch (SyncopeClientException e) {
                LOG.error("While deleting workflow definition {}", model.getObject().getName(), e);
                SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
            }
            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
        }
    }, ActionLink.ActionType.DELETE, StandardEntitlement.WORKFLOW_DEF_DELETE, true);
    return panel;
}
Also used : IModel(org.apache.wicket.model.IModel) XMLEditorPanel(org.apache.syncope.client.console.wicket.markup.html.form.XMLEditorPanel) Form(org.apache.wicket.markup.html.form.Form) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Page(org.apache.wicket.Page) ModelerPopupPage(org.apache.syncope.client.console.pages.ModelerPopupPage) BasePage(org.apache.syncope.client.console.pages.BasePage) IOException(java.io.IOException) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) WorkflowDefinitionTO(org.apache.syncope.common.lib.to.WorkflowDefinitionTO) BasePage(org.apache.syncope.client.console.pages.BasePage) ImageModalPanel(org.apache.syncope.client.console.wicket.markup.html.form.ImageModalPanel)

Example 2 with XMLEditorPanel

use of org.apache.syncope.client.console.wicket.markup.html.form.XMLEditorPanel 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

BasePage (org.apache.syncope.client.console.pages.BasePage)2 XMLEditorPanel (org.apache.syncope.client.console.wicket.markup.html.form.XMLEditorPanel)2 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 IOException (java.io.IOException)1 Serializable (java.io.Serializable)1 UserFormLayoutInfo (org.apache.syncope.client.console.layout.UserFormLayoutInfo)1 ModelerPopupPage (org.apache.syncope.client.console.pages.ModelerPopupPage)1 AnyTypeRestClient (org.apache.syncope.client.console.rest.AnyTypeRestClient)1 ImageModalPanel (org.apache.syncope.client.console.wicket.markup.html.form.ImageModalPanel)1 UserTemplateWizardBuilder (org.apache.syncope.client.console.wizards.any.UserTemplateWizardBuilder)1 SAML2IdPTO (org.apache.syncope.common.lib.to.SAML2IdPTO)1 UserTO (org.apache.syncope.common.lib.to.UserTO)1 WorkflowDefinitionTO (org.apache.syncope.common.lib.to.WorkflowDefinitionTO)1 Page (org.apache.wicket.Page)1 Form (org.apache.wicket.markup.html.form.Form)1 IModel (org.apache.wicket.model.IModel)1 StringResourceModel (org.apache.wicket.model.StringResourceModel)1 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)1