You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2018/09/25 12:32:10 UTC
[12/34] syncope git commit: [SYNCOPE-1369] Flowable support
refactored as extension + code review (now with variable cleanup)
http://git-wip-us.apache.org/repos/asf/syncope/blob/3cabe08a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableUserWorkflowAdapter.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableUserWorkflowAdapter.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableUserWorkflowAdapter.java
deleted file mode 100644
index d71d8c2..0000000
--- a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableUserWorkflowAdapter.java
+++ /dev/null
@@ -1,1035 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.workflow.flowable;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
-import javax.annotation.Resource;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.tuple.Pair;
-import org.apache.syncope.common.lib.SyncopeClientException;
-import org.apache.syncope.common.lib.patch.PasswordPatch;
-import org.apache.syncope.common.lib.patch.UserPatch;
-import org.apache.syncope.common.lib.to.UserTO;
-import org.apache.syncope.common.lib.to.WorkflowDefinitionTO;
-import org.apache.syncope.common.lib.to.WorkflowFormPropertyTO;
-import org.apache.syncope.common.lib.to.WorkflowFormTO;
-import org.apache.syncope.common.lib.to.WorkflowTaskTO;
-import org.apache.syncope.core.provisioning.api.PropagationByResource;
-import org.apache.syncope.common.lib.types.ResourceOperation;
-import org.apache.syncope.common.lib.types.WorkflowFormPropertyType;
-import org.apache.syncope.core.spring.security.AuthContextUtils;
-import org.apache.syncope.core.spring.BeanUtils;
-import org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException;
-import org.apache.syncope.core.persistence.api.attrvalue.validation.ParsingValidationException;
-import org.apache.syncope.core.persistence.api.dao.NotFoundException;
-import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
-import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.apache.syncope.core.provisioning.api.WorkflowResult;
-import org.apache.syncope.core.workflow.flowable.spring.DomainProcessEngine;
-import org.apache.syncope.core.workflow.api.WorkflowDefinitionFormat;
-import org.apache.syncope.core.workflow.api.WorkflowException;
-import org.apache.syncope.core.workflow.java.AbstractUserWorkflowAdapter;
-import org.flowable.bpmn.converter.BpmnXMLConverter;
-import org.flowable.bpmn.model.BpmnModel;
-import org.flowable.bpmn.model.FlowElement;
-import org.flowable.bpmn.model.Gateway;
-import org.flowable.bpmn.model.Process;
-import org.flowable.bpmn.model.SequenceFlow;
-import org.flowable.editor.constants.ModelDataJsonConstants;
-import org.flowable.editor.language.json.converter.BpmnJsonConverter;
-import org.flowable.common.engine.api.FlowableException;
-import org.flowable.engine.form.FormProperty;
-import org.flowable.engine.form.FormType;
-import org.flowable.engine.form.TaskFormData;
-import org.flowable.engine.history.HistoricActivityInstance;
-import org.flowable.engine.impl.persistence.entity.HistoricFormPropertyEntity;
-import org.flowable.engine.repository.Deployment;
-import org.flowable.engine.repository.Model;
-import org.flowable.engine.repository.ProcessDefinition;
-import org.flowable.engine.runtime.ProcessInstance;
-import org.flowable.task.api.Task;
-import org.flowable.task.api.TaskQuery;
-import org.flowable.task.api.history.HistoricTaskInstance;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * <a href="http://www.flowable.org/">Flowable</a> based implementation.
- */
-public class FlowableUserWorkflowAdapter extends AbstractUserWorkflowAdapter {
-
- protected static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
-
- protected static final String[] PROPERTY_IGNORE_PROPS = { "type" };
-
- public static final String WF_PROCESS_ID = "userWorkflow";
-
- public static final String USER = "user";
-
- public static final String WF_EXECUTOR = "wfExecutor";
-
- public static final String FORM_SUBMITTER = "formSubmitter";
-
- public static final String USER_TO = "userTO";
-
- public static final String ENABLED = "enabled";
-
- public static final String USER_PATCH = "userPatch";
-
- public static final String EMAIL_KIND = "emailKind";
-
- public static final String TASK = "task";
-
- public static final String TOKEN = "token";
-
- public static final String PASSWORD = "password";
-
- public static final String PROP_BY_RESOURCE = "propByResource";
-
- public static final String PROPAGATE_ENABLE = "propagateEnable";
-
- public static final String ENCRYPTED_PWD = "encryptedPwd";
-
- public static final String TASK_IS_FORM = "taskIsForm";
-
- public static final String MODEL_DATA_JSON_MODEL = "model";
-
- public static final String STORE_PASSWORD = "storePassword";
-
- public static final String EVENT = "event";
-
- @Resource(name = "adminUser")
- protected String adminUser;
-
- @Autowired
- protected DomainProcessEngine engine;
-
- @Override
- public String getPrefix() {
- return "ACT_";
- }
-
- protected void throwException(final FlowableException e, final String defaultMessage) {
- if (e.getCause() != null) {
- if (e.getCause().getCause() instanceof SyncopeClientException) {
- throw (SyncopeClientException) e.getCause().getCause();
- } else if (e.getCause().getCause() instanceof ParsingValidationException) {
- throw (ParsingValidationException) e.getCause().getCause();
- } else if (e.getCause().getCause() instanceof InvalidEntityException) {
- throw (InvalidEntityException) e.getCause().getCause();
- }
- }
-
- throw new WorkflowException(defaultMessage, e);
- }
-
- protected void updateStatus(final User user) {
- List<Task> tasks = engine.getTaskService().createTaskQuery().processInstanceId(user.getWorkflowId()).list();
- if (tasks.isEmpty() || tasks.size() > 1) {
- LOG.warn("While setting user status: unexpected task number ({})", tasks.size());
- } else {
- user.setStatus(tasks.get(0).getTaskDefinitionKey());
- }
- }
-
- protected String getFormTask(final User user) {
- String result = null;
-
- List<Task> tasks = engine.getTaskService().createTaskQuery().processInstanceId(user.getWorkflowId()).list();
- if (tasks.isEmpty() || tasks.size() > 1) {
- LOG.debug("While checking if form task: unexpected task number ({})", tasks.size());
- } else {
- try {
- TaskFormData formData = engine.getFormService().getTaskFormData(tasks.get(0).getId());
- if (formData != null && !formData.getFormProperties().isEmpty()) {
- result = tasks.get(0).getId();
- }
- } catch (FlowableException e) {
- LOG.warn("Could not get task form data", e);
- }
- }
-
- return result;
- }
-
- protected Set<String> getPerformedTasks(final User user) {
- final Set<String> result = new HashSet<>();
-
- engine.getHistoryService().createHistoricActivityInstanceQuery().executionId(user.getWorkflowId()).list().
- forEach((task) -> {
- result.add(task.getActivityId());
- });
-
- return result;
- }
-
- /**
- * Saves resources to be propagated and password for later - after form submission - propagation.
- *
- * @param user user
- * @param password password
- * @param propByRes current propagation actions against resources
- */
- protected void saveForFormSubmit(final User user, final String password, final PropagationByResource propByRes) {
- String formTaskId = getFormTask(user);
- if (formTaskId != null) {
- UserTO userTO = engine.getRuntimeService().getVariable(user.getWorkflowId(), USER_TO, UserTO.class);
- if (userTO != null) {
- userTO.setKey(user.getKey());
- userTO.setCreationDate(user.getCreationDate());
- userTO.setLastChangeDate(user.getLastChangeDate());
- if (password == null) {
- String encryptedPwd = engine.getRuntimeService().
- getVariable(user.getWorkflowId(), ENCRYPTED_PWD, String.class);
- if (encryptedPwd != null) {
- userTO.setPassword(decrypt(encryptedPwd));
- }
- } else {
- userTO.setPassword(password);
- }
-
- engine.getRuntimeService().setVariable(user.getWorkflowId(), USER_TO, userTO);
- }
-
- // SYNCOPE-238: This is needed to simplify the task query in this.getForms()
- engine.getTaskService().setVariableLocal(formTaskId, TASK_IS_FORM, Boolean.TRUE);
-
- engine.getRuntimeService().setVariable(user.getWorkflowId(), PROP_BY_RESOURCE, propByRes);
- if (propByRes != null) {
- propByRes.clear();
- }
-
- if (password != null) {
- engine.getRuntimeService().setVariable(user.getWorkflowId(), ENCRYPTED_PWD, encrypt(password));
- }
- }
- }
-
- public <T> T getVariable(final String executionId, final String variableName, final Class<T> variableClass) {
- return engine.getRuntimeService().getVariable(executionId, variableName, variableClass);
- }
-
- public void setVariable(final String executionId, final String variableName, final Object value) {
- engine.getRuntimeService().setVariable(executionId, variableName, value);
- }
-
- @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);
- }
-
- protected Set<String> doExecuteTask(final User user, final String task, final Map<String, Object> moreVariables) {
- Set<String> preTasks = getPerformedTasks(user);
-
- Map<String, Object> variables = new HashMap<>();
- variables.put(WF_EXECUTOR, AuthContextUtils.getUsername());
- variables.put(TASK, task);
-
- // using BeanUtils to access all user's properties and trigger lazy loading - we are about to
- // serialize a User instance for availability within workflow tasks, and this breaks transactions
- BeanUtils.copyProperties(user, entityFactory.newEntity(User.class));
- variables.put(USER, user);
-
- if (moreVariables != null && !moreVariables.isEmpty()) {
- variables.putAll(moreVariables);
- }
-
- if (StringUtils.isBlank(user.getWorkflowId())) {
- throw new WorkflowException(new NotFoundException("Empty workflow id for " + user));
- }
-
- List<Task> tasks = engine.getTaskService().createTaskQuery().processInstanceId(user.getWorkflowId()).list();
- if (tasks.size() == 1) {
- try {
- engine.getTaskService().complete(tasks.get(0).getId(), variables);
- } catch (FlowableException e) {
- throwException(e, "While completing task '" + tasks.get(0).getName() + "' for " + user);
- }
- } else {
- LOG.warn("Expected a single task, found {}", tasks.size());
- }
-
- Set<String> postTasks = getPerformedTasks(user);
- postTasks.removeAll(preTasks);
- postTasks.add(task);
-
- return postTasks;
- }
-
- @Override
- protected WorkflowResult<String> doActivate(final User user, final String token) {
- Set<String> tasks = doExecuteTask(user, "activate", Collections.singletonMap(TOKEN, (Object) token));
-
- updateStatus(user);
- User updated = userDAO.save(user);
-
- return new WorkflowResult<>(updated.getKey(), null, tasks);
- }
-
- @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);
- saveForFormSubmit(
- updated, userPatch.getPassword() == null ? null : userPatch.getPassword().getValue(), propByRes);
-
- Boolean propagateEnable = engine.getRuntimeService().getVariable(
- user.getWorkflowId(), PROPAGATE_ENABLE, Boolean.class);
-
- return new WorkflowResult<>(Pair.of(userPatch, propagateEnable), propByRes, tasks);
- }
-
- @Override
- public WorkflowResult<String> requestCertify(final User user) {
- String authUser = AuthContextUtils.getUsername();
- engine.getRuntimeService().setVariable(user.getWorkflowId(), FORM_SUBMITTER, authUser);
-
- 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);
- }
-
- @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);
- }
-
- @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);
- }
-
- @Override
- protected void doRequestPasswordReset(final User user) {
- Map<String, Object> variables = new HashMap<>(2);
- variables.put(USER_TO, dataBinder.getUserTO(user, true));
- variables.put(EVENT, "requestPasswordReset");
-
- doExecuteTask(user, "requestPasswordReset", variables);
- userDAO.save(user);
- }
-
- @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);
- }
-
- @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);
- }
- }
-
- @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);
- }
-
- protected WorkflowFormPropertyType fromFlowableFormType(final FormType flowableFormType) {
- WorkflowFormPropertyType result = WorkflowFormPropertyType.String;
-
- if ("string".equals(flowableFormType.getName())) {
- result = WorkflowFormPropertyType.String;
- }
- if ("long".equals(flowableFormType.getName())) {
- result = WorkflowFormPropertyType.Long;
- }
- if ("enum".equals(flowableFormType.getName())) {
- result = WorkflowFormPropertyType.Enum;
- }
- if ("date".equals(flowableFormType.getName())) {
- result = WorkflowFormPropertyType.Date;
- }
- if ("boolean".equals(flowableFormType.getName())) {
- result = WorkflowFormPropertyType.Boolean;
- }
-
- return result;
- }
-
- protected WorkflowFormTO getFormTO(final Task task) {
- return getFormTO(task, engine.getFormService().getTaskFormData(task.getId()));
- }
-
- protected WorkflowFormTO getFormTO(final Task task, final TaskFormData fd) {
- WorkflowFormTO formTO =
- getFormTO(task.getProcessInstanceId(), task.getId(), fd.getFormKey(), fd.getFormProperties());
- BeanUtils.copyProperties(task, formTO);
-
- return formTO;
- }
-
- protected WorkflowFormTO getFormTO(final HistoricTaskInstance task) {
- final List<HistoricFormPropertyEntity> props = new ArrayList<>();
-
- engine.getHistoryService().createHistoricDetailQuery().taskId(task.getId()).list().stream().
- filter(historicDetail -> (historicDetail instanceof HistoricFormPropertyEntity)).
- forEachOrdered(historicDetail -> {
- props.add((HistoricFormPropertyEntity) historicDetail);
- });
-
- WorkflowFormTO formTO = getHistoricFormTO(
- task.getProcessInstanceId(), task.getId(), task.getFormKey(), props);
- BeanUtils.copyProperties(task, formTO);
-
- HistoricActivityInstance historicActivityInstance = engine.getHistoryService().
- createHistoricActivityInstanceQuery().
- executionId(task.getExecutionId()).activityType("userTask").activityName(task.getName()).singleResult();
-
- if (historicActivityInstance != null) {
- formTO.setCreateTime(historicActivityInstance.getStartTime());
- formTO.setDueDate(historicActivityInstance.getEndTime());
- }
-
- return formTO;
- }
-
- 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;
- }
-
- @SuppressWarnings("unchecked")
- protected WorkflowFormTO getFormTO(
- final String processInstanceId,
- final String taskId,
- final String formKey,
- final List<FormProperty> properties) {
-
- 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));
-
- properties.stream().map(fProp -> {
- WorkflowFormPropertyTO propertyTO = new WorkflowFormPropertyTO();
- BeanUtils.copyProperties(fProp, propertyTO, PROPERTY_IGNORE_PROPS);
- propertyTO.setType(fromFlowableFormType(fProp.getType()));
- if (propertyTO.getType() == WorkflowFormPropertyType.Date) {
- propertyTO.setDatePattern((String) fProp.getType().getInformation("datePattern"));
- }
- if (propertyTO.getType() == WorkflowFormPropertyType.Enum) {
- propertyTO.getEnumValues().putAll((Map<String, String>) fProp.getType().getInformation("values"));
- }
- return propertyTO;
- }).forEachOrdered(propertyTO -> {
- formTO.getProperties().add(propertyTO);
- });
-
- return formTO;
- }
-
- @Transactional(readOnly = true)
- @Override
- public Pair<Integer, List<WorkflowFormTO>> getForms(
- final int page, final int size, final List<OrderByClause> orderByClauses) {
-
- Pair<Integer, List<WorkflowFormTO>> forms = null;
-
- String authUser = AuthContextUtils.getUsername();
- if (adminUser.equals(authUser)) {
- forms = getForms(engine.getTaskService().createTaskQuery().
- taskVariableValueEquals(TASK_IS_FORM, Boolean.TRUE), page, size, orderByClauses);
- } else {
- User user = userDAO.findByUsername(authUser);
- if (user == null) {
- throw new NotFoundException("Syncope User " + authUser);
- }
-
- forms = getForms(engine.getTaskService().createTaskQuery().
- taskVariableValueEquals(TASK_IS_FORM, Boolean.TRUE).
- taskCandidateOrAssigned(user.getUsername()), page, size, orderByClauses);
-
- List<String> candidateGroups = new ArrayList<>();
- userDAO.findAllGroupNames(user).forEach(group -> {
- candidateGroups.add(group);
- });
- if (!candidateGroups.isEmpty()) {
- forms = getForms(engine.getTaskService().createTaskQuery().
- taskVariableValueEquals(TASK_IS_FORM, Boolean.TRUE).
- taskCandidateGroupIn(candidateGroups), page, size, orderByClauses);
- }
- }
-
- return forms == null
- ? Pair.of(0, Collections.<WorkflowFormTO>emptyList())
- : forms;
- }
-
- protected Pair<Integer, List<WorkflowFormTO>> getForms(
- final TaskQuery query, final int page, final int size, final List<OrderByClause> orderByClauses) {
-
- TaskQuery sortedQuery = query;
- for (OrderByClause clause : orderByClauses) {
- boolean ack = true;
- switch (clause.getField().trim()) {
- case "taskId":
- sortedQuery = sortedQuery.orderByTaskId();
- break;
-
- case "createTime":
- sortedQuery = sortedQuery.orderByTaskCreateTime();
- break;
-
- case "dueDate":
- sortedQuery = sortedQuery.orderByTaskDueDate();
- break;
-
- case "owner":
- sortedQuery = sortedQuery.orderByTaskOwner();
- break;
-
- default:
- LOG.warn("Form sort request by {}: unsupported, ignoring", clause.getField().trim());
- ack = false;
- }
- if (ack) {
- if (clause.getDirection() == OrderByClause.Direction.ASC) {
- sortedQuery = sortedQuery.asc();
- } else {
- sortedQuery = sortedQuery.desc();
- }
- }
- }
-
- List<WorkflowFormTO> result = sortedQuery.listPage(size * (page <= 0 ? 0 : page - 1), size).stream().
- map(task -> {
- if (task instanceof HistoricTaskInstance) {
- return getFormTO((HistoricTaskInstance) task);
- } else {
- return getFormTO(task);
- }
- }).collect(Collectors.toList());
-
- return Pair.of((int) query.count(), result);
- }
-
- @Override
- public WorkflowFormTO getForm(final String workflowId) {
- Task task;
- try {
- task = engine.getTaskService().createTaskQuery().processInstanceId(workflowId).singleResult();
- } catch (FlowableException e) {
- throw new WorkflowException("While reading form for workflow instance " + workflowId, e);
- }
-
- TaskFormData formData;
- try {
- formData = engine.getFormService().getTaskFormData(task.getId());
- } catch (FlowableException e) {
- LOG.debug("No form found for task {}", task.getId(), e);
- formData = null;
- }
-
- WorkflowFormTO result = null;
- if (formData != null && !formData.getFormProperties().isEmpty()) {
- result = getFormTO(task);
- }
-
- return result;
- }
-
- 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);
- }
-
- @Override
- public WorkflowFormTO claimForm(final String taskId) {
- String authUser = AuthContextUtils.getUsername();
- Pair<Task, TaskFormData> checked = checkTask(taskId, authUser);
-
- if (!adminUser.equals(authUser)) {
- List<Task> tasksForUser = engine.getTaskService().createTaskQuery().taskId(taskId).taskCandidateUser(
- authUser).list();
- if (tasksForUser.isEmpty()) {
- throw new WorkflowException(
- new IllegalArgumentException(authUser + " is not candidate for task " + taskId));
- }
- }
-
- Task task;
- try {
- engine.getTaskService().setOwner(taskId, authUser);
- task = engine.getTaskService().createTaskQuery().taskId(taskId).singleResult();
- } catch (FlowableException e) {
- throw new WorkflowException("While reading task " + taskId, e);
- }
-
- return getFormTO(task, checked.getValue());
- }
-
- private Map<String, String> getPropertiesForSubmit(final WorkflowFormTO form) {
- Map<String, String> props = new HashMap<>();
- form.getProperties().stream().
- filter(prop -> (prop.isWritable())).
- forEachOrdered(prop -> {
- props.put(prop.getId(), prop.getValue());
- });
-
- return Collections.unmodifiableMap(props);
- }
-
- @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);
- }
-
- protected void navigateAvailableTasks(final FlowElement flow, final List<String> availableTasks) {
- if (flow instanceof Gateway) {
- ((Gateway) flow).getOutgoingFlows().forEach(subflow -> navigateAvailableTasks(subflow, availableTasks));
- } else if (flow instanceof SequenceFlow) {
- availableTasks.add(((SequenceFlow) flow).getTargetRef());
- } else {
- LOG.debug("Unexpected flow found: {}", flow);
- }
- }
-
- @Override
- public List<WorkflowTaskTO> getAvailableTasks(final String workflowId) {
- List<String> availableTasks = new ArrayList<>();
- try {
- Task currentTask = engine.getTaskService().createTaskQuery().processInstanceId(workflowId).singleResult();
-
- Process process = engine.getRepositoryService().
- getBpmnModel(getProcessDefinitionByKey(WF_PROCESS_ID).getId()).getProcesses().get(0);
- process.getFlowElements().stream().
- filter(SequenceFlow.class::isInstance).
- map(SequenceFlow.class::cast).
- filter(sequenceFlow -> sequenceFlow.getSourceRef().equals(currentTask.getTaskDefinitionKey())).
- forEach(sequenceFlow -> {
- FlowElement target = process.getFlowElement(sequenceFlow.getTargetRef(), true);
- navigateAvailableTasks(target, availableTasks);
- });
- } catch (FlowableException e) {
- throw new WorkflowException("While reading available tasks for workflow instance " + workflowId, e);
- }
-
- return availableTasks.stream().map(input -> {
- WorkflowTaskTO workflowTaskTO = new WorkflowTaskTO();
- workflowTaskTO.setName(input);
- return workflowTaskTO;
- }).collect(Collectors.toList());
- }
-
- protected Model getModel(final ProcessDefinition procDef) {
- try {
- Model model = engine.getRepositoryService().createModelQuery().
- deploymentId(procDef.getDeploymentId()).singleResult();
- if (model == null) {
- throw new NotFoundException("Could not find Model for deployment " + procDef.getDeploymentId());
- }
- return model;
- } catch (Exception e) {
- throw new WorkflowException("While accessing process " + procDef.getKey(), e);
- }
- }
-
- @Override
- public List<WorkflowDefinitionTO> getDefinitions() {
- try {
- return engine.getRepositoryService().createProcessDefinitionQuery().latestVersion().list().stream().
- map(procDef -> {
- WorkflowDefinitionTO defTO = new WorkflowDefinitionTO();
- defTO.setKey(procDef.getKey());
- defTO.setName(procDef.getName());
-
- try {
- defTO.setModelId(getModel(procDef).getId());
- } catch (NotFoundException e) {
- LOG.warn("No model found for definition {}, ignoring", procDef.getDeploymentId(), e);
- }
-
- defTO.setMain(WF_PROCESS_ID.equals(procDef.getKey()));
-
- return defTO;
- }).collect(Collectors.toList());
- } catch (FlowableException e) {
- throw new WorkflowException("While listing available process definitions", e);
- }
- }
-
- protected ProcessDefinition getProcessDefinitionByKey(final String key) {
- try {
- return engine.getRepositoryService().createProcessDefinitionQuery().
- processDefinitionKey(key).latestVersion().singleResult();
- } catch (FlowableException e) {
- throw new WorkflowException("While accessing process " + key, e);
- }
-
- }
-
- protected ProcessDefinition getProcessDefinitionByDeploymentId(final String deploymentId) {
- try {
- return engine.getRepositoryService().createProcessDefinitionQuery().
- deploymentId(deploymentId).latestVersion().singleResult();
- } catch (FlowableException e) {
- throw new WorkflowException("While accessing deployment " + deploymentId, e);
- }
-
- }
-
- protected void exportProcessModel(final String key, final OutputStream os) {
- Model model = getModel(getProcessDefinitionByKey(key));
-
- try {
- ObjectNode modelNode = (ObjectNode) OBJECT_MAPPER.readTree(model.getMetaInfo());
- modelNode.put(ModelDataJsonConstants.MODEL_ID, model.getId());
- modelNode.replace(MODEL_DATA_JSON_MODEL,
- OBJECT_MAPPER.readTree(engine.getRepositoryService().getModelEditorSource(model.getId())));
-
- os.write(modelNode.toString().getBytes());
- } catch (IOException e) {
- LOG.error("While exporting workflow definition {}", model.getId(), e);
- }
- }
-
- protected void exportProcessResource(final String deploymentId, final String resourceName, final OutputStream os) {
- try (InputStream procDefIS = engine.getRepositoryService().getResourceAsStream(deploymentId, resourceName)) {
- IOUtils.copy(procDefIS, os);
- } catch (IOException e) {
- LOG.error("While exporting {}", resourceName, e);
- }
- }
-
- @Override
- public void exportDefinition(final String key, final WorkflowDefinitionFormat format, final OutputStream os) {
- switch (format) {
- case JSON:
- exportProcessModel(key, os);
- break;
-
- case XML:
- default:
- ProcessDefinition procDef = getProcessDefinitionByKey(key);
- exportProcessResource(procDef.getDeploymentId(), procDef.getResourceName(), os);
- }
- }
-
- @Override
- public void exportDiagram(final String key, final OutputStream os) {
- ProcessDefinition procDef = getProcessDefinitionByKey(key);
- if (procDef == null) {
- throw new NotFoundException("Workflow process definition for " + key);
- }
- exportProcessResource(procDef.getDeploymentId(), procDef.getDiagramResourceName(), os);
- }
-
- @Override
- public void importDefinition(final String key, final WorkflowDefinitionFormat format, final String definition) {
- ProcessDefinition procDef = getProcessDefinitionByKey(key);
- String resourceName = procDef == null ? key + ".bpmn20.xml" : procDef.getResourceName();
- Deployment deployment;
- switch (format) {
- case JSON:
- JsonNode definitionNode;
- try {
- definitionNode = OBJECT_MAPPER.readTree(definition);
- if (definitionNode.has(MODEL_DATA_JSON_MODEL)) {
- definitionNode = definitionNode.get(MODEL_DATA_JSON_MODEL);
- }
- if (!definitionNode.has(BpmnJsonConverter.EDITOR_CHILD_SHAPES)) {
- throw new IllegalArgumentException(
- "Could not find JSON node " + BpmnJsonConverter.EDITOR_CHILD_SHAPES);
- }
-
- BpmnModel bpmnModel = new BpmnJsonConverter().convertToBpmnModel(definitionNode);
- deployment = FlowableDeployUtils.deployDefinition(
- engine,
- resourceName,
- new BpmnXMLConverter().convertToXML(bpmnModel));
- } catch (Exception e) {
- throw new WorkflowException("While creating or updating process " + key, e);
- }
- break;
-
- case XML:
- default:
- deployment = FlowableDeployUtils.deployDefinition(
- engine,
- resourceName,
- definition.getBytes());
- }
-
- procDef = getProcessDefinitionByDeploymentId(deployment.getId());
- if (!key.equals(procDef.getKey())) {
- throw new WorkflowException("Mismatching key: expected " + key + ", found " + procDef.getKey());
- }
- FlowableDeployUtils.deployModel(engine, procDef);
- }
-
- @Override
- public void deleteDefinition(final String key) {
- ProcessDefinition procDef = getProcessDefinitionByKey(key);
- if (WF_PROCESS_ID.equals(procDef.getKey())) {
- throw new WorkflowException("Cannot delete the main process " + WF_PROCESS_ID);
- }
-
- try {
- engine.getRepositoryService().deleteDeployment(procDef.getDeploymentId());
- } catch (Exception e) {
- throw new WorkflowException("While deleting " + key, e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3cabe08a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableUtils.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableUtils.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableUtils.java
deleted file mode 100644
index b6a0fa6..0000000
--- a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableUtils.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.workflow.flowable;
-
-import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.springframework.transaction.annotation.Transactional;
-
-public class FlowableUtils {
-
- @Transactional(readOnly = true)
- public boolean isUserIngroup(final User user, final String groupName) {
- return user.getMemberships().stream().
- anyMatch(membership -> groupName != null && groupName.equals(membership.getRightEnd().getName()));
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3cabe08a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeEntitiesVariableType.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeEntitiesVariableType.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeEntitiesVariableType.java
deleted file mode 100644
index 81c2d88..0000000
--- a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeEntitiesVariableType.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.workflow.flowable;
-
-import org.apache.syncope.core.persistence.api.entity.Entity;
-import org.flowable.variable.service.impl.types.SerializableType;
-
-/**
- * Flowable variable type for handling Syncope entities as Flowable variables.
- * Main purpose: avoid Flowable to handle Syncope entities as JPA entities,
- * since this can cause troubles with transactions.
- */
-public class SyncopeEntitiesVariableType extends SerializableType {
-
- @Override
- public boolean isAbleToStore(final Object value) {
- return value instanceof Entity;
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3cabe08a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeGroupQueryImpl.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeGroupQueryImpl.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeGroupQueryImpl.java
deleted file mode 100644
index b2387e5..0000000
--- a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeGroupQueryImpl.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.workflow.flowable;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.stream.Collectors;
-import org.apache.syncope.core.persistence.api.dao.GroupDAO;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.flowable.idm.api.Group;
-import org.flowable.idm.engine.impl.GroupQueryImpl;
-import org.flowable.idm.engine.impl.persistence.entity.GroupEntity;
-import org.flowable.idm.engine.impl.persistence.entity.GroupEntityImpl;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-
-public class SyncopeGroupQueryImpl extends GroupQueryImpl {
-
- private static final long serialVersionUID = -2595069675443343682L;
-
- @Autowired
- private UserDAO userDAO;
-
- @Autowired
- private GroupDAO groupDAO;
-
- private List<Group> result;
-
- private Group fromSyncopeGroup(final String name) {
- GroupEntity group = new GroupEntityImpl();
- group.setId(name);
- return group;
- }
-
- private void execute() {
- if (id != null) {
- org.apache.syncope.core.persistence.api.entity.group.Group syncopeGroup = groupDAO.findByName(id);
- if (syncopeGroup == null) {
- result = Collections.emptyList();
- } else {
- result = Collections.singletonList(fromSyncopeGroup(syncopeGroup.getName()));
- }
- } else if (userId != null) {
- result = userDAO.findAllGroupNames(userDAO.findByUsername(userId)).stream().
- map(groupName -> fromSyncopeGroup(groupName)).
- collect(Collectors.toList());
- }
- }
-
- @Transactional(readOnly = true)
- @Override
- public long count() {
- checkQueryOk();
-
- this.resultType = ResultType.COUNT;
- if (result == null) {
- execute();
- }
- return result.size();
- }
-
- @Transactional(readOnly = true)
- @Override
- public List<Group> list() {
- checkQueryOk();
-
- this.resultType = ResultType.LIST;
- if (result == null) {
- execute();
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3cabe08a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeIdmIdentityService.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeIdmIdentityService.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeIdmIdentityService.java
deleted file mode 100644
index 7e0dff9..0000000
--- a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeIdmIdentityService.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.workflow.flowable;
-
-import org.flowable.idm.api.GroupQuery;
-import org.flowable.idm.api.UserQuery;
-import org.flowable.idm.engine.impl.IdmIdentityServiceImpl;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.ConfigurableApplicationContext;
-
-public class SyncopeIdmIdentityService extends IdmIdentityServiceImpl implements ApplicationContextAware {
-
- private ConfigurableApplicationContext ctx;
-
- @Override
- public void setApplicationContext(final ApplicationContext ctx) throws BeansException {
- this.ctx = (ConfigurableApplicationContext) ctx;
- }
-
- @Override
- public UserQuery createUserQuery() {
- return (UserQuery) ctx.getBeanFactory().
- createBean(SyncopeUserQueryImpl.class, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false);
- }
-
- @Override
- public GroupQuery createGroupQuery() {
- return (GroupQuery) ctx.getBeanFactory().
- createBean(SyncopeGroupQueryImpl.class, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3cabe08a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeSession.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeSession.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeSession.java
deleted file mode 100644
index 71a6f57..0000000
--- a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeSession.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.workflow.flowable;
-
-import org.flowable.common.engine.impl.interceptor.Session;
-
-public interface SyncopeSession extends Session {
-
- Class<?> getType();
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3cabe08a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeSessionFactory.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeSessionFactory.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeSessionFactory.java
deleted file mode 100644
index f9f0550..0000000
--- a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeSessionFactory.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.workflow.flowable;
-
-import org.flowable.common.engine.impl.interceptor.CommandContext;
-import org.flowable.common.engine.impl.interceptor.Session;
-import org.flowable.common.engine.impl.interceptor.SessionFactory;
-
-public class SyncopeSessionFactory implements SessionFactory {
-
- private SyncopeSession syncopeSession;
-
- @Override
- public Class<?> getSessionType() {
- return syncopeSession.getType();
- }
-
- @Override
- public Session openSession(final CommandContext cc) {
- return syncopeSession;
- }
-
- public SyncopeSession getSyncopeSession() {
- return syncopeSession;
- }
-
- public void setSyncopeSession(final SyncopeSession syncopeSession) {
- this.syncopeSession = syncopeSession;
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3cabe08a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeUserQueryImpl.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeUserQueryImpl.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeUserQueryImpl.java
deleted file mode 100644
index 6e8f0c7c7..0000000
--- a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeUserQueryImpl.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.workflow.flowable;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.apache.syncope.core.persistence.api.dao.GroupDAO;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.entity.group.Group;
-import org.apache.syncope.core.persistence.api.entity.user.UMembership;
-import org.flowable.idm.api.User;
-import org.flowable.idm.engine.impl.UserQueryImpl;
-import org.flowable.idm.engine.impl.persistence.entity.UserEntity;
-import org.flowable.idm.engine.impl.persistence.entity.UserEntityImpl;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-
-public class SyncopeUserQueryImpl extends UserQueryImpl {
-
- private static final long serialVersionUID = 4403344392227706318L;
-
- @Autowired
- private UserDAO userDAO;
-
- @Autowired
- private GroupDAO groupDAO;
-
- private List<User> result;
-
- private User fromSyncopeUser(final org.apache.syncope.core.persistence.api.entity.user.User syncopeUser) {
- UserEntity user = new UserEntityImpl();
- user.setId(syncopeUser.getUsername());
- return user;
- }
-
- private void execute() {
- if (id != null) {
- org.apache.syncope.core.persistence.api.entity.user.User user = userDAO.findByUsername(id);
- if (user == null) {
- result = Collections.<User>emptyList();
- } else if (groupId == null || userDAO.findAllGroupNames(user).contains(groupId)) {
- result = Collections.singletonList(fromSyncopeUser(user));
- }
- } else if (groupId != null) {
- Group group = groupDAO.findByName(groupId);
- if (group == null) {
- result = Collections.<User>emptyList();
- } else {
- result = new ArrayList<>();
- List<UMembership> memberships = groupDAO.findUMemberships(group);
- memberships.stream().map(membership -> fromSyncopeUser(membership.getLeftEnd())).
- filter(user -> (!result.contains(user))).
- forEachOrdered(user -> {
- result.add(user);
- });
- }
- }
- }
-
- @Transactional(readOnly = true)
- @Override
- public long count() {
- checkQueryOk();
-
- this.resultType = ResultType.COUNT;
- if (result == null) {
- execute();
- }
- return result.size();
- }
-
- @Transactional(readOnly = true)
- @Override
- public List<User> list() {
- checkQueryOk();
-
- this.resultType = ResultType.LIST;
- if (result == null) {
- execute();
- }
- return result;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3cabe08a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/spring/DomainProcessEngine.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/spring/DomainProcessEngine.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/spring/DomainProcessEngine.java
deleted file mode 100644
index 92e9aff..0000000
--- a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/spring/DomainProcessEngine.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.workflow.flowable.spring;
-
-import java.util.Collections;
-import java.util.Map;
-import javax.sql.DataSource;
-import org.apache.syncope.core.spring.security.AuthContextUtils;
-import org.flowable.engine.DynamicBpmnService;
-import org.flowable.engine.FormService;
-import org.flowable.engine.HistoryService;
-import org.flowable.engine.IdentityService;
-import org.flowable.engine.ManagementService;
-import org.flowable.engine.ProcessEngine;
-import org.flowable.engine.ProcessEngineConfiguration;
-import org.flowable.engine.RepositoryService;
-import org.flowable.engine.RuntimeService;
-import org.flowable.engine.TaskService;
-import org.flowable.engine.impl.ProcessEngineImpl;
-
-/**
- * {@link ProcessEngine} delegating actual method invocation to the inner map of {@link ProcessEngine} instances,
- * one for each Syncope domain.
- */
-public class DomainProcessEngine implements ProcessEngine {
-
- private final Map<String, ProcessEngine> engines;
-
- public DomainProcessEngine(final Map<String, ProcessEngine> engines) {
- this.engines = Collections.synchronizedMap(engines);
- }
-
- public Map<String, ProcessEngine> getEngines() {
- return engines;
- }
-
- @Override
- public String getName() {
- return engines.get(AuthContextUtils.getDomain()).getName();
- }
-
- @Override
- public void close() {
- engines.values().forEach(engine -> {
- engine.close();
- });
- }
-
- @Override
- public RepositoryService getRepositoryService() {
- return engines.get(AuthContextUtils.getDomain()).getRepositoryService();
- }
-
- @Override
- public RuntimeService getRuntimeService() {
- return engines.get(AuthContextUtils.getDomain()).getRuntimeService();
- }
-
- @Override
- public FormService getFormService() {
- return engines.get(AuthContextUtils.getDomain()).getFormService();
- }
-
- @Override
- public TaskService getTaskService() {
- return engines.get(AuthContextUtils.getDomain()).getTaskService();
- }
-
- @Override
- public HistoryService getHistoryService() {
- return engines.get(AuthContextUtils.getDomain()).getHistoryService();
- }
-
- @Override
- public IdentityService getIdentityService() {
- return engines.get(AuthContextUtils.getDomain()).getIdentityService();
- }
-
- @Override
- public ManagementService getManagementService() {
- return engines.get(AuthContextUtils.getDomain()).getManagementService();
- }
-
- @Override
- public ProcessEngineConfiguration getProcessEngineConfiguration() {
- return engines.get(AuthContextUtils.getDomain()).getProcessEngineConfiguration();
- }
-
- @Override
- public DynamicBpmnService getDynamicBpmnService() {
- return engines.get(AuthContextUtils.getDomain()).getDynamicBpmnService();
- }
-
- public DataSource getDataSource() {
- ProcessEngineImpl engine = (ProcessEngineImpl) engines.get(AuthContextUtils.getDomain());
- return engine.getProcessEngineConfiguration().getDataSource();
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3cabe08a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/spring/DomainProcessEngineFactoryBean.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/spring/DomainProcessEngineFactoryBean.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/spring/DomainProcessEngineFactoryBean.java
deleted file mode 100644
index ed6cd25..0000000
--- a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/spring/DomainProcessEngineFactoryBean.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.workflow.flowable.spring;
-
-import java.util.HashMap;
-import java.util.Map;
-import javax.sql.DataSource;
-import org.apache.commons.lang3.StringUtils;
-import org.flowable.engine.ProcessEngine;
-import org.flowable.common.engine.impl.cfg.SpringBeanFactoryProxyMap;
-import org.flowable.common.engine.impl.interceptor.EngineConfigurationConstants;
-import org.flowable.engine.impl.util.EngineServiceUtil;
-import org.flowable.idm.spring.SpringIdmEngineConfiguration;
-import org.flowable.spring.SpringExpressionManager;
-import org.flowable.spring.SpringProcessEngineConfiguration;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.transaction.PlatformTransactionManager;
-
-/**
- * Spring factory for {@link DomainProcessEngine} which takes the provided {@link SpringProcessEngineConfiguration} as
- * template for each of the configured Syncope domains.
- */
-public class DomainProcessEngineFactoryBean
- implements FactoryBean<DomainProcessEngine>, DisposableBean, ApplicationContextAware {
-
- private ApplicationContext ctx;
-
- private DomainProcessEngine engine;
-
- @Override
- public void setApplicationContext(final ApplicationContext ctx) throws BeansException {
- this.ctx = ctx;
- }
-
- @Override
- public DomainProcessEngine getObject() throws Exception {
- if (engine == null) {
- Map<String, ProcessEngine> engines = new HashMap<>();
-
- ctx.getBeansOfType(DataSource.class).forEach((key, dataSource) -> {
- if (!key.startsWith("local")) {
- String domain = StringUtils.substringBefore(key, DataSource.class.getSimpleName());
- PlatformTransactionManager transactionManager = ctx.getBean(
- domain + "TransactionManager", PlatformTransactionManager.class);
- Object entityManagerFactory = ctx.getBean(domain + "EntityManagerFactory");
-
- SpringProcessEngineConfiguration conf = ctx.getBean(SpringProcessEngineConfiguration.class);
- conf.setDataSource(dataSource);
- conf.setTransactionManager(transactionManager);
- conf.setTransactionsExternallyManaged(true);
- conf.setJpaEntityManagerFactory(entityManagerFactory);
- if (conf.getBeans() == null) {
- conf.setBeans(new SpringBeanFactoryProxyMap(ctx));
- }
- if (conf.getExpressionManager() == null) {
- conf.setExpressionManager(new SpringExpressionManager(ctx, conf.getBeans()));
- }
- if (EngineServiceUtil.getIdmEngineConfiguration(conf) == null) {
- conf.addEngineConfiguration(
- EngineConfigurationConstants.KEY_IDM_ENGINE_CONFIG,
- ctx.getBean(SpringIdmEngineConfiguration.class));
- }
-
- engines.put(domain, conf.buildProcessEngine());
- }
- });
-
- engine = new DomainProcessEngine(engines);
- }
-
- return engine;
- }
-
- @Override
- public Class<DomainProcessEngine> getObjectType() {
- return DomainProcessEngine.class;
- }
-
- @Override
- public boolean isSingleton() {
- return true;
- }
-
- @Override
- public void destroy() throws Exception {
- if (engine != null) {
- engine.close();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3cabe08a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/AbstractFlowableServiceTask.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/AbstractFlowableServiceTask.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/AbstractFlowableServiceTask.java
deleted file mode 100644
index b9f87ca..0000000
--- a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/AbstractFlowableServiceTask.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.workflow.flowable.task;
-
-import org.flowable.engine.ProcessEngine;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * Abstract base class for Flowable's service tasks in Syncope, with Spring support.
- */
-@Component
-public abstract class AbstractFlowableServiceTask {
-
- protected static final Logger LOG = LoggerFactory.getLogger(AbstractFlowableServiceTask.class);
-
- @Autowired
- protected ProcessEngine engine;
-
- @Transactional(rollbackFor = { Throwable.class })
- public void execute(final String executionId) {
- doExecute(executionId);
- }
-
- protected abstract void doExecute(final String executionId);
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3cabe08a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/AutoActivate.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/AutoActivate.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/AutoActivate.java
deleted file mode 100644
index 02ee77f..0000000
--- a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/AutoActivate.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.workflow.flowable.task;
-
-import org.apache.syncope.common.lib.AnyOperations;
-import org.apache.syncope.common.lib.patch.UserPatch;
-import org.apache.syncope.common.lib.to.UserTO;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.apache.syncope.core.provisioning.api.data.UserDataBinder;
-import org.apache.syncope.core.workflow.flowable.FlowableUserWorkflowAdapter;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class AutoActivate extends AbstractFlowableServiceTask {
-
- @Autowired
- private UserDataBinder dataBinder;
-
- @Autowired
- private UserDAO userDAO;
-
- @Override
- protected void doExecute(final String executionId) {
- User user = engine.getRuntimeService().
- getVariable(executionId, FlowableUserWorkflowAdapter.USER, User.class);
- UserTO userTO = engine.getRuntimeService().
- getVariable(executionId, FlowableUserWorkflowAdapter.USER_TO, UserTO.class);
- if (userTO != null && userTO.getKey() != null && user.getKey() != null) {
- user = userDAO.save(user);
-
- UserPatch userPatch = AnyOperations.diff(userTO, dataBinder.getUserTO(user, true), false);
- // don't mess with password, as the cleartext values was already properly saved
- userPatch.setPassword(null);
-
- dataBinder.update(user, userPatch);
-
- engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.USER, user);
- }
-
- engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.PROPAGATE_ENABLE, Boolean.TRUE);
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3cabe08a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Create.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Create.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Create.java
deleted file mode 100644
index be9bfec..0000000
--- a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Create.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.workflow.flowable.task;
-
-import org.apache.syncope.common.lib.to.UserTO;
-import org.apache.syncope.core.persistence.api.entity.EntityFactory;
-import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.apache.syncope.core.provisioning.api.data.UserDataBinder;
-import org.apache.syncope.core.workflow.flowable.FlowableUserWorkflowAdapter;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class Create extends AbstractFlowableServiceTask {
-
- @Autowired
- private UserDataBinder dataBinder;
-
- @Autowired
- private EntityFactory entityFactory;
-
- @Override
- protected void doExecute(final String executionId) {
- UserTO userTO = engine.getRuntimeService().
- getVariable(executionId, FlowableUserWorkflowAdapter.USER_TO, UserTO.class);
- Boolean storePassword = engine.getRuntimeService().
- getVariable(executionId, FlowableUserWorkflowAdapter.STORE_PASSWORD, Boolean.class);
- // create and set workflow id
- User user = entityFactory.newEntity(User.class);
- dataBinder.create(user, userTO, storePassword == null ? true : storePassword);
- user.setWorkflowId(executionId);
-
- // report user as result
- engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.USER, user);
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3cabe08a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Delete.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Delete.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Delete.java
deleted file mode 100644
index d4efe09..0000000
--- a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Delete.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.workflow.flowable.task;
-
-import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.apache.syncope.core.workflow.flowable.FlowableUserWorkflowAdapter;
-import org.springframework.stereotype.Component;
-
-@Component
-public class Delete extends AbstractFlowableServiceTask {
-
- @Override
- protected void doExecute(final String executionId) {
- User user = engine.getRuntimeService().
- getVariable(executionId, FlowableUserWorkflowAdapter.USER, User.class);
-
- // Do something with user...
- if (user != null) {
- user.checkToken("");
- }
-
- // remove user variable
- engine.getRuntimeService().removeVariable(executionId, FlowableUserWorkflowAdapter.USER);
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3cabe08a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/GenerateToken.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/GenerateToken.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/GenerateToken.java
deleted file mode 100644
index 08f6000..0000000
--- a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/GenerateToken.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.workflow.flowable.task;
-
-import org.apache.syncope.core.persistence.api.dao.ConfDAO;
-import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.apache.syncope.core.workflow.flowable.FlowableUserWorkflowAdapter;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class GenerateToken extends AbstractFlowableServiceTask {
-
- @Autowired
- private ConfDAO confDAO;
-
- @Override
- protected void doExecute(final String executionId) {
- User user = engine.getRuntimeService().
- getVariable(executionId, FlowableUserWorkflowAdapter.USER, User.class);
-
- user.generateToken(
- confDAO.find("token.length", 256L).intValue(),
- confDAO.find("token.expireTime", 60L).intValue());
-
- engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.USER, user);
- }
-}