Package org.apache.syncope.common.to

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


                    result.setId(created.getResult().getKey());
                    result.setName(((UserTO) actual).getUsername());
                } else if (AttributableType.ROLE == attrUtil.getType()) {
                    WorkflowResult<Long> created = rwfAdapter.create((RoleTO) actual);
                    AttributeTO roleOwner = actual.getAttributeMap().get(StringUtils.EMPTY);
                    if (roleOwner != null) {
                        roleOwnerMap.put(created.getResult(), roleOwner.getValues().iterator().next());
                    }

                    EntitlementUtil.extendAuthContext(created.getResult());

                    List<PropagationTask> tasks = propagationManager.getRoleCreateTaskIds(created,
View Full Code Here


            final Collection<? extends AbstractAttr> attributes,
            final Collection<? extends AbstractDerAttr> derivedAttributes,
            final Collection<? extends AbstractVirAttr> virtualAttributes,
            final Collection<ExternalResource> resources) {

        AttributeTO attributeTO;
        for (AbstractAttr attribute : attributes) {
            attributeTO = new AttributeTO();
            attributeTO.setSchema(attribute.getSchema().getName());
            attributeTO.setValues(attribute.getValuesAsStrings());
            attributeTO.setReadonly(attribute.getSchema().isReadonly());

            abstractAttributableTO.addAttribute(attributeTO);
        }

        for (AbstractDerAttr derivedAttribute : derivedAttributes) {
            attributeTO = new AttributeTO();
            attributeTO.setSchema(derivedAttribute.getDerivedSchema().getName());
            attributeTO.addValue(derivedAttribute.getValue(attributes));
            attributeTO.setReadonly(true);

            abstractAttributableTO.addDerivedAttribute(attributeTO);
        }

        for (AbstractVirAttr virtualAttribute : virtualAttributes) {
            attributeTO = new AttributeTO();
            attributeTO.setSchema(virtualAttribute.getVirtualSchema().getName());
            attributeTO.setValues(virtualAttribute.getValues());
            attributeTO.setReadonly(virtualAttribute.getVirtualSchema().isReadonly());

            abstractAttributableTO.addVirtualAttribute(attributeTO);
        }

        for (ExternalResource resource : resources) {
View Full Code Here

        for (String attrName : attrsToBeRemoved) {
            rwattrs.remove(attrName);
        }
        for (AttributeMod attrMod : attrsToBeUpdated) {
            if (rwattrs.containsKey(attrMod.getSchema())) {
                AttributeTO attrTO = rwattrs.get(attrMod.getSchema());
                attrTO.getValues().removeAll(attrMod.getValuesToBeRemoved());
                attrTO.getValues().addAll(attrMod.getValuesToBeAdded());
            } else {
                AttributeTO attrTO = new AttributeTO();
                attrTO.setSchema(attrMod.getSchema());
                attrTO.setValues(attrMod.getValuesToBeAdded());

                rwattrs.put(attrMod.getSchema(), attrTO);
            }
        }
View Full Code Here

        Map<String, AttributeTO> attrs = to.getDerivedAttributeMap();
        for (String attrName : mod.getDerivedAttributesToBeRemoved()) {
            attrs.remove(attrName);
        }
        for (String attrName : mod.getDerivedAttributesToBeAdded()) {
            AttributeTO attrTO = new AttributeTO();
            attrTO.setSchema(attrName);

            attrs.put(attrName, attrTO);
        }
        result.setDerivedAttributes(new ArrayList<AttributeTO>(attrs.values()));
View Full Code Here

        for (AbstractMappingItem item : attrUtil.getMappingItems(
                syncTask.getResource(), MappingPurpose.SYNCHRONIZATION)) {

            Attribute attribute = obj.getAttributeByName(item.getExtAttrName());

            AttributeTO attributeTO;
            switch (item.getIntMappingType()) {
                case UserId:
                case RoleId:
                    break;

                case Password:
                    if (attributableTO instanceof UserTO && attribute != null && attribute.getValue() != null
                            && !attribute.getValue().isEmpty()) {

                        ((UserTO) attributableTO).setPassword(getPassword(attribute.getValue().get(0)));
                    }
                    break;

                case Username:
                    if (attributableTO instanceof UserTO) {
                        ((UserTO) attributableTO).setUsername(attribute == null || attribute.getValue().isEmpty()
                                || attribute.getValue().get(0) == null
                                ? null
                                : attribute.getValue().get(0).toString());
                    }
                    break;

                case RoleName:
                    if (attributableTO instanceof RoleTO) {
                        ((RoleTO) attributableTO).setName(attribute == null || attribute.getValue().isEmpty()
                                || attribute.getValue().get(0) == null
                                ? null
                                : attribute.getValue().get(0).toString());
                    }
                    break;

                case RoleOwnerSchema:
                    if (attributableTO instanceof RoleTO && attribute != null) {
                        // using a special attribute (with schema "", that will be ignored) for carrying the
                        // RoleOwnerSchema value
                        attributeTO = new AttributeTO();
                        attributeTO.setSchema(StringUtils.EMPTY);
                        if (attribute.getValue().isEmpty() || attribute.getValue().get(0) == null) {
                            attributeTO.addValue(StringUtils.EMPTY);
                        } else {
                            attributeTO.addValue(attribute.getValue().get(0).toString());
                        }

                        ((RoleTO) attributableTO).addAttribute(attributeTO);
                    }
                    break;

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

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

                    attributableTO.addAttribute(attributeTO);
                    break;

                case UserDerivedSchema:
                case RoleDerivedSchema:
                    attributeTO = new AttributeTO();
                    attributeTO.setSchema(item.getIntAttrName());
                    attributableTO.addDerivedAttribute(attributeTO);
                    break;

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

                    for (Object value : attribute == null || attribute.getValue() == null
                            ? Collections.emptyList()
                            : attribute.getValue()) {

                        if (value != null) {
                            attributeTO.addValue(value.toString());
                        }
                    }

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

     */
    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) {
                        if (value instanceof GuardedString || value instanceof GuardedByteArray) {
                            attrTO.addValue(getPassword(value));
                        } else {
                            attrTO.addValue(value.toString());
                        }
                    }
                }
            }

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

            SyncTaskTO task = taskService.read(TaskType.SYNCHRONIZATION, SYNC_TASK_ID);
            assertNotNull(task);

            // add user template

            AttributeTO newAttrTO = new AttributeTO();
            newAttrTO.setSchema("firstname");
            newAttrTO.setValues(Collections.singletonList(""));

            UserTO template = new UserTO();
            template.addAttribute(newAttrTO);
            template.addAttribute(attributeTO("userId", "'test'"));
            template.addAttribute(attributeTO("fullname", "'test'"));
View Full Code Here

    @Test
    public void issueSYNCOPE307() {
        UserTO userTO = UserTestITCase.getUniqueSampleTO("s307@apache.org");

        AttributeTO csvuserid = new AttributeTO();
        csvuserid.setSchema("csvuserid");
        userTO.addDerivedAttribute(csvuserid);

        userTO.getResources().clear();
        userTO.addResource(RESOURCE_NAME_WS2);
        userTO.addResource(RESOURCE_NAME_CSV);

        userTO = createUser(userTO);
        assertNotNull(userTO);

        userTO = userService.read(userTO.getId());
        assertEquals("virtualvalue", userTO.getVirtualAttributeMap().get("virtualdata").getValues().get(0));

        // Update sync task
        SyncTaskTO task = taskService.read(TaskType.SYNCHRONIZATION, 12L);
        assertNotNull(task);

        //  add user template
        UserTO template = new UserTO();
        template.addResource(RESOURCE_NAME_DBVIRATTR);

        AttributeTO userId = attributeTO("userId", "'s307@apache.org'");
        template.addAttribute(userId);

        AttributeTO email = attributeTO("email", "'s307@apache.org'");
        template.addAttribute(email);

        task.setUserTemplate(template);

        taskService.update(task.getId(), task);
View Full Code Here

     */
    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) {
                        if (value instanceof GuardedString || value instanceof GuardedByteArray) {
                            attrTO.addValue(getPassword(value));
                        } else {
                            attrTO.addValue(value.toString());
                        }
                    }
                }
            }

View Full Code Here

TOP

Related Classes of org.apache.syncope.common.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.