Package org.apache.syncope.core.persistence.beans.membership

Examples of org.apache.syncope.core.persistence.beans.membership.Membership


        return entityManager.merge(membership);
    }

    @Override
    public void delete(final Long id) {
        Membership membership = find(id);
        if (membership == null) {
            return;
        }

        membership.getSyncopeUser().removeMembership(membership);
        userDAO.save(membership.getSyncopeUser());

        entityManager.remove(membership);
    }
View Full Code Here


        assertEquals(virAttr, actual);
    }

    @Test
    public void saveMVirAttribute() {
        Membership owner = membershipDAO.find(3L);
        assertNotNull("did not get expected membership", owner);

        MVirAttr virAttr = new MVirAttr();
        virAttr.setOwner(owner);
        virAttr.setTemplate(owner.getSyncopeRole().getAttrTemplate(MVirAttrTemplate.class, "mvirtualdata"));

        virAttr = virAttrDAO.save(virAttr);
        assertNotNull(virAttr.getTemplate());

        MVirAttr actual = virAttrDAO.find(virAttr.getId(), MVirAttr.class);
View Full Code Here

                .getValue(owner.getAttrs()));
    }

    @Test
    public void saveMDerAttribute() {
        Membership owner = membershipDAO.find(1L);
        assertNotNull("did not get expected user", owner);

        MDerAttr derAttr = new MDerAttr();
        derAttr.setOwner(owner);
        derAttr.setTemplate(owner.getSyncopeRole().getAttrTemplate(MDerAttrTemplate.class, "mderiveddata"));

        derAttr = derAttrDAO.save(derAttr);
        assertNotNull(derAttr.getTemplate());

        MDerAttr actual = derAttrDAO.find(derAttr.getId(), MDerAttr.class);
        assertNotNull("expected save to work", actual);
        assertEquals(derAttr, actual);

        MAttrValue sx = (MAttrValue) owner.getAttr("mderived_sx").getValues().iterator().next();
        MAttrValue dx = (MAttrValue) owner.getAttr("mderived_dx").getValues().iterator().next();

        assertEquals(sx.getValue() + "-" + dx.getValue(), derAttr.getValue(owner.getAttrs()));
    }
View Full Code Here

        MDerSchema actual = derSchemaDAO.find("sderived", MDerSchema.class);
        assertNotNull("expected save to work", actual);
        assertEquals(sderived, actual);

        Membership owner = membershipDAO.find(4L);
        assertNotNull("did not get expected membership", owner);

        MDerAttrTemplate template = new MDerAttrTemplate();
        template.setSchema(sderived);
        owner.getSyncopeRole().getAttrTemplates(MDerAttrTemplate.class).add(template);

        MDerAttr derAttr = new MDerAttr();
        derAttr.setOwner(owner);
        derAttr.setTemplate(owner.getSyncopeRole().getAttrTemplate(MDerAttrTemplate.class, sderived.getName()));

        derAttr = derAttrDAO.save(derAttr);
        assertNotNull(derAttr.getTemplate());
        derAttrDAO.flush();

        derAttr = derAttrDAO.find(derAttr.getId(), MDerAttr.class);
        assertNotNull("expected save to work", derAttr);

        String value = derAttr.getValue(owner.getAttrs());
        assertNotNull(value);
        assertFalse(value.isEmpty());
        assertTrue(value.equalsIgnoreCase("4"));
    }
View Full Code Here

                ((UserTO) updated).setPassword(null);
            }

            for (MembershipTO membTO : ((UserTO) updated).getMemberships()) {
                Membership memb = user.getMembership(membTO.getRoleId());
                if (memb != null) {
                    membTO.setId(memb.getId());
                }
            }

            return (T) AttributableOperations.diff(((UserTO) updated), ((UserTO) original), true);
        }
View Full Code Here

                    doExtractAttributes(handler, memb, memb.getAttrMap().keySet(), memb.getDerAttrMap()
                            .keySet(), memb.getVirAttrMap().keySet());

                    if (conf.getFeatures().contains(Feature.resources)) {
                        Membership actualMemb = user.getMembership(memb.getRoleId());
                        if (actualMemb == null) {
                            LOG.warn("Unexpected: cannot find membership for role {} for user {}", memb.getRoleId(),
                                    user);
                        } else {
                            doExtractResources(handler, roleDataBinder.getRoleTO(actualMemb.getSyncopeRole()));
                        }
                    }

                    handler.endElement("", "", "membership");
                }
View Full Code Here

    public boolean removeMembership(final Membership membership) {
        return memberships.remove(membership);
    }

    public Membership getMembership(final Long syncopeRoleId) {
        Membership result = null;
        Membership membership;
        for (Iterator<Membership> itor = getMemberships().iterator(); result == null && itor.hasNext();) {

            membership = itor.next();
            if (membership.getSyncopeRole() != null && syncopeRoleId.equals(membership.getSyncopeRole().getId())) {
                result = membership;
            }
        }
        return result;
    }
View Full Code Here

        if (StringUtils.isBlank(updated.getPassword()) || userDataBinder.verifyPassword(user, updated.getPassword())) {
            updated.setPassword(null);
        }

        for (MembershipTO membTO : updated.getMemberships()) {
            Membership memb = user.getMembership(membTO.getRoleId());
            if (memb != null) {
                membTO.setId(memb.getId());
            }
        }

        final UserMod userMod = AttributableOperations.diff(updated, original, true);
View Full Code Here

    public boolean removeMembership(final Membership membership) {
        return memberships.remove(membership);
    }

    public Membership getMembership(final Long syncopeRoleId) {
        Membership result = null;
        Membership membership;
        for (Iterator<Membership> itor = getMemberships().iterator(); result == null && itor.hasNext();) {

            membership = itor.next();
            if (membership.getSyncopeRole() != null && syncopeRoleId.equals(membership.getSyncopeRole().getId())) {

                result = membership;
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.syncope.core.persistence.beans.membership.Membership

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.