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 2015/01/26 15:48:13 UTC
[07/12] syncope git commit: [SYNCOPE-620] IT with Activiti
http://git-wip-us.apache.org/repos/asf/syncope/blob/1327b2a4/syncope620/server/workflow-activiti/src/main/java/org/apache/syncope/workflow/activiti/task/Notify.java
----------------------------------------------------------------------
diff --git a/syncope620/server/workflow-activiti/src/main/java/org/apache/syncope/workflow/activiti/task/Notify.java b/syncope620/server/workflow-activiti/src/main/java/org/apache/syncope/workflow/activiti/task/Notify.java
deleted file mode 100644
index 3c2bd86..0000000
--- a/syncope620/server/workflow-activiti/src/main/java/org/apache/syncope/workflow/activiti/task/Notify.java
+++ /dev/null
@@ -1,62 +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.workflow.activiti.task;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.syncope.common.lib.to.UserTO;
-import org.apache.syncope.common.lib.types.AuditElements;
-import org.apache.syncope.server.persistence.api.entity.user.User;
-import org.apache.syncope.server.provisioning.api.notification.NotificationManager;
-import org.apache.syncope.workflow.activiti.ActivitiUserWorkflowAdapter;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * General-purpose notification task for usage within workflow.
- * It requires a pre-existing <tt>Notification</tt> with category <tt>CUSTOM</tt> and result <tt>SUCCESS</tt>.
- * An <tt>event</tt> workflow variable needs to be provided as well.
- */
-@Component
-public class Notify extends AbstractActivitiServiceTask {
-
- @Autowired
- private NotificationManager notificationManager;
-
- @Override
- protected void doExecute(final String executionId) {
- User user = runtimeService.getVariable(executionId, ActivitiUserWorkflowAdapter.SYNCOPE_USER, User.class);
- UserTO userTO = runtimeService.getVariable(executionId, ActivitiUserWorkflowAdapter.USER_TO, UserTO.class);
- String event = runtimeService.getVariable(executionId, ActivitiUserWorkflowAdapter.EVENT, String.class);
-
- if (StringUtils.isNotBlank(event)) {
- notificationManager.createTasks(
- AuditElements.EventCategoryType.CUSTOM,
- null,
- null,
- event,
- AuditElements.Result.SUCCESS,
- userTO,
- null,
- user.getToken());
- } else {
- LOG.debug("Not sending any notification since no event was found");
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/1327b2a4/syncope620/server/workflow-activiti/src/main/java/org/apache/syncope/workflow/activiti/task/PasswordReset.java
----------------------------------------------------------------------
diff --git a/syncope620/server/workflow-activiti/src/main/java/org/apache/syncope/workflow/activiti/task/PasswordReset.java b/syncope620/server/workflow-activiti/src/main/java/org/apache/syncope/workflow/activiti/task/PasswordReset.java
deleted file mode 100644
index 7b9e4be..0000000
--- a/syncope620/server/workflow-activiti/src/main/java/org/apache/syncope/workflow/activiti/task/PasswordReset.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.workflow.activiti.task;
-
-import org.apache.syncope.server.persistence.api.entity.user.User;
-import org.apache.syncope.server.workflow.api.WorkflowException;
-import org.apache.syncope.workflow.activiti.ActivitiUserWorkflowAdapter;
-import org.springframework.stereotype.Component;
-
-@Component
-public class PasswordReset extends AbstractActivitiServiceTask {
-
- @Override
- protected void doExecute(final String executionId) {
- User user = runtimeService.getVariable(executionId, ActivitiUserWorkflowAdapter.SYNCOPE_USER, User.class);
- String token = runtimeService.getVariable(executionId, ActivitiUserWorkflowAdapter.TOKEN, String.class);
- String password = runtimeService.getVariable(executionId, ActivitiUserWorkflowAdapter.PASSWORD, String.class);
-
- if (!user.checkToken(token)) {
- throw new WorkflowException(new IllegalArgumentException("Wrong token: " + token + " for " + user));
- }
-
- user.removeToken();
- user.setPassword(password, user.getCipherAlgorithm());
- runtimeService.setVariable(executionId, ActivitiUserWorkflowAdapter.SYNCOPE_USER, user);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/1327b2a4/syncope620/server/workflow-activiti/src/main/java/org/apache/syncope/workflow/activiti/task/Reactivate.java
----------------------------------------------------------------------
diff --git a/syncope620/server/workflow-activiti/src/main/java/org/apache/syncope/workflow/activiti/task/Reactivate.java b/syncope620/server/workflow-activiti/src/main/java/org/apache/syncope/workflow/activiti/task/Reactivate.java
deleted file mode 100644
index 6d105ba..0000000
--- a/syncope620/server/workflow-activiti/src/main/java/org/apache/syncope/workflow/activiti/task/Reactivate.java
+++ /dev/null
@@ -1,29 +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.workflow.activiti.task;
-
-import org.springframework.stereotype.Component;
-
-@Component
-public class Reactivate extends AbstractActivitiServiceTask {
-
- @Override
- protected void doExecute(final String executionId) {
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/1327b2a4/syncope620/server/workflow-activiti/src/main/java/org/apache/syncope/workflow/activiti/task/Suspend.java
----------------------------------------------------------------------
diff --git a/syncope620/server/workflow-activiti/src/main/java/org/apache/syncope/workflow/activiti/task/Suspend.java b/syncope620/server/workflow-activiti/src/main/java/org/apache/syncope/workflow/activiti/task/Suspend.java
deleted file mode 100644
index 24a7bdd..0000000
--- a/syncope620/server/workflow-activiti/src/main/java/org/apache/syncope/workflow/activiti/task/Suspend.java
+++ /dev/null
@@ -1,29 +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.workflow.activiti.task;
-
-import org.springframework.stereotype.Component;
-
-@Component
-public class Suspend extends AbstractActivitiServiceTask {
-
- @Override
- protected void doExecute(final String executionId) {
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/1327b2a4/syncope620/server/workflow-activiti/src/main/java/org/apache/syncope/workflow/activiti/task/Update.java
----------------------------------------------------------------------
diff --git a/syncope620/server/workflow-activiti/src/main/java/org/apache/syncope/workflow/activiti/task/Update.java b/syncope620/server/workflow-activiti/src/main/java/org/apache/syncope/workflow/activiti/task/Update.java
deleted file mode 100644
index 15d1b3f..0000000
--- a/syncope620/server/workflow-activiti/src/main/java/org/apache/syncope/workflow/activiti/task/Update.java
+++ /dev/null
@@ -1,54 +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.workflow.activiti.task;
-
-import org.apache.commons.lang3.SerializationUtils;
-import org.apache.syncope.common.lib.mod.UserMod;
-import org.apache.syncope.common.lib.types.PropagationByResource;
-import org.apache.syncope.server.persistence.api.entity.user.User;
-import org.apache.syncope.server.provisioning.api.data.UserDataBinder;
-import org.apache.syncope.workflow.activiti.ActivitiUserWorkflowAdapter;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class Update extends AbstractActivitiServiceTask {
-
- @Autowired
- private UserDataBinder dataBinder;
-
- @Override
- protected void doExecute(final String executionId) {
- User user = runtimeService.getVariable(executionId, ActivitiUserWorkflowAdapter.SYNCOPE_USER, User.class);
- UserMod userMod =
- runtimeService.getVariable(executionId, ActivitiUserWorkflowAdapter.USER_MOD, UserMod.class);
-
- // update password internally only if required
- UserMod actualMod = SerializationUtils.clone(userMod);
- if (actualMod.getPwdPropRequest() != null && !actualMod.getPwdPropRequest().isOnSyncope()) {
- actualMod.setPassword(null);
- }
- // update SyncopeUser
- PropagationByResource propByRes = dataBinder.update(user, actualMod);
-
- // report updated user and propagation by resource as result
- runtimeService.setVariable(executionId, ActivitiUserWorkflowAdapter.SYNCOPE_USER, user);
- runtimeService.setVariable(executionId, ActivitiUserWorkflowAdapter.PROP_BY_RESOURCE, propByRes);
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/1327b2a4/syncope620/server/workflow-activiti/src/main/resources/workflow.properties
----------------------------------------------------------------------
diff --git a/syncope620/server/workflow-activiti/src/main/resources/workflow.properties b/syncope620/server/workflow-activiti/src/main/resources/workflow.properties
new file mode 100644
index 0000000..0cad37e
--- /dev/null
+++ b/syncope620/server/workflow-activiti/src/main/resources/workflow.properties
@@ -0,0 +1,20 @@
+# 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.
+wf.directory=${conf.directory}
+jobExecutorActivate=true
+uwfAdapter=org.apache.syncope.server.workflow.activiti.ActivitiUserWorkflowAdapter
+rwfAdapter=org.apache.syncope.server.workflow.java.DefaultRoleWorkflowAdapter
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/syncope/blob/1327b2a4/syncope620/server/workflow-activiti/src/main/resources/workflowActivitiContext.xml
----------------------------------------------------------------------
diff --git a/syncope620/server/workflow-activiti/src/main/resources/workflowActivitiContext.xml b/syncope620/server/workflow-activiti/src/main/resources/workflowActivitiContext.xml
index 463c2c7..41670fb 100644
--- a/syncope620/server/workflow-activiti/src/main/resources/workflowActivitiContext.xml
+++ b/syncope620/server/workflow-activiti/src/main/resources/workflowActivitiContext.xml
@@ -26,12 +26,12 @@ under the License.
http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="userWorkflowDef" class="org.apache.syncope.server.misc.spring.ResourceWithFallbackLoader">
- <property name="primary" value="file:${conf.directory}/userWorkflow.bpmn20.xml"/>
+ <property name="primary" value="file:${wf.directory}/userWorkflow.bpmn20.xml"/>
<property name="fallback" value="classpath:userWorkflow.bpmn20.xml"/>
</bean>
- <bean id="syncopeActivitiUserManager" class="org.apache.syncope.workflow.activiti.SyncopeUserManager"/>
- <bean id="syncopeActivitiGroupManager" class="org.apache.syncope.workflow.activiti.SyncopeGroupManager"/>
+ <bean id="syncopeActivitiUserManager" class="org.apache.syncope.server.workflow.activiti.SyncopeUserManager"/>
+ <bean id="syncopeActivitiGroupManager" class="org.apache.syncope.server.workflow.activiti.SyncopeGroupManager"/>
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="dataSource" ref="dataSource"/>
@@ -47,17 +47,17 @@ under the License.
<property name="customSessionFactories">
<list>
- <bean class="org.apache.syncope.workflow.activiti.SyncopeSessionFactory">
+ <bean class="org.apache.syncope.server.workflow.activiti.SyncopeSessionFactory">
<property name="syncopeSession" ref="syncopeActivitiUserManager"/>
</bean>
- <bean class="org.apache.syncope.workflow.activiti.SyncopeSessionFactory">
+ <bean class="org.apache.syncope.server.workflow.activiti.SyncopeSessionFactory">
<property name="syncopeSession" ref="syncopeActivitiGroupManager"/>
</bean>
</list>
</property>
<property name="customPreVariableTypes">
<list>
- <bean class="org.apache.syncope.workflow.activiti.SyncopeEntitiesVariableType"/>
+ <bean class="org.apache.syncope.server.workflow.activiti.SyncopeEntitiesVariableType"/>
</list>
</property>
</bean>
@@ -74,6 +74,6 @@ under the License.
<bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService"/>
<bean id="formService" factory-bean="processEngine" factory-method="getFormService"/>
- <context:component-scan base-package="org.apache.syncope.workflow.activiti"/>
+ <context:component-scan base-package="org.apache.syncope.server.workflow.activiti"/>
</beans>
http://git-wip-us.apache.org/repos/asf/syncope/blob/1327b2a4/syncope620/server/workflow-java/src/main/resources/workflow.properties
----------------------------------------------------------------------
diff --git a/syncope620/server/workflow-java/src/main/resources/workflow.properties b/syncope620/server/workflow-java/src/main/resources/workflow.properties
index a72e766..2c08d50 100644
--- a/syncope620/server/workflow-java/src/main/resources/workflow.properties
+++ b/syncope620/server/workflow-java/src/main/resources/workflow.properties
@@ -14,5 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+wf.directory=${conf.directory}
+jobExecutorActivate=false
uwfAdapter=org.apache.syncope.server.workflow.java.DefaultUserWorkflowAdapter
rwfAdapter=org.apache.syncope.server.workflow.java.DefaultRoleWorkflowAdapter
\ No newline at end of file