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 2012/11/28 18:21:16 UTC
svn commit: r1414832 - in /syncope/trunk: ./
console/src/main/java/org/apache/syncope/console/rest/
core/src/main/java/org/apache/syncope/core/rest/controller/
core/src/main/java/org/apache/syncope/core/workflow/
core/src/test/java/org/apache/syncope/c...
Author: ilgrosso
Date: Wed Nov 28 17:21:15 2012
New Revision: 1414832
URL: http://svn.apache.org/viewvc?rev=1414832&view=rev
Log:
Merge from 1_0_X
Modified:
syncope/trunk/ (props changed)
syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ApprovalRestClient.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/WorkflowController.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/ActivitiUserWorkflowAdapter.java
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
Propchange: syncope/trunk/
------------------------------------------------------------------------------
Merged /syncope/branches/1_0_X:r1414744-1414827
Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ApprovalRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ApprovalRestClient.java?rev=1414832&r1=1414831&r2=1414832&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ApprovalRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ApprovalRestClient.java Wed Nov 28 17:21:15 2012
@@ -20,10 +20,10 @@ package org.apache.syncope.console.rest;
import java.util.Arrays;
import java.util.List;
-import org.springframework.stereotype.Component;
import org.apache.syncope.client.to.UserTO;
import org.apache.syncope.client.to.WorkflowFormTO;
import org.apache.syncope.console.SyncopeSession;
+import org.springframework.stereotype.Component;
/**
* Console client for invoking Rest Todo services.
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/WorkflowController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/WorkflowController.java?rev=1414832&r1=1414831&r2=1414832&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/WorkflowController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/WorkflowController.java Wed Nov 28 17:21:15 2012
@@ -50,7 +50,6 @@ public class WorkflowController extends
@RequestMapping(method = RequestMethod.GET, value = "/definition")
@Transactional(readOnly = true)
public WorkflowDefinitionTO getDefinition() throws WorkflowException {
-
WorkflowDefinitionTO result = wfAdapter.getDefinition();
auditManager.audit(Category.workflow, WorkflowSubCategory.getDefinition, Result.success,
@@ -73,7 +72,6 @@ public class WorkflowController extends
@PreAuthorize("hasRole('WORKFLOW_TASK_LIST')")
@RequestMapping(method = RequestMethod.GET, value = "/tasks")
public ModelAndView getDefinedTasks() throws WorkflowException {
-
List<String> definedTasks = wfAdapter.getDefinedTasks();
auditManager.audit(Category.workflow, WorkflowSubCategory.getDefinedTasks, Result.success,
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/ActivitiUserWorkflowAdapter.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/ActivitiUserWorkflowAdapter.java?rev=1414832&r1=1414831&r2=1414832&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/ActivitiUserWorkflowAdapter.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/ActivitiUserWorkflowAdapter.java Wed Nov 28 17:21:15 2012
@@ -113,6 +113,8 @@ public class ActivitiUserWorkflowAdapter
public static final String ENCRYPTED_PWD = "encryptedPwd";
+ public static final String TASK_IS_FORM = "taskIsForm";
+
@Resource(name = "adminUser")
private String adminUser;
@@ -145,8 +147,8 @@ public class ActivitiUserWorkflowAdapter
}
}
- private boolean waitingForForm(final SyncopeUser user) {
- boolean result = false;
+ private String getFormTask(final SyncopeUser user) {
+ String result = null;
List<Task> tasks = taskService.createTaskQuery().processInstanceId(user.getWorkflowId()).list();
if (tasks.isEmpty() || tasks.size() > 1) {
@@ -154,7 +156,9 @@ public class ActivitiUserWorkflowAdapter
} else {
try {
TaskFormData formData = formService.getTaskFormData(tasks.get(0).getId());
- result = formData != null && !formData.getFormProperties().isEmpty();
+ if (formData != null && !formData.getFormProperties().isEmpty()) {
+ result = tasks.get(0).getId();
+ }
} catch (ActivitiException e) {
LOG.warn("Could not get task form data", e);
}
@@ -191,6 +195,7 @@ public class ActivitiUserWorkflowAdapter
@Override
public WorkflowResult<Map.Entry<Long, Boolean>> create(final UserTO userTO, final boolean disablePwdPolicyCheck)
throws WorkflowException {
+
return create(userTO, disablePwdPolicyCheck, null);
}
@@ -213,8 +218,7 @@ public class ActivitiUserWorkflowAdapter
SyncopeUser user = (SyncopeUser) runtimeService.getVariable(processInstance.getProcessInstanceId(),
SYNCOPE_USER);
- // this will make SyncopeUserValidator not to consider
- // password policies at all
+ // this will make SyncopeUserValidator not to consider password policies at all
if (disablePwdPolicyCheck) {
user.removeClearPassword();
}
@@ -224,7 +228,6 @@ public class ActivitiUserWorkflowAdapter
Boolean propagateEnable = (Boolean) runtimeService.getVariable(processInstance.getProcessInstanceId(),
PROPAGATE_ENABLE);
-
if (propagateEnable == null) {
propagateEnable = enabled;
}
@@ -234,7 +237,11 @@ public class ActivitiUserWorkflowAdapter
PropagationByResource propByRes = new PropagationByResource();
propByRes.set(PropagationOperation.CREATE, user.getResourceNames());
- if (waitingForForm(user)) {
+ 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;
@@ -248,8 +255,8 @@ public class ActivitiUserWorkflowAdapter
propByRes, getPerformedTasks(user));
}
- private Set<String> doExecuteTask(final SyncopeUser user, final String task, final Map<String, Object> moreVariables)
- throws WorkflowException {
+ private Set<String> doExecuteTask(final SyncopeUser user, final String task,
+ final Map<String, Object> moreVariables) throws WorkflowException {
Set<String> preTasks = getPerformedTasks(user);
@@ -266,14 +273,14 @@ public class ActivitiUserWorkflowAdapter
}
List<Task> tasks = taskService.createTaskQuery().processInstanceId(user.getWorkflowId()).list();
- if (tasks.size() != 1) {
- LOG.warn("Expected a single task, found {}", tasks.size());
- } else {
+ if (tasks.size() == 1) {
try {
taskService.complete(tasks.get(0).getId(), variables);
} catch (ActivitiException e) {
throw new WorkflowException(e);
}
+ } else {
+ LOG.warn("Expected a single task, found {}", tasks.size());
}
Set<String> postTasks = getPerformedTasks(user);
@@ -305,10 +312,14 @@ public class ActivitiUserWorkflowAdapter
PropagationByResource propByRes = (PropagationByResource) runtimeService.getVariable(user.getWorkflowId(),
PROP_BY_RESOURCE);
- // save resources to be propagated and password for later -
- // after form submission - propagation
- if (waitingForForm(user) && StringUtils.isNotBlank(userMod.getPassword())) {
- runtimeService.setVariable(user.getWorkflowId(), ENCRYPTED_PWD, encrypt(userMod.getPassword()));
+ // save resources to be propagated and password for later - after form submission - propagation
+ 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);
+ if (StringUtils.isNotBlank(userMod.getPassword())) {
+ runtimeService.setVariable(user.getWorkflowId(), ENCRYPTED_PWD, encrypt(userMod.getPassword()));
+ }
}
Boolean propagateEnable = (Boolean) runtimeService.getVariable(user.getWorkflowId(), PROPAGATE_ENABLE);
@@ -469,7 +480,6 @@ public class ActivitiUserWorkflowAdapter
}
private WorkflowFormPropertyType fromActivitiFormType(final FormType activitiFormType) {
-
WorkflowFormPropertyType result = WorkflowFormPropertyType.String;
if ("string".equals(activitiFormType.getName())) {
@@ -492,7 +502,6 @@ public class ActivitiUserWorkflowAdapter
}
private WorkflowFormTO getFormTO(final Task task, final TaskFormData formData) {
-
WorkflowFormTO formTO = new WorkflowFormTO();
formTO.setTaskId(task.getId());
formTO.setKey(formData.getFormKey());
@@ -523,7 +532,7 @@ public class ActivitiUserWorkflowAdapter
List<WorkflowFormTO> forms = new ArrayList<WorkflowFormTO>();
TaskFormData formData;
- for (Task task : taskService.createTaskQuery().list()) {
+ for (Task task : taskService.createTaskQuery().taskVariableValueEquals(TASK_IS_FORM, Boolean.TRUE).list()) {
try {
formData = formService.getTaskFormData(task.getId());
} catch (ActivitiException e) {
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java?rev=1414832&r1=1414831&r2=1414832&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java Wed Nov 28 17:21:15 2012
@@ -779,7 +779,12 @@ public class UserTestITCase extends Abst
}
assertNotNull(exception);
- // 2. request if there is any pending task for user just created
+ // 2. request if there is any pending form for user just created
+ List<WorkflowFormTO> forms = Arrays.asList(restTemplate.getForObject(
+ BASE_URL + "user/workflow/form/list", WorkflowFormTO[].class));
+ assertNotNull(forms);
+ assertEquals(1, forms.size());
+
WorkflowFormTO form = restTemplate.getForObject(BASE_URL + "user/workflow/form/{userId}", WorkflowFormTO.class,
userTO.getId());
assertNotNull(form);