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");
}
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");
}
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");
}
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);
}
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;
}
}
}
Aggregations