Search in sources :

Example 31 with PropagationReporter

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

the class DefaultGroupProvisioningManager method update.

@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
public Pair<GroupPatch, List<PropagationStatus>> update(final GroupPatch groupPatch, final Set<String> excludedResources, final boolean nullPriorityAsync) {
    WorkflowResult<GroupPatch> updated = gwfAdapter.update(groupPatch);
    List<PropagationTaskTO> tasks = propagationManager.getUpdateTasks(AnyTypeKind.GROUP, updated.getResult().getKey(), false, null, updated.getPropByRes(), groupPatch.getVirAttrs(), excludedResources);
    PropagationReporter propagationReporter = taskExecutor.execute(tasks, nullPriorityAsync);
    return Pair.of(updated.getResult(), propagationReporter.getStatuses());
}
Also used : PropagationTaskTO(org.apache.syncope.common.lib.to.PropagationTaskTO) PropagationReporter(org.apache.syncope.core.provisioning.api.propagation.PropagationReporter) GroupPatch(org.apache.syncope.common.lib.patch.GroupPatch) Transactional(org.springframework.transaction.annotation.Transactional)

Example 32 with PropagationReporter

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

the class DefaultGroupProvisioningManager method provision.

@Override
public List<PropagationStatus> provision(final String key, final Collection<String> resources, final boolean nullPriorityAsync) {
    PropagationByResource propByRes = new PropagationByResource();
    propByRes.addAll(ResourceOperation.UPDATE, resources);
    List<PropagationTaskTO> tasks = propagationManager.getUpdateTasks(AnyTypeKind.GROUP, key, false, null, propByRes, null, null);
    PropagationReporter propagationReporter = taskExecutor.execute(tasks, nullPriorityAsync);
    return propagationReporter.getStatuses();
}
Also used : PropagationTaskTO(org.apache.syncope.common.lib.to.PropagationTaskTO) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource) PropagationReporter(org.apache.syncope.core.provisioning.api.propagation.PropagationReporter)

Example 33 with PropagationReporter

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

the class DefaultGroupProvisioningManager method deprovision.

@Override
public List<PropagationStatus> deprovision(final String key, final Collection<String> resources, final boolean nullPriorityAsync) {
    PropagationByResource propByRes = new PropagationByResource();
    propByRes.addAll(ResourceOperation.DELETE, resources);
    List<PropagationTaskTO> tasks = propagationManager.getDeleteTasks(AnyTypeKind.GROUP, key, propByRes, groupDAO.findAllResourceKeys(key).stream().filter(resource -> !resources.contains(resource)).collect(Collectors.toList()));
    PropagationReporter propagationReporter = taskExecutor.execute(tasks, nullPriorityAsync);
    return propagationReporter.getStatuses();
}
Also used : PropagationTaskTO(org.apache.syncope.common.lib.to.PropagationTaskTO) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource) PropagationReporter(org.apache.syncope.core.provisioning.api.propagation.PropagationReporter)

Example 34 with PropagationReporter

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

the class RealmLogic method update.

@PreAuthorize("hasRole('" + StandardEntitlement.REALM_UPDATE + "')")
public ProvisioningResult<RealmTO> update(final RealmTO realmTO) {
    Realm realm = realmDAO.findByFullPath(realmTO.getFullPath());
    if (realm == null) {
        LOG.error("Could not find realm '" + realmTO.getFullPath() + "'");
        throw new NotFoundException(realmTO.getFullPath());
    }
    PropagationByResource propByRes = binder.update(realm, realmTO);
    realm = realmDAO.save(realm);
    List<PropagationTaskTO> tasks = propagationManager.createTasks(realm, propByRes, null);
    PropagationReporter propagationReporter = taskExecutor.execute(tasks, false);
    ProvisioningResult<RealmTO> result = new ProvisioningResult<>();
    result.setEntity(binder.getRealmTO(realm, true));
    result.getPropagationStatuses().addAll(propagationReporter.getStatuses());
    return result;
}
Also used : PropagationTaskTO(org.apache.syncope.common.lib.to.PropagationTaskTO) ProvisioningResult(org.apache.syncope.common.lib.to.ProvisioningResult) RealmTO(org.apache.syncope.common.lib.to.RealmTO) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource) PropagationReporter(org.apache.syncope.core.provisioning.api.propagation.PropagationReporter) Realm(org.apache.syncope.core.persistence.api.entity.Realm) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 35 with PropagationReporter

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

the class RealmLogic method create.

@PreAuthorize("hasRole('" + StandardEntitlement.REALM_CREATE + "')")
public ProvisioningResult<RealmTO> create(final String parentPath, final RealmTO realmTO) {
    Realm parent;
    if (StringUtils.isBlank(realmTO.getParent())) {
        parent = realmDAO.findByFullPath(parentPath);
        if (parent == null) {
            LOG.error("Could not find parent realm " + parentPath);
            throw new NotFoundException(parentPath);
        }
        realmTO.setParent(parent.getFullPath());
    } else {
        parent = realmDAO.find(realmTO.getParent());
        if (parent == null) {
            LOG.error("Could not find parent realm " + realmTO.getParent());
            throw new NotFoundException(realmTO.getParent());
        }
        if (!parent.getFullPath().equals(parentPath)) {
            SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidPath);
            sce.getElements().add("Mismatching parent realm: " + parentPath + " Vs " + parent.getFullPath());
            throw sce;
        }
    }
    String fullPath = StringUtils.appendIfMissing(parent.getFullPath(), "/") + realmTO.getName();
    if (realmDAO.findByFullPath(fullPath) != null) {
        throw new DuplicateException(fullPath);
    }
    Realm realm = realmDAO.save(binder.create(parent, realmTO));
    PropagationByResource propByRes = new PropagationByResource();
    realm.getResourceKeys().forEach(resource -> {
        propByRes.add(ResourceOperation.CREATE, resource);
    });
    List<PropagationTaskTO> tasks = propagationManager.createTasks(realm, propByRes, null);
    PropagationReporter propagationReporter = taskExecutor.execute(tasks, false);
    ProvisioningResult<RealmTO> result = new ProvisioningResult<>();
    result.setEntity(binder.getRealmTO(realm, true));
    result.getPropagationStatuses().addAll(propagationReporter.getStatuses());
    return result;
}
Also used : PropagationTaskTO(org.apache.syncope.common.lib.to.PropagationTaskTO) DuplicateException(org.apache.syncope.core.persistence.api.dao.DuplicateException) ProvisioningResult(org.apache.syncope.common.lib.to.ProvisioningResult) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) RealmTO(org.apache.syncope.common.lib.to.RealmTO) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource) PropagationReporter(org.apache.syncope.core.provisioning.api.propagation.PropagationReporter) Realm(org.apache.syncope.core.persistence.api.entity.Realm) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

PropagationReporter (org.apache.syncope.core.provisioning.api.propagation.PropagationReporter)36 PropagationTaskTO (org.apache.syncope.common.lib.to.PropagationTaskTO)28 PropagationByResource (org.apache.syncope.core.provisioning.api.PropagationByResource)23 Transactional (org.springframework.transaction.annotation.Transactional)10 ArrayList (java.util.ArrayList)8 Pair (org.apache.commons.lang3.tuple.Pair)7 List (java.util.List)6 WorkflowResult (org.apache.syncope.core.provisioning.api.WorkflowResult)6 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)5 PropagationException (org.apache.syncope.core.provisioning.api.propagation.PropagationException)5 Map (java.util.Map)4 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)4 AnyTO (org.apache.syncope.common.lib.to.AnyTO)4 Realm (org.apache.syncope.core.persistence.api.entity.Realm)4 Collectors (java.util.stream.Collectors)3 ProvisioningResult (org.apache.syncope.common.lib.to.ProvisioningResult)3 RealmTO (org.apache.syncope.common.lib.to.RealmTO)3 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)3 User (org.apache.syncope.core.persistence.api.entity.user.User)3 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)3