Search in sources :

Example 11 with BasePage

use of org.apache.syncope.client.console.pages.BasePage 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 12 with BasePage

use of org.apache.syncope.client.console.pages.BasePage in project syncope by apache.

the class ClassPathScanImplementationLookup method load.

@SuppressWarnings("unchecked")
public void load() {
    pages = new ArrayList<>();
    previewers = new ArrayList<>();
    extPages = new ArrayList<>();
    extWidgets = new ArrayList<>();
    ssoLoginFormPanels = new ArrayList<>();
    reportletConfs = new HashMap<>();
    accountRuleConfs = new HashMap<>();
    passwordRuleConfs = new HashMap<>();
    pullCorrelationRuleConfs = new HashMap<>();
    ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);
    scanner.addIncludeFilter(new AssignableTypeFilter(BasePage.class));
    scanner.addIncludeFilter(new AssignableTypeFilter(AbstractBinaryPreviewer.class));
    scanner.addIncludeFilter(new AssignableTypeFilter(BaseExtPage.class));
    scanner.addIncludeFilter(new AssignableTypeFilter(BaseExtWidget.class));
    scanner.addIncludeFilter(new AssignableTypeFilter(SSOLoginFormPanel.class));
    scanner.addIncludeFilter(new AssignableTypeFilter(ReportletConf.class));
    scanner.addIncludeFilter(new AssignableTypeFilter(AccountRuleConf.class));
    scanner.addIncludeFilter(new AssignableTypeFilter(PasswordRuleConf.class));
    scanner.addIncludeFilter(new AssignableTypeFilter(PullCorrelationRuleConf.class));
    scanner.findCandidateComponents(getBasePackage()).forEach(bd -> {
        try {
            Class<?> clazz = ClassUtils.resolveClassName(bd.getBeanClassName(), ClassUtils.getDefaultClassLoader());
            boolean isAbsractClazz = Modifier.isAbstract(clazz.getModifiers());
            if (!isAbsractClazz) {
                if (BaseExtPage.class.isAssignableFrom(clazz)) {
                    if (clazz.isAnnotationPresent(ExtPage.class)) {
                        extPages.add((Class<? extends BaseExtPage>) clazz);
                    } else {
                        LOG.error("Could not find annotation {} in {}, ignoring", ExtPage.class.getName(), clazz.getName());
                    }
                } else if (BaseExtWidget.class.isAssignableFrom(clazz)) {
                    if (clazz.isAnnotationPresent(ExtWidget.class)) {
                        extWidgets.add((Class<? extends BaseExtWidget>) clazz);
                    } else {
                        LOG.error("Could not find annotation {} in {}, ignoring", ExtWidget.class.getName(), clazz.getName());
                    }
                } else if (BasePage.class.isAssignableFrom(clazz)) {
                    pages.add((Class<? extends BasePage>) clazz);
                } else if (AbstractBinaryPreviewer.class.isAssignableFrom(clazz)) {
                    previewers.add((Class<? extends AbstractBinaryPreviewer>) clazz);
                } else if (SSOLoginFormPanel.class.isAssignableFrom(clazz)) {
                    ssoLoginFormPanels.add((Class<? extends SSOLoginFormPanel>) clazz);
                } else if (ReportletConf.class.isAssignableFrom(clazz)) {
                    reportletConfs.put(clazz.getName(), (Class<? extends ReportletConf>) clazz);
                } else if (AccountRuleConf.class.isAssignableFrom(clazz)) {
                    accountRuleConfs.put(clazz.getName(), (Class<? extends AccountRuleConf>) clazz);
                } else if (PasswordRuleConf.class.isAssignableFrom(clazz)) {
                    passwordRuleConfs.put(clazz.getName(), (Class<? extends PasswordRuleConf>) clazz);
                } else if (PullCorrelationRuleConf.class.isAssignableFrom(clazz)) {
                    pullCorrelationRuleConfs.put(clazz.getName(), (Class<? extends PullCorrelationRuleConf>) clazz);
                }
            }
        } catch (Throwable t) {
            LOG.warn("Could not inspect class {}", bd.getBeanClassName(), t);
        }
    });
    pages = Collections.unmodifiableList(pages);
    previewers = Collections.unmodifiableList(previewers);
    Collections.sort(extPages, (o1, o2) -> ObjectUtils.compare(o1.getAnnotation(ExtPage.class).priority(), o2.getAnnotation(ExtPage.class).priority()));
    extPages = Collections.unmodifiableList(extPages);
    Collections.sort(extWidgets, (o1, o2) -> ObjectUtils.compare(o1.getAnnotation(ExtWidget.class).priority(), o2.getAnnotation(ExtWidget.class).priority()));
    extWidgets = Collections.unmodifiableList(extWidgets);
    ssoLoginFormPanels = Collections.unmodifiableList(ssoLoginFormPanels);
    reportletConfs = Collections.unmodifiableMap(reportletConfs);
    accountRuleConfs = Collections.unmodifiableMap(accountRuleConfs);
    passwordRuleConfs = Collections.unmodifiableMap(passwordRuleConfs);
    pullCorrelationRuleConfs = Collections.unmodifiableMap(pullCorrelationRuleConfs);
    LOG.debug("Binary previewers found: {}", previewers);
    LOG.debug("Extension pages found: {}", extPages);
    LOG.debug("Extension widgets found: {}", extWidgets);
    LOG.debug("SSO Login pages found: {}", ssoLoginFormPanels);
    LOG.debug("Reportlet configurations found: {}", reportletConfs);
    LOG.debug("Account Rule configurations found: {}", accountRuleConfs);
    LOG.debug("Password Rule configurations found: {}", passwordRuleConfs);
    LOG.debug("Pull Correlation Rule configurations found: {}", pullCorrelationRuleConfs);
}
Also used : SSOLoginFormPanel(org.apache.syncope.client.console.panels.SSOLoginFormPanel) BaseExtPage(org.apache.syncope.client.console.pages.BaseExtPage) PasswordRuleConf(org.apache.syncope.common.lib.policy.PasswordRuleConf) BaseExtPage(org.apache.syncope.client.console.pages.BaseExtPage) ExtPage(org.apache.syncope.client.console.annotations.ExtPage) ClassPathScanningCandidateComponentProvider(org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider) AccountRuleConf(org.apache.syncope.common.lib.policy.AccountRuleConf) ReportletConf(org.apache.syncope.common.lib.report.ReportletConf) AbstractBinaryPreviewer(org.apache.syncope.client.console.wicket.markup.html.form.preview.AbstractBinaryPreviewer) PullCorrelationRuleConf(org.apache.syncope.common.lib.policy.PullCorrelationRuleConf) ExtWidget(org.apache.syncope.client.console.annotations.ExtWidget) BaseExtWidget(org.apache.syncope.client.console.widgets.BaseExtWidget) BasePage(org.apache.syncope.client.console.pages.BasePage) AssignableTypeFilter(org.springframework.core.type.filter.AssignableTypeFilter) BaseExtWidget(org.apache.syncope.client.console.widgets.BaseExtWidget)

Example 13 with BasePage

use of org.apache.syncope.client.console.pages.BasePage 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 14 with BasePage

use of org.apache.syncope.client.console.pages.BasePage 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)

Example 15 with BasePage

use of org.apache.syncope.client.console.pages.BasePage in project syncope by apache.

the class PropagationTaskDirectoryPanel method getActions.

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

        private static final long serialVersionUID = -3722207913631435501L;

        @Override
        public void onClick(final AjaxRequestTarget target, final PropagationTaskTO modelObject) {
            PropagationTaskDirectoryPanel.this.getTogglePanel().close(target);
            viewTask(taskTO, target);
        }
    }, ActionLink.ActionType.VIEW_EXECUTIONS, StandardEntitlement.TASK_READ);
    // [SYNCOPE-1115] - Display attributes for propagation tasks
    panel.add(new ActionLink<PropagationTaskTO>() {

        private static final long serialVersionUID = 9206257220553949594L;

        @Override
        public void onClick(final AjaxRequestTarget target, final PropagationTaskTO modelObject) {
            PropagationTaskDirectoryPanel.this.getTogglePanel().close(target);
            viewTaskDetails(modelObject, target);
        }
    }, ActionLink.ActionType.VIEW_DETAILS, StandardEntitlement.TASK_READ);
    panel.add(new ActionLink<PropagationTaskTO>() {

        private static final long serialVersionUID = -3722207913631435501L;

        @Override
        public void onClick(final AjaxRequestTarget target, final PropagationTaskTO modelObject) {
            try {
                restClient.startExecution(taskTO.getKey(), null);
                SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                target.add(container);
            } catch (SyncopeClientException e) {
                SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
                LOG.error("While running {}", taskTO.getKey(), e);
            }
            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
        }
    }, ActionLink.ActionType.EXECUTE, StandardEntitlement.TASK_EXECUTE);
    panel.add(new ActionLink<PropagationTaskTO>() {

        private static final long serialVersionUID = -3722207913631435501L;

        @Override
        public void onClick(final AjaxRequestTarget target, final PropagationTaskTO modelObject) {
            try {
                restClient.delete(TaskType.PROPAGATION, taskTO.getKey());
                SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                target.add(container);
                PropagationTaskDirectoryPanel.this.getTogglePanel().close(target);
            } catch (SyncopeClientException e) {
                LOG.error("While deleting {}", taskTO.getKey(), e);
                SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
            }
            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
        }
    }, ActionLink.ActionType.DELETE, StandardEntitlement.TASK_DELETE, true);
    return panel;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PropagationTaskTO(org.apache.syncope.common.lib.to.PropagationTaskTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) BasePage(org.apache.syncope.client.console.pages.BasePage)

Aggregations

BasePage (org.apache.syncope.client.console.pages.BasePage)15 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)14 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)13 StringResourceModel (org.apache.wicket.model.StringResourceModel)8 AnyTypeRestClient (org.apache.syncope.client.console.rest.AnyTypeRestClient)4 AjaxWizard (org.apache.syncope.client.console.wizards.AjaxWizard)4 UserTO (org.apache.syncope.common.lib.to.UserTO)4 IModel (org.apache.wicket.model.IModel)3 ResourceModel (org.apache.wicket.model.ResourceModel)3 Serializable (java.io.Serializable)2 XMLEditorPanel (org.apache.syncope.client.console.wicket.markup.html.form.XMLEditorPanel)2 GroupTO (org.apache.syncope.common.lib.to.GroupTO)2 Form (org.apache.wicket.markup.html.form.Form)2 CompoundPropertyModel (org.apache.wicket.model.CompoundPropertyModel)2 IOException (java.io.IOException)1 ExtPage (org.apache.syncope.client.console.annotations.ExtPage)1 ExtWidget (org.apache.syncope.client.console.annotations.ExtWidget)1 ConsoleLayoutInfo (org.apache.syncope.client.console.layout.ConsoleLayoutInfo)1 UserFormLayoutInfo (org.apache.syncope.client.console.layout.UserFormLayoutInfo)1 NotificationTasks (org.apache.syncope.client.console.notifications.NotificationTasks)1