Package org.apache.syncope.client.to

Examples of org.apache.syncope.client.to.AttributeTO


     */
    public ConnObjectTO getConnObjectTO(final ConnectorObject connObject) {
        final ConnObjectTO connObjectTO = new ConnObjectTO();

        for (Attribute attr : connObject.getAttributes()) {
            AttributeTO attrTO = new AttributeTO();
            attrTO.setSchema(attr.getName());

            if (attr.getValue() != null) {
                for (Object value : attr.getValue()) {
                    if (value != null) {
                        attrTO.addValue(value.toString());
                    }
                }
            }

            connObjectTO.addAttribute(attrTO);
View Full Code Here


        }
    }

    private AttributeTO evaluateAttrTemplate(final AbstractAttributableTO attributableTO, final AttributeTO template) {

        AttributeTO result = new AttributeTO();
        result.setSchema(template.getSchema());

        if (template.getValues() != null && !template.getValues().isEmpty()) {
            for (String value : template.getValues()) {
                String evaluated = jexlUtil.evaluate(value, attributableTO);
                if (StringUtils.isNotBlank(evaluated)) {
                    result.addValue(evaluated);
                }
            }
        }

        return result;
View Full Code Here

        // 1. fill with data from connector object
        for (SchemaMapping mapping : syncTask.getResource().getMappings()) {
            Attribute attribute = obj.getAttributeByName(SchemaMappingUtil.getExtAttrName(mapping));

            AttributeTO attributeTO;
            switch (mapping.getIntMappingType()) {
                case SyncopeUserId:
                    break;

                case Password:
                    if (attribute != null && attribute.getValue() != null && !attribute.getValue().isEmpty()) {
                        userTO.setPassword(getPassword(attribute.getValue().get(0)));
                    }
                    break;

                case Username:
                    userTO.setUsername(attribute == null || attribute.getValue().isEmpty()
                            ? null
                            : attribute.getValue().get(0).toString());
                    break;

                case UserSchema:
                    attributeTO = new AttributeTO();
                    attributeTO.setSchema(mapping.getIntAttrName());

                    for (Object value : attribute == null || attribute.getValue() == null
                            ? Collections.EMPTY_LIST
                            : attribute.getValue()) {
                        attributeTO.addValue(value.toString());
                    }

                    userTO.addAttribute(attributeTO);
                    break;

                case UserDerivedSchema:
                    attributeTO = new AttributeTO();
                    attributeTO.setSchema(mapping.getIntAttrName());
                    userTO.addDerivedAttribute(attributeTO);
                    break;

                case UserVirtualSchema:
                    attributeTO = new AttributeTO();
                    attributeTO.setSchema(mapping.getIntAttrName());

                    for (Object value : attribute == null || attribute.getValue() == null
                            ? Collections.EMPTY_LIST
                            : attribute.getValue()) {
                        attributeTO.addValue(value.toString());
                    }

                    userTO.addVirtualAttribute(attributeTO);
                    break;
View Full Code Here

    public void updateRemovingVirAttribute() {
        RoleTO roleTO = new RoleTO();
        roleTO.setName("withvirtual");
        roleTO.setParent(8L);

        final AttributeTO rvirtualdata = new AttributeTO();
        rvirtualdata.setSchema("rvirtualdata");
        roleTO.addVirtualAttribute(rvirtualdata);

        roleTO = restTemplate.postForObject(BASE_URL + "role/create", roleTO, RoleTO.class);

        assertNotNull(roleTO);
View Full Code Here

    public void updateRemovingDerAttribute() {
        RoleTO roleTO = new RoleTO();
        roleTO.setName("withderived");
        roleTO.setParent(8L);

        final AttributeTO deriveddata = new AttributeTO();
        deriveddata.setSchema("rderivedschema");
        roleTO.addDerivedAttribute(deriveddata);

        roleTO = restTemplate.postForObject(BASE_URL + "role/create", roleTO, RoleTO.class);

        assertNotNull(roleTO);
View Full Code Here

public class RoleTestITCase extends AbstractTest {

    @Test
    public void createWithException() {
        AttributeTO attributeTO = new AttributeTO();
        attributeTO.setSchema("attr1");
        attributeTO.addValue("value1");

        RoleTO newRoleTO = new RoleTO();
        newRoleTO.addAttribute(attributeTO);

        Throwable t = null;
View Full Code Here

        roleTO.setInheritPasswordPolicy(true);
        // inherited so setter execution should be ignored
        roleTO.setPasswordPolicy(2L);

        AttributeTO icon = new AttributeTO();
        icon.setSchema("icon");
        icon.addValue("anIcon");

        RoleTO actual = restTemplate.postForObject(BASE_URL + "role/create", roleTO, RoleTO.class);

        roleTO.setId(actual.getId());
View Full Code Here

        roleTO.setInheritPasswordPolicy(true);
        // inherited so setter execution should be ignored
        roleTO.setPasswordPolicy(2L);

        AttributeTO icon = new AttributeTO();
        icon.setSchema("icon");
        icon.addValue("anIcon");
        roleTO.addAttribute(icon);

        roleTO = restTemplate.postForObject(BASE_URL + "role/create", roleTO, RoleTO.class);

        assertEquals(1, roleTO.getAttributes().size());
View Full Code Here

        // 2. create an user with the role created above (as admin)
        UserTO userTO = UserTestITCase.getSampleTO("auth@test.org");

        MembershipTO membershipTO = new MembershipTO();
        membershipTO.setRoleId(authRoleTO.getId());
        AttributeTO testAttributeTO = new AttributeTO();
        testAttributeTO.setSchema("testAttribute");
        testAttributeTO.addValue("a value");
        membershipTO.addAttribute(testAttributeTO);
        userTO.addMembership(membershipTO);

        userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
        assertNotNull(userTO);
View Full Code Here

    public void testUserRead() {
        UserTO userTO = UserTestITCase.getSampleTO("testuserread@test.org");

        MembershipTO membershipTO = new MembershipTO();
        membershipTO.setRoleId(7L);
        AttributeTO testAttributeTO = new AttributeTO();
        testAttributeTO.setSchema("testAttribute");
        testAttributeTO.addValue("a value");
        membershipTO.addAttribute(testAttributeTO);
        userTO.addMembership(membershipTO);

        userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
        assertNotNull(userTO);
View Full Code Here

TOP

Related Classes of org.apache.syncope.client.to.AttributeTO

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.