processInstance = runtimeService.startProcessInstanceByKey(WF_PROCESS_ID, variables);
} catch (ActivitiException e) {
throw new WorkflowException("While starting " + WF_PROCESS_ID + " instance", e);
}
SyncopeUser user = (SyncopeUser) runtimeService.getVariable(processInstance.getProcessInstanceId(),
SYNCOPE_USER);
Boolean updatedEnabled = (Boolean) runtimeService.getVariable(processInstance.getProcessInstanceId(), ENABLED);
if (updatedEnabled != null) {
user.setSuspended(!updatedEnabled);
}
// this will make SyncopeUserValidator not to consider password policies at all
if (disablePwdPolicyCheck) {
user.removeClearPassword();
}
updateStatus(user);
user = userDAO.save(user);
Boolean propagateEnable = (Boolean) runtimeService.getVariable(processInstance.getProcessInstanceId(),
PROPAGATE_ENABLE);
if (propagateEnable == null) {
propagateEnable = enabled;
}
// save resources to be propagated and password for later - after form submission - propagation
PropagationByResource propByRes = new PropagationByResource();
propByRes.set(ResourceOperation.CREATE, user.getResourceNames());
String formTaskId = getFormTask(user);
if (formTaskId != null) {
// SYNCOPE-238: This is needed to simplify the task query in this.getForms()
taskService.setVariableLocal(formTaskId, TASK_IS_FORM, Boolean.TRUE);
runtimeService.setVariable(processInstance.getProcessInstanceId(), PROP_BY_RESOURCE, propByRes);
propByRes = null;
if (StringUtils.isNotBlank(userTO.getPassword())) {
runtimeService.setVariable(
processInstance.getProcessInstanceId(), ENCRYPTED_PWD, encrypt(userTO.getPassword()));
}
}
return new WorkflowResult<Map.Entry<Long, Boolean>>(
new SimpleEntry<Long, Boolean>(user.getId(), propagateEnable), propByRes, getPerformedTasks(user));
}