use of org.apache.syncope.core.provisioning.api.PropagationByResource 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();
}
use of org.apache.syncope.core.provisioning.api.PropagationByResource in project syncope by apache.
the class FlowableUserWorkflowAdapter method submitForm.
@Override
public WorkflowResult<UserPatch> submitForm(final WorkflowFormTO form) {
String authUser = AuthContextUtils.getUsername();
Pair<Task, TaskFormData> checked = checkTask(form.getTaskId(), authUser);
if (!checked.getKey().getOwner().equals(authUser)) {
throw new WorkflowException(new IllegalArgumentException("Task " + form.getTaskId() + " assigned to " + checked.getKey().getOwner() + " but submitted by " + authUser));
}
User user = userDAO.findByWorkflowId(checked.getKey().getProcessInstanceId());
if (user == null) {
throw new NotFoundException("User with workflow id " + checked.getKey().getProcessInstanceId());
}
Set<String> preTasks = getPerformedTasks(user);
try {
engine.getFormService().submitTaskFormData(form.getTaskId(), getPropertiesForSubmit(form));
engine.getRuntimeService().setVariable(user.getWorkflowId(), FORM_SUBMITTER, authUser);
} catch (FlowableException e) {
throwException(e, "While submitting form for task " + form.getTaskId());
}
Set<String> postTasks = getPerformedTasks(user);
postTasks.removeAll(preTasks);
postTasks.add(form.getTaskId());
updateStatus(user);
User updated = userDAO.save(user);
// see if there is any propagation to be done
PropagationByResource propByRes = engine.getRuntimeService().getVariable(user.getWorkflowId(), PROP_BY_RESOURCE, PropagationByResource.class);
// fetch - if available - the encrypted password
String clearPassword = null;
String encryptedPwd = engine.getRuntimeService().getVariable(user.getWorkflowId(), ENCRYPTED_PWD, String.class);
if (StringUtils.isNotBlank(encryptedPwd)) {
clearPassword = decrypt(encryptedPwd);
}
// supports approval chains
saveForFormSubmit(user, clearPassword, propByRes);
UserPatch userPatch = engine.getRuntimeService().getVariable(user.getWorkflowId(), USER_PATCH, UserPatch.class);
if (userPatch == null) {
userPatch = new UserPatch();
userPatch.setKey(updated.getKey());
userPatch.setPassword(new PasswordPatch.Builder().onSyncope(true).value(clearPassword).build());
if (propByRes != null) {
userPatch.getPassword().getResources().addAll(propByRes.get(ResourceOperation.CREATE));
}
}
return new WorkflowResult<>(userPatch, propByRes, postTasks);
}
use of org.apache.syncope.core.provisioning.api.PropagationByResource in project syncope by apache.
the class FlowableUserWorkflowAdapter method execute.
@Override
public WorkflowResult<String> execute(final UserTO userTO, final String taskId) {
User user = userDAO.authFind(userTO.getKey());
Map<String, Object> variables = new HashMap<>();
variables.put(USER_TO, userTO);
Set<String> performedTasks = doExecuteTask(user, taskId, variables);
updateStatus(user);
User updated = userDAO.save(user);
PropagationByResource propByRes = engine.getRuntimeService().getVariable(user.getWorkflowId(), PROP_BY_RESOURCE, PropagationByResource.class);
saveForFormSubmit(updated, userTO.getPassword(), propByRes);
return new WorkflowResult<>(updated.getKey(), null, performedTasks);
}
use of org.apache.syncope.core.provisioning.api.PropagationByResource in project syncope by apache.
the class FlowableUserWorkflowAdapter method requestCertify.
@Override
public WorkflowResult<String> requestCertify(final User user) {
String authUser = AuthContextUtils.getUsername();
engine.getRuntimeService().setVariable(user.getWorkflowId(), FORM_SUBMITTER, authUser);
LOG.debug("Executing request-certify");
Set<String> performedTasks = doExecuteTask(user, "request-certify", null);
PropagationByResource propByRes = engine.getRuntimeService().getVariable(user.getWorkflowId(), PROP_BY_RESOURCE, PropagationByResource.class);
saveForFormSubmit(user, null, propByRes);
return new WorkflowResult<>(user.getKey(), null, performedTasks);
}
use of org.apache.syncope.core.provisioning.api.PropagationByResource in project syncope by apache.
the class FlowableUserWorkflowAdapter method doUpdate.
@Override
protected WorkflowResult<Pair<UserPatch, Boolean>> doUpdate(final User user, final UserPatch userPatch) {
Set<String> tasks = doExecuteTask(user, "update", Collections.singletonMap(USER_PATCH, (Object) userPatch));
updateStatus(user);
User updated = userDAO.save(user);
PropagationByResource propByRes = engine.getRuntimeService().getVariable(user.getWorkflowId(), PROP_BY_RESOURCE, PropagationByResource.class);
UserPatch updatedPatch = engine.getRuntimeService().getVariable(user.getWorkflowId(), USER_PATCH, UserPatch.class);
saveForFormSubmit(updated, updatedPatch.getPassword() == null ? null : updatedPatch.getPassword().getValue(), propByRes);
Boolean propagateEnable = engine.getRuntimeService().getVariable(user.getWorkflowId(), PROPAGATE_ENABLE, Boolean.class);
return new WorkflowResult<>(Pair.of(updatedPatch, propagateEnable), propByRes, tasks);
}
Aggregations