Package org.apache.syncope.common.mod

Examples of org.apache.syncope.common.mod.RoleMod


        assertNotNull(roleTO.getEntitlements());
        assertFalse(roleTO.getEntitlements().isEmpty());

        List<String> entitlements = roleTO.getEntitlements();

        RoleMod roleMod = new RoleMod();
        roleMod.setId(roleTO.getId());
        roleMod.setInheritDerivedAttributes(Boolean.TRUE);

        roleTO = roleService.update(roleMod.getId(), roleMod);
        assertNotNull(roleTO);
        assertEquals(entitlements, roleTO.getEntitlements());

        roleMod = new RoleMod();
        roleMod.setId(roleTO.getId());
        roleMod.setEntitlements(new ArrayList<String>());

        roleTO = roleService.update(roleMod.getId(), roleMod);
        assertNotNull(roleTO);
        assertTrue(roleTO.getEntitlements().isEmpty());
    }
View Full Code Here


        final RoleTO result;
        if (createFlag) {
            result = roleRestClient.create(roleTO);
        } else {
            RoleMod roleMod = AttributableOperations.diff(roleTO, originalRoleTO);

            // update role just if it is changed
            if (roleMod.isEmpty()) {
                result = roleTO;
            } else {
                result = roleRestClient.update(originalRoleTO.getETagValue(), roleMod);
            }
        }
View Full Code Here

    protected void setRoleOwners(final RoleSyncResultHandler rhandler)
            throws UnauthorizedRoleException, NotFoundException {

        for (Map.Entry<Long, String> entry : rhandler.getRoleOwnerMap().entrySet()) {
            RoleMod roleMod = new RoleMod();
            roleMod.setId(entry.getKey());

            if (StringUtils.isBlank(entry.getValue())) {
                roleMod.setRoleOwner(null);
                roleMod.setUserOwner(null);
            } else {
                Long userId = syncUtilities.findMatchingAttributableId(
                        ObjectClass.ACCOUNT,
                        entry.getValue(),
                        rhandler.getProfile().getSyncTask().getResource(),
                        rhandler.getProfile().getConnector());

                if (userId == null) {
                    Long roleId = syncUtilities.findMatchingAttributableId(
                            ObjectClass.GROUP,
                            entry.getValue(),
                            rhandler.getProfile().getSyncTask().getResource(),
                            rhandler.getProfile().getConnector());

                    if (roleId != null) {
                        roleMod.setRoleOwner(new ReferenceMod(roleId));
                    }
                } else {
                    roleMod.setUserOwner(new ReferenceMod(userId));
                }
            }

            rwfAdapter.update(roleMod);
        }
View Full Code Here

    }

    @Override
    protected AbstractSubject link(final AbstractSubject sbj, final Boolean unlink) {

        final RoleMod roleMod = new RoleMod();
        roleMod.setId(sbj.getId());

        if (unlink) {
            roleMod.getResourcesToRemove().add(profile.getSyncTask().getResource().getName());
        } else {
            roleMod.getResourcesToAdd().add(profile.getSyncTask().getResource().getName());
        }

        rwfAdapter.update(roleMod);

        return roleDataBinder.getRoleFromId(sbj.getId());
View Full Code Here

        return roleDataBinder.getRoleFromId(sbj.getId());
    }

    @Override
    protected AbstractSubject unassign(final AbstractSubject sbj) {
        final RoleMod roleMod = new RoleMod();
        roleMod.setId(sbj.getId());
        roleMod.getResourcesToRemove().add(profile.getSyncTask().getResource().getName());
        rwfAdapter.update(roleMod);
        return deprovision(sbj);
    }
View Full Code Here

        return deprovision(sbj);
    }

    @Override
    protected AbstractSubject assign(final AbstractSubject sbj, final Boolean enabled) {
        final RoleMod roleMod = new RoleMod();
        roleMod.setId(sbj.getId());
        roleMod.getResourcesToAdd().add(profile.getSyncTask().getResource().getName());
        rwfAdapter.update(roleMod);
        return provision(sbj, enabled);
    }
View Full Code Here

            final AbstractSubjectTO before,
            final SyncResult result,
            final boolean unlink)
            throws Exception {

        final RoleMod roleMod = new RoleMod();
        roleMod.setId(before.getId());

        if (unlink) {
            roleMod.getResourcesToRemove().add(profile.getSyncTask().getResource().getName());
        } else {
            roleMod.getResourcesToAdd().add(profile.getSyncTask().getResource().getName());
        }

        return userDataBinder.getUserTO(rwfAdapter.update(roleMod).getResult());
    }
View Full Code Here

            final AbstractSubjectMod subjectMod,
            final SyncDelta delta,
            final SyncResult result)
            throws Exception {

        RoleMod roleMod = RoleMod.class.cast(subjectMod);

        final WorkflowResult<Long> updated = rwfAdapter.update(roleMod);
        String roleOwner = null;
        for (AttributeMod attrMod : roleMod.getAttrsToUpdate()) {
            if (attrMod.getSchema().isEmpty()) {
                roleOwner = attrMod.getValuesToBeAdded().iterator().next();
            }
        }
        if (roleOwner != null) {
            roleOwnerMap.put(updated.getResult(), roleOwner);
        }

        List<PropagationTask> tasks = propagationManager.getRoleUpdateTaskIds(updated,
                roleMod.getVirAttrsToRemove(),
                roleMod.getVirAttrsToUpdate(),
                Collections.singleton(profile.getSyncTask().getResource().getName()));

        taskExecutor.execute(tasks);

        final RoleTO after = roleDataBinder.getRoleTO(updated.getResult());
View Full Code Here

                resourceService.getConnectorObject(RESOURCE_NAME_LDAP, SubjectType.ROLE, roleTO.getId());
        assertNotNull(connObjectTO);
        assertNotNull(connObjectTO.getAttrMap().get("owner"));

        // SYNCOPE-515: remove ownership
        final RoleMod roleMod = new RoleMod();
        roleMod.setId(roleTO.getId());
        roleMod.setRoleOwner(new ReferenceMod());

        assertNull(updateRole(roleMod).getRoleOwner());
    }
View Full Code Here

        assertEquals(6L, (long) roleTO.getAccountPolicy());

        assertNotNull(roleTO.getPasswordPolicy());
        assertEquals(4L, (long) roleTO.getPasswordPolicy());

        RoleMod roleMod = new RoleMod();
        roleMod.setId(roleTO.getId());
        String modName = "finalRole" + getUUIDString();
        roleMod.setName(modName);
        roleMod.getAttrsToUpdate().add(attributeMod("show", "FALSE"));

        // change password policy inheritance
        roleMod.setInheritPasswordPolicy(Boolean.FALSE);

        roleTO = updateRole(roleMod);

        assertEquals(modName, roleTO.getName());
        assertEquals(2, roleTO.getAttrs().size());
View Full Code Here

TOP

Related Classes of org.apache.syncope.common.mod.RoleMod

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.