Search in sources :

Example 1 with ConnectorWizardBuilder

use of org.apache.syncope.client.console.wizards.resources.ConnectorWizardBuilder 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 2 with ConnectorWizardBuilder

use of org.apache.syncope.client.console.wizards.resources.ConnectorWizardBuilder 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

ConnectorWizardBuilder (org.apache.syncope.client.console.wizards.resources.ConnectorWizardBuilder)2 ConnInstanceTO (org.apache.syncope.common.lib.to.ConnInstanceTO)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 IndicatingAjaxLink (org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink)2 Fragment (org.apache.wicket.markup.html.panel.Fragment)2 CompoundPropertyModel (org.apache.wicket.model.CompoundPropertyModel)2 HistoryConfList (org.apache.syncope.client.console.panels.HistoryConfList)1 IndicatingOnConfirmAjaxLink (org.apache.syncope.client.console.wicket.markup.html.form.IndicatingOnConfirmAjaxLink)1 AbstractResourceWizardBuilder (org.apache.syncope.client.console.wizards.resources.AbstractResourceWizardBuilder)1 ResourceWizardBuilder (org.apache.syncope.client.console.wizards.resources.ResourceWizardBuilder)1 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)1 ResourceTO (org.apache.syncope.common.lib.to.ResourceTO)1