use of org.apache.syncope.core.provisioning.api.PropagationByResource in project syncope by apache.
the class FlowableUserWorkflowAdapter method doConfirmPasswordReset.
@Override
protected WorkflowResult<Pair<UserPatch, Boolean>> doConfirmPasswordReset(final User user, final String token, final String password) {
Map<String, Object> variables = new HashMap<>(4);
variables.put(TOKEN, token);
variables.put(PASSWORD, password);
variables.put(USER_TO, dataBinder.getUserTO(user, true));
variables.put(EVENT, "confirmPasswordReset");
Set<String> tasks = doExecuteTask(user, "confirmPasswordReset", variables);
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);
Boolean propagateEnable = engine.getRuntimeService().getVariable(user.getWorkflowId(), PROPAGATE_ENABLE, Boolean.class);
return new WorkflowResult<>(Pair.of(updatedPatch, propagateEnable), propByRes, tasks);
}
use of org.apache.syncope.core.provisioning.api.PropagationByResource in project syncope by apache.
the class FlowableUserWorkflowAdapter method doCreate.
@Override
protected WorkflowResult<Pair<String, Boolean>> doCreate(final UserTO userTO, final boolean disablePwdPolicyCheck, final Boolean enabled, final boolean storePassword) {
Map<String, Object> variables = new HashMap<>();
variables.put(WF_EXECUTOR, AuthContextUtils.getUsername());
variables.put(USER_TO, userTO);
variables.put(ENABLED, enabled);
variables.put(STORE_PASSWORD, storePassword);
ProcessInstance processInstance = null;
try {
processInstance = engine.getRuntimeService().startProcessInstanceByKey(WF_PROCESS_ID, variables);
} catch (FlowableException e) {
throwException(e, "While starting " + WF_PROCESS_ID + " instance");
}
User user = engine.getRuntimeService().getVariable(processInstance.getProcessInstanceId(), USER, User.class);
Boolean updatedEnabled = engine.getRuntimeService().getVariable(processInstance.getProcessInstanceId(), ENABLED, Boolean.class);
if (updatedEnabled != null) {
user.setSuspended(!updatedEnabled);
}
// this will make UserValidator not to consider password policies at all
if (disablePwdPolicyCheck) {
user.removeClearPassword();
}
updateStatus(user);
user = userDAO.save(user);
Boolean propagateEnable = engine.getRuntimeService().getVariable(processInstance.getProcessInstanceId(), PROPAGATE_ENABLE, Boolean.class);
if (propagateEnable == null) {
propagateEnable = enabled;
}
PropagationByResource propByRes = new PropagationByResource();
propByRes.set(ResourceOperation.CREATE, userDAO.findAllResourceKeys(user.getKey()));
saveForFormSubmit(user, userTO.getPassword(), propByRes);
Set<String> tasks = getPerformedTasks(user);
return new WorkflowResult<>(Pair.of(user.getKey(), propagateEnable), propByRes, tasks);
}
use of org.apache.syncope.core.provisioning.api.PropagationByResource in project syncope by apache.
the class FlowableUserWorkflowAdapter method doDelete.
@Override
protected void doDelete(final User user) {
doExecuteTask(user, "delete", null);
PropagationByResource propByRes = new PropagationByResource();
propByRes.set(ResourceOperation.DELETE, userDAO.findAllResourceKeys(user.getKey()));
saveForFormSubmit(user, null, propByRes);
if (engine.getRuntimeService().createProcessInstanceQuery().processInstanceId(user.getWorkflowId()).active().list().isEmpty()) {
userDAO.delete(user.getKey());
if (!engine.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(user.getWorkflowId()).list().isEmpty()) {
engine.getHistoryService().deleteHistoricProcessInstance(user.getWorkflowId());
}
} else {
updateStatus(user);
userDAO.save(user);
}
}
use of org.apache.syncope.core.provisioning.api.PropagationByResource in project syncope by apache.
the class Update method doExecute.
@Override
protected void doExecute(final String executionId) {
User user = engine.getRuntimeService().getVariable(executionId, FlowableUserWorkflowAdapter.USER, User.class);
UserPatch userPatch = engine.getRuntimeService().getVariable(executionId, FlowableUserWorkflowAdapter.USER_PATCH, UserPatch.class);
user = userDAO.save(user);
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(user.getKey());
userPatch = AnyOperations.diff(updated, original, false);
userPatch.setPassword(password);
userPatch.getVirAttrs().clear();
userPatch.getVirAttrs().addAll(virAttrs);
// report updated user and propagation by resource as result
engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.USER, user);
engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.USER_TO, updated);
engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.USER_PATCH, userPatch);
engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.PROP_BY_RESOURCE, propByRes);
}
use of org.apache.syncope.core.provisioning.api.PropagationByResource in project syncope by apache.
the class DefaultAnyObjectWorkflowAdapter method doUpdate.
@Override
protected WorkflowResult<AnyObjectPatch> doUpdate(final AnyObject anyObject, final AnyObjectPatch anyObjectPatch) {
AnyObjectTO original = dataBinder.getAnyObjectTO(anyObject, true);
PropagationByResource propByRes = dataBinder.update(anyObject, anyObjectPatch);
Set<AttrTO> virAttrs = anyObjectPatch.getVirAttrs();
AnyObjectTO updated = dataBinder.getAnyObjectTO(anyObjectDAO.save(anyObject), true);
AnyObjectPatch effectivePatch = AnyOperations.diff(updated, original, false);
effectivePatch.getVirAttrs().clear();
effectivePatch.getVirAttrs().addAll(virAttrs);
return new WorkflowResult<>(effectivePatch, propByRes, "update");
}
Aggregations