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/10/18 14:51:34 UTC
svn commit: r1399638 - in /incubator/syncope/branches/1_0_X/core: ./
src/main/java/org/apache/syncope/core/init/
src/main/java/org/apache/syncope/core/workflow/
src/test/java/org/apache/syncope/core/
src/test/java/org/apache/syncope/core/rest/ src/test...
Author: ilgrosso
Date: Thu Oct 18 12:51:33 2012
New Revision: 1399638
URL: http://svn.apache.org/viewvc?rev=1399638&view=rev
Log:
[SYNCOPE-224] Workflow initialization is now called by reflection + added a 'noopworkflow' build profile
Added:
incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/WorkflowLoader.java (with props)
incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/
incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/stripActivitiFromContent.xsl (with props)
incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/workflow.properties (with props)
incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/workflowContext.xml (with props)
Modified:
incubator/syncope/branches/1_0_X/core/pom.xml
incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/ActivitiWorkflowLoader.java
incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/ContentLoader.java
incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/JobInstanceLoader.java
incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/SpringContextInitializer.java
incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/workflow/AbstractUserWorkflowAdapter.java
incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/workflow/ActivitiUserWorkflowAdapter.java
incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/workflow/NoOpUserWorkflowAdapter.java
incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/workflow/UserWorkflowAdapter.java
incubator/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/AbstractTest.java
incubator/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
incubator/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java
incubator/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
Modified: incubator/syncope/branches/1_0_X/core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/1_0_X/core/pom.xml?rev=1399638&r1=1399637&r2=1399638&view=diff
==============================================================================
--- incubator/syncope/branches/1_0_X/core/pom.xml (original)
+++ incubator/syncope/branches/1_0_X/core/pom.xml Thu Oct 18 12:51:33 2012
@@ -794,7 +794,9 @@ under the License.
<phase>process-test-resources</phase>
<configuration>
<target>
- <copy tofile="${project.build.directory}/classes/META-INF/orm.xml" file="${basedir}/src/main/resources/META-INF/orm.xml.oracle" overwrite="true" />
+ <copy tofile="${project.build.directory}/classes/META-INF/orm.xml"
+ file="${basedir}/src/main/resources/META-INF/orm.xml.oracle"
+ overwrite="true" />
</target>
</configuration>
<goals>
@@ -820,6 +822,90 @@ under the License.
</testResources>
</build>
</profile>
+
+ <profile>
+ <id>noopworkflow</id>
+ <properties>
+ <javaagent />
+ </properties>
+ <build>
+ <defaultGoal>clean verify</defaultGoal>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <inherited>true</inherited>
+ <executions>
+ <execution>
+ <id>remove-activiti</id>
+ <phase>process-test-resources</phase>
+ <configuration>
+ <target>
+ <copy tofile="${project.build.directory}/classes/workflowContext.xml"
+ file="${basedir}/src/test/resources/noopworkflow/workflowContext.xml"
+ overwrite="true" />
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- Strip Activiti-related entries from content.xml -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>xml-maven-plugin</artifactId>
+ <inherited>true</inherited>
+ <executions>
+ <execution>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>transform</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <forceCreation>true</forceCreation>
+ <transformationSets>
+ <transformationSet>
+ <dir>${project.build.directory}/test-classes</dir>
+ <includes>
+ <include>content.xml</include>
+ </includes>
+ <outputDir>${project.build.directory}/test-classes/</outputDir>
+ <stylesheet>${basedir}/src/test/resources/noopworkflow/stripActivitiFromContent.xsl</stylesheet>
+ <outputProperties>
+ <outputProperty>
+ <name>indent</name>
+ <value>yes</value>
+ </outputProperty>
+ </outputProperties>
+ </transformationSet>
+ </transformationSets>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ <excludes>
+ <exclude>workflow.properties</exclude>
+ </excludes>
+ </testResource>
+ <testResource>
+ <directory>src/test/resources/noopworkflow</directory>
+ <filtering>true</filtering>
+ </testResource>
+ </testResources>
+ </build>
+ </profile>
<profile>
<id>sqlserver-it</id>
Modified: incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/ActivitiWorkflowLoader.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/ActivitiWorkflowLoader.java?rev=1399638&r1=1399637&r2=1399638&view=diff
==============================================================================
--- incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/ActivitiWorkflowLoader.java (original)
+++ incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/ActivitiWorkflowLoader.java Thu Oct 18 12:51:33 2012
@@ -23,20 +23,19 @@ import java.io.InputStream;
import java.util.List;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.ProcessDefinition;
+import org.apache.syncope.core.workflow.ActivitiUserWorkflowAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import org.apache.syncope.core.workflow.ActivitiUserWorkflowAdapter;
-@Component
-public class ActivitiWorkflowLoader {
+public class ActivitiWorkflowLoader implements WorkflowLoader {
private static final Logger LOG = LoggerFactory.getLogger(ActivitiWorkflowLoader.class);
@Autowired
private RepositoryService repositoryService;
+ @Override
public void load() {
List<ProcessDefinition> processes = repositoryService.createProcessDefinitionQuery().processDefinitionKey(
ActivitiUserWorkflowAdapter.WF_PROCESS_ID).list();
Modified: incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/ContentLoader.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/ContentLoader.java?rev=1399638&r1=1399637&r2=1399638&view=diff
==============================================================================
--- incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/ContentLoader.java (original)
+++ incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/ContentLoader.java Thu Oct 18 12:51:33 2012
@@ -24,7 +24,6 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
-import java.util.logging.Level;
import javax.sql.DataSource;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
@@ -39,7 +38,7 @@ import org.springframework.transaction.a
/**
* If empty, load default content to Syncope database by reading from
- * <code>content.xml</code>.
+ * <code>ckasspath:/content.xml</code>.
*/
@Component
public class ContentLoader {
@@ -66,7 +65,8 @@ public class ContentLoader {
boolean existingData = false;
try {
final String queryContent = "SELECT * FROM " + SyncopeConf.class.getSimpleName();
- statement = conn.prepareStatement(queryContent, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ statement = conn.prepareStatement(
+ queryContent, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
resultSet = statement.executeQuery();
resultSet.last();
@@ -156,17 +156,20 @@ public class ContentLoader {
LOG.error("While creating indexes", e);
}
- try {
- statement = conn.prepareStatement("DELETE FROM ACT_GE_PROPERTY");
- statement.executeUpdate();
- } catch (SQLException e) {
- LOG.error("Error during ACT_GE_PROPERTY delete rows", e);
- } finally {
- if (statement != null) {
- try {
- statement.close();
- } catch (SQLException e) {
- LOG.error("Error closing statement of ACT_GE_PROPERTY delete rows", e);
+ // Can't test wfAdapter.getClass() because it is @Autowired
+ if (SpringContextInitializer.isActivitiConfigured()) {
+ try {
+ statement = conn.prepareStatement("DELETE FROM ACT_GE_PROPERTY");
+ statement.executeUpdate();
+ } catch (SQLException e) {
+ LOG.error("Error during ACT_GE_PROPERTY delete rows", e);
+ } finally {
+ if (statement != null) {
+ try {
+ statement.close();
+ } catch (SQLException e) {
+ LOG.error("Error closing statement of ACT_GE_PROPERTY delete rows", e);
+ }
}
}
}
Modified: incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/JobInstanceLoader.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/JobInstanceLoader.java?rev=1399638&r1=1399637&r2=1399638&view=diff
==============================================================================
--- incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/JobInstanceLoader.java (original)
+++ incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/JobInstanceLoader.java Thu Oct 18 12:51:33 2012
@@ -69,9 +69,9 @@ public class JobInstanceLoader {
private ReportDAO reportDAO;
private DefaultListableBeanFactory getBeanFactory() {
- ConfigurableApplicationContext context = ApplicationContextProvider.getApplicationContext();
+ ConfigurableApplicationContext ctx = ApplicationContextProvider.getApplicationContext();
- return (DefaultListableBeanFactory) context.getBeanFactory();
+ return (DefaultListableBeanFactory) ctx.getBeanFactory();
}
private static Long getIdFromJobName(final String name, final String pattern, final int prefixLength) {
Modified: incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/SpringContextInitializer.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/SpringContextInitializer.java?rev=1399638&r1=1399637&r2=1399638&view=diff
==============================================================================
--- incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/SpringContextInitializer.java (original)
+++ incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/SpringContextInitializer.java Thu Oct 18 12:51:33 2012
@@ -18,12 +18,21 @@
*/
package org.apache.syncope.core.init;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
import javax.servlet.ServletContext;
+import org.apache.syncope.core.workflow.ActivitiUserWorkflowAdapter;
+import org.apache.syncope.core.workflow.UserWorkflowAdapter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.context.ServletContextAware;
@@ -33,6 +42,51 @@ import org.springframework.web.context.S
@Component
public class SpringContextInitializer implements ServletContextAware, BeanFactoryAware, InitializingBean {
+ /**
+ * Logger.
+ */
+ private static final Logger LOG = LoggerFactory.getLogger(SpringContextInitializer.class);
+
+ private static String wfAdapterClassName;
+
+ static {
+ try {
+ initWFAdapterClassName();
+ } catch (IOException e) {
+ LOG.error("Could not init wfAdapterClassName", e);
+ }
+ }
+
+ /**
+ * Read classpath:/workflow.properties in order to determine the configured workflow adapter class name.
+ *
+ * @throws IOException if anything goes wrong
+ */
+ public static void initWFAdapterClassName() throws IOException {
+ Properties props = new java.util.Properties();
+ InputStream propStream = null;
+ try {
+ propStream = ContentLoader.class.getResourceAsStream("/workflow.properties");
+ props.load(propStream);
+ wfAdapterClassName = props.getProperty("wfAdapter");
+ } catch (Exception e) {
+ LOG.error("Could not load workflow.properties", e);
+ } finally {
+ if (propStream != null) {
+ propStream.close();
+ }
+ }
+ }
+
+ /**
+ * Check if the configured user workflow adapter is Activiti's.
+ *
+ * @return whether Activiti is configured for workflow or not
+ */
+ public static boolean isActivitiConfigured() {
+ return wfAdapterClassName != null && wfAdapterClassName.equals(ActivitiUserWorkflowAdapter.class.getName());
+ }
+
@Autowired
private ConnInstanceLoader connInstanceLoader;
@@ -43,7 +97,7 @@ public class SpringContextInitializer im
private JobInstanceLoader jobInstanceLoader;
@Autowired
- private ActivitiWorkflowLoader activitiWorkflowLoader;
+ private UserWorkflowAdapter wfAdapter;
@Autowired
private LoggerLoader loggerLoader;
@@ -51,22 +105,29 @@ public class SpringContextInitializer im
@Autowired
private ImplementationClassNamesLoader classNamesLoader;
+ private DefaultListableBeanFactory beanFactory;
+
@Override
public void setServletContext(final ServletContext servletContext) {
}
@Override
public void setBeanFactory(final BeanFactory beanFactory) throws BeansException {
+ this.beanFactory = (DefaultListableBeanFactory) beanFactory;
}
@Override
public void afterPropertiesSet() throws Exception {
-
contentLoader.load();
connInstanceLoader.load();
jobInstanceLoader.load();
- activitiWorkflowLoader.load();
loggerLoader.load();
classNamesLoader.load();
+
+ if (wfAdapter.getLoaderClass() != null) {
+ final WorkflowLoader wfLoader = (WorkflowLoader) beanFactory.createBean(
+ wfAdapter.getLoaderClass(), AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false);
+ wfLoader.load();
+ }
}
}
Added: incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/WorkflowLoader.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/WorkflowLoader.java?rev=1399638&view=auto
==============================================================================
--- incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/WorkflowLoader.java (added)
+++ incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/WorkflowLoader.java Thu Oct 18 12:51:33 2012
@@ -0,0 +1,24 @@
+/*
+ * 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.init;
+
+public interface WorkflowLoader {
+
+ void load();
+}
Propchange: incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/WorkflowLoader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/WorkflowLoader.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/WorkflowLoader.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/workflow/AbstractUserWorkflowAdapter.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/workflow/AbstractUserWorkflowAdapter.java?rev=1399638&r1=1399637&r2=1399638&view=diff
==============================================================================
--- incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/workflow/AbstractUserWorkflowAdapter.java (original)
+++ incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/workflow/AbstractUserWorkflowAdapter.java Thu Oct 18 12:51:33 2012
@@ -21,16 +21,17 @@ package org.apache.syncope.core.workflow
import java.util.Map;
import java.util.Map.Entry;
import javassist.NotFoundException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
import org.apache.syncope.client.mod.UserMod;
import org.apache.syncope.client.to.UserTO;
+import org.apache.syncope.core.init.WorkflowLoader;
import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
import org.apache.syncope.core.persistence.dao.UserDAO;
import org.apache.syncope.core.rest.controller.UnauthorizedRoleException;
import org.apache.syncope.core.rest.data.UserDataBinder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
-@Transactional(rollbackFor = { Throwable.class })
+@Transactional(rollbackFor = {Throwable.class})
public abstract class AbstractUserWorkflowAdapter implements UserWorkflowAdapter {
@Autowired
@@ -40,6 +41,11 @@ public abstract class AbstractUserWorkfl
protected UserDAO userDAO;
@Override
+ public Class<? extends WorkflowLoader> getLoaderClass() {
+ return null;
+ }
+
+ @Override
public WorkflowResult<Entry<Long, Boolean>> create(final UserTO userTO)
throws UnauthorizedRoleException, WorkflowException {
Modified: incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/workflow/ActivitiUserWorkflowAdapter.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/workflow/ActivitiUserWorkflowAdapter.java?rev=1399638&r1=1399637&r2=1399638&view=diff
==============================================================================
--- incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/workflow/ActivitiUserWorkflowAdapter.java (original)
+++ incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/workflow/ActivitiUserWorkflowAdapter.java Thu Oct 18 12:51:33 2012
@@ -55,23 +55,25 @@ import org.activiti.engine.runtime.Proce
import org.activiti.engine.task.Task;
import org.apache.commons.collections.keyvalue.DefaultMapEntry;
import org.apache.commons.lang.StringUtils;
-import org.identityconnectors.common.security.EncryptorFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
import org.apache.syncope.client.mod.UserMod;
import org.apache.syncope.client.to.UserTO;
import org.apache.syncope.client.to.WorkflowDefinitionTO;
import org.apache.syncope.client.to.WorkflowFormPropertyTO;
import org.apache.syncope.client.to.WorkflowFormTO;
+import org.apache.syncope.core.init.ActivitiWorkflowLoader;
+import org.apache.syncope.core.init.WorkflowLoader;
import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
import org.apache.syncope.core.propagation.PropagationByResource;
import org.apache.syncope.core.rest.controller.UnauthorizedRoleException;
import org.apache.syncope.types.PropagationOperation;
import org.apache.syncope.types.WorkflowFormPropertyType;
+import org.identityconnectors.common.security.EncryptorFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.codec.Base64;
+import org.springframework.transaction.annotation.Transactional;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
@@ -129,6 +131,11 @@ public class ActivitiUserWorkflowAdapter
@Autowired
private RepositoryService repositoryService;
+ @Override
+ public Class<? extends WorkflowLoader> getLoaderClass() {
+ return ActivitiWorkflowLoader.class;
+ }
+
private void updateStatus(final SyncopeUser user) {
List<Task> tasks = taskService.createTaskQuery().processInstanceId(user.getWorkflowId()).list();
if (tasks.isEmpty() || tasks.size() > 1) {
Modified: incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/workflow/NoOpUserWorkflowAdapter.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/workflow/NoOpUserWorkflowAdapter.java?rev=1399638&r1=1399637&r2=1399638&view=diff
==============================================================================
--- incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/workflow/NoOpUserWorkflowAdapter.java (original)
+++ incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/workflow/NoOpUserWorkflowAdapter.java Thu Oct 18 12:51:33 2012
@@ -24,7 +24,6 @@ import java.util.List;
import java.util.Map;
import javassist.NotFoundException;
import org.apache.commons.collections.keyvalue.DefaultMapEntry;
-import org.springframework.transaction.annotation.Transactional;
import org.apache.syncope.client.mod.UserMod;
import org.apache.syncope.client.to.UserTO;
import org.apache.syncope.client.to.WorkflowDefinitionTO;
@@ -33,15 +32,16 @@ import org.apache.syncope.core.persisten
import org.apache.syncope.core.propagation.PropagationByResource;
import org.apache.syncope.core.rest.controller.UnauthorizedRoleException;
import org.apache.syncope.types.PropagationOperation;
+import org.springframework.transaction.annotation.Transactional;
/**
* Simple implementation basically not involving any workflow engine.
*/
-@Transactional(rollbackFor = { Throwable.class })
+@Transactional(rollbackFor = {Throwable.class})
public class NoOpUserWorkflowAdapter extends AbstractUserWorkflowAdapter {
- private static final List<String> TASKS = Arrays.asList(new String[] { "create", "activate", "update", "suspend",
- "reactivate", "delete" });
+ private static final List<String> TASKS =
+ Arrays.asList(new String[]{"create", "activate", "update", "suspend", "reactivate", "delete"});
public static final String ENABLED = "enabled";
@@ -65,16 +65,15 @@ public class NoOpUserWorkflowAdapter ext
}
String status;
- boolean propagate_enable;
-
+ boolean propagateEnable;
if (enabled == null) {
status = "created";
- propagate_enable = true;
+ propagateEnable = true;
} else {
status = enabled
? "active"
: "suspended";
- propagate_enable = enabled;
+ propagateEnable = enabled;
}
user.setStatus(status);
@@ -83,7 +82,7 @@ public class NoOpUserWorkflowAdapter ext
final PropagationByResource propByRes = new PropagationByResource();
propByRes.set(PropagationOperation.CREATE, user.getResourceNames());
- return new WorkflowResult<Map.Entry<Long, Boolean>>(new DefaultMapEntry(user.getId(), propagate_enable),
+ return new WorkflowResult<Map.Entry<Long, Boolean>>(new DefaultMapEntry(user.getId(), propagateEnable),
propByRes, "create");
}
Modified: incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/workflow/UserWorkflowAdapter.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/workflow/UserWorkflowAdapter.java?rev=1399638&r1=1399637&r2=1399638&view=diff
==============================================================================
--- incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/workflow/UserWorkflowAdapter.java (original)
+++ incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/workflow/UserWorkflowAdapter.java Thu Oct 18 12:51:33 2012
@@ -25,6 +25,8 @@ import org.apache.syncope.client.mod.Use
import org.apache.syncope.client.to.UserTO;
import org.apache.syncope.client.to.WorkflowDefinitionTO;
import org.apache.syncope.client.to.WorkflowFormTO;
+import org.apache.syncope.core.init.SpringContextInitializer;
+import org.apache.syncope.core.init.WorkflowLoader;
import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
import org.apache.syncope.core.rest.controller.UnauthorizedRoleException;
@@ -34,6 +36,15 @@ import org.apache.syncope.core.rest.cont
public interface UserWorkflowAdapter {
/**
+ * Give the class to be instantiated and invoked by SpringContextInitializer for loading anything needed by this
+ * adapter.
+ *
+ * @return null if no init is needed or the WorkflowLoader class for handling initialization
+ * @see SpringContextInitializer
+ */
+ Class<? extends WorkflowLoader> getLoaderClass();
+
+ /**
* Create an user.
*
* @param userTO user to be created and wether to propagate it as active
Modified: incubator/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/AbstractTest.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/AbstractTest.java?rev=1399638&r1=1399637&r2=1399638&view=diff
==============================================================================
--- incubator/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/AbstractTest.java (original)
+++ incubator/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/AbstractTest.java Thu Oct 18 12:51:33 2012
@@ -21,12 +21,13 @@ package org.apache.syncope.core;
import static org.junit.Assert.*;
import java.io.InputStream;
+import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
-import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,8 +35,8 @@ import org.springframework.test.context.
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "classpath:syncopeContext.xml", "classpath:persistenceContext.xml",
- "classpath:schedulingContext.xml", "classpath:workflowContext.xml" })
+@ContextConfiguration(locations = {"classpath:syncopeContext.xml", "classpath:persistenceContext.xml",
+ "classpath:schedulingContext.xml", "classpath:workflowContext.xml"})
public abstract class AbstractTest {
/**
@@ -76,16 +77,21 @@ public abstract class AbstractTest {
}
}
- @Before
- public void setUpIdentityConnectorsBundles() {
+ @BeforeClass
+ public static void setUpIdentityConnectorsBundles() throws IOException {
Properties props = new java.util.Properties();
+ InputStream propStream = null;
try {
- InputStream propStream = getClass().getResourceAsStream("/bundles.properties");
+ propStream = AbstractTest.class.getResourceAsStream("/bundles.properties");
props.load(propStream);
connidSoapVersion = props.getProperty("connid.soap.version");
bundlesDirectory = props.getProperty("bundles.directory");
} catch (Exception e) {
LOG.error("Could not load bundles.properties", e);
+ } finally {
+ if (propStream != null) {
+ propStream.close();
+ }
}
assertNotNull(connidSoapVersion);
assertNotNull(bundlesDirectory);
Modified: incubator/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java?rev=1399638&r1=1399637&r2=1399638&view=diff
==============================================================================
--- incubator/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java (original)
+++ incubator/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java Thu Oct 18 12:51:33 2012
@@ -21,6 +21,7 @@ package org.apache.syncope.core.rest;
import javax.sql.DataSource;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
@@ -29,7 +30,6 @@ import org.springframework.beans.factory
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.client.RestTemplate;
-import org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:restClientContext.xml", "classpath:testJDBCContext.xml"})
Modified: incubator/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java?rev=1399638&r1=1399637&r2=1399638&view=diff
==============================================================================
--- incubator/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java (original)
+++ incubator/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java Thu Oct 18 12:51:33 2012
@@ -38,6 +38,7 @@ import org.apache.syncope.client.to.Sche
import org.apache.syncope.client.to.SyncTaskTO;
import org.apache.syncope.client.to.TaskTO;
import org.apache.syncope.client.to.UserTO;
+import org.apache.syncope.core.init.SpringContextInitializer;
import org.apache.syncope.types.PropagationTaskExecStatus;
import org.apache.syncope.core.scheduling.TestSyncJobActions;
import org.apache.syncope.types.IntMappingType;
@@ -316,7 +317,7 @@ public class TaskTestITCase extends Abst
assertNotNull(userTO);
assertEquals("test9", userTO.getUsername());
- assertEquals("active", userTO.getStatus());
+ assertEquals(SpringContextInitializer.isActivitiConfigured() ? "active" : "created", userTO.getStatus());
assertEquals("test9@syncope.apache.org", userTO.getAttributeMap().get("email").getValues().get(0));
assertEquals("test9@syncope.apache.org", userTO.getAttributeMap().get("userId").getValues().get(0));
assertTrue(Integer.valueOf(userTO.getAttributeMap().get("fullname").getValues().get(0)) <= 10);
Modified: incubator/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java?rev=1399638&r1=1399637&r2=1399638&view=diff
==============================================================================
--- incubator/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java (original)
+++ incubator/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java Thu Oct 18 12:51:33 2012
@@ -59,10 +59,12 @@ import org.apache.syncope.client.to.Work
import org.apache.syncope.client.util.AttributableOperations;
import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
import org.apache.syncope.client.validation.SyncopeClientException;
+import org.apache.syncope.core.init.SpringContextInitializer;
import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
import org.apache.syncope.types.CipherAlgorithm;
import org.apache.syncope.types.PropagationTaskExecStatus;
import org.apache.syncope.types.SyncopeClientExceptionType;
+import org.junit.Assume;
import org.springframework.util.StringUtils;
public class UserTestITCase extends AbstractTest {
@@ -633,6 +635,8 @@ public class UserTestITCase extends Abst
@Test
public void createWithReject() {
+ Assume.assumeTrue(SpringContextInitializer.isActivitiConfigured());
+
UserTO userTO = getSampleTO("createWithReject@syncope.apache.org");
// User with role 9 are defined in workflow as subject to approval
@@ -695,6 +699,8 @@ public class UserTestITCase extends Abst
@Test
public void createWithApproval() {
+ Assume.assumeTrue(SpringContextInitializer.isActivitiConfigured());
+
JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
UserTO userTO = getSampleTO("createWithApproval@syncope.apache.org");
@@ -1298,6 +1304,8 @@ public class UserTestITCase extends Abst
@Test
public void createActivate() {
+ Assume.assumeTrue(SpringContextInitializer.isActivitiConfigured());
+
UserTO userTO = getSampleTO("createActivate@syncope.apache.org");
MembershipTO membershipTO = new MembershipTO();
@@ -1324,6 +1332,8 @@ public class UserTestITCase extends Abst
@Test
public void createActivateByUsername() {
+ Assume.assumeTrue(SpringContextInitializer.isActivitiConfigured());
+
UserTO userTO = getSampleTO("createActivateByUsername@syncope.apache.org");
MembershipTO membershipTO = new MembershipTO();
@@ -1360,7 +1370,7 @@ public class UserTestITCase extends Abst
userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
assertNotNull(userTO);
- assertEquals("active", userTO.getStatus());
+ assertEquals(SpringContextInitializer.isActivitiConfigured() ? "active" : "created", userTO.getStatus());
userTO = restTemplate.getForObject(BASE_URL + "user/suspend/" + userTO.getId(), UserTO.class);
@@ -1384,7 +1394,7 @@ public class UserTestITCase extends Abst
userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
assertNotNull(userTO);
- assertEquals("active", userTO.getStatus());
+ assertEquals(SpringContextInitializer.isActivitiConfigured() ? "active" : "created", userTO.getStatus());
userTO = restTemplate.getForObject(
BASE_URL + "user/suspendByUsername/{username}.json", UserTO.class, userTO.getUsername());
@@ -1421,7 +1431,7 @@ public class UserTestITCase extends Abst
userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
assertNotNull(userTO);
- assertEquals("active", userTO.getStatus());
+ assertEquals(SpringContextInitializer.isActivitiConfigured() ? "active" : "created", userTO.getStatus());
String query = "?resourceNames=" + dbTable.getName() + "&resourceNames=" + ldap.getName()
+ "&performLocally=true"; // check also performLocally
Added: incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/stripActivitiFromContent.xsl
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/stripActivitiFromContent.xsl?rev=1399638&view=auto
==============================================================================
--- incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/stripActivitiFromContent.xsl (added)
+++ incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/stripActivitiFromContent.xsl Thu Oct 18 12:51:33 2012
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+ <xsl:template match="/dataset/ACT_GE_PROPERTY"/>
+
+ <xsl:template match="node()|@*|comment()">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+
+</xsl:stylesheet>
Propchange: incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/stripActivitiFromContent.xsl
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/stripActivitiFromContent.xsl
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/stripActivitiFromContent.xsl
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/workflow.properties
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/workflow.properties?rev=1399638&view=auto
==============================================================================
--- incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/workflow.properties (added)
+++ incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/workflow.properties Thu Oct 18 12:51:33 2012
@@ -0,0 +1,18 @@
+# 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.
+wfAdapter=org.apache.syncope.core.workflow.NoOpUserWorkflowAdapter
+jobExecutorActivate=false
\ No newline at end of file
Propchange: incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/workflow.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/workflow.properties
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Added: incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/workflowContext.xml
URL: http://svn.apache.org/viewvc/incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/workflowContext.xml?rev=1399638&view=auto
==============================================================================
--- incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/workflowContext.xml (added)
+++ incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/workflowContext.xml Thu Oct 18 12:51:33 2012
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <bean id="adminUser" class="java.lang.String">
+ <constructor-arg value="${adminUser}"/>
+ </bean>
+
+ <bean id="wfAdapter" class="${wfAdapter}"/>
+
+ <bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
+ <property name="velocityProperties">
+ <value>
+ resource.loader=class
+ class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
+ </value>
+ </property>
+ </bean>
+</beans>
\ No newline at end of file
Propchange: incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/workflowContext.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/workflowContext.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/workflowContext.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml