Search in sources :

Example 6 with PropagationByResource

use of org.apache.syncope.core.provisioning.api.PropagationByResource in project syncope by apache.

the class DefaultGroupWorkflowAdapter method doUpdate.

@Override
protected WorkflowResult<GroupPatch> doUpdate(final Group group, final GroupPatch groupPatch) {
    GroupTO original = dataBinder.getGroupTO(group, true);
    PropagationByResource propByRes = dataBinder.update(group, groupPatch);
    Set<AttrTO> virAttrs = groupPatch.getVirAttrs();
    GroupTO updated = dataBinder.getGroupTO(groupDAO.save(group), true);
    GroupPatch effectivePatch = AnyOperations.diff(updated, original, false);
    effectivePatch.getVirAttrs().clear();
    effectivePatch.getVirAttrs().addAll(virAttrs);
    return new WorkflowResult<>(effectivePatch, propByRes, "update");
}
Also used : WorkflowResult(org.apache.syncope.core.provisioning.api.WorkflowResult) AttrTO(org.apache.syncope.common.lib.to.AttrTO) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource) GroupPatch(org.apache.syncope.common.lib.patch.GroupPatch) GroupTO(org.apache.syncope.common.lib.to.GroupTO)

Example 7 with PropagationByResource

use of org.apache.syncope.core.provisioning.api.PropagationByResource in project syncope by apache.

the class DefaultGroupWorkflowAdapter method doCreate.

@Override
protected WorkflowResult<String> doCreate(final GroupTO groupTO) {
    Group group = entityFactory.newEntity(Group.class);
    dataBinder.create(group, groupTO);
    group = groupDAO.save(group);
    PropagationByResource propByRes = new PropagationByResource();
    propByRes.set(ResourceOperation.CREATE, groupDAO.findAllResourceKeys(group.getKey()));
    return new WorkflowResult<>(group.getKey(), propByRes, "create");
}
Also used : Group(org.apache.syncope.core.persistence.api.entity.group.Group) WorkflowResult(org.apache.syncope.core.provisioning.api.WorkflowResult) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource)

Example 8 with PropagationByResource

use of org.apache.syncope.core.provisioning.api.PropagationByResource in project syncope by apache.

the class DefaultUserWorkflowAdapter method doUpdate.

@Override
protected WorkflowResult<Pair<UserPatch, Boolean>> doUpdate(final User user, final UserPatch userPatch) {
    UserTO original = dataBinder.getUserTO(user, true);
    PropagationByResource propByRes = dataBinder.update(user, userPatch);
    PasswordPatch password = userPatch.getPassword();
    Set<AttrTO> virAttrs = userPatch.getVirAttrs();
    UserTO updated = dataBinder.getUserTO(userDAO.save(user), true);
    UserPatch effectivePatch = AnyOperations.diff(updated, original, false);
    effectivePatch.setPassword(password);
    effectivePatch.getVirAttrs().clear();
    effectivePatch.getVirAttrs().addAll(virAttrs);
    return new WorkflowResult<>(Pair.of(effectivePatch, !user.isSuspended()), propByRes, "update");
}
Also used : WorkflowResult(org.apache.syncope.core.provisioning.api.WorkflowResult) PasswordPatch(org.apache.syncope.common.lib.patch.PasswordPatch) UserTO(org.apache.syncope.common.lib.to.UserTO) AttrTO(org.apache.syncope.common.lib.to.AttrTO) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource) UserPatch(org.apache.syncope.common.lib.patch.UserPatch)

Example 9 with PropagationByResource

use of org.apache.syncope.core.provisioning.api.PropagationByResource in project syncope by apache.

the class CamelUserProvisioningManager method update.

@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
@SuppressWarnings("unchecked")
public Pair<UserPatch, List<PropagationStatus>> update(final UserPatch userPatch, final ProvisioningReport result, final Boolean enabled, final Set<String> excludedResources, final boolean nullPriorityAsync) {
    PollingConsumer pollingConsumer = getConsumer("direct:updateInPullPort");
    Map<String, Object> props = new HashMap<>();
    props.put("key", userPatch.getKey());
    props.put("result", result);
    props.put("enabled", enabled);
    props.put("excludedResources", excludedResources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    sendMessage("direct:updateUserInPull", userPatch, props);
    Exchange exchange = pollingConsumer.receive();
    Exception ex = (Exception) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    if (ex != null) {
        LOG.error("Update of user {} failed, trying to pull its status anyway (if configured)", nullPriorityAsync, ex);
        result.setStatus(ProvisioningReport.Status.FAILURE);
        result.setMessage("Update failed, trying to pull status anyway (if configured)\n" + ex.getMessage());
        WorkflowResult<Pair<UserPatch, Boolean>> updated = new WorkflowResult<>(Pair.of(userPatch, false), new PropagationByResource(), new HashSet<>());
        sendMessage("direct:userInPull", updated, props);
        exchange = pollingConsumer.receive();
    }
    return exchange.getIn().getBody(Pair.class);
}
Also used : Exchange(org.apache.camel.Exchange) PollingConsumer(org.apache.camel.PollingConsumer) WorkflowResult(org.apache.syncope.core.provisioning.api.WorkflowResult) HashMap(java.util.HashMap) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource) Pair(org.apache.commons.lang3.tuple.Pair) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with PropagationByResource

use of org.apache.syncope.core.provisioning.api.PropagationByResource in project syncope by apache.

the class DeleteProducer method process.

@SuppressWarnings("unchecked")
@Override
public void process(final Exchange exchange) throws Exception {
    String key = exchange.getIn().getBody(String.class);
    Set<String> excludedResources = exchange.getProperty("excludedResources", Set.class);
    Boolean nullPriorityAsync = exchange.getProperty("nullPriorityAsync", Boolean.class);
    if (null != getAnyTypeKind()) {
        List<PropagationTaskTO> tasks;
        PropagationReporter propagationReporter;
        switch(getAnyTypeKind()) {
            case USER:
                PropagationByResource propByRes = new PropagationByResource();
                propByRes.set(ResourceOperation.DELETE, userDAO.findAllResourceKeys(key));
                // Note here that we can only notify about "delete", not any other
                // task defined in workflow process definition: this because this
                // information could only be available after uwfAdapter.delete(), which
                // will also effectively remove user from db, thus making virtually
                // impossible by NotificationManager to fetch required user information
                tasks = getPropagationManager().getDeleteTasks(AnyTypeKind.USER, key, propByRes, excludedResources);
                propagationReporter = getPropagationTaskExecutor().execute(tasks, nullPriorityAsync);
                exchange.setProperty("statuses", propagationReporter.getStatuses());
                break;
            case GROUP:
                tasks = new ArrayList<>();
                // resources only because of the reason being deleted (see SYNCOPE-357)
                for (Map.Entry<String, PropagationByResource> entry : groupDataBinder.findUsersWithTransitiveResources(key).entrySet()) {
                    tasks.addAll(getPropagationManager().getDeleteTasks(AnyTypeKind.USER, entry.getKey(), entry.getValue(), excludedResources));
                }
                for (Map.Entry<String, PropagationByResource> entry : groupDataBinder.findAnyObjectsWithTransitiveResources(key).entrySet()) {
                    tasks.addAll(getPropagationManager().getDeleteTasks(AnyTypeKind.ANY_OBJECT, entry.getKey(), entry.getValue(), excludedResources));
                }
                // Generate propagation tasks for deleting this group from resources
                tasks.addAll(getPropagationManager().getDeleteTasks(AnyTypeKind.GROUP, key, null, null));
                propagationReporter = getPropagationTaskExecutor().execute(tasks, nullPriorityAsync);
                exchange.setProperty("statuses", propagationReporter.getStatuses());
                break;
            case ANY_OBJECT:
                tasks = getPropagationManager().getDeleteTasks(AnyTypeKind.ANY_OBJECT, key, null, excludedResources);
                propagationReporter = getPropagationTaskExecutor().execute(tasks, nullPriorityAsync);
                exchange.setProperty("statuses", propagationReporter.getStatuses());
                break;
            default:
                break;
        }
    }
}
Also used : PropagationTaskTO(org.apache.syncope.common.lib.to.PropagationTaskTO) PropagationReporter(org.apache.syncope.core.provisioning.api.propagation.PropagationReporter) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource) Map(java.util.Map)

Aggregations

PropagationByResource (org.apache.syncope.core.provisioning.api.PropagationByResource)56 PropagationReporter (org.apache.syncope.core.provisioning.api.propagation.PropagationReporter)23 PropagationTaskTO (org.apache.syncope.common.lib.to.PropagationTaskTO)21 WorkflowResult (org.apache.syncope.core.provisioning.api.WorkflowResult)19 Realm (org.apache.syncope.core.persistence.api.entity.Realm)13 ArrayList (java.util.ArrayList)12 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)12 User (org.apache.syncope.core.persistence.api.entity.user.User)12 HashMap (java.util.HashMap)11 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)11 Transactional (org.springframework.transaction.annotation.Transactional)10 PropagationException (org.apache.syncope.core.provisioning.api.propagation.PropagationException)9 Pair (org.apache.commons.lang3.tuple.Pair)8 List (java.util.List)7 RealmTO (org.apache.syncope.common.lib.to.RealmTO)7 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)7 Map (java.util.Map)6 Collectors (java.util.stream.Collectors)6 PasswordPatch (org.apache.syncope.common.lib.patch.PasswordPatch)6 AttrTO (org.apache.syncope.common.lib.to.AttrTO)6