exo-jcr SVN: r5016 - in core/trunk: exo.core.component.organization.jdbc/src/test and 7 other directories.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2011-10-04 05:03:41 -0400 (Tue, 04 Oct 2011)
New Revision: 5016
Added:
core/trunk/exo.core.component.organization.jdbc/src/test/resources/conf/standalone/
core/trunk/exo.core.component.organization.jdbc/src/test/resources/conf/standalone/test-configuration-hibernate.xml
core/trunk/exo.core.component.organization.jdbc/src/test/resources/conf/standalone/test-configuration-jdbc.xml
Removed:
core/trunk/exo.core.component.organization.jdbc/src/test/java/
core/trunk/exo.core.component.organization.jdbc/src/test/resources/conf/portal/
core/trunk/exo.core.component.organization.ldap/src/test/java/org/exoplatform/services/organization/TestOrganizationServiceWithApacheDS.java
Modified:
core/trunk/exo.core.component.organization.jdbc/pom.xml
core/trunk/exo.core.component.organization.jdbc/src/test/resources/test.policy
core/trunk/exo.core.component.organization.ldap/pom.xml
core/trunk/exo.core.component.organization.ldap/src/test/java/org/exoplatform/services/organization/DummyLDAPServiceImpl.java
core/trunk/exo.core.component.organization.ldap/src/test/java/org/exoplatform/services/organization/DummyLdapContext.java
core/trunk/exo.core.component.organization.ldap/src/test/resources/test.policy
core/trunk/exo.core.component.organization.tests/src/main/java/org/exoplatform/services/tck/organization/AbstractOrganizationServiceTest.java
Log:
EXOJCR-953: Added tck tests to jdbc, hibernate and ldap organization services, tests are run by default.
As jdbc and hibernate org services are contained in a single module a user can launch 'hibernate' or 'jdbc' (active by default) maven profiles to run test for each service.
Some tests were excluded due to assertions failures, there is a need to investigate more.
Now TCK tests can use system property 'orgservice.configuration.test.file' to acquire test configuration file path.
Modified: core/trunk/exo.core.component.organization.jdbc/pom.xml
===================================================================
--- core/trunk/exo.core.component.organization.jdbc/pom.xml 2011-10-04 08:21:04 UTC (rev 5015)
+++ core/trunk/exo.core.component.organization.jdbc/pom.xml 2011-10-04 09:03:41 UTC (rev 5016)
@@ -79,6 +79,12 @@
<artifactId>exo.core.component.organization.api</artifactId>
</dependency>
<dependency>
+ <groupId>org.exoplatform.core</groupId>
+ <artifactId>exo.core.component.organization.tests</artifactId>
+ <classifier>sources</classifier>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
@@ -97,9 +103,91 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.exoplatform.core</groupId>
+ <artifactId>exo.core.component.organization.tests</artifactId>
+ <classifier>sources</classifier>
+ <type>jar</type>
+ <overWrite>false</overWrite>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.directory}/org-service-tck-tests</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.3</version>
+ <executions>
+ <execution>
+ <id>add-test-resource</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>add-test-resource</goal>
+ </goals>
+ <configuration>
+ <resources>
+ <resource>
+ <directory>${project.build.directory}/org-service-tck-tests</directory>
+ <excludes>
+ </excludes>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>add-test-source</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${project.build.directory}/org-service-tck-tests</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>${env.MAVEN_OPTS} -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy</argLine>
+ <systemProperties>
+ <!--
+ This property defines TCK tests configuration file location
+ -->
+ <property>
+ <name>orgservice.test.configuration.file</name>
+ <value>${orgservice.test.configuration.file}</value>
+ </property>
+ </systemProperties>
+ <includes>
+ <include>org/exoplatform/services/tck/organization/Test*.java</include>
+ </includes>
+ <excludes>
+ <!--
+ Temporary excluded, to investigate cause of failures and errors.
+ -->
+ <exclude>org/exoplatform/services/tck/organization/Test*.java</exclude>
+ <!--
+ Excluded as this class has no tests to be run
+ -->
+ <exclude>**/AbstractOrganizationServiceTest.java</exclude>
+ </excludes>
</configuration>
</plugin>
<plugin>
@@ -142,4 +230,21 @@
</plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+ <profiles>
+ <profile>
+ <id>hibernate</id>
+ <properties>
+ <orgservice.test.configuration.file>/conf/standalone/test-configuration-hibernate.xml</orgservice.test.configuration.file>
+ </properties>
+ </profile>
+ <profile>
+ <id>jdbc</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <properties>
+ <orgservice.test.configuration.file>/conf/standalone/test-configuration-jdbc.xml</orgservice.test.configuration.file>
+ </properties>
+ </profile>
+ </profiles>
+</project>
Added: core/trunk/exo.core.component.organization.jdbc/src/test/resources/conf/standalone/test-configuration-hibernate.xml
===================================================================
--- core/trunk/exo.core.component.organization.jdbc/src/test/resources/conf/standalone/test-configuration-hibernate.xml (rev 0)
+++ core/trunk/exo.core.component.organization.jdbc/src/test/resources/conf/standalone/test-configuration-hibernate.xml 2011-10-04 09:03:41 UTC (rev 5016)
@@ -0,0 +1,331 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<configuration
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
+
+ <component>
+ <key>org.exoplatform.services.log.LogConfigurationInitializer</key>
+ <type>org.exoplatform.services.log.LogConfigurationInitializer</type>
+ <init-params>
+ <value-param>
+ <name>logger</name>
+ <value>org.exoplatform.services.log.impl.BufferedLog4JLogger</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+ <value>org.exoplatform.services.log.impl.Log4JConfigurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>Log4J properties</description>
+ <property name="log4j.rootLogger" value="INFO, stdout, file"/>
+
+ <property name="log4j.appender.stdout" value="org.apache.log4j.ConsoleAppender"/>
+ <property name="log4j.appender.stdout.threshold" value="INFO"/>
+
+ <property name="log4j.appender.stdout.layout" value="org.apache.log4j.PatternLayout"/>
+ <property name="log4j.appender.stdout.layout.ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n"/>
+
+ <property name="log4j.appender.file" value="org.apache.log4j.FileAppender"/>
+ <property name="log4j.appender.file.File" value="target/jcr.log"/>
+
+ <property name="log4j.appender.file.layout" value="org.apache.log4j.PatternLayout"/>
+
+ </properties-param>
+ </init-params>
+ </component>
+
+ <component>
+ <key>org.exoplatform.services.database.HibernateService</key>
+ <jmx-name>database:type=HibernateService</jmx-name>
+ <type>org.exoplatform.services.database.impl.HibernateServiceImpl</type>
+ <init-params>
+ <properties-param>
+ <name>hibernate.properties</name>
+ <description>Default Hibernate Service</description>
+ <property name="hibernate.show_sql" value="false"/>
+ <property name="hibernate.cglib.use_reflection_optimizer" value="true"/>
+ <property name="hibernate.connection.url" value="jdbc:hsqldb:file:../temp/data/exodb"/>
+ <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
+ <property name="hibernate.connection.autocommit" value="true"/>
+ <property name="hibernate.connection.username" value="sa"/>
+ <property name="hibernate.connection.password" value=""/>
+ <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
+ <property name="hibernate.c3p0.min_size" value="5"/>
+ <property name="hibernate.c3p0.max_size" value="20"/>
+ <property name="hibernate.c3p0.timeout" value="1800"/>
+ <property name="hibernate.c3p0.max_statements" value="50"/>
+ </properties-param>
+ </init-params>
+ </component>
+
+ <component>
+ <key>org.exoplatform.services.organization.OrganizationService</key>
+ <type>org.exoplatform.services.organization.hibernate.OrganizationServiceImpl</type>
+ </component>
+
+ <external-component-plugins>
+ <target-component>org.exoplatform.services.database.HibernateService</target-component>
+ <component-plugin>
+ <name>add.hibernate.mapping</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.database.impl.AddHibernateMappingPlugin</type>
+ <init-params>
+ <values-param>
+ <name>hibernate.mapping</name>
+ <value>org/exoplatform/services/organization/impl/UserImpl.hbm.xml</value>
+ <value>org/exoplatform/services/organization/impl/MembershipImpl.hbm.xml</value>
+ <value>org/exoplatform/services/organization/impl/GroupImpl.hbm.xml</value>
+ <value>org/exoplatform/services/organization/impl/MembershipTypeImpl.hbm.xml</value>
+ <value>org/exoplatform/services/organization/impl/UserProfileData.hbm.xml</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+
+ <!-- org service initializer, copied from ECM portal.war -->
+ <external-component-plugins>
+ <target-component>org.exoplatform.services.organization.OrganizationService</target-component>
+ <component-plugin>
+ <name>init.service.listener</name>
+ <set-method>addListenerPlugin</set-method>
+ <type>org.exoplatform.services.organization.OrganizationDatabaseInitializer</type>
+ <description>this listener populate organization data for the first launch</description>
+ <init-params>
+ <value-param>
+ <name>checkDatabaseAlgorithm</name>
+ <description>check database</description>
+ <value>entry</value>
+ </value-param>
+ <value-param>
+ <name>printInformation</name>
+ <description>Print information init database</description>
+ <value>false</value>
+ </value-param>
+ <object-param>
+ <name>configuration</name>
+ <description>description</description>
+ <object type="org.exoplatform.services.organization.OrganizationConfig">
+ <field name="membershipType">
+ <collection type="java.util.ArrayList">
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$MembershipType">
+ <field name="type"><string>manager</string></field>
+ <field name="description"><string>manager membership type</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$MembershipType">
+ <field name="type"><string>member</string></field>
+ <field name="description"><string>member membership type</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$MembershipType">
+ <field name="type"><string>validator</string></field>
+ <field name="description"><string>validator membership type</string></field>
+ </object>
+ </value>
+ </collection>
+ </field>
+
+ <field name="group">
+ <collection type="java.util.ArrayList">
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>platform</string></field>
+ <field name="parentId"><string></string></field>
+ <field name="description"><string>the /platform group</string></field>
+ <field name="label"><string>Platform</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>administrators</string></field>
+ <field name="parentId"><string>/platform</string></field>
+ <field name="description"><string>the /platform/administrators group</string></field>
+ <field name="label"><string>Administrators</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>users</string></field>
+ <field name="parentId"><string>/platform</string></field>
+ <field name="description"><string>the /platform/users group</string></field>
+ <field name="label"><string>Users</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>guests</string></field>
+ <field name="parentId"><string>/platform</string></field>
+ <field name="description"><string>the /platform/guests group</string></field>
+ <field name="label"><string>Guests</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>organization</string></field>
+ <field name="parentId"><string></string></field>
+ <field name="description"><string>the organization group</string></field>
+ <field name="label"><string>Organization</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>management</string></field>
+ <field name="parentId"><string>/organization</string></field>
+ <field name="description"><string>the /organization/management group</string></field>
+ <field name="label"><string>Management</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>executive-board</string></field>
+ <field name="parentId"><string>/organization/management</string></field>
+ <field name="description"><string>the /organization/management/executive-board group</string></field>
+ <field name="label"><string>Executive Board</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>human-resources</string></field>
+ <field name="parentId"><string>/organization/management</string></field>
+ <field name="description"><string>the /organization/management/human-resource group</string></field>
+ <field name="label"><string>Human Resources</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>communication</string></field>
+ <field name="parentId"><string>/organization</string></field>
+ <field name="description"><string>the /organization/communication group</string></field>
+ <field name="label"><string>Communication</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>marketing</string></field>
+ <field name="parentId"><string>/organization/communication</string></field>
+ <field name="description"><string>the /organization/communication/marketing group</string></field>
+ <field name="label"><string>Marketing</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>press-and-media</string></field>
+ <field name="parentId"><string>/organization/communication</string></field>
+ <field name="description"><string>the /organization/communication/press-and-media group</string></field>
+ <field name="label"><string>Press and Media</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>operations</string></field>
+ <field name="parentId"><string>/organization</string></field>
+ <field name="description"><string>the /organization/operations and media group</string></field>
+ <field name="label"><string>Operations</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>sales</string></field>
+ <field name="parentId"><string>/organization/operations</string></field>
+ <field name="description"><string>the /organization/operations/sales group</string></field>
+ <field name="label"><string>Sales</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>finances</string></field>
+ <field name="parentId"><string>/organization/operations</string></field>
+ <field name="description"><string>the /organization/operations/finances group</string></field>
+ <field name="label"><string>Finances</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>customers</string></field>
+ <field name="parentId"><string></string></field>
+ <field name="description"><string>the /customers group</string></field>
+ <field name="label"><string>Customers</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>partners</string></field>
+ <field name="parentId"><string></string></field>
+ <field name="description"><string>the /partners group</string></field>
+ <field name="label"><string>Partners</string></field>
+ </object>
+ </value>
+ </collection>
+ </field>
+
+ <field name="user">
+ <collection type="java.util.ArrayList">
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$User">
+ <field name="userName"><string>root</string></field>
+ <field name="password"><string>exo</string></field>
+ <field name="firstName"><string>Root</string></field>
+ <field name="lastName"><string>Root</string></field>
+ <field name="email"><string>root@localhost</string></field>
+ <field name="groups">
+ <string>
+ manager:/platform/administrators,member:/platform/users,
+ member:/organization/management/executive-board
+ </string>
+ </field>
+ </object>
+ </value>
+
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$User">
+ <field name="userName"><string>john</string></field>
+ <field name="password"><string>exo</string></field>
+ <field name="firstName"><string>John</string></field>
+ <field name="lastName"><string>Anthony</string></field>
+ <field name="email"><string>john@localhost</string></field>
+ <field name="groups">
+ <string>
+ member:/platform/administrators,member:/platform/users,
+ manager:/organization/management/executive-board
+ </string>
+ </field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$User">
+ <field name="userName"><string>marry</string></field>
+ <field name="password"><string>exo</string></field>
+ <field name="firstName"><string>Marry</string></field>
+ <field name="lastName"><string>Kelly</string></field>
+ <field name="email"><string>marry@localhost</string></field>
+ <field name="groups">
+ <string>member:/platform/users</string>
+ </field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$User">
+ <field name="userName"><string>demo</string></field>
+ <field name="password"><string>exo</string></field>
+ <field name="firstName"><string>Demo</string></field>
+ <field name="lastName"><string>exo</string></field>
+ <field name="email"><string>demo@localhost</string></field>
+ <field name="groups">
+ <string>member:/platform/guests,member:/platform/users</string>
+ </field>
+ </object>
+ </value>
+ </collection>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+
+</configuration>
Added: core/trunk/exo.core.component.organization.jdbc/src/test/resources/conf/standalone/test-configuration-jdbc.xml
===================================================================
--- core/trunk/exo.core.component.organization.jdbc/src/test/resources/conf/standalone/test-configuration-jdbc.xml (rev 0)
+++ core/trunk/exo.core.component.organization.jdbc/src/test/resources/conf/standalone/test-configuration-jdbc.xml 2011-10-04 09:03:41 UTC (rev 5016)
@@ -0,0 +1,381 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplatform.org/xml/ns/kernel_1_2.xsd http://www.exoplatform.org/xml/ns/kernel_1_2.xsd"
+ xmlns="http://www.exoplatform.org/xml/ns/kernel_1_2.xsd">
+
+ <component>
+ <key>org.exoplatform.services.log.LogConfigurationInitializer</key>
+ <type>org.exoplatform.services.log.LogConfigurationInitializer</type>
+ <init-params>
+ <value-param>
+ <name>logger</name>
+ <value>org.exoplatform.services.log.impl.BufferedLog4JLogger</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+ <value>org.exoplatform.services.log.impl.Log4JConfigurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>Log4J properties</description>
+ <property name="log4j.rootLogger" value="INFO, stdout, file"/>
+
+ <property name="log4j.appender.stdout" value="org.apache.log4j.ConsoleAppender"/>
+ <property name="log4j.appender.stdout.threshold" value="INFO"/>
+
+ <property name="log4j.appender.stdout.layout" value="org.apache.log4j.PatternLayout"/>
+ <property name="log4j.appender.stdout.layout.ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n"/>
+
+ <property name="log4j.appender.file" value="org.apache.log4j.FileAppender"/>
+ <property name="log4j.appender.file.File" value="target/jcr.log"/>
+
+ <property name="log4j.appender.file.layout" value="org.apache.log4j.PatternLayout"/>
+
+ </properties-param>
+ </init-params>
+ </component>
+
+ <component>
+ <key>org.exoplatform.services.database.impl.ExoCacheProvider</key>
+ <type>org.exoplatform.services.database.impl.ExoCacheProvider</type>
+ </component>
+ <component>
+ <key>org.exoplatform.services.database.jdbc.DBSchemaCreator</key>
+ <type>org.exoplatform.services.database.jdbc.DBSchemaCreator</type>
+ </component>
+ <component>
+ <key>org.exoplatform.services.organization.OrganizationService</key>
+ <type>org.exoplatform.services.organization.jdbc.OrganizationServiceImpl</type>
+ </component>
+
+ <component>
+ <key>org.exoplatform.services.database.DatabaseService</key>
+ <type>org.exoplatform.services.database.impl.XAPoolTxSupportDatabaseService</type>
+ <description>support the transaction db connection pool implementation</description>
+ <init-params>
+ <properties-param>
+ <name>connection.config</name>
+ <description>Connection configuration</description>
+ <property name='connection.driver' value='org.hsqldb.jdbcDriver' />
+ <property name='connection.url' value='jdbc:hsqldb:file:target/temp' />
+ <property name='connection.login' value='sa' />
+ <property name='connection.password' value='' />
+ <property name='connection.min-size' value='3' />
+ <property name='connection.max-size' value='25' />
+ </properties-param>
+ </init-params>
+ </component>
+
+ <component>
+ <key>org.exoplatform.services.transaction.TransactionService</key>
+ <type>org.exoplatform.services.transaction.impl.jotm.TransactionServiceJotmImpl</type>
+ <init-params>
+ <value-param>
+ <name>timeout</name>
+ <value>-1</value>
+ </value-param>
+ </init-params>
+ </component>
+
+ <external-component-plugins>
+ <target-component>org.exoplatform.services.listener.ListenerService</target-component>
+ <component-plugin>
+ <name>organization.user.preDelete</name>
+ <set-method>addListener</set-method>
+ <type>org.exoplatform.services.organization.jdbc.listeners.RemoveUserProfileListener</type>
+ </component-plugin>
+ <component-plugin>
+ <name>organization.user.postCreate</name>
+ <set-method>addListener</set-method>
+ <type>org.exoplatform.services.organization.jdbc.listeners.CreateUserListener</type>
+ </component-plugin>
+ <component-plugin>
+ <name>organization.user.preDelete</name>
+ <set-method>addListener</set-method>
+ <type>org.exoplatform.services.organization.jdbc.listeners.RemoveMembershipListener</type>
+ </component-plugin>
+ <component-plugin>
+ <name>organization.membershipType.preDelete</name>
+ <set-method>addListener</set-method>
+ <type>org.exoplatform.services.organization.jdbc.listeners.RemoveMembershipListener</type>
+ </component-plugin>
+ <component-plugin>
+ <name>organization.group.preDelete</name>
+ <set-method>addListener</set-method>
+ <type>org.exoplatform.services.organization.jdbc.listeners.RemoveMembershipListener</type>
+ </component-plugin>
+ <component-plugin>
+ <name>organization.group.preDelete</name>
+ <set-method>addListener</set-method>
+ <type>org.exoplatform.services.organization.jdbc.listeners.RemoveGroupListener</type>
+ </component-plugin>
+ </external-component-plugins>
+
+
+ <!-- org service initializer, copied from ECM portal.war -->
+ <external-component-plugins>
+ <target-component>org.exoplatform.services.organization.OrganizationService</target-component>
+ <component-plugin>
+ <name>init.service.listener</name>
+ <set-method>addListenerPlugin</set-method>
+ <type>org.exoplatform.services.organization.OrganizationDatabaseInitializer</type>
+ <description>this listener populate organization data for the first launch</description>
+ <init-params>
+ <value-param>
+ <name>checkDatabaseAlgorithm</name>
+ <description>check database</description>
+ <value>entry</value>
+ </value-param>
+ <value-param>
+ <name>printInformation</name>
+ <description>Print information init database</description>
+ <value>false</value>
+ </value-param>
+ <object-param>
+ <name>configuration</name>
+ <description>description</description>
+ <object type="org.exoplatform.services.organization.OrganizationConfig">
+ <field name="membershipType">
+ <collection type="java.util.ArrayList">
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$MembershipType">
+ <field name="type"><string>manager</string></field>
+ <field name="description"><string>manager membership type</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$MembershipType">
+ <field name="type"><string>member</string></field>
+ <field name="description"><string>member membership type</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$MembershipType">
+ <field name="type"><string>validator</string></field>
+ <field name="description"><string>validator membership type</string></field>
+ </object>
+ </value>
+ </collection>
+ </field>
+
+ <field name="group">
+ <collection type="java.util.ArrayList">
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>platform</string></field>
+ <field name="parentId"><string></string></field>
+ <field name="description"><string>the /platform group</string></field>
+ <field name="label"><string>Platform</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>administrators</string></field>
+ <field name="parentId"><string>/platform</string></field>
+ <field name="description"><string>the /platform/administrators group</string></field>
+ <field name="label"><string>Administrators</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>users</string></field>
+ <field name="parentId"><string>/platform</string></field>
+ <field name="description"><string>the /platform/users group</string></field>
+ <field name="label"><string>Users</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>guests</string></field>
+ <field name="parentId"><string>/platform</string></field>
+ <field name="description"><string>the /platform/guests group</string></field>
+ <field name="label"><string>Guests</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>organization</string></field>
+ <field name="parentId"><string></string></field>
+ <field name="description"><string>the organization group</string></field>
+ <field name="label"><string>Organization</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>management</string></field>
+ <field name="parentId"><string>/organization</string></field>
+ <field name="description"><string>the /organization/management group</string></field>
+ <field name="label"><string>Management</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>executive-board</string></field>
+ <field name="parentId"><string>/organization/management</string></field>
+ <field name="description"><string>the /organization/management/executive-board group</string></field>
+ <field name="label"><string>Executive Board</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>human-resources</string></field>
+ <field name="parentId"><string>/organization/management</string></field>
+ <field name="description"><string>the /organization/management/human-resource group</string></field>
+ <field name="label"><string>Human Resources</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>communication</string></field>
+ <field name="parentId"><string>/organization</string></field>
+ <field name="description"><string>the /organization/communication group</string></field>
+ <field name="label"><string>Communication</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>marketing</string></field>
+ <field name="parentId"><string>/organization/communication</string></field>
+ <field name="description"><string>the /organization/communication/marketing group</string></field>
+ <field name="label"><string>Marketing</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>press-and-media</string></field>
+ <field name="parentId"><string>/organization/communication</string></field>
+ <field name="description"><string>the /organization/communication/press-and-media group</string></field>
+ <field name="label"><string>Press and Media</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>operations</string></field>
+ <field name="parentId"><string>/organization</string></field>
+ <field name="description"><string>the /organization/operations and media group</string></field>
+ <field name="label"><string>Operations</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>sales</string></field>
+ <field name="parentId"><string>/organization/operations</string></field>
+ <field name="description"><string>the /organization/operations/sales group</string></field>
+ <field name="label"><string>Sales</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>finances</string></field>
+ <field name="parentId"><string>/organization/operations</string></field>
+ <field name="description"><string>the /organization/operations/finances group</string></field>
+ <field name="label"><string>Finances</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>customers</string></field>
+ <field name="parentId"><string></string></field>
+ <field name="description"><string>the /customers group</string></field>
+ <field name="label"><string>Customers</string></field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$Group">
+ <field name="name"><string>partners</string></field>
+ <field name="parentId"><string></string></field>
+ <field name="description"><string>the /partners group</string></field>
+ <field name="label"><string>Partners</string></field>
+ </object>
+ </value>
+ </collection>
+ </field>
+
+ <field name="user">
+ <collection type="java.util.ArrayList">
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$User">
+ <field name="userName"><string>root</string></field>
+ <field name="password"><string>exo</string></field>
+ <field name="firstName"><string>Root</string></field>
+ <field name="lastName"><string>Root</string></field>
+ <field name="email"><string>root@localhost</string></field>
+ <field name="groups">
+ <string>
+ manager:/platform/administrators,member:/platform/users,
+ member:/organization/management/executive-board
+ </string>
+ </field>
+ </object>
+ </value>
+
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$User">
+ <field name="userName"><string>john</string></field>
+ <field name="password"><string>exo</string></field>
+ <field name="firstName"><string>John</string></field>
+ <field name="lastName"><string>Anthony</string></field>
+ <field name="email"><string>john@localhost</string></field>
+ <field name="groups">
+ <string>
+ member:/platform/administrators,member:/platform/users,
+ manager:/organization/management/executive-board
+ </string>
+ </field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$User">
+ <field name="userName"><string>marry</string></field>
+ <field name="password"><string>exo</string></field>
+ <field name="firstName"><string>Marry</string></field>
+ <field name="lastName"><string>Kelly</string></field>
+ <field name="email"><string>marry@localhost</string></field>
+ <field name="groups">
+ <string>member:/platform/users</string>
+ </field>
+ </object>
+ </value>
+ <value>
+ <object type="org.exoplatform.services.organization.OrganizationConfig$User">
+ <field name="userName"><string>demo</string></field>
+ <field name="password"><string>exo</string></field>
+ <field name="firstName"><string>Demo</string></field>
+ <field name="lastName"><string>exo</string></field>
+ <field name="email"><string>demo@localhost</string></field>
+ <field name="groups">
+ <string>member:/platform/guests,member:/platform/users</string>
+ </field>
+ </object>
+ </value>
+ </collection>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+
+</configuration>
+
+
+
Modified: core/trunk/exo.core.component.organization.jdbc/src/test/resources/test.policy
===================================================================
--- core/trunk/exo.core.component.organization.jdbc/src/test/resources/test.policy 2011-10-04 08:21:04 UTC (rev 5015)
+++ core/trunk/exo.core.component.organization.jdbc/src/test/resources/test.policy 2011-10-04 09:03:41 UTC (rev 5016)
@@ -7,6 +7,7 @@
};
grant codeBase "@TEST_CLASSES@-"{
+ permission java.security.AllPermission;
};
grant codeBase "@MAIN_CLASSES@../../../exo.core.component.database/-"{
Modified: core/trunk/exo.core.component.organization.ldap/pom.xml
===================================================================
--- core/trunk/exo.core.component.organization.ldap/pom.xml 2011-10-04 08:21:04 UTC (rev 5015)
+++ core/trunk/exo.core.component.organization.ldap/pom.xml 2011-10-04 09:03:41 UTC (rev 5016)
@@ -68,6 +68,12 @@
<artifactId>exo.core.component.organization.jdbc</artifactId>
</dependency>
<dependency>
+ <groupId>org.exoplatform.core</groupId>
+ <artifactId>exo.core.component.organization.tests</artifactId>
+ <classifier>sources</classifier>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-server-unit</artifactId>
</dependency>
@@ -85,12 +91,95 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.exoplatform.core</groupId>
+ <artifactId>exo.core.component.organization.tests</artifactId>
+ <classifier>sources</classifier>
+ <type>jar</type>
+ <overWrite>false</overWrite>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.directory}/org-service-tck-tests</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.3</version>
+ <executions>
+ <execution>
+ <id>add-test-resource</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>add-test-resource</goal>
+ </goals>
+ <configuration>
+ <resources>
+ <resource>
+ <directory>${project.build.directory}/org-service-tck-tests</directory>
+ <excludes>
+ </excludes>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>add-test-source</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${project.build.directory}/org-service-tck-tests</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>${env.MAVEN_OPTS} -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy</argLine>
- <excludes>
- <exclude>**/TestOrganizationService.java</exclude>
- </excludes>
+ <systemProperties>
+ <!--
+ This property defines TCK tests configuration file location
+ -->
+ <property>
+ <name>orgservice.test.configuration.file</name>
+ <value>/conf/standalone/test-configuration.xml</value>
+ </property>
+ </systemProperties>
+ <includes>
+ <include>org/exoplatform/services/tck/organization/Test*.java</include>
+ </includes>
+ <excludes>
+ <!--
+ Temporary excluded, to investigate cause of failures and errors.
+ -->
+ <exclude>org/exoplatform/services/tck/organization/Test*.java</exclude>
+ <!--
+ Excluded as this class has no tests to be run
+ -->
+ <exclude>**/AbstractOrganizationServiceTest.java</exclude>
+ <!--
+ Not a unit test.
+ -->
+ <exclude>**/TestOrganizationService.java</exclude>
+ </excludes>
</configuration>
</plugin>
<plugin>
Modified: core/trunk/exo.core.component.organization.ldap/src/test/java/org/exoplatform/services/organization/DummyLDAPServiceImpl.java
===================================================================
--- core/trunk/exo.core.component.organization.ldap/src/test/java/org/exoplatform/services/organization/DummyLDAPServiceImpl.java 2011-10-04 08:21:04 UTC (rev 5015)
+++ core/trunk/exo.core.component.organization.ldap/src/test/java/org/exoplatform/services/organization/DummyLDAPServiceImpl.java 2011-10-04 09:03:41 UTC (rev 5016)
@@ -19,17 +19,31 @@
package org.exoplatform.services.organization;
+import org.apache.commons.io.FileUtils;
+import org.apache.directory.server.configuration.MutableServerStartupConfiguration;
+import org.apache.directory.server.core.configuration.MutablePartitionConfiguration;
+import org.apache.directory.server.jndi.ServerContextFactory;
+import org.apache.mina.util.AvailablePortFinder;
import org.exoplatform.services.ldap.LDAPService;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import java.io.File;
+import java.io.IOException;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Hashtable;
import java.util.Map;
+import java.util.Set;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.ldap.InitialLdapContext;
import javax.naming.ldap.LdapContext;
/**
@@ -41,10 +55,56 @@
private Map<String, String> env = new HashMap<String, String>();
- private int serverType = DEFAULT_SERVER;
+ protected MutableServerStartupConfiguration configuration = new MutableServerStartupConfiguration();
- public DummyLDAPServiceImpl()
+ protected int port = -1;
+
+ protected boolean doDelete = true;
+
+ protected LdapContext sysRoot;
+
+ protected LdapContext rootDSE;
+
+ public DummyLDAPServiceImpl() throws Exception
{
+ // configuration and launch of embedded ldap server
+ MutablePartitionConfiguration pcfg = new MutablePartitionConfiguration();
+
+ pcfg.setName("eXoTestPartition");
+ pcfg.setSuffix("dc=exoplatform,dc=org");
+
+ Set<String> indexedAttrs = new HashSet<String>();
+ indexedAttrs.add("objectClass");
+ indexedAttrs.add("o");
+ pcfg.setIndexedAttributes(indexedAttrs);
+
+ Attributes attrs = new BasicAttributes(true);
+ Attribute attr = new BasicAttribute("objectClass");
+ attr.add("top");
+ attr.add("organization");
+ attrs.put(attr);
+ attr = new BasicAttribute("o");
+ attr.add("eXoTestPartition");
+ attrs.put(attr);
+ pcfg.setContextEntry(attrs);
+
+ Set<MutablePartitionConfiguration> pcfgs = new HashSet<MutablePartitionConfiguration>();
+ pcfgs.add(pcfg);
+ configuration.setContextPartitionConfigurations(pcfgs);
+ File workingDirectory = new File("target/working-server");
+ workingDirectory.mkdirs();
+ configuration.setWorkingDirectory(workingDirectory);
+
+ doDelete(configuration.getWorkingDirectory());
+
+ port = AvailablePortFinder.getNextAvailable(1024);
+ configuration.setLdapPort(port);
+ configuration.setShutdownHookEnabled(false);
+
+ setContexts("uid=admin,ou=system", "secret");
+ // server launched and configured
+
+ // configuration of client side
env.put(Context.PROVIDER_URL, "dc=exoplatform,dc=org");
env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
env.put(Context.SECURITY_CREDENTIALS, "secret");
@@ -146,4 +206,39 @@
}
}
+ protected void doDelete(File wkdir) throws IOException
+ {
+ if (doDelete)
+ {
+ if (wkdir.exists())
+ {
+ FileUtils.deleteDirectory(wkdir);
+ }
+ if (wkdir.exists())
+ {
+ throw new IOException("Failed to delete: " + wkdir);
+ }
+ }
+ }
+
+ protected void setContexts(String user, String passwd) throws NamingException
+ {
+ Hashtable env = new Hashtable(configuration.toJndiEnvironment());
+ env.put(Context.SECURITY_PRINCIPAL, user);
+ env.put(Context.SECURITY_CREDENTIALS, passwd);
+ env.put(Context.SECURITY_AUTHENTICATION, "simple");
+ env.put(Context.INITIAL_CONTEXT_FACTORY, ServerContextFactory.class.getName());
+ setContexts(env);
+ }
+
+ protected void setContexts(Hashtable env) throws NamingException
+ {
+ Hashtable envFinal = new Hashtable(env);
+ envFinal.put(Context.PROVIDER_URL, "ou=system");
+ sysRoot = new InitialLdapContext(envFinal, null);
+
+ envFinal.put(Context.PROVIDER_URL, "");
+ rootDSE = new InitialLdapContext(envFinal, null);
+ }
+
}
Modified: core/trunk/exo.core.component.organization.ldap/src/test/java/org/exoplatform/services/organization/DummyLdapContext.java
===================================================================
--- core/trunk/exo.core.component.organization.ldap/src/test/java/org/exoplatform/services/organization/DummyLdapContext.java 2011-10-04 08:21:04 UTC (rev 5015)
+++ core/trunk/exo.core.component.organization.ldap/src/test/java/org/exoplatform/services/organization/DummyLdapContext.java 2011-10-04 09:03:41 UTC (rev 5016)
@@ -447,6 +447,12 @@
return null;
}
+ /**
+ * Utility method cut off the "dc=exoplatform, dc=org" string
+ * to avoid it to be used twice
+ * @param name
+ * @return
+ */
private String removeExoplatformOrg(String name)
{
int i = name.toLowerCase().indexOf("dc=exoplatform,dc=org");
@@ -457,6 +463,12 @@
return name;
}
+ /**
+ * Utility method cut off the "ou=groups,ou=portal" string
+ * to avoid it to be used twice
+ * @param name
+ * @return
+ */
private String removeGroupProtal(String name)
{
name = removeExoplatformOrg(name);
Deleted: core/trunk/exo.core.component.organization.ldap/src/test/java/org/exoplatform/services/organization/TestOrganizationServiceWithApacheDS.java
===================================================================
--- core/trunk/exo.core.component.organization.ldap/src/test/java/org/exoplatform/services/organization/TestOrganizationServiceWithApacheDS.java 2011-10-04 08:21:04 UTC (rev 5015)
+++ core/trunk/exo.core.component.organization.ldap/src/test/java/org/exoplatform/services/organization/TestOrganizationServiceWithApacheDS.java 2011-10-04 09:03:41 UTC (rev 5016)
@@ -1,482 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.organization;
-
-import org.apache.directory.server.core.configuration.MutablePartitionConfiguration;
-import org.apache.directory.server.unit.AbstractServerTest;
-import org.exoplatform.commons.utils.PageList;
-import org.exoplatform.container.StandaloneContainer;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
-
-/**
- * Created by The eXo Platform SAS Author : Hoa Pham
- * hoapham@exoplatform.com,phamvuxuanhoa(a)yahoo.com Oct 27, 2005
- */
-
-@SuppressWarnings("unchecked")
-public class TestOrganizationServiceWithApacheDS extends AbstractServerTest
-{
-
- static String GroupParent = "GroupParent";
-
- static String Group1 = "Group1";
-
- static String Group2 = "Group2";
-
- static String Benj = "Benj";
-
- static String Tuan = "Tuan";
-
- static String TestMembershipType1 = "TestMembership1";
-
- static String TestMembershipType2 = "TestMembership2";
-
- static String TestMembershipType3 = "TestMembership3";
-
- OrganizationService service_;
-
- UserHandler userHandler_;
-
- UserProfileHandler profileHandler_;
-
- GroupHandler groupHandler_;
-
- MembershipTypeHandler mtHandler_;
-
- MembershipHandler membershipHandler_;
-
- boolean runtest = true;
-
- public void setUp() throws Exception
- {
- if (!runtest)
- {
- return;
- }
-
- MutablePartitionConfiguration pcfg = new MutablePartitionConfiguration();
-
- pcfg.setName("eXoTestPartition");
- pcfg.setSuffix("dc=exoplatform,dc=org");
-
- Set<String> indexedAttrs = new HashSet<String>();
- indexedAttrs.add("objectClass");
- indexedAttrs.add("o");
- pcfg.setIndexedAttributes(indexedAttrs);
-
- Attributes attrs = new BasicAttributes(true);
- Attribute attr = new BasicAttribute("objectClass");
- attr.add("top");
- attr.add("organization");
- attrs.put(attr);
- attr = new BasicAttribute("o");
- attr.add("eXoTestPartition");
- attrs.put(attr);
- pcfg.setContextEntry(attrs);
- Set<MutablePartitionConfiguration> pcfgs = new HashSet<MutablePartitionConfiguration>();
- pcfgs.add(pcfg);
- configuration.setContextPartitionConfigurations(pcfgs);
- File workingDirectory = new File("server-work");
- configuration.setWorkingDirectory(workingDirectory);
- super.setUp();
-
- String containerConf =
- TestOrganizationServiceWithApacheDS.class.getResource("/conf/standalone/test-configuration.xml").toString();
- StandaloneContainer.addConfigurationURL(containerConf);
- StandaloneContainer container = StandaloneContainer.getInstance();
-
- service_ = (OrganizationService)container.getComponentInstanceOfType(OrganizationService.class);
- userHandler_ = service_.getUserHandler();
- profileHandler_ = service_.getUserProfileHandler();
- groupHandler_ = service_.getGroupHandler();
- mtHandler_ = service_.getMembershipTypeHandler();
- membershipHandler_ = service_.getMembershipHandler();
- }
-
- public void tearDown() throws Exception
- {
- if (!runtest)
- {
- return;
- }
- mtHandler_.removeMembershipType(TestMembershipType1, true);
- mtHandler_.removeMembershipType(TestMembershipType2, true);
- mtHandler_.removeMembershipType(TestMembershipType3, true);
-
- Group gr = groupHandler_.findGroupById("/" + Group1);
- if (gr != null)
- {
- groupHandler_.removeGroup(gr, true);
- }
-
- gr = groupHandler_.findGroupById("/" + Group2);
- if (gr != null)
- {
- groupHandler_.removeGroup(gr, true);
- }
-
- gr = groupHandler_.findGroupById("/" + GroupParent);
- if (gr != null)
- {
- groupHandler_.removeGroup(gr, true);
- }
-
- userHandler_.removeUser(Benj, true);
- userHandler_.removeUser(Tuan, true);
- }
-
- protected String getDescription()
- {
- if (!runtest)
- {
- return "";
- }
-
- return "Test hibernate organization service.";
- }
-
- public void testUserPageSize() throws Exception
- {
- if (!runtest)
- {
- return;
- }
-
- /* Create an user with UserName: test */
- String USER = "test";
- int s = 15;
-
- for (int i = 0; i < s; i++)
- {
- createUser(USER + "_" + String.valueOf(i));
- }
-
- Query query = new Query();
- PageList users = userHandler_.findUsers(query);
- System.out.println("size: " + users.getAvailablePage());
-
- System.out.println("\npage 1:");
- List list = users.getPage(1);
- System.out.println("size : " + list.size());
- for (Object ele : list)
- {
- User u = (User)ele;
- System.out.println(u.getUserName() + " and " + u.getEmail());
- }
- System.out.println("\n\n");
- //
- try
- {
- for (int i = 0; i < s; i++)
- userHandler_.removeUser(USER + "_" + String.valueOf(i), true);
- }
- catch (Exception exp)
- {
- exp.printStackTrace();
- }
- }
-
- public void testUser() throws Exception
- {
- /* Create an user with UserName: test */
- String USER = "test";
- User user = createUser(USER);
-
- // authentication
- user.setPassword("test");
- userHandler_.saveUser(user, true);
- assertTrue("Authentication failed ", userHandler_.authenticate(USER, "test"));
-
- User u = userHandler_.findUserByName(USER);
- assertTrue("Found user instance", u != null);
- assertEquals("Expect user name is: ", USER, u.getUserName());
-
- UserProfile up = profileHandler_.createUserProfileInstance(USER);
- profileHandler_.saveUserProfile(up, true);
-
- up = profileHandler_.findUserProfileByName(USER);
- assertTrue("Expect user profile is found: ", profileHandler_.findUserProfileByName(USER) != null);
-
- // Update user's information
- u.setFirstName("Exo(Update)");
- userHandler_.saveUser(u, false);
- up.getUserInfoMap().put("user.gender", "male");
- profileHandler_.saveUserProfile(up, true);
- up = profileHandler_.findUserProfileByName(USER);
- assertEquals("expect first name is", "Exo(Update)", u.getFirstName());
- assertEquals("Expect profile is updated: user.gender is ", "male", up.getUserInfoMap().get("user.gender"));
-
- // Remove a user: Expect result: user and it's profile will be removed
- // NOTE >>>> FIX without listeners remove profile manually
- userHandler_.removeUser(USER, true);
- profileHandler_.removeUserProfile(USER, true);
- assertEquals(null, userHandler_.findUserByName(USER));
- assertTrue(profileHandler_.findUserProfileByName(USER) == null);
- }
-
- public void testGroup() throws Exception
- {
- if (!runtest)
- {
- return;
- }
-
- Group groupParent = groupHandler_.createGroupInstance();
- groupParent.setGroupName(GroupParent);
- groupParent.setDescription("This is description");
- groupHandler_.addChild(null, groupParent, true);
- assertTrue(((Group)groupParent).getId() != null);
-
- groupParent = groupHandler_.findGroupById(groupParent.getId());
- assertEquals(groupParent.getGroupName(), "GroupParent");
-
- /* Create a child group with name: Group1 */
- Group groupChild = groupHandler_.createGroupInstance();
- groupChild.setGroupName(Group1);
- groupHandler_.addChild(groupParent, groupChild, true);
- groupChild = groupHandler_.findGroupById(groupChild.getId());
- assertEquals(groupChild.getParentId(), groupParent.getId());
- assertEquals("Expect group child's name is: ", Group1, groupChild.getGroupName());
-
- /* Update groupChild's information */
- groupChild.setLabel("GroupRenamed");
- groupChild.setDescription("new description ");
- groupHandler_.saveGroup(groupChild, true);
- assertEquals(groupHandler_.findGroupById(groupChild.getId()).getLabel(), "GroupRenamed");
-
- /* Create a group child with name is: Group2 */
- groupChild = groupHandler_.createGroupInstance();
- groupChild.setGroupName(Group2);
- groupHandler_.addChild(groupParent, groupChild, true);
- groupChild = groupHandler_.findGroupById(groupChild.getId());
- assertEquals(groupChild.getParentId(), groupParent.getId());
- assertEquals("Expect group child's name is: ", Group2, groupChild.getGroupName());
-
- Collection groups = groupHandler_.findGroups(groupParent);
- assertEquals("Expect number of child group in parent group is: ", 2, groups.size());
- Object arraygroups[] = groups.toArray();
- assertEquals("Expect child group's name is: ", Group1, ((Group)arraygroups[0]).getGroupName());
- assertEquals("Expect child group's name is: ", Group2, ((Group)arraygroups[1]).getGroupName());
-
- groupHandler_.removeGroup(groupHandler_.findGroupById("/" + GroupParent + "/" + Group1), true);
- assertEquals("Expect child group has been removed: ", null, groupHandler_.findGroupById("/" + Group1));
- assertEquals("Expect only 1 child group in parent group", 1, groupHandler_.findGroups(groupParent).size());
-
- groupHandler_.removeGroup(groupParent, true);
- assertEquals("Expect ParentGroup is removed:", null, groupHandler_.findGroupById(groupParent.getId()));
- assertEquals("Expect all child group is removed: ", 0, groupHandler_.findGroups(groupParent).size());
- }
-
- public void testMembershipType() throws Exception
- {
- if (!runtest)
- {
- return;
- }
-
- int bmn = mtHandler_.findMembershipTypes().size();
-
- MembershipType mt = mtHandler_.createMembershipTypeInstance();
- mt.setName(TestMembershipType1);
- mt.setDescription("This is a test");
- mt.setOwner("exo");
- mtHandler_.createMembershipType(mt, true);
- assertEquals("Expect mebershiptype is:", TestMembershipType1, mtHandler_.findMembershipType(TestMembershipType1)
- .getName());
-
- String desc = "This is a test (update)";
- mt.setDescription(desc);
- mtHandler_.saveMembershipType(mt, true);
- assertEquals("Expect membershiptype's description", desc, mtHandler_.findMembershipType(TestMembershipType1)
- .getDescription());
-
- mt = mtHandler_.createMembershipTypeInstance();
- mt.setName(TestMembershipType2);
- mt.setOwner("exo");
- mtHandler_.createMembershipType(mt, true);
-
- Collection ms = mtHandler_.findMembershipTypes();
- assertEquals("Expect " + (bmn + 2) + " membership in collection: ", bmn + 2, ms.size());
-
- mtHandler_.removeMembershipType(TestMembershipType1, true);
- assertEquals("Membership type has been removed:", null, mtHandler_.findMembershipType(TestMembershipType1));
- assertEquals("Expect " + (bmn + 1) + " membership in collection(1 is default): ", bmn + 1, mtHandler_
- .findMembershipTypes().size());
-
- mtHandler_.removeMembershipType(TestMembershipType2, true);
- assertEquals("Membership type has been removed:", null, mtHandler_.findMembershipType(TestMembershipType2));
- assertEquals("Expect " + bmn + " membership in collection(default type): ", bmn, mtHandler_
- .findMembershipTypes().size());
-
- }
-
- public void testMembership() throws Exception
- {
- if (!runtest)
- {
- return;
- }
-
- User user = createUser(Benj);
- User user2 = createUser(Tuan);
-
- Group group1 = groupHandler_.createGroupInstance();
- group1.setGroupName(Group1);
- groupHandler_.addChild(null, group1, true);
-
- Group group2 = groupHandler_.createGroupInstance();
- group2.setGroupName(Group2);
- groupHandler_.addChild(null, group2, true);
-
- MembershipType mt1 = mtHandler_.createMembershipTypeInstance();
- mt1.setName(TestMembershipType1);
- mtHandler_.createMembershipType(mt1, true);
-
- membershipHandler_.linkMembership(user, groupHandler_.findGroupById("/" + Group1), mt1, true);
- membershipHandler_.linkMembership(user, groupHandler_.findGroupById("/" + Group2), mt1, true);
- membershipHandler_.linkMembership(user2, groupHandler_.findGroupById("/" + Group2), mt1, true);
-
- MembershipType mt2 = mtHandler_.createMembershipTypeInstance();
- mt2.setName(TestMembershipType2);
- mtHandler_.createMembershipType(mt2, true);
- membershipHandler_.linkMembership(user, groupHandler_.findGroupById("/" + Group2), mt2, true);
-
- MembershipType mt3 = mtHandler_.createMembershipTypeInstance();
- mt3.setName(TestMembershipType3);
- mtHandler_.createMembershipType(mt3, true);
- membershipHandler_.linkMembership(user, groupHandler_.findGroupById("/" + Group2), mt3, true);
-
- System.out.println(" --------- find memberships by group -------------");
- Collection<Membership> mems =
- membershipHandler_.findMembershipsByGroup(groupHandler_.findGroupById("/" + Group2));
- assertEquals("Expect number of membership in group 2 is: ", 4, mems.size());
- for (Membership m : mems)
- {
- System.out.println(m);
- }
-
- System.out.println(" --------- find memberships by user and group--------------");
- mems = membershipHandler_.findMembershipsByUserAndGroup(Benj, "/" + Group2);
- assertEquals("Expect number of membership in " + Group2 + " relate with benj is: ", 3, mems.size());
- for (Membership m : mems)
- {
- System.out.println(m);
- }
-
- System.out.println(" --------- find memberships by user-------------");
- mems = membershipHandler_.findMembershipsByUser(Benj);
- assertEquals("expect membership is: ", 4, mems.size());
- for (Membership m : mems)
- {
- System.out.println(m);
- }
-
- System.out.println("---------- find membership by User, Group and Type-----------");
- Membership membership =
- membershipHandler_.findMembershipByUserGroupAndType(Benj, "/" + Group2, TestMembershipType1);
- assertTrue("Expect membership is found:", membership != null);
- assertEquals("Expect membership type is: ", TestMembershipType1, membership.getMembershipType());
- assertEquals("Expect groupId of this membership is: ", "/" + Group2, membership.getGroupId());
- assertEquals("Expect user of this membership is: ", Benj, membership.getUserName());
-
- System.out.println(" --------- find groups by user -------------");
- Collection<Group> groups = groupHandler_.findGroupsOfUser(Benj);
- assertEquals("expect group is: ", 2, groups.size());
- for (Group g : groups)
- {
- System.out.println(g);
- }
-
- System.out.println("---------- find group of a user by membership-----------");
- groups = groupHandler_.findGroupByMembership(Benj, TestMembershipType1);
- assertEquals("expect group is: ", 2, groups.size());
- for (Group g : groups)
- {
- System.out.println(g);
- }
-
- System.out.println("----------------- removed a membership ---------------------");
- String memId =
- membershipHandler_.findMembershipByUserGroupAndType(Benj, "/" + Group2, TestMembershipType3).getId();
- for (Group g : groups)
- {
- System.out.println(g);
- }
- membershipHandler_.removeMembership(memId, true);
- assertTrue("Membership was removed: ",
- membershipHandler_.findMembershipByUserGroupAndType(Benj, "/" + Group2, TestMembershipType3) == null);
- for (Group g : groups)
- {
- System.out.println(g);
- }
-
- System.out.println("----------------- removed a user----------------------");
- userHandler_.removeUser(Tuan, true);
- assertTrue("This user was removed", userHandler_.findUserByName(Tuan) == null);
- mems = membershipHandler_.findMembershipsByUser(Tuan);
- assertTrue("All membership related with this user was removed:", mems.isEmpty());
-
- System.out.println("----------------- removed a group------------");
- groupHandler_.removeGroup(groupHandler_.findGroupById("/" + Group1), true);
- assertTrue("This group was removed", groupHandler_.findGroupById("/" + Group1) == null);
-
- System.out.println("----------------- removed a membershipType------------");
- mtHandler_.removeMembershipType(TestMembershipType1, true);
- assertTrue("This membershipType was removed: ", mtHandler_.findMembershipType(TestMembershipType1) == null);
- // Check all memberships associate with all groups
- // to guarantee that no membership associate with removed membershipType
- groups = groupHandler_.findGroups(groupHandler_.findGroupById("/"));
- for (Group g : groups)
- {
- mems = membershipHandler_.findMembershipsByGroup(g);
- for (Membership m : mems)
- {
- assertFalse("MembershipType of this membership is not: " + TestMembershipType1, m.getMembershipType()
- .equalsIgnoreCase(TestMembershipType1));
- }
- }
-
- }
-
- public User createUser(String userName) throws Exception
- {
- User user = userHandler_.findUserByName(userName);
- if (user != null)
- {
- return user;
- }
- user = userHandler_.createUserInstance(userName);
- user.setPassword("default");
- user.setFirstName("default");
- user.setLastName("default");
- user.setEmail("exo(a)exoportal.org");
- userHandler_.createUser(user, true);
- return user;
- }
-}
Modified: core/trunk/exo.core.component.organization.ldap/src/test/resources/test.policy
===================================================================
--- core/trunk/exo.core.component.organization.ldap/src/test/resources/test.policy 2011-10-04 08:21:04 UTC (rev 5015)
+++ core/trunk/exo.core.component.organization.ldap/src/test/resources/test.policy 2011-10-04 09:03:41 UTC (rev 5016)
@@ -25,5 +25,9 @@
permission java.security.AllPermission;
};
+grant codeBase "@MAIN_CLASSES@../../../exo.core.component.organization.ldap/-"{
+ permission java.security.AllPermission;
+};
+
Modified: core/trunk/exo.core.component.organization.tests/src/main/java/org/exoplatform/services/tck/organization/AbstractOrganizationServiceTest.java
===================================================================
--- core/trunk/exo.core.component.organization.tests/src/main/java/org/exoplatform/services/tck/organization/AbstractOrganizationServiceTest.java 2011-10-04 08:21:04 UTC (rev 5015)
+++ core/trunk/exo.core.component.organization.tests/src/main/java/org/exoplatform/services/tck/organization/AbstractOrganizationServiceTest.java 2011-10-04 09:03:41 UTC (rev 5016)
@@ -93,7 +93,14 @@
{
super.setUp();
- String containerConf = getClass().getResource("/conf/standalone/test-configuration.xml").toString();
+
+ String configPath = System.getProperty("orgservice.test.configuration.file");
+ if (configPath == null)
+ {
+ configPath = "/conf/standalone/test-configuration.xml";
+ }
+
+ String containerConf = getClass().getResource(configPath).toString();
StandaloneContainer.addConfigurationURL(containerConf);
container = StandaloneContainer.getInstance();
14 years, 7 months
exo-jcr SVN: r5014 - in jcr/trunk: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query and 4 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-10-04 04:17:14 -0400 (Tue, 04 Oct 2011)
New Revision: 5014
Added:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/utils/io/TestDirectoryHelper.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/DirectoryRestore.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRdbmsFullBackupJob.java
Log:
EXOJCR-1565: compress directory into single file
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/DirectoryRestore.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/DirectoryRestore.java 2011-10-04 06:51:40 UTC (rev 5013)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/rdbms/DirectoryRestore.java 2011-10-04 08:17:14 UTC (rev 5014)
@@ -48,9 +48,9 @@
protected final List<File> dataDirs = new ArrayList<File>();
/**
- * The list of directories with backuped data.
+ * The list of compressed files.
*/
- protected final List<File> backupDirs = new ArrayList<File>();
+ protected final List<File> zipFiles = new ArrayList<File>();
/**
* The list of temporary directories.
@@ -71,24 +71,24 @@
* Constructor DirectoryRestorer.
*
* @param dataDirs
- * @param backupDirs
+ * @param zipFiles
*/
- public DirectoryRestore(List<File> dataDirs, List<File> backupDirs)
+ public DirectoryRestore(List<File> dataDirs, List<File> zipFiles)
{
this.dataDirs.addAll(dataDirs);
- this.backupDirs.addAll(backupDirs);
+ this.zipFiles.addAll(zipFiles);
}
/**
* Constructor DirectoryRestorer.
*
* @param dataDir
- * @param backupDir
+ * @param zipFile
*/
- public DirectoryRestore(File dataDir, File backupDir)
+ public DirectoryRestore(File dataDir, File zipFile)
{
this.dataDirs.add(dataDir);
- this.backupDirs.add(backupDir);
+ this.zipFiles.add(zipFile);
}
/**
@@ -96,8 +96,10 @@
*/
public void clean() throws BackupException
{
- for (File dataDir : dataDirs)
+ for (int i = 0; i < dataDirs.size(); i++)
{
+ File dataDir = dataDirs.get(i);
+
try
{
File tmpDir = new File(tempDir, PREFIX + IdGenerator.generate());
@@ -122,14 +124,14 @@
*/
public void restore() throws BackupException
{
- for (int i = 0; i < backupDirs.size(); i++)
+ for (int i = 0; i < zipFiles.size(); i++)
{
- File backupDir = backupDirs.get(i);
+ File zipFile = zipFiles.get(i);
File dataDir = dataDirs.get(i);
try
{
- DirectoryHelper.uncompressDirectory(backupDir, dataDir);
+ DirectoryHelper.uncompressDirectory(zipFile, dataDir);
}
catch (IOException e)
{
@@ -189,7 +191,7 @@
}
dataDirs.clear();
- backupDirs.clear();
+ zipFiles.clear();
tmpDirs.clear();
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2011-10-04 06:51:40 UTC (rev 5013)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2011-10-04 08:17:14 UTC (rev 5014)
@@ -18,9 +18,9 @@
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;
+import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.WildcardQuery;
-import org.apache.lucene.search.BooleanClause.Occur;
import org.exoplatform.commons.utils.PrivilegedFileHelper;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.container.configuration.ConfigurationManager;
@@ -1571,8 +1571,8 @@
}
else
{
- File destDir = new File(storageDir, getStorageName());
- DirectoryHelper.compressDirectory(indexDir, destDir);
+ File destZip = new File(storageDir, getStorageName() + ".zip");
+ DirectoryHelper.compressDirectory(indexDir, destZip);
}
}
catch (RepositoryConfigurationException e)
@@ -1613,16 +1613,16 @@
{
try
{
- File backupDir = new File((File)context.getObject(DataRestoreContext.STORAGE_DIR), getStorageName());
+ File zipFile = new File((File)context.getObject(DataRestoreContext.STORAGE_DIR), getStorageName() + ".zip");
- if (!PrivilegedFileHelper.exists(backupDir))
+ if (!PrivilegedFileHelper.exists(zipFile))
{
- throw new RepositoryConfigurationException("Can't restore index. Directory " + backupDir.getName()
+ throw new RepositoryConfigurationException("Can't restore index. File " + zipFile.getName()
+ " doesn't exists");
}
else
{
- return new DirectoryRestore(getIndexDirectory(), backupDir);
+ return new DirectoryRestore(getIndexDirectory(), zipFile);
}
}
catch (RepositoryConfigurationException e)
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2011-10-04 06:51:40 UTC (rev 5013)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2011-10-04 08:17:14 UTC (rev 5014)
@@ -73,6 +73,7 @@
import java.io.File;
import java.io.FileNotFoundException;
+import java.io.FilenameFilter;
import java.io.IOException;
import java.security.PrivilegedExceptionAction;
import java.sql.Connection;
@@ -1119,10 +1120,8 @@
}
else
{
- File destValuesDir = new File(storageDir, "values");
- File destDir = new File(destValuesDir, valueStorage.getId());
-
- DirectoryHelper.compressDirectory(srcDir, destDir);
+ File zipFile = new File(storageDir, "values-" + valueStorage.getId() + ".zip");
+ DirectoryHelper.compressDirectory(srcDir, zipFile);
}
}
}
@@ -1308,16 +1307,22 @@
restorers.add(new DBRestore(storageDir, jdbcConn, tables, wsConfig, swapCleaner));
}
+
// prepare value storage restorer
- File backupValueStorageDir = new File(storageDir, "values");
+ List<ValueStorageEntry> valueStorages = wsConfig.getContainer().getValueStorages();
+ String[] valueStoragesFiles = PrivilegedFileHelper.list(storageDir, new FilenameFilter()
+ {
+ public boolean accept(File dir, String name)
+ {
+ return name.startsWith("values-") && name.endsWith(".zip");
+ }
+ });
+
if (wsConfig.getContainer().getValueStorages() != null)
{
List<File> dataDirs = new ArrayList<File>();
List<File> backupDirs = new ArrayList<File>();
- List<ValueStorageEntry> valueStorages = wsConfig.getContainer().getValueStorages();
- String[] valueStoragesFiles = PrivilegedFileHelper.list(backupValueStorageDir);
-
if ((valueStoragesFiles == null && valueStorages.size() != 0)
|| (valueStoragesFiles != null && valueStoragesFiles.length != valueStorages.size()))
{
@@ -1327,18 +1332,18 @@
for (ValueStorageEntry valueStorage : valueStorages)
{
- File backupDir = new File(backupValueStorageDir, valueStorage.getId());
- if (!PrivilegedFileHelper.exists(backupDir))
+ File zipFile = new File(storageDir, "values-" + valueStorage.getId() + ".zip");
+ if (!PrivilegedFileHelper.exists(zipFile))
{
- throw new RepositoryConfigurationException("Can't restore value storage. Directory "
- + backupDir.getName() + " doesn't exists");
+ throw new RepositoryConfigurationException("Can't restore value storage. File " + zipFile.getName()
+ + " doesn't exists");
}
else
{
File dataDir = new File(valueStorage.getParameterValue(FileValueStorage.PATH));
dataDirs.add(dataDir);
- backupDirs.add(backupDir);
+ backupDirs.add(zipFile);
}
}
@@ -1346,7 +1351,7 @@
}
else
{
- if (PrivilegedFileHelper.exists(backupValueStorageDir))
+ if (valueStoragesFiles != null && valueStoragesFiles.length != 0)
{
throw new RepositoryConfigurationException("Value storage didn't configure in workspace ["
+ wsConfig.getName() + "] configuration but value storage backup files exist");
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java 2011-10-04 06:51:40 UTC (rev 5013)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/DirectoryHelper.java 2011-10-04 08:17:14 UTC (rev 5014)
@@ -108,15 +108,7 @@
in = PrivilegedFileHelper.fileInputStream(srcPath);
out = PrivilegedFileHelper.fileOutputStream(dstPath);
- // Transfer bytes from in to out
- byte[] buf = new byte[2048];
-
- int len;
-
- while ((len = in.read(buf)) > 0)
- {
- out.write(buf, 0, len);
- }
+ transfer(in, out);
}
finally
{
@@ -166,50 +158,72 @@
}
/**
- * Compress directory.
+ * Compress data. In case when <code>rootPath</code> is a directory this method
+ * compress all files and folders inside the directory into single one. IOException
+ * will be thrown if directory is empty. If the <code>rootPath</code> is the file
+ * the only this file will be compressed.
*
- * @param srcPath
- * source path
- * @param dstPath
- * destination path
+ * @param rootPath
+ * the root path, can be the directory or the file
+ * @param dstZipPath
+ * the path to the destination compressed file
* @throws IOException
* if any exception occurred
*/
- public static void compressDirectory(File srcPath, File dstPath) throws IOException
+ public static void compressDirectory(File rootPath, File dstZipPath) throws IOException
{
- if (PrivilegedFileHelper.isDirectory(srcPath))
+ ZipOutputStream zip = PrivilegedFileHelper.zipOutputStream(dstZipPath);
+ try
{
- if (!PrivilegedFileHelper.exists(dstPath))
+ if (PrivilegedFileHelper.isDirectory(rootPath))
{
- PrivilegedFileHelper.mkdirs(dstPath);
+ String files[] = PrivilegedFileHelper.list(rootPath);
+ for (int i = 0; i < files.length; i++)
+ {
+ compressDirectory("", new File(rootPath, files[i]), zip);
+ }
}
+ else
+ {
+ compressDirectory("", rootPath, zip);
+ }
+ }
+ finally
+ {
+ if (zip != null)
+ {
+ zip.flush();
+ zip.close();
+ }
+ }
+ }
+ /**
+ * Compress files and directories.
+ */
+ private static void compressDirectory(String relativePath, File srcPath, ZipOutputStream zip) throws IOException
+ {
+ if (PrivilegedFileHelper.isDirectory(srcPath))
+ {
+ zip.putNextEntry(new ZipEntry(relativePath + "/" + srcPath.getName() + "/"));
+ zip.closeEntry();
+
String files[] = PrivilegedFileHelper.list(srcPath);
for (int i = 0; i < files.length; i++)
{
- compressDirectory(new File(srcPath, files[i]), new File(dstPath, files[i]));
+ compressDirectory(relativePath + "/" + srcPath.getName(), new File(srcPath, files[i]), zip);
}
}
else
{
- InputStream in = null;
- ZipOutputStream out = null;
-
+ InputStream in = PrivilegedFileHelper.fileInputStream(srcPath);
try
{
- in = PrivilegedFileHelper.fileInputStream(srcPath);
- out = PrivilegedFileHelper.zipOutputStream(dstPath);
- out.putNextEntry(new ZipEntry(srcPath.getName()));
+ zip.putNextEntry(new ZipEntry(relativePath + "/" + srcPath.getName()));
- // Transfer bytes from in to out
- byte[] buf = new byte[2048];
+ transfer(in, zip);
- int len;
-
- while ((len = in.read(buf)) > 0)
- {
- out.write(buf, 0, len);
- }
+ zip.closeEntry();
}
finally
{
@@ -217,29 +231,74 @@
{
in.close();
}
-
- if (out != null)
- {
- out.flush();
- out.closeEntry();
- out.close();
- }
}
}
}
/**
- * Uncompress directory.
+ * Uncompress data to the destination directory. If <code>srcZipPath</code> is the directory we assume
+ * that every file in the directory is compressed, in other case <code>srcZipPath</code> should contain
+ * the compress data.
*
- * @param srcPath
- * source path
- * @param dstPath
+ * @param srcZipPath
+ * path to the compressed file, could be the file or the directory
+ * @param dstDirPath
* destination path
* @throws IOException
* if any exception occurred
*/
- public static void uncompressDirectory(File srcPath, File dstPath) throws IOException
+ public static void uncompressDirectory(File srcZipPath, File dstDirPath) throws IOException
{
+ if (PrivilegedFileHelper.isDirectory(srcZipPath))
+ {
+ uncompressEveryFileInDirectory(srcZipPath, dstDirPath);
+ }
+ else
+ {
+
+ ZipInputStream in = PrivilegedFileHelper.zipInputStream(srcZipPath);
+ ZipEntry entry = null;
+
+ try
+ {
+ while ((entry = in.getNextEntry()) != null)
+ {
+ File dstFile = new File(dstDirPath, entry.getName());
+ PrivilegedFileHelper.mkdirs(dstFile.getParentFile());
+
+ if (entry.isDirectory())
+ {
+ PrivilegedFileHelper.mkdirs(dstFile);
+ }
+ else
+ {
+ OutputStream out = PrivilegedFileHelper.fileOutputStream(dstFile);
+ try
+ {
+ transfer(in, out);
+ }
+ finally
+ {
+ out.close();
+ }
+ }
+ }
+ }
+ finally
+ {
+ if (in != null)
+ {
+ in.close();
+ }
+ }
+ }
+ }
+
+ /**
+ * Uncompress data in case when every file in the directory is compressed.
+ */
+ private static void uncompressEveryFileInDirectory(File srcPath, File dstPath) throws IOException
+ {
if (PrivilegedFileHelper.isDirectory(srcPath))
{
if (!PrivilegedFileHelper.exists(dstPath))
@@ -250,7 +309,7 @@
String files[] = PrivilegedFileHelper.list(srcPath);
for (int i = 0; i < files.length; i++)
{
- uncompressDirectory(new File(srcPath, files[i]), new File(dstPath, files[i]));
+ uncompressEveryFileInDirectory(new File(srcPath, files[i]), new File(dstPath, files[i]));
}
}
else
@@ -262,17 +321,10 @@
{
in = PrivilegedFileHelper.zipInputStream(srcPath);
in.getNextEntry();
+
out = PrivilegedFileHelper.fileOutputStream(dstPath);
- // Transfer bytes from in to out
- byte[] buf = new byte[2048];
-
- int len;
-
- while ((len = in.read(buf)) > 0)
- {
- out.write(buf, 0, len);
- }
+ transfer(in, out);
}
finally
{
@@ -290,6 +342,21 @@
}
/**
+ * Transfer bytes from in to out
+ */
+ public static void transfer(InputStream in, OutputStream out) throws IOException
+ {
+ byte[] buf = new byte[2048];
+
+ int len;
+
+ while ((len = in.read(buf)) > 0)
+ {
+ out.write(buf, 0, len);
+ }
+ }
+
+ /**
* Rename file.
*
* @param srcFile
@@ -314,9 +381,8 @@
// rename fails, we manually rename by copying the srcFile file to the new one
if (!PrivilegedFileHelper.renameTo(srcFile, dstFile))
{
- java.io.InputStream in = null;
- java.io.OutputStream out = null;
- byte buffer[] = null;
+ InputStream in = null;
+ OutputStream out = null;
try
{
in = PrivilegedFileHelper.fileInputStream(srcFile);
@@ -324,15 +390,7 @@
// see if the buffer needs to be initialized. Initialization is
// only done on-demand since many VM's will never run into the renameTo
// bug and hence shouldn't waste 1K of mem for no reason.
- if (buffer == null)
- {
- buffer = new byte[1024];
- }
- int len;
- while ((len = in.read(buffer)) >= 0)
- {
- out.write(buffer, 0, len);
- }
+ transfer(in, out);
// delete the srcFile file.
PrivilegedFileHelper.delete(srcFile);
Added: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/utils/io/TestDirectoryHelper.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/utils/io/TestDirectoryHelper.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/utils/io/TestDirectoryHelper.java 2011-10-04 08:17:14 UTC (rev 5014)
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.utils.io;
+
+import junit.framework.TestCase;
+
+import org.exoplatform.services.jcr.impl.util.io.DirectoryHelper;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
+ * @version $Id: TestDirectoryHelper.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class TestDirectoryHelper extends TestCase
+{
+
+ public void testCompressEmptyDirectory() throws Exception
+ {
+ File rootDir = new File("./target/emptyDir");
+ rootDir.mkdir();
+
+ File zipFile = new File("./target/compress.zip");
+
+ try
+ {
+ DirectoryHelper.compressDirectory(rootDir, zipFile);
+ fail("Exception should be thrown");
+ }
+ catch (IOException e)
+ {
+ // can't compress empty directory
+ }
+ }
+
+ public void testCompressDirectory() throws Exception
+ {
+ // compress/compress.1
+ File rootDir = new File("./target/compress");
+ rootDir.mkdir();
+
+ OutputStream out = new FileOutputStream(new File(rootDir, "compress.1"));
+ out.write("compress.1".getBytes());
+ out.close();
+
+ // compress/a/a.1
+ // compress/a/a.2
+ File dirA = new File(rootDir, "a");
+ dirA.mkdir();
+
+ out = new FileOutputStream(new File(dirA, "a.1"));
+ out.write("a.1".getBytes());
+ out.close();
+
+ out = new FileOutputStream(new File(dirA, "a.2"));
+ out.write("a.2".getBytes());
+ out.close();
+
+ // compress/a/c/c.1
+ File dirAC = new File(dirA, "c");
+ dirAC.mkdir();
+
+ out = new FileOutputStream(new File(dirAC, "c.1"));
+ out.write("c.1".getBytes());
+ out.close();
+
+ // compress/b/b.1
+ File dirB = new File(rootDir, "b");
+ dirB.mkdir();
+
+ out = new FileOutputStream(new File(dirB, "b.1"));
+ out.write("b.1".getBytes());
+ out.close();
+
+ File zipFile = new File("./target/compressDir.zip");
+
+ DirectoryHelper.compressDirectory(rootDir, zipFile);
+
+ assertTrue(zipFile.exists());
+
+ File dir = new File("./target/uncompress");
+ DirectoryHelper.uncompressDirectory(zipFile, dir);
+
+ assertFile(dir, "compress.1");
+ assertFile(new File(dir, "a"), "a.1");
+ assertFile(new File(dir, "a"), "a.2");
+ assertFile(new File(dir, "b"), "b.1");
+ assertFile(new File(new File(dir, "a"), "c"), "c.1");
+ }
+
+ public void testCompressFile() throws Exception
+ {
+ OutputStream out = new FileOutputStream(new File("./target/compress.file"));
+ out.write("compress.file".getBytes());
+ out.close();
+
+ File zipFile = new File("./target/compressFile.zip");
+
+ DirectoryHelper.compressDirectory(new File("./target/compress.file"), zipFile);
+
+ assertTrue(zipFile.exists());
+
+ File dir = new File("./target/uncompress");
+ DirectoryHelper.uncompressDirectory(zipFile, dir);
+
+ assertFile(dir, "compress.file");
+ }
+
+ private void assertFile(File dir, String fileName) throws Exception
+ {
+ byte[] buf = new byte[20];
+
+ File file = new File(dir, fileName);
+ assertTrue(file.exists());
+
+ InputStream in = new FileInputStream(file);
+ int len = in.read(buf);
+ in.close();
+ assertEquals(fileName, new String(buf, 0, len));
+ }
+}
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRdbmsFullBackupJob.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRdbmsFullBackupJob.java 2011-10-04 06:51:40 UTC (rev 5013)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRdbmsFullBackupJob.java 2011-10-04 08:17:14 UTC (rev 5014)
@@ -19,7 +19,6 @@
package org.exoplatform.services.jcr.ext.backup;
import org.exoplatform.services.jcr.ext.backup.impl.rdbms.FullBackupJob;
-import org.exoplatform.services.jcr.impl.core.query.SystemSearchManager;
import java.io.File;
import java.net.URL;
@@ -49,28 +48,15 @@
URL url = job.getStorageURL();
assertNotNull(url);
- File valuesDir = new File(url.getFile(), "values");
- assertTrue(valuesDir.exists());
- String values[] = valuesDir.list();
-
- assertEquals(values.length, 1);
- assertTrue(new File(valuesDir, values[0]).isDirectory());
-
- File indexesDir = new File(url.getFile(), "index");
- assertTrue(indexesDir.exists());
-
- indexesDir = new File(url.getFile(), "index" + "_" + SystemSearchManager.INDEX_DIR_SUFFIX);
- assertTrue(indexesDir.exists());
-
+ assertTrue(new File(url.getFile(), "values-draft.zip").exists());
+ assertTrue(new File(url.getFile(), "index.zip").exists());
+ assertTrue(new File(url.getFile(), "index_system.zip").exists());
assertTrue(new File(url.getFile(), "JCR_MITEM.dump").exists());
assertTrue(new File(url.getFile(), "JCR_MITEM.len").exists());
-
assertTrue(new File(url.getFile(), "JCR_MVALUE.dump").exists());
assertTrue(new File(url.getFile(), "JCR_MVALUE.len").exists());
-
assertTrue(new File(url.getFile(), "JCR_MREF.dump").exists());
assertTrue(new File(url.getFile(), "JCR_MREF.len").exists());
-
}
public void testRDBMSFullBackupJob() throws Exception
@@ -89,15 +75,10 @@
URL url = job.getStorageURL();
assertNotNull(url);
- File valuesDir = new File(url.getFile(), "values");
- assertFalse(valuesDir.exists());
+ assertFalse(new File(url.getFile(), "values-draft.zip").exists());
+ assertTrue(new File(url.getFile(), "index.zip").exists());
+ assertFalse(new File(url.getFile(), "index_system.zip").exists());
- File indexesDir = new File(url.getFile(), "index");
- assertTrue(indexesDir.exists());
-
- indexesDir = new File(url.getFile(), "index" + "_" + SystemSearchManager.INDEX_DIR_SUFFIX);
- assertFalse(indexesDir.exists());
-
assertTrue(new File(url.getFile(), "JCR_MITEM.dump").exists());
assertTrue(new File(url.getFile(), "JCR_MITEM.len").exists());
14 years, 7 months
exo-jcr SVN: r5013 - jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2011-10-04 02:51:40 -0400 (Tue, 04 Oct 2011)
New Revision: 5013
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobRepositoryRestore.java
Log:
EXOJCR-1563 : reverting prev.changes.
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java 2011-10-04 06:15:55 UTC (rev 5012)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java 2011-10-04 06:51:40 UTC (rev 5013)
@@ -116,20 +116,20 @@
File fullBackupDir =
JCRRestore.getFullBackupFile(workspacesMapping.get(wEntry.getName()).getBackupConfig().getBackupDir());
-
+
DataRestoreContext context;
if (jdbcConn != null)
{
- context =
- new DataRestoreContext(
- new String[]{DataRestoreContext.STORAGE_DIR, DataRestoreContext.DB_CONNECTION}, new Object[]{
- fullBackupDir, jdbcConn});
+ context = new DataRestoreContext(
+ new String[] {DataRestoreContext.STORAGE_DIR, DataRestoreContext.DB_CONNECTION},
+ new Object[] {fullBackupDir, jdbcConn});
}
else
{
- context =
- new DataRestoreContext(new String[]{DataRestoreContext.STORAGE_DIR}, new Object[]{fullBackupDir});
+ context = new DataRestoreContext(
+ new String[] {DataRestoreContext.STORAGE_DIR},
+ new Object[] {fullBackupDir});
}
for (Backupable component : backupable)
@@ -226,13 +226,4 @@
}
}
}
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSameConfiguration()
- {
- return true;
- }
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobRepositoryRestore.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobRepositoryRestore.java 2011-10-04 06:15:55 UTC (rev 5012)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobRepositoryRestore.java 2011-10-04 06:51:40 UTC (rev 5013)
@@ -16,6 +16,8 @@
*/
package org.exoplatform.services.jcr.ext.backup.impl;
+
+
import org.exoplatform.services.jcr.RepositoryService;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.RepositoryEntry;
@@ -160,7 +162,7 @@
* will be generated the Throwable
*/
protected void restoreRepository() throws RepositoryRestoreExeption, BackupOperationException,
- ClassNotFoundException
+ ClassNotFoundException
{
List<WorkspaceEntry> originalWorkspaceEntrys = repositoryEntry.getWorkspaceEntries();
@@ -180,7 +182,7 @@
//getting backup chail log to system workspace.
BackupChainLog systemBackupChainLog = workspacesMapping.get(systemWorkspaceEntry.getName());
-
+
WorkspaceInitializerEntry wiEntry = getWorkspaceInitializerEntry(systemBackupChainLog);
// set initializer
@@ -204,15 +206,8 @@
WorkspaceEntry createdWorkspaceEntry = (WorkspaceEntry)wcf.getComponent(WorkspaceEntry.class);
createdWorkspaceEntry.setInitializer(wieOriginal);
- // if same configuration is used, then no need to retain configuration. There is
- // a common usecase, when no configuration persister is used, so configuration can't
- // be rewritten, but backup-restore cycles are always performed. This usecase is
- // correct if same configuration used. Otherwise exception will be thrown on retain.
- if (!isSameConfiguration())
- {
- // save configuration to persistence (file or persister)
- repositoryService.getConfig().retain();
- }
+ // save configuration to persistence (file or persister)
+ repositoryService.getConfig().retain();
for (WorkspaceEntry wsEntry : originalWorkspaceEntrys)
{
@@ -275,7 +270,8 @@
* @throws RepositoryConfigurationException
*/
protected void removeRepository(RepositoryService repositoryService, String repositoryName)
- throws RepositoryException, RepositoryConfigurationException
+ throws RepositoryException,
+ RepositoryConfigurationException
{
ManageableRepository mr = null;
@@ -297,7 +293,7 @@
}
private WorkspaceInitializerEntry getWorkspaceInitializerEntry(BackupChainLog systemBackupChainLog)
- throws BackupOperationException, ClassNotFoundException
+ throws BackupOperationException, ClassNotFoundException
{
String fullBackupPath = systemBackupChainLog.getJobEntryInfos().get(0).getURL().getPath();
@@ -309,20 +305,20 @@
fullbackupType = systemBackupChainLog.getFullBackupType();
}
else if ((Class.forName(systemBackupChainLog.getFullBackupType())
- .equals(org.exoplatform.services.jcr.ext.backup.impl.rdbms.FullBackupJob.class)))
+ .equals(org.exoplatform.services.jcr.ext.backup.impl.rdbms.FullBackupJob.class)))
{
fullbackupType = systemBackupChainLog.getFullBackupType();
}
else
{
throw new BackupOperationException("Class \"" + systemBackupChainLog.getFullBackupType()
- + "\" is not support as full backup.");
+ + "\" is not support as full backup.");
}
}
catch (ClassNotFoundException e)
{
throw new BackupOperationException("Class \"" + systemBackupChainLog.getFullBackupType() + "\" is not found.",
- e);
+ e);
}
WorkspaceInitializerEntry wiEntry = new WorkspaceInitializerEntry();
@@ -333,19 +329,19 @@
List<SimpleParameterEntry> wieParams = new ArrayList<SimpleParameterEntry>();
wieParams.add(new SimpleParameterEntry(BackupWorkspaceInitializer.RESTORE_PATH_PARAMETER, (new File(
- fullBackupPath).getParent())));
+ fullBackupPath).getParent())));
wiEntry.setParameters(wieParams);
}
else if ((Class.forName(fullbackupType)
- .equals(org.exoplatform.services.jcr.ext.backup.impl.rdbms.FullBackupJob.class)))
+ .equals(org.exoplatform.services.jcr.ext.backup.impl.rdbms.FullBackupJob.class)))
{
// set the initializer RdbmsBackupWorkspaceInitializer
wiEntry.setType(RdbmsBackupWorkspaceInitializer.class.getCanonicalName());
List<SimpleParameterEntry> wieParams = new ArrayList<SimpleParameterEntry>();
wieParams.add(new SimpleParameterEntry(RdbmsBackupWorkspaceInitializer.RESTORE_PATH_PARAMETER, (new File(
- fullBackupPath).getParent())));
+ fullBackupPath).getParent())));
wiEntry.setParameters(wieParams);
}
@@ -399,14 +395,6 @@
}
/**
- * @return true, if configuration the same
- */
- public boolean isSameConfiguration()
- {
- return false;
- }
-
- /**
* getRestoreException.
*
* @return Throwable return the exception of repository restore.
14 years, 7 months
exo-jcr SVN: r5012 - jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2011-10-04 02:15:55 -0400 (Tue, 04 Oct 2011)
New Revision: 5012
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobRepositoryRestore.java
Log:
EXOJCR-1563 : don't call retain if same configuration used.
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java 2011-09-30 07:40:14 UTC (rev 5011)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java 2011-10-04 06:15:55 UTC (rev 5012)
@@ -116,20 +116,20 @@
File fullBackupDir =
JCRRestore.getFullBackupFile(workspacesMapping.get(wEntry.getName()).getBackupConfig().getBackupDir());
-
+
DataRestoreContext context;
if (jdbcConn != null)
{
- context = new DataRestoreContext(
- new String[] {DataRestoreContext.STORAGE_DIR, DataRestoreContext.DB_CONNECTION},
- new Object[] {fullBackupDir, jdbcConn});
+ context =
+ new DataRestoreContext(
+ new String[]{DataRestoreContext.STORAGE_DIR, DataRestoreContext.DB_CONNECTION}, new Object[]{
+ fullBackupDir, jdbcConn});
}
else
{
- context = new DataRestoreContext(
- new String[] {DataRestoreContext.STORAGE_DIR},
- new Object[] {fullBackupDir});
+ context =
+ new DataRestoreContext(new String[]{DataRestoreContext.STORAGE_DIR}, new Object[]{fullBackupDir});
}
for (Backupable component : backupable)
@@ -226,4 +226,13 @@
}
}
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isSameConfiguration()
+ {
+ return true;
+ }
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobRepositoryRestore.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobRepositoryRestore.java 2011-09-30 07:40:14 UTC (rev 5011)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobRepositoryRestore.java 2011-10-04 06:15:55 UTC (rev 5012)
@@ -16,8 +16,6 @@
*/
package org.exoplatform.services.jcr.ext.backup.impl;
-
-
import org.exoplatform.services.jcr.RepositoryService;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.RepositoryEntry;
@@ -162,7 +160,7 @@
* will be generated the Throwable
*/
protected void restoreRepository() throws RepositoryRestoreExeption, BackupOperationException,
- ClassNotFoundException
+ ClassNotFoundException
{
List<WorkspaceEntry> originalWorkspaceEntrys = repositoryEntry.getWorkspaceEntries();
@@ -182,7 +180,7 @@
//getting backup chail log to system workspace.
BackupChainLog systemBackupChainLog = workspacesMapping.get(systemWorkspaceEntry.getName());
-
+
WorkspaceInitializerEntry wiEntry = getWorkspaceInitializerEntry(systemBackupChainLog);
// set initializer
@@ -206,8 +204,15 @@
WorkspaceEntry createdWorkspaceEntry = (WorkspaceEntry)wcf.getComponent(WorkspaceEntry.class);
createdWorkspaceEntry.setInitializer(wieOriginal);
- // save configuration to persistence (file or persister)
- repositoryService.getConfig().retain();
+ // if same configuration is used, then no need to retain configuration. There is
+ // a common usecase, when no configuration persister is used, so configuration can't
+ // be rewritten, but backup-restore cycles are always performed. This usecase is
+ // correct if same configuration used. Otherwise exception will be thrown on retain.
+ if (!isSameConfiguration())
+ {
+ // save configuration to persistence (file or persister)
+ repositoryService.getConfig().retain();
+ }
for (WorkspaceEntry wsEntry : originalWorkspaceEntrys)
{
@@ -270,8 +275,7 @@
* @throws RepositoryConfigurationException
*/
protected void removeRepository(RepositoryService repositoryService, String repositoryName)
- throws RepositoryException,
- RepositoryConfigurationException
+ throws RepositoryException, RepositoryConfigurationException
{
ManageableRepository mr = null;
@@ -293,7 +297,7 @@
}
private WorkspaceInitializerEntry getWorkspaceInitializerEntry(BackupChainLog systemBackupChainLog)
- throws BackupOperationException, ClassNotFoundException
+ throws BackupOperationException, ClassNotFoundException
{
String fullBackupPath = systemBackupChainLog.getJobEntryInfos().get(0).getURL().getPath();
@@ -305,20 +309,20 @@
fullbackupType = systemBackupChainLog.getFullBackupType();
}
else if ((Class.forName(systemBackupChainLog.getFullBackupType())
- .equals(org.exoplatform.services.jcr.ext.backup.impl.rdbms.FullBackupJob.class)))
+ .equals(org.exoplatform.services.jcr.ext.backup.impl.rdbms.FullBackupJob.class)))
{
fullbackupType = systemBackupChainLog.getFullBackupType();
}
else
{
throw new BackupOperationException("Class \"" + systemBackupChainLog.getFullBackupType()
- + "\" is not support as full backup.");
+ + "\" is not support as full backup.");
}
}
catch (ClassNotFoundException e)
{
throw new BackupOperationException("Class \"" + systemBackupChainLog.getFullBackupType() + "\" is not found.",
- e);
+ e);
}
WorkspaceInitializerEntry wiEntry = new WorkspaceInitializerEntry();
@@ -329,19 +333,19 @@
List<SimpleParameterEntry> wieParams = new ArrayList<SimpleParameterEntry>();
wieParams.add(new SimpleParameterEntry(BackupWorkspaceInitializer.RESTORE_PATH_PARAMETER, (new File(
- fullBackupPath).getParent())));
+ fullBackupPath).getParent())));
wiEntry.setParameters(wieParams);
}
else if ((Class.forName(fullbackupType)
- .equals(org.exoplatform.services.jcr.ext.backup.impl.rdbms.FullBackupJob.class)))
+ .equals(org.exoplatform.services.jcr.ext.backup.impl.rdbms.FullBackupJob.class)))
{
// set the initializer RdbmsBackupWorkspaceInitializer
wiEntry.setType(RdbmsBackupWorkspaceInitializer.class.getCanonicalName());
List<SimpleParameterEntry> wieParams = new ArrayList<SimpleParameterEntry>();
wieParams.add(new SimpleParameterEntry(RdbmsBackupWorkspaceInitializer.RESTORE_PATH_PARAMETER, (new File(
- fullBackupPath).getParent())));
+ fullBackupPath).getParent())));
wiEntry.setParameters(wieParams);
}
@@ -395,6 +399,14 @@
}
/**
+ * @return true, if configuration the same
+ */
+ public boolean isSameConfiguration()
+ {
+ return false;
+ }
+
+ /**
* getRestoreException.
*
* @return Throwable return the exception of repository restore.
14 years, 7 months