Package org.apache.syncope.common.to

Examples of org.apache.syncope.common.to.PolicyTO


            @Override
            public void populateItem(final Item<ICellPopulator<PolicyTO>> cellItem, final String componentId,
                    final IModel<PolicyTO> model) {

                final PolicyTO accountPolicyTO = model.getObject();

                final ActionLinksPanel panel = new ActionLinksPanel(componentId, model, pageRef);

                panel.add(new ActionLink() {

                    private static final long serialVersionUID = -3722207913631435501L;

                    @Override
                    public void onClick(final AjaxRequestTarget target) {

                        mwindow.setPageCreator(new ModalWindow.PageCreator() {

                            private static final long serialVersionUID = -7834632442532690940L;

                            @Override
                            public Page createPage() {
                                return new PolicyModalPage(mwindow, accountPolicyTO, pageRef);
                            }
                        });

                        mwindow.show(target);
                    }
                }, ActionLink.ActionType.EDIT, "Policies");

                panel.add(new ActionLink() {

                    private static final long serialVersionUID = -3722207913631435501L;

                    @Override
                    public void onClick(final AjaxRequestTarget target) {
                        try {

                            policyRestClient.delete(accountPolicyTO.getId(), accountPolicyTO.getClass());
                            info(getString("operation_succeeded"));

                        } catch (SyncopeClientCompositeErrorException e) {
                            error(getString("operation_error"));

                            LOG.error("While deleting resource {}({})", new Object[]{accountPolicyTO.getId(),
                                        accountPolicyTO.getDescription()}, e);
                        }

                        target.add(container);
                        target.add(getPage().get("feedback"));
                    }
View Full Code Here


            return new CompoundPropertyModel<PolicyTO>(object);
        }
    }

    private PolicyTO getPolicyTOInstance(final PolicyType policyType) {
        PolicyTO policyTO;
        switch (policyType) {
            case GLOBAL_ACCOUNT:
                policyTO = new AccountPolicyTO(true);
                break;
View Full Code Here

            UserTO userTO = getUniqueSampleTO("issue172@syncope.apache.org");
            createUser(userTO);
        } finally {
            for (PasswordPolicyTO policyTO : policies) {
                Response response = policyService.create(PolicyType.GLOBAL_PASSWORD, policyTO);
                PolicyTO cPolicyTO = getObject(response, PasswordPolicyTO.class, policyService);
                assertNotNull(cPolicyTO);
            }
        }
    }
View Full Code Here

    private UriInfo uriInfo;

    @Override
    public <T extends PolicyTO> Response create(final PolicyType type, final T policyTO) {
        PolicyTO policy = policyController.createInternal(policyTO);
        URI location = uriInfo.getAbsolutePathBuilder().path(policy.getId() + "").build();
        return Response.created(location).header(SyncopeConstants.REST_HEADER_ID, policy.getId()).build();
    }
View Full Code Here

            LOG.debug("No policy found", ignore);
        }

        if (includeGlobal) {
            try {
                PolicyTO globalPolicy = getGlobalPolicy(type);
                if (globalPolicy != null) {
                    res.add(0, (T) globalPolicy);
                }
            } catch (Exception ignore) {
                LOG.warn("No global policy found", ignore);
View Full Code Here

            UserTO userTO = getUniqueSampleTO("issue172@syncope.apache.org");
            createUser(userTO);
        } finally {
            for (PasswordPolicyTO policyTO : policies) {
                Response response = policyService.create(PolicyType.GLOBAL_PASSWORD, policyTO);
                PolicyTO cPolicyTO = getObject(response, PasswordPolicyTO.class, policyService);
                assertNotNull(cPolicyTO);
            }
        }
    }
View Full Code Here

     * @param policy bean.
     * @return policy TO.
     */
    @SuppressWarnings("unchecked")
    public <T extends PolicyTO> T getPolicyTO(final Policy policy) {
        final PolicyTO policyTO;

        final boolean isGlobal = isGlobalPolicy(policy.getType());

        switch (policy.getType()) {
            case GLOBAL_PASSWORD:
            case PASSWORD:
                if (!(policy.getSpecification() instanceof PasswordPolicySpec)) {
                    throw new ClassCastException("Expected " + PasswordPolicySpec.class.getName()
                            + ", found " + policy.getSpecification().getClass().getName());
                }
                policyTO = new PasswordPolicyTO(isGlobal);
                ((PasswordPolicyTO) policyTO).setSpecification((PasswordPolicySpec) policy.getSpecification());
                break;

            case GLOBAL_ACCOUNT:
            case ACCOUNT:
                if (!(policy.getSpecification() instanceof AccountPolicySpec)) {
                    throw new ClassCastException("Expected " + AccountPolicySpec.class.getName()
                            + ", found " + policy.getSpecification().getClass().getName());
                }
                policyTO = new AccountPolicyTO(isGlobal);
                ((AccountPolicyTO) policyTO).setSpecification((AccountPolicySpec) policy.getSpecification());
                break;

            case GLOBAL_SYNC:
            case SYNC:
            default:
                if (!(policy.getSpecification() instanceof SyncPolicySpec)) {
                    throw new ClassCastException("Expected " + SyncPolicySpec.class.getName()
                            + ", found " + policy.getSpecification().getClass().getName());

                }
                policyTO = new SyncPolicyTO(isGlobal);
                ((SyncPolicyTO) policyTO).setSpecification((SyncPolicySpec) policy.getSpecification());
        }

        policyTO.setId(policy.getId());
        policyTO.setDescription(policy.getDescription());

        return (T) policyTO;
    }
View Full Code Here

        Policy policy = policyDAO.find(id);
        if (policy == null) {
            throw new NotFoundException("Policy " + id + " not found");
        }

        PolicyTO policyToDelete = binder.getPolicyTO(policy);
        policyDAO.delete(id);

        auditManager.audit(Category.policy, PolicySubCategory.delete, Result.success,
                "Successfully deleted policy: " + id);
View Full Code Here

        super(baseUrl, restTemplate);
    }

    @Override
    public <T extends PolicyTO> Response create(final PolicyType type, final T policyTO) {
        PolicyTO policy = getRestTemplate().postForObject(baseUrl + "policy/{kind}/create", policyTO,
                policyTO.getClass(), typeToUrl(policyTO.getType()));

        return Response.created(URI.create(baseUrl + "policy/read/" + policy.getId() + ".json")).build();
    }
View Full Code Here

            UserTO userTO = getUniqueSampleTO("issue172@syncope.apache.org");
            createUser(userTO);
        } finally {
            for (PasswordPolicyTO policyTO : policies) {
                Response response = policyService.create(PolicyType.GLOBAL_PASSWORD, policyTO);
                PolicyTO cPolicyTO = getObject(response, PasswordPolicyTO.class, policyService);
                assertNotNull(cPolicyTO);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.syncope.common.to.PolicyTO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.