syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject svn commit: r1442175 - in /syncope/trunk: archetype/src/main/resources/archetype-resources/console/ archetype/src/main/resources/archetype-resources/core/ client/src/main/java/org/apache/syncope/client/services/proxy/ common/src/main/java/org/apache/sy...
Date Mon, 04 Feb 2013 16:57:43 GMT
Author: ilgrosso
Date: Mon Feb  4 16:57:42 2013
New Revision: 1442175

URL: http://svn.apache.org/viewvc?rev=1442175&view=rev
Log:
[SYNCOPE-284] Export now takes into account everything but user data; activiticontent.xml removed but similar logic delegated to workflow adapter loader

Removed:
    syncope/trunk/core/src/main/resources/activiticontent.xml
    syncope/trunk/core/src/test/resources/workflow.properties
Modified:
    syncope/trunk/archetype/src/main/resources/archetype-resources/console/pom.xml
    syncope/trunk/archetype/src/main/resources/archetype-resources/core/pom.xml
    syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/ConfigurationServiceProxy.java
    syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ConfigurationService.java
    syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ReportService.java
    syncope/trunk/common/src/main/java/org/apache/syncope/common/validation/SyncopeClientErrorHandler.java
    syncope/trunk/console/pom.xml
    syncope/trunk/core/pom.xml
    syncope/trunk/core/src/main/java/org/apache/syncope/core/init/SpringContextInitializer.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/init/WorkflowAdapterLoader.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/ContentLoader.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/util/ImportExport.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/util/multiparent/MultiParentNode.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/ActivitiDetector.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/WorkflowAdapter.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/WorkflowInstanceLoader.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/user/activiti/ActivitiWorkflowLoader.java
    syncope/trunk/core/src/main/resources/workflow.properties
    syncope/trunk/core/src/test/java/org/apache/syncope/core/AbstractTest.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/impl/TestDbInitializer.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java
    syncope/trunk/core/src/test/resources/content.xml
    syncope/trunk/core/src/test/resources/noopworkflow/workflowContext.xml

Modified: syncope/trunk/archetype/src/main/resources/archetype-resources/console/pom.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/archetype/src/main/resources/archetype-resources/console/pom.xml?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/archetype/src/main/resources/archetype-resources/console/pom.xml (original)
+++ syncope/trunk/archetype/src/main/resources/archetype-resources/console/pom.xml Mon Feb  4 16:57:42 2013
@@ -187,7 +187,6 @@ under the License.
                   <patternset>
                     <exclude name="**/content.xml" />
                     <exclude name="**/persistence.properties" />
-                    <exclude name="**/workflow.properties" />
                   </patternset>
                 </unzip>
                 <copy file="${project.build.directory}/test-classes/db.jsp" todir="${cargo.run.dir}"/>

Modified: syncope/trunk/archetype/src/main/resources/archetype-resources/core/pom.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/archetype/src/main/resources/archetype-resources/core/pom.xml?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/archetype/src/main/resources/archetype-resources/core/pom.xml (original)
+++ syncope/trunk/archetype/src/main/resources/archetype-resources/core/pom.xml Mon Feb  4 16:57:42 2013
@@ -200,7 +200,6 @@ under the License.
                   <patternset>
                     <exclude name="**/content.xml"/>
                     <exclude name="**/persistence.properties"/>
-                    <exclude name="**/workflow.properties" />
                   </patternset>
                 </unzip>
                 <copy file="${project.build.directory}/test-classes/db.jsp" todir="${cargo.run.dir}"/>

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/ConfigurationServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/ConfigurationServiceProxy.java?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/ConfigurationServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/ConfigurationServiceProxy.java Mon Feb  4 16:57:42 2013
@@ -18,7 +18,7 @@
  */
 package org.apache.syncope.client.services.proxy;
 
-import java.io.InputStream;
+import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
 import java.net.URLEncoder;
@@ -26,10 +26,20 @@ import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-
 import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.core.Response;
-
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.client.AuthCache;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.protocol.ClientContext;
+import org.apache.http.impl.auth.BasicScheme;
+import org.apache.http.impl.client.BasicAuthCache;
+import org.apache.http.protocol.BasicHttpContext;
+import org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory;
 import org.apache.syncope.common.SyncopeConstants;
 import org.apache.syncope.common.services.ConfigurationService;
 import org.apache.syncope.common.to.ConfigurationTO;
@@ -98,8 +108,36 @@ public class ConfigurationServiceProxy e
 
     @Override
     public Response dbExport() {
-        return Response.ok(getRestTemplate().getForObject(baseUrl + "configuration/dbexport", InputStream.class))
-                .build();
-    }
+        final AuthScope scope = ((PreemptiveAuthHttpRequestFactory) getRestTemplate().getRequestFactory()).
+                getAuthScope();
+        final HttpHost targetHost = new HttpHost(scope.getHost(), scope.getPort(), scope.getScheme());
+        final BasicHttpContext localcontext = new BasicHttpContext();
+        final AuthCache authCache = new BasicAuthCache();
+        authCache.put(targetHost, new BasicScheme());
+        localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache);
+
+        final HttpGet getMethod = new HttpGet(baseUrl + "configuration/dbexport");
+        try {
+            final HttpResponse httpResponse =
+                    ((PreemptiveAuthHttpRequestFactory) getRestTemplate().getRequestFactory()).
+                    getHttpClient().execute(targetHost, getMethod, localcontext);
+
+            Response response;
+            if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+                HttpEntity entity = httpResponse.getEntity();
+                response = Response.ok(entity.getContent(), entity.getContentType().getValue()).
+                        location(getMethod.getURI()).
+                        header("Content-Disposition", httpResponse.getLastHeader("Content-Disposition").getValue()).
+                        build();
+            } else {
+                response = Response.noContent().status(httpResponse.getStatusLine().getStatusCode()).
+                        location(getMethod.getURI()).
+                        build();
+            }
 
+            return response;
+        } catch (IOException e) {
+            throw new InternalServerErrorException(e);
+        }
+    }
 }

Modified: syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ConfigurationService.java
URL: http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ConfigurationService.java?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ConfigurationService.java (original)
+++ syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ConfigurationService.java Mon Feb  4 16:57:42 2013
@@ -20,7 +20,6 @@ package org.apache.syncope.common.servic
 
 import java.util.List;
 import java.util.Set;
-
 import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
@@ -28,7 +27,6 @@ import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.core.Response;
-
 import org.apache.syncope.common.to.ConfigurationTO;
 import org.apache.syncope.common.to.MailTemplateTO;
 import org.apache.syncope.common.to.ValidatorTO;
@@ -94,5 +92,4 @@ public interface ConfigurationService {
     @PUT
     @Path("{key}")
     void update(@PathParam("key") String key, ConfigurationTO configurationTO);
-
 }

Modified: syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ReportService.java
URL: http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ReportService.java?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ReportService.java (original)
+++ syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ReportService.java Mon Feb  4 16:57:42 2013
@@ -19,7 +19,6 @@
 package org.apache.syncope.common.services;
 
 import java.util.List;
-
 import javax.ws.rs.DELETE;
 import javax.ws.rs.DefaultValue;
 import javax.ws.rs.GET;
@@ -29,7 +28,6 @@ import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Response;
-
 import org.apache.syncope.common.to.ReportExecTO;
 import org.apache.syncope.common.to.ReportTO;
 import org.apache.syncope.common.types.ReportExecExportFormat;
@@ -135,5 +133,4 @@ public interface ReportService {
     @PUT
     @Path("{reportId}")
     void update(@PathParam("reportId") Long reportId, ReportTO reportTO);
-
 }

Modified: syncope/trunk/common/src/main/java/org/apache/syncope/common/validation/SyncopeClientErrorHandler.java
URL: http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/validation/SyncopeClientErrorHandler.java?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/common/src/main/java/org/apache/syncope/common/validation/SyncopeClientErrorHandler.java (original)
+++ syncope/trunk/common/src/main/java/org/apache/syncope/common/validation/SyncopeClientErrorHandler.java Mon Feb  4 16:57:42 2013
@@ -39,11 +39,10 @@ public class SyncopeClientErrorHandler e
      */
     private static final Logger LOG = LoggerFactory.getLogger(SyncopeClientErrorHandler.class);
 
-    public static final HttpStatus[] MANAGED_STATUSES = new HttpStatus[] { HttpStatus.BAD_REQUEST, HttpStatus.NOT_FOUND };
+    private static final HttpStatus[] MANAGED_STATUSES = {HttpStatus.BAD_REQUEST, HttpStatus.NOT_FOUND};
 
     @Override
     public void handleError(final ClientHttpResponse response) throws IOException {
-
         if (!ArrayUtils.contains(MANAGED_STATUSES, response.getStatusCode())) {
             super.handleError(response);
         }
@@ -55,8 +54,8 @@ public class SyncopeClientErrorHandler e
             return;
         }
 
-        SyncopeClientCompositeErrorException compositeException = new SyncopeClientCompositeErrorException(response
-                .getStatusCode());
+        SyncopeClientCompositeErrorException compositeException =
+                new SyncopeClientCompositeErrorException(response.getStatusCode());
 
         Set<String> handledExceptions = new HashSet<String>();
         for (String exceptionTypeAsString : exceptionTypesInHeaders) {

Modified: syncope/trunk/console/pom.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/console/pom.xml?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/console/pom.xml (original)
+++ syncope/trunk/console/pom.xml Mon Feb  4 16:57:42 2013
@@ -16,7 +16,6 @@ software distributed under the License i
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
-
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 
@@ -233,7 +232,6 @@ under the License.
                   <patternset>
                     <exclude name="**/content.xml" />
                     <exclude name="**/persistence.properties" />
-                    <exclude name="**/workflow.properties" />
                   </patternset>
                 </unzip>
                 <copy file="${project.build.directory}/test-classes/db.jsp" todir="${cargo.run.dir}" />

Modified: syncope/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/core/pom.xml?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/core/pom.xml (original)
+++ syncope/trunk/core/pom.xml Mon Feb  4 16:57:42 2013
@@ -438,7 +438,6 @@ under the License.
                   <patternset>
                     <exclude name="**/content.xml"/>
                     <exclude name="**/persistence.properties"/>
-                    <exclude name="**/workflow.properties"/>
                   </patternset>
                 </unzip>
                 <copy file="${project.build.directory}/test-classes/org/apache/syncope/core/sync/TestSyncActions.class" 
@@ -793,7 +792,6 @@ under the License.
                     <excludes>
                       <exclude>content.xml</exclude>
                       <exclude>persistence.properties</exclude>
-                      <exclude>workflow.properties</exclude>
                     </excludes>
                   </resource>
                 </resources>
@@ -887,37 +885,13 @@ under the License.
       </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>
-        </plugins>
         
         <testResources>
           <testResource>
             <directory>src/test/resources</directory>
             <filtering>true</filtering>
             <excludes>
+              <exclude>workflowContext.xml</exclude>
               <exclude>workflow.properties</exclude>
             </excludes>
           </testResource>

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/init/SpringContextInitializer.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/SpringContextInitializer.java?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/init/SpringContextInitializer.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/init/SpringContextInitializer.java Mon Feb  4 16:57:42 2013
@@ -19,10 +19,8 @@
 package org.apache.syncope.core.init;
 
 import javax.servlet.ServletContext;
-
 import org.apache.syncope.core.persistence.dao.impl.ContentLoader;
 import org.apache.syncope.core.propagation.ConnectorFactory;
-import org.apache.syncope.core.workflow.ActivitiDetector;
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
@@ -48,9 +46,9 @@ public class SpringContextInitializer im
 
     @Autowired
     private ImplementationClassNamesLoader classNamesLoader;
-    
+
     @Autowired
-    private WorkflowAdapterLoader workflowSetup;
+    private WorkflowAdapterLoader workflowAdapterLoader;
 
     @Override
     public void setServletContext(final ServletContext servletContext) {
@@ -58,11 +56,11 @@ public class SpringContextInitializer im
 
     @Override
     public void afterPropertiesSet() throws Exception {
-        contentLoader.load(ActivitiDetector.isActivitiEnabledForUsers());
+        contentLoader.load(workflowAdapterLoader.getInitSQLStatements());
         connInstanceLoader.load();
         jobInstanceLoader.load();
         loggerLoader.load();
         classNamesLoader.load();
-        workflowSetup.load();
+        workflowAdapterLoader.load();
     }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/init/WorkflowAdapterLoader.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/WorkflowAdapterLoader.java?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/init/WorkflowAdapterLoader.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/init/WorkflowAdapterLoader.java Mon Feb  4 16:57:42 2013
@@ -21,6 +21,8 @@ package org.apache.syncope.core.init;
 import org.apache.syncope.core.workflow.WorkflowInstanceLoader;
 import org.apache.syncope.core.workflow.role.RoleWorkflowAdapter;
 import org.apache.syncope.core.workflow.user.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;
@@ -31,6 +33,9 @@ import org.springframework.stereotype.Co
 
 @Component
 public class WorkflowAdapterLoader implements BeanFactoryAware {
+
+    private static final Logger LOG = LoggerFactory.getLogger(WorkflowAdapterLoader.class);
+
     @Autowired
     private UserWorkflowAdapter uwfAdapter;
 
@@ -39,20 +44,42 @@ public class WorkflowAdapterLoader imple
 
     private DefaultListableBeanFactory beanFactory;
 
+    private WorkflowInstanceLoader wfLoader;
+
     @Override
     public void setBeanFactory(final BeanFactory beanFactory) throws BeansException {
         this.beanFactory = (DefaultListableBeanFactory) beanFactory;
     }
-    
-    public void load() {
-        if (uwfAdapter.getLoaderClass() != null) {
-            final WorkflowInstanceLoader wfLoader = (WorkflowInstanceLoader) beanFactory.createBean(
-                    uwfAdapter.getLoaderClass(), AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false);
-            wfLoader.load();
+
+    private void lazyInit() {
+        if (wfLoader == null) {
+            if (uwfAdapter.getLoaderClass() != null) {
+                wfLoader = (WorkflowInstanceLoader) beanFactory.createBean(
+                        uwfAdapter.getLoaderClass(), AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false);
+            }
+            if (rwfAdapter.getLoaderClass() != null) {
+                wfLoader = (WorkflowInstanceLoader) beanFactory.createBean(
+                        rwfAdapter.getLoaderClass(), AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false);
+            }
         }
-        if (rwfAdapter.getLoaderClass() != null) {
-            final WorkflowInstanceLoader wfLoader = (WorkflowInstanceLoader) beanFactory.createBean(
-                    rwfAdapter.getLoaderClass(), AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false);
+    }
+
+    public String getTablePrefix() {
+        lazyInit();
+        return wfLoader == null ? null : wfLoader.getTablePrefix();
+    }
+
+    public String[] getInitSQLStatements() {
+        lazyInit();
+        return wfLoader == null ? null : wfLoader.getInitSQLStatements();
+    }
+
+    public void load() {
+        lazyInit();
+        if (wfLoader == null) {
+            LOG.debug("Configured workflow adapter does not need loading");
+        } else {
+            LOG.debug("Loading workflow adapter by {}", wfLoader.getClass().getName());
             wfLoader.load();
         }
     }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/ContentLoader.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/ContentLoader.java?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/ContentLoader.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/ContentLoader.java Mon Feb  4 16:57:42 2013
@@ -47,10 +47,6 @@ public class ContentLoader {
 
     private static final String INDEXES_FILE = "/indexes.xml";
 
-    private static final String CONTENT_FILE = "/content.xml";
-
-    private static final String ACTIVITY_CONTENT_FILE = "/activiticontent.xml";
-
     private static final Logger LOG = LoggerFactory.getLogger(ContentLoader.class);
 
     @Autowired
@@ -60,7 +56,7 @@ public class ContentLoader {
     private ImportExport importExport;
 
     @Transactional
-    public void load(final boolean activitiEnabledForUsers) {
+    public void load(final String[] wfInitSQLStatements) {
         Connection conn = null;
         try {
             conn = DataSourceUtils.getConnection(dataSource);
@@ -73,13 +69,7 @@ public class ContentLoader {
 
                 createViews(conn);
                 createIndexes(conn);
-                if (activitiEnabledForUsers) {
-                    deleteActivitiProperties(conn);
-                }
-                loadDefaultContent(CONTENT_FILE);
-                if (activitiEnabledForUsers) {
-                    loadDefaultContent(ACTIVITY_CONTENT_FILE);
-                }
+                loadDefaultContent(wfInitSQLStatements);
             }
         } finally {
             DataSourceUtils.releaseConnection(conn, dataSource);
@@ -149,9 +139,7 @@ public class ContentLoader {
         } catch (Exception e) {
             LOG.error("While creating views", e);
         } finally {
-            if (viewsStream != null) {
-                IOUtils.closeQuietly(viewsStream);
-            }
+            IOUtils.closeQuietly(viewsStream);
         }
     }
 
@@ -184,23 +172,13 @@ public class ContentLoader {
         }
     }
 
-    private void deleteActivitiProperties(final Connection conn) {
-        PreparedStatement statement = null;
-        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 {
-            closeStatement(statement);
-        }
-    }
-
-    private void loadDefaultContent(final String contentPath) {
+    private void loadDefaultContent(final String[] wfInitSQLStatements) {
         SAXParserFactory factory = SAXParserFactory.newInstance();
         InputStream in = null;
         try {
-            in = getClass().getResourceAsStream(contentPath);
+            in = getClass().getResourceAsStream("/" + ImportExport.CONTENT_FILE);
+
+            importExport.setWfInitSQLStatements(wfInitSQLStatements);
 
             SAXParser parser = factory.newSAXParser();
             parser.parse(in, importExport);
@@ -208,9 +186,7 @@ public class ContentLoader {
         } catch (Exception e) {
             LOG.error("While loading default content", e);
         } finally {
-            if (in != null) {
-                IOUtils.closeQuietly(in);
-            }
+            IOUtils.closeQuietly(in);
         }
     }
 

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java Mon Feb  4 16:57:42 2013
@@ -24,16 +24,15 @@ import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-
 import org.apache.syncope.common.to.ConfigurationTO;
 import org.apache.syncope.common.types.AuditElements.Category;
 import org.apache.syncope.common.types.AuditElements.ConfigurationSubCategory;
 import org.apache.syncope.common.types.AuditElements.Result;
 import org.apache.syncope.core.audit.AuditManager;
 import org.apache.syncope.core.init.ImplementationClassNamesLoader;
+import org.apache.syncope.core.init.WorkflowAdapterLoader;
 import org.apache.syncope.core.persistence.beans.SyncopeConf;
 import org.apache.syncope.core.persistence.dao.ConfDAO;
 import org.apache.syncope.core.persistence.dao.MissingConfKeyException;
@@ -75,6 +74,9 @@ public class ConfigurationController ext
     @Autowired
     private ResourcePatternResolver resResolver;
 
+    @Autowired
+    private WorkflowAdapterLoader wfAdapterLoader;
+
     @PreAuthorize("hasRole('CONFIGURATION_CREATE')")
     @RequestMapping(method = RequestMethod.POST, value = "/create")
     public ConfigurationTO create(final HttpServletResponse response,
@@ -209,7 +211,7 @@ public class ConfigurationController ext
     @Transactional(readOnly = true)
     public void dbExport(final HttpServletResponse response) {
         response.setContentType(MediaType.TEXT_XML_VALUE);
-        response.setHeader("Content-Disposition", "attachment; filename=content.xml");
+        response.setHeader("Content-Disposition", "attachment; filename=" + ImportExport.CONTENT_FILE);
         try {
             dbExportInternal(response.getOutputStream());
         } catch (IOException e) {
@@ -218,9 +220,9 @@ public class ConfigurationController ext
     }
 
     @Transactional(readOnly = true)
-    public void dbExportInternal(OutputStream os) {
+    public void dbExportInternal(final OutputStream os) {
         try {
-            importExport.export(os);
+            importExport.export(os, wfAdapterLoader.getTablePrefix());
 
             auditManager.audit(Category.configuration, ConfigurationSubCategory.dbExport, Result.success,
                     "Successfully exported database content");

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/util/ImportExport.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/util/ImportExport.java?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/util/ImportExport.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/util/ImportExport.java Mon Feb  4 16:57:42 2013
@@ -33,6 +33,7 @@ import java.sql.Types;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
@@ -53,6 +54,8 @@ import javax.xml.transform.sax.SAXTransf
 import javax.xml.transform.sax.TransformerHandler;
 import javax.xml.transform.stream.StreamResult;
 import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.SerializationUtils;
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.time.DateUtils;
 import org.apache.syncope.common.SyncopeConstants;
 import org.apache.syncope.core.util.multiparent.MultiParentNode;
@@ -71,14 +74,13 @@ import org.xml.sax.helpers.DefaultHandle
 @Component
 public class ImportExport extends DefaultHandler {
 
-    /**
-     * Logger.
-     */
     private static final Logger LOG = LoggerFactory.getLogger(ImportExport.class);
 
-    private final static String ROOT_ELEMENT = "dataset";
+    public static final String CONTENT_FILE = "content.xml";
 
-    protected static final ThreadLocal<SimpleDateFormat> DATE_FORMAT = new ThreadLocal<SimpleDateFormat>() {
+    private static final String ROOT_ELEMENT = "dataset";
+
+    private static final ThreadLocal<SimpleDateFormat> DATE_FORMAT = new ThreadLocal<SimpleDateFormat>() {
 
         @Override
         protected SimpleDateFormat initialValue() {
@@ -92,6 +94,27 @@ public class ImportExport extends Defaul
     @Autowired
     private DataSource dataSource;
 
+    private final Set<String> tablePrefixesToBeExcluded = new HashSet<String>(
+            Arrays.asList(new String[]{"QRTZ_", "LOGGING", "REPORTEXEC", "TASKEXEC",
+                "SYNCOPEUSER", "UATTR", "UATTRVALUE", "UATTRUNIQUEVALUE", "UDERATTR", "UVIRATTR",
+                "MEMBERSHIP", "MATTR", "MATTRVALUE", "MATTRUNIQUEVALUE", "MDERATTR", "MVIRATTR"}));
+
+    private final Map<String, String> tablesTobeFiltered =
+            Collections.singletonMap("TASK", "DTYPE <> 'PropagationTask'");
+
+    private final Map<String, Set<String>> columnsToBeNullified =
+            Collections.singletonMap("SYNCOPEROLE", Collections.singleton("USEROWNER_ID"));
+
+    private String[] wfInitSQLStatements;
+
+    public void setWfInitSQLStatements(final String[] wfInitSQLStatements) {
+        if (wfInitSQLStatements == null) {
+            this.wfInitSQLStatements = new String[0];
+        } else {
+            this.wfInitSQLStatements = (String[]) SerializationUtils.clone(wfInitSQLStatements);
+        }
+    }
+
     private String readSchema() {
         String schema = null;
 
@@ -108,13 +131,7 @@ public class ImportExport extends Defaul
                 LOG.error("Could not find persistence.properties");
             }
         } finally {
-            if (dbPropsStream != null) {
-                try {
-                    dbPropsStream.close();
-                } catch (IOException e) {
-                    LOG.error("While trying to read persistence.properties", e);
-                }
-            }
+            IOUtils.closeQuietly(dbPropsStream);
         }
 
         return schema;
@@ -263,8 +280,14 @@ public class ImportExport extends Defaul
     public void startElement(final String uri, final String localName, final String qName, final Attributes atts)
             throws SAXException {
 
-        // skip root element
+        // skip root element and perform workflow init statements
         if (ROOT_ELEMENT.equals(qName)) {
+            if (wfInitSQLStatements != null) {
+                for (String wfInitSQLStmt : wfInitSQLStatements) {
+                    Query query = entityManager.createNativeQuery(wfInitSQLStmt);
+                    query.executeUpdate();
+                }
+            }
             return;
         }
 
@@ -288,15 +311,14 @@ public class ImportExport extends Defaul
         query.executeUpdate();
     }
 
-    private void doExportTable(final TransformerHandler handler, final Connection conn, final String tableName)
-            throws SQLException, SAXException {
+    private void doExportTable(final TransformerHandler handler, final Connection conn, final String tableName,
+            final String whereClause) throws SQLException, SAXException {
 
         AttributesImpl attrs = new AttributesImpl();
 
         PreparedStatement stmt = null;
         ResultSet rs = null;
         ResultSet pkeyRS = null;
-
         try {
             // ------------------------------------
             // retrieve primary keys to perform an ordered select
@@ -308,7 +330,6 @@ public class ImportExport extends Defaul
 
             while (pkeyRS.next()) {
                 final String columnName = pkeyRS.getString("COLUMN_NAME");
-
                 if (columnName != null) {
                     if (orderBy.length() > 0) {
                         orderBy.append(",");
@@ -319,23 +340,30 @@ public class ImportExport extends Defaul
             }
 
             // ------------------------------------
-            stmt = conn.prepareStatement(
-                    "SELECT * FROM " + tableName + " a" + (orderBy.length() > 0 ? " ORDER BY " + orderBy : ""));
+            StringBuilder query = new StringBuilder();
+            query.append("SELECT * FROM ").append(tableName).append(" a");
+            if (StringUtils.isNotBlank(whereClause)) {
+                query.append(" WHERE ").append(whereClause);
+            }
+            if (orderBy.length() > 0) {
+                query.append(" ORDER BY ").append(orderBy);
+            }
+            stmt = conn.prepareStatement(query.toString());
 
             rs = stmt.executeQuery();
-            for (int rowNo = 0; rs.next(); rowNo++) {
+            while (rs.next()) {
                 attrs.clear();
 
                 final ResultSetMetaData rsMeta = rs.getMetaData();
-
                 for (int i = 0; i < rsMeta.getColumnCount(); i++) {
                     final String columnName = rsMeta.getColumnName(i + 1);
                     final Integer columnType = rsMeta.getColumnType(i + 1);
 
                     // Retrieve value taking care of binary values.
                     String value = getValues(rs, columnName, columnType);
+                    if (value != null && (!columnsToBeNullified.containsKey(tableName)
+                            || !columnsToBeNullified.get(tableName).contains(columnName))) {
 
-                    if (value != null) {
                         attrs.addAttribute("", "", columnName, "CDATA", value);
                     }
                 }
@@ -381,19 +409,16 @@ public class ImportExport extends Defaul
         final Set<String> pkTableNames = new HashSet<String>();
 
         for (String tableName : tableNames) {
-
             MultiParentNode<String> node = exploited.get(tableName);
-
             if (node == null) {
                 node = new MultiParentNode<String>(tableName);
                 roots.add(node);
                 exploited.put(tableName, node);
             }
 
-            ResultSet rs = null;
-
             pkTableNames.clear();
 
+            ResultSet rs = null;
             try {
                 rs = meta.getImportedKeys(conn.getCatalog(), readSchema(), tableName);
 
@@ -413,9 +438,7 @@ public class ImportExport extends Defaul
 
             for (String pkTableName : pkTableNames) {
                 if (!tableName.equalsIgnoreCase(pkTableName)) {
-
                     MultiParentNode<String> pkNode = exploited.get(pkTableName);
-
                     if (pkNode == null) {
                         pkNode = new MultiParentNode<String>(pkTableName);
                         roots.add(pkNode);
@@ -435,12 +458,29 @@ public class ImportExport extends Defaul
         MultiParentNodeOp.traverseTree(roots, sortedTableNames);
 
         Collections.reverse(sortedTableNames);
+        // remove from sortedTableNames any table possibly added during lookup 
+        // but matching some item in this.tablePrefixesToBeExcluded
+        sortedTableNames.retainAll(tableNames);
         return sortedTableNames;
     }
 
-    public void export(final OutputStream os)
+    private boolean isTableAllowed(final String tableName) {
+        boolean allowed = true;
+        for (String prefix : tablePrefixesToBeExcluded) {
+            if (tableName.toUpperCase().startsWith(prefix)) {
+                allowed = false;
+            }
+        }
+        return allowed;
+    }
+
+    public void export(final OutputStream os, final String wfTablePrefix)
             throws SAXException, TransformerConfigurationException {
 
+        if (StringUtils.isNotBlank(wfTablePrefix)) {
+            tablePrefixesToBeExcluded.add(wfTablePrefix);
+        }
+
         StreamResult streamResult = new StreamResult(os);
         final SAXTransformerFactory transformerFactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
 
@@ -466,16 +506,14 @@ public class ImportExport extends Defaul
 
             while (rs.next()) {
                 String tableName = rs.getString("TABLE_NAME");
-
-                // these tables must be ignored
-                if (!tableName.toUpperCase().startsWith("QRTZ_") && !tableName.toUpperCase().startsWith("LOGGING_")) {
+                if (isTableAllowed(tableName)) {
                     tableNames.add(tableName);
                 }
             }
 
             // then sort tables based on foreign keys and dump
             for (String tableName : sortByForeignKeys(conn, tableNames, schema)) {
-                doExportTable(handler, conn, tableName);
+                doExportTable(handler, conn, tableName, tablesTobeFiltered.get(tableName.toUpperCase()));
             }
         } catch (SQLException e) {
             LOG.error("While exporting database content", e);

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/util/multiparent/MultiParentNode.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/util/multiparent/MultiParentNode.java?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/util/multiparent/MultiParentNode.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/util/multiparent/MultiParentNode.java Mon Feb  4 16:57:42 2013
@@ -20,7 +20,6 @@ package org.apache.syncope.core.util.mul
 
 import java.util.HashSet;
 import java.util.Set;
-
 import org.apache.commons.lang.builder.EqualsBuilder;
 import org.apache.commons.lang.builder.HashCodeBuilder;
 

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/ActivitiDetector.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/ActivitiDetector.java?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/ActivitiDetector.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/ActivitiDetector.java Mon Feb  4 16:57:42 2013
@@ -21,22 +21,29 @@ package org.apache.syncope.core.workflow
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Properties;
-
+import org.apache.commons.io.IOUtils;
 import org.apache.syncope.core.persistence.dao.impl.ContentLoader;
 import org.apache.syncope.core.workflow.user.activiti.ActivitiUserWorkflowAdapter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class ActivitiDetector {
+
     private static final Logger LOG = LoggerFactory.getLogger(ActivitiDetector.class);
+
+    private static final String XX = "/workflow.properties";
+
     private static String uwfAdapterClassName;
+
     private static String rwfAdapterClassName;
 
+    private static String activitiVersion;
+
     static {
         try {
-            initWFAdapterClassNames();
+            init();
         } catch (IOException e) {
-            LOG.error("Could not init uwfAdapterClassName", e);
+            LOG.error("Could not read from {}", XX, e);
         }
     }
 
@@ -45,20 +52,19 @@ public class ActivitiDetector {
      *
      * @throws IOException if anything goes wrong
      */
-    private static void initWFAdapterClassNames() throws IOException {
+    private static void init() throws IOException {
         Properties props = new java.util.Properties();
         InputStream propStream = null;
         try {
-            propStream = ContentLoader.class.getResourceAsStream("/workflow.properties");
+            propStream = ContentLoader.class.getResourceAsStream(XX);
             props.load(propStream);
             uwfAdapterClassName = props.getProperty("uwfAdapter");
             rwfAdapterClassName = props.getProperty("rwfAdapter");
+            activitiVersion = props.getProperty("activitiVersion");
         } catch (Exception e) {
             LOG.error("Could not load workflow.properties", e);
         } finally {
-            if (propStream != null) {
-                propStream.close();
-            }
+            IOUtils.closeQuietly(propStream);
         }
     }
 
@@ -70,7 +76,7 @@ public class ActivitiDetector {
     public static boolean isActivitiEnabledForUsers() {
         return uwfAdapterClassName != null && uwfAdapterClassName.equals(ActivitiUserWorkflowAdapter.class.getName());
     }
-    
+
     /**
      * Check if the configured role workflow adapter is Activiti's.
      *
@@ -81,4 +87,11 @@ public class ActivitiDetector {
         //return rwfAdapterClassName != null && rwfAdapterClassName.equals(ActivitiRoleWorkflowAdapter.class.getName());
         return false;
     }
+
+    /**
+     * @return the version of Activiti packages, as configured in Maven
+     */
+    public static String getActivitiVersion() {
+        return activitiVersion;
+    }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/WorkflowAdapter.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/WorkflowAdapter.java?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/WorkflowAdapter.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/WorkflowAdapter.java Mon Feb  4 16:57:42 2013
@@ -20,7 +20,6 @@ package org.apache.syncope.core.workflow
 
 import java.util.List;
 import java.util.Map;
-
 import org.apache.syncope.common.to.WorkflowDefinitionTO;
 import org.apache.syncope.common.to.WorkflowFormTO;
 import org.apache.syncope.core.persistence.dao.NotFoundException;

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/WorkflowInstanceLoader.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/WorkflowInstanceLoader.java?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/WorkflowInstanceLoader.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/WorkflowInstanceLoader.java Mon Feb  4 16:57:42 2013
@@ -21,4 +21,8 @@ package org.apache.syncope.core.workflow
 public interface WorkflowInstanceLoader {
 
     void load();
+
+    String getTablePrefix();
+
+    String[] getInitSQLStatements();
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/user/activiti/ActivitiWorkflowLoader.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/user/activiti/ActivitiWorkflowLoader.java?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/user/activiti/ActivitiWorkflowLoader.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/user/activiti/ActivitiWorkflowLoader.java Mon Feb  4 16:57:42 2013
@@ -18,12 +18,13 @@
  */
 package org.apache.syncope.core.workflow.user.activiti;
 
-import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
 import java.util.List;
-
 import org.activiti.engine.RepositoryService;
 import org.activiti.engine.repository.ProcessDefinition;
+import org.apache.commons.io.IOUtils;
+import org.apache.syncope.core.workflow.ActivitiDetector;
 import org.apache.syncope.core.workflow.WorkflowInstanceLoader;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -37,6 +38,26 @@ public class ActivitiWorkflowLoader impl
     private RepositoryService repositoryService;
 
     @Override
+    public String getTablePrefix() {
+        return "ACT_";
+    }
+
+    @Override
+    public String[] getInitSQLStatements() {
+        final List<String> initSQLStatements = new ArrayList<String>();
+
+        initSQLStatements.add("DELETE FROM ACT_GE_PROPERTY");
+        initSQLStatements.add("INSERT INTO ACT_GE_PROPERTY(NAME_, VALUE_, REV_) "
+                + "VALUES('schema.version', '" + ActivitiDetector.getActivitiVersion() + "', 1)");
+        initSQLStatements.add("INSERT INTO ACT_GE_PROPERTY(NAME_, VALUE_, REV_) "
+                + "VALUES('schema.history', 'create(" + ActivitiDetector.getActivitiVersion() + ")', 1)");
+        initSQLStatements.add("INSERT INTO ACT_GE_PROPERTY(NAME_, VALUE_, REV_) VALUES('next.dbid', '1', 1)");
+        initSQLStatements.add("INSERT INTO ACT_GE_PROPERTY(NAME_, VALUE_, REV_) VALUES('historyLevel', '1', 1)");
+
+        return initSQLStatements.toArray(new String[initSQLStatements.size()]);
+    }
+
+    @Override
     public void load() {
         List<ProcessDefinition> processes = repositoryService.createProcessDefinitionQuery().processDefinitionKey(
                 ActivitiUserWorkflowAdapter.WF_PROCESS_ID).list();
@@ -52,14 +73,7 @@ public class ActivitiWorkflowLoader impl
                 repositoryService.createDeployment().addInputStream(
                         ActivitiUserWorkflowAdapter.WF_PROCESS_RESOURCE, wfDefinitionStream).deploy();
             } finally {
-                if (wfDefinitionStream != null) {
-                    try {
-                        wfDefinitionStream.close();
-                    } catch (IOException e) {
-                        LOG.error("While closing input stream for {}",
-                                ActivitiUserWorkflowAdapter.WF_PROCESS_RESOURCE, e);
-                    }
-                }
+                IOUtils.closeQuietly(wfDefinitionStream);;
             }
         }
     }

Modified: syncope/trunk/core/src/main/resources/workflow.properties
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/workflow.properties?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/workflow.properties (original)
+++ syncope/trunk/core/src/main/resources/workflow.properties Mon Feb  4 16:57:42 2013
@@ -17,3 +17,4 @@
 uwfAdapter=org.apache.syncope.core.workflow.user.activiti.ActivitiUserWorkflowAdapter
 rwfAdapter=org.apache.syncope.core.workflow.role.NoOpRoleWorkflowAdapter
 jobExecutorActivate=true
+activitiVersion=${activiti.version}

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/AbstractTest.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/AbstractTest.java?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/AbstractTest.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/AbstractTest.java Mon Feb  4 16:57:42 2013
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertNot
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Properties;
+import org.apache.commons.io.IOUtils;
 import org.junit.BeforeClass;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -50,9 +51,7 @@ public abstract class AbstractTest {
         } catch (Exception e) {
             LOG.error("Could not load bundles.properties", e);
         } finally {
-            if (propStream != null) {
-                propStream.close();
-            }
+            IOUtils.closeQuietly(propStream);
         }
         assertNotNull(connidSoapVersion);
         assertNotNull(bundlesDirectory);

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/impl/TestDbInitializer.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/impl/TestDbInitializer.java?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/impl/TestDbInitializer.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/impl/TestDbInitializer.java Mon Feb  4 16:57:42 2013
@@ -18,27 +18,21 @@
  */
 package org.apache.syncope.core.persistence.dao.impl;
 
-import javax.servlet.ServletContext;
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
-import org.springframework.web.context.ServletContextAware;
 
 /**
  * Take care of all initializations needed by Syncope to run up and safe for tests.
  */
 @Component
-public class TestDbInitializer implements ServletContextAware, InitializingBean {
+public class TestDbInitializer implements InitializingBean {
 
     @Autowired
     private ContentLoader contentLoader;
 
     @Override
-    public void setServletContext(final ServletContext servletContext) {
-    }
-
-    @Override
     public void afterPropertiesSet() throws Exception {
-        contentLoader.load(false);
+        contentLoader.load(null);
     }
-}
\ No newline at end of file
+}

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java Mon Feb  4 16:57:42 2013
@@ -89,7 +89,7 @@ import org.springframework.test.context.
 import org.springframework.web.client.RestTemplate;
 
 @RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "classpath:restClientContext.xml", "classpath:testJDBCContext.xml" })
+@ContextConfiguration(locations = {"classpath:restClientContext.xml", "classpath:testJDBCContext.xml"})
 public abstract class AbstractTest {
 
     /**
@@ -104,7 +104,9 @@ public abstract class AbstractTest {
     protected static final String ADMIN_PWD = "password";
 
     public static final String CONTENT_TYPE_JSON = "application/json";
+
     public static final String CONTENT_TYPE_XML = "application/xml";
+
     public static final String DEFAULT_CONTENT_TYPE = CONTENT_TYPE_JSON;
 
     private static final String ENV_KEY_CONTENT_TYPE = "jaxrsContentType";
@@ -205,7 +207,6 @@ public abstract class AbstractTest {
     }
 
     // END Spring MVC Initialization
-
     // BEGIN CXF Initialization
     public void setupCXFServices() throws Exception {
         userService = createServiceInstance(UserService.class);
@@ -261,9 +262,9 @@ public abstract class AbstractTest {
     }
 
     // END CXF Initialization
-
     @SuppressWarnings("unchecked")
-    public <T> T setupCredentials(final T proxy, final Class<?> serviceInterface, final String username, final String password) {
+    public <T> T setupCredentials(final T proxy, final Class<?> serviceInterface, final String username,
+            final String password) {
         if (proxy instanceof SpringServiceProxy) {
             SpringServiceProxy service = (SpringServiceProxy) proxy;
             if (username == null && password == null) {
@@ -285,10 +286,10 @@ public abstract class AbstractTest {
     public <T> T getObject(final Response response, final Class<T> type, final Object serviceProxy) {
         assertNotNull(response);
         assertNotNull(response.getLocation());
-        if (!enabledCXF) {
-            return getObjectSpring(response, type);
-        } else {
+        if (enabledCXF) {
             return getObjectCXF(response, type, serviceProxy);
+        } else {
+            return getObjectSpring(response, type);
         }
     }
 
@@ -366,7 +367,7 @@ public abstract class AbstractTest {
         }
         return response;
     }
-    
+
     protected RoleTO createRole(RoleService roleService, RoleTO newRoleTO) {
         Response response = roleService.create(newRoleTO);
         if (response.getStatus() != org.apache.http.HttpStatus.SC_CREATED) {
@@ -378,7 +379,6 @@ public abstract class AbstractTest {
         return getObject(response, RoleTO.class, roleService);
     }
 
-
     protected Response createPolicy(PolicyService policyService, PolicyType policyType, PolicyTO policy) {
         Response response = policyService.create(policyType, policy);
         if (response.getStatus() != org.apache.http.HttpStatus.SC_CREATED) {

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java Mon Feb  4 16:57:42 2013
@@ -19,18 +19,22 @@
 package org.apache.syncope.core.rest;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
+import java.io.IOException;
+import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.util.List;
-
 import javax.ws.rs.core.Response;
-
+import org.apache.commons.io.IOUtils;
 import org.apache.syncope.common.to.ConfigurationTO;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
 import org.junit.runners.MethodSorters;
 import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
 import org.springframework.web.client.HttpStatusCodeException;
 
 @FixMethodOrder(MethodSorters.JVM)
@@ -104,4 +108,17 @@ public class ConfigurationTestITCase ext
         newConfigurationTO = configurationService.read("token.expireTime");
         assertEquals(configurationTO, newConfigurationTO);
     }
+
+    @Test
+    public void dbExport() throws IOException {
+        Response response = configurationService.dbExport();
+        assertNotNull(response);
+        assertNotNull(response.getLocation());
+        assertTrue(response.getHeaderString("Content-Type").startsWith(MediaType.TEXT_XML_VALUE));
+        assertNotNull(response.getHeaderString("Content-Disposition"));
+
+        Object entity = response.getEntity();
+        assertTrue(entity instanceof InputStream);
+        assertFalse(IOUtils.toString((InputStream) entity, "UTF-8").isEmpty());
+    }
 }

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java Mon Feb  4 16:57:42 2013
@@ -29,9 +29,7 @@ import java.io.StringWriter;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.util.List;
-
 import javax.ws.rs.core.Response;
-
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.io.IOUtils;
 import org.apache.syncope.common.report.UserReportletConf;
@@ -159,6 +157,7 @@ public class ReportTestITCase extends Ab
 
     private void checkExport(final long execId, final String fmt, final String encodedAuth)
             throws IOException {
+
         URL url = new URL(BASE_URL + "report/execution/export/" + execId + "?fmt=" + fmt);
         int responseCode = 0;
         String export = null;
@@ -186,7 +185,6 @@ public class ReportTestITCase extends Ab
 
     @Test
     public void executeAndExport() throws IOException {
-
         ReportTO reportTO = reportService.read(1L);
         reportTO.setId(0);
         reportTO.setName("executeAndExport" + getUUIDString());

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java Mon Feb  4 16:57:42 2013
@@ -27,7 +27,6 @@ import static org.junit.Assert.assertTru
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
-
 import javax.ws.rs.core.Response;
 import org.apache.syncope.common.search.AttributableCond;
 import org.apache.syncope.common.search.AttributeCond;
@@ -54,7 +53,6 @@ import org.apache.syncope.common.types.T
 import org.apache.syncope.common.types.TraceLevel;
 import org.apache.syncope.core.sync.TestSyncActions;
 import org.apache.syncope.core.sync.impl.SyncJob;
-import org.apache.syncope.core.workflow.ActivitiDetector;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
 import org.junit.runners.MethodSorters;
@@ -283,14 +281,12 @@ public class TaskTestITCase extends Abst
 
             execSyncTask(SYNC_TASK_ID, 50, false);
 
-            // after execution of the sync task the user data should be synced
-            // from
+            // after execution of the sync task the user data should be synced from
             // csv datasource and processed by user template
             UserTO userTO = userService.read(inUserTO.getId());
             assertNotNull(userTO);
             assertEquals("test9", userTO.getUsername());
-            assertEquals(ActivitiDetector.isActivitiEnabledForUsers() ? "active"
-                    : "created", userTO.getStatus());
+            assertEquals("active", 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: syncope/trunk/core/src/test/resources/content.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/resources/content.xml?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/core/src/test/resources/content.xml (original)
+++ syncope/trunk/core/src/test/resources/content.xml Mon Feb  4 16:57:42 2013
@@ -762,19 +762,12 @@ under the License.
                 xmlAbout="%3Corg.apache.syncope.common.search.NodeCond%3E%0A++%3Ctype%3EAND%3C%2Ftype%3E%0A++%3CleftNodeCond%3E%0A++++%3Ctype%3ELEAF%3C%2Ftype%3E%0A++++%3CattributeCond%3E%0A++++++%3Ctype%3ELIKE%3C%2Ftype%3E%0A++++++%3Cschema%3Efullname%3C%2Fschema%3E%0A++++++%3Cexpression%3E%25o%25%3C%2Fexpression%3E%0A++++%3C%2FattributeCond%3E%0A++%3C%2FleftNodeCond%3E%0A++%3CrightNodeCond%3E%0A++++%3Ctype%3ELEAF%3C%2Ftype%3E%0A++++%3CattributeCond%3E%0A++++++%3Ctype%3ELIKE%3C%2Ftype%3E%0A++++++%3Cschema%3Efullname%3C%2Fschema%3E%0A++++++%3Cexpression%3E%25i%25%3C%2Fexpression%3E%0A++++%3C%2FattributeCond%3E%0A++%3C%2FrightNodeCond%3E%0A%3C%2Forg.apache.syncope.common.search.NodeCond%3E"
                 xmlRecipients="%3Corg.apache.syncope.common.search.NodeCond%3E%0A++%3Ctype%3ELEAF%3C%2Ftype%3E%0A++%3CmembershipCond%3E%0A++++%3CroleId%3E7%3C%2FroleId%3E%0A++%3C%2FmembershipCond%3E%0A%3C%2Forg.apache.syncope.common.search.NodeCond%3E"
                 recipientAttrType="UserSchema" recipientAttrName="email"/>
-  <!--Notification id="101" sender="test@syncope.apache.org" subject="Test subject" template="test" selfAsRecipient="0" traceLevel="ALL"
-  xmlAbout="%3Corg.apache.syncope.common.search.NodeCond%3E%0A++%3Ctype%3EAND%3C%2Ftype%3E%0A++%3CleftNodeCond%3E%0A++++%3Ctype%3ELEAF%3C%2Ftype%3E%0A++++%3CattributeCond%3E%0A++++++%3Ctype%3ELIKE%3C%2Ftype%3E%0A++++++%3Cschema%3Efullname%3C%2Fschema%3E%0A++++++%3Cexpression%3E%25o%25%3C%2Fexpression%3E%0A++++%3C%2FattributeCond%3E%0A++%3C%2FleftNodeCond%3E%0A++%3CrightNodeCond%3E%0A++++%3Ctype%3ELEAF%3C%2Ftype%3E%0A++++%3CattributeCond%3E%0A++++++%3Ctype%3ELIKE%3C%2Ftype%3E%0A++++++%3Cschema%3Efullname%3C%2Fschema%3E%0A++++++%3Cexpression%3E%25i%25%3C%2Fexpression%3E%0A++++%3C%2FattributeCond%3E%0A++%3C%2FrightNodeCond%3E%0A%3C%2Forg.apache.syncope.common.search.NodeCond%3E"
-  xmlRecipients="%3Corg.apache.syncope.common.search.NodeCond%3E%0A++%3Ctype%3ELEAF%3C%2Ftype%3E%0A++%3CmembershipCond%3E%0A++++%3CroleId%3E7%3C%2FroleId%3E%0A++%3C%2FmembershipCond%3E%0A%3C%2Forg.apache.syncope.common.search.NodeCond%3E"
-  recipientAttrType="UserSchema" recipientAttrName="email"/-->
   <Notification_events Notification_id="100" events="unexisting1"/>
   <Notification_events Notification_id="100" events="unexisting2"/>
-  <!--Notification_events Notification_id="101" events="unexisting1"/-->
-  <!--Notification_events Notification_id="101" events="unexisting2"/-->
     
   <Report id="1" name="test"/>
   <ReportletConfInstance id="1" Report_id="1" serializedInstance="%3Corg.apache.syncope.common.report.UserReportletConf%3E%0A++%3Cname%3EtestUserReportlet%3C%2Fname%3E%0A++%3Cattrs%3E%0A++++%3Cstring%3Efullname%3C%2Fstring%3E%0A++++%3Cstring%3Egender%3C%2Fstring%3E%0A++%3C%2Fattrs%3E%0A++%3CderAttrs+class%3D%22singleton-list%22%3E%0A++++%3Cstring%3Ecn%3C%2Fstring%3E%0A++%3C%2FderAttrs%3E%0A++%3CvirAttrs+class%3D%22singleton-list%22%3E%0A++++%3Cstring%3Evirtualdata%3C%2Fstring%3E%0A++%3C%2FvirAttrs%3E%0A++%3Cfeatures+class%3D%22java.util.Arrays%24ArrayList%22%3E%0A++++%3Ca+class%3D%22org.apache.syncope.common.report.UserReportletConf%24Feature-array%22%3E%0A++++++%3Corg.apache.syncope.common.report.UserReportletConf_-Feature%3Eid%3C%2Forg.apache.syncope.common.report.UserReportletConf_-Feature%3E%0A++++++%3Corg.apache.syncope.common.report.UserReportletConf_-Feature%3Eusername%3C%2Forg.apache.syncope.common.report.UserReportletConf_-Feature%3E%0A++++++%3Corg.apache.syncope.co
 mmon.report.UserReportletConf_-Feature%3EworkflowId%3C%2Forg.apache.syncope.common.report.UserReportletConf_-Feature%3E%0A++++++%3Corg.apache.syncope.common.report.UserReportletConf_-Feature%3Estatus%3C%2Forg.apache.syncope.common.report.UserReportletConf_-Feature%3E%0A++++++%3Corg.apache.syncope.common.report.UserReportletConf_-Feature%3EcreationDate%3C%2Forg.apache.syncope.common.report.UserReportletConf_-Feature%3E%0A++++++%3Corg.apache.syncope.common.report.UserReportletConf_-Feature%3ElastLoginDate%3C%2Forg.apache.syncope.common.report.UserReportletConf_-Feature%3E%0A++++++%3Corg.apache.syncope.common.report.UserReportletConf_-Feature%3EchangePwdDate%3C%2Forg.apache.syncope.common.report.UserReportletConf_-Feature%3E%0A++++++%3Corg.apache.syncope.common.report.UserReportletConf_-Feature%3EpasswordHistorySize%3C%2Forg.apache.syncope.common.report.UserReportletConf_-Feature%3E%0A++++++%3Corg.apache.syncope.common.report.UserReportletConf_-Feature%3EfailedLoginCount%3C%2Fo
 rg.apache.syncope.common.report.UserReportletConf_-Feature%3E%0A++++++%3Corg.apache.syncope.common.report.UserReportletConf_-Feature%3Ememberships%3C%2Forg.apache.syncope.common.report.UserReportletConf_-Feature%3E%0A++++++%3Corg.apache.syncope.common.report.UserReportletConf_-Feature%3Eresources%3C%2Forg.apache.syncope.common.report.UserReportletConf_-Feature%3E%0A++++%3C%2Fa%3E%0A++%3C%2Ffeatures%3E%0A%3C%2Forg.apache.syncope.common.report.UserReportletConf%3E"/>
   <ReportExec Report_id="1" id="1" status="SUCCESS" startDate="2012-02-26 15:40:04" endDate="2012-02-26 15:41:04"/>
   
   <SyncopeLogger logName="syncope.audit.authentication.getEntitlements.success" logLevel="DEBUG" logType="AUDIT"/>
-
 </dataset>

Modified: syncope/trunk/core/src/test/resources/noopworkflow/workflowContext.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/resources/noopworkflow/workflowContext.xml?rev=1442175&r1=1442174&r2=1442175&view=diff
==============================================================================
--- syncope/trunk/core/src/test/resources/noopworkflow/workflowContext.xml (original)
+++ syncope/trunk/core/src/test/resources/noopworkflow/workflowContext.xml Mon Feb  4 16:57:42 2013
@@ -16,7 +16,6 @@ software distributed under the License i
 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"
@@ -28,6 +27,7 @@ under the License.
   </bean>
     
   <bean id="uwfAdapter" class="${uwfAdapter}"/>
+  <bean id="rwfAdapter" class="${rwfAdapter}"/>
 
   <bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
     <property name="velocityProperties">
@@ -37,4 +37,4 @@ under the License.
       </value>
     </property>
   </bean>
-</beans>
\ No newline at end of file
+</beans>



Mime
View raw message