use of org.apache.syncope.core.persistence.api.entity.user.User in project syncope by apache.
the class FlowableUserWorkflowAdapter method getHistoricFormTO.
protected WorkflowFormTO getHistoricFormTO(final String processInstanceId, final String taskId, final String formKey, final List<HistoricFormPropertyEntity> props) {
WorkflowFormTO formTO = new WorkflowFormTO();
User user = userDAO.findByWorkflowId(processInstanceId);
if (user == null) {
throw new NotFoundException("User with workflow id " + processInstanceId);
}
formTO.setUsername(user.getUsername());
formTO.setTaskId(taskId);
formTO.setKey(formKey);
formTO.setUserTO(engine.getRuntimeService().getVariable(processInstanceId, USER_TO, UserTO.class));
formTO.setUserPatch(engine.getRuntimeService().getVariable(processInstanceId, USER_PATCH, UserPatch.class));
props.stream().map(prop -> {
WorkflowFormPropertyTO propertyTO = new WorkflowFormPropertyTO();
propertyTO.setId(prop.getPropertyId());
propertyTO.setName(prop.getPropertyId());
propertyTO.setValue(prop.getPropertyValue());
return propertyTO;
}).forEachOrdered(propertyTO -> {
formTO.getProperties().add(propertyTO);
});
return formTO;
}
use of org.apache.syncope.core.persistence.api.entity.user.User in project syncope by apache.
the class FlowableUserWorkflowAdapter method checkTask.
protected Pair<Task, TaskFormData> checkTask(final String taskId, final String authUser) {
Task task;
try {
task = engine.getTaskService().createTaskQuery().taskId(taskId).singleResult();
if (task == null) {
throw new FlowableException("NULL result");
}
} catch (FlowableException e) {
throw new NotFoundException("Flowable Task " + taskId, e);
}
TaskFormData formData;
try {
formData = engine.getFormService().getTaskFormData(task.getId());
} catch (FlowableException e) {
throw new NotFoundException("Form for Flowable Task " + taskId, e);
}
if (!adminUser.equals(authUser)) {
User user = userDAO.findByUsername(authUser);
if (user == null) {
throw new NotFoundException("Syncope User " + authUser);
}
}
return Pair.of(task, formData);
}
use of org.apache.syncope.core.persistence.api.entity.user.User 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.persistence.api.entity.user.User in project syncope by apache.
the class FlowableUserWorkflowAdapter method doSuspend.
@Override
protected WorkflowResult<String> doSuspend(final User user) {
Set<String> performedTasks = doExecuteTask(user, "suspend", null);
updateStatus(user);
User updated = userDAO.save(user);
return new WorkflowResult<>(updated.getKey(), null, performedTasks);
}
use of org.apache.syncope.core.persistence.api.entity.user.User in project syncope by apache.
the class FlowableUserWorkflowAdapter method doReactivate.
@Override
protected WorkflowResult<String> doReactivate(final User user) {
Set<String> performedTasks = doExecuteTask(user, "reactivate", null);
updateStatus(user);
User updated = userDAO.save(user);
return new WorkflowResult<>(updated.getKey(), null, performedTasks);
}
Aggregations