exo-jcr SVN: r5169 - in core/trunk/exo.core.component.organization.jdbc: src/test/resources/conf/standalone and 1 other directory.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2011-11-08 02:47:11 -0500 (Tue, 08 Nov 2011)
New Revision: 5169
Modified:
core/trunk/exo.core.component.organization.jdbc/pom.xml
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
Log:
EXOJCR-1572: changed unit tests executions, now both jdbc and hibernate org service tests are run during single lounch by default
Modified: core/trunk/exo.core.component.organization.jdbc/pom.xml
===================================================================
--- core/trunk/exo.core.component.organization.jdbc/pom.xml 2011-11-07 16:37:38 UTC (rev 5168)
+++ core/trunk/exo.core.component.organization.jdbc/pom.xml 2011-11-08 07:47:11 UTC (rev 5169)
@@ -99,10 +99,78 @@
<scope>test</scope>
</dependency>
</dependencies>
+
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!--
+ We have no unit tests, we run TCK tests instead.
+ So we skip default unit tests.
+ -->
+ <skip>true</skip>
+ <!-- Common configuration for both jdbc and hibernate
+ organization services.
+ -->
+ <argLine>${env.MAVEN_OPTS} -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy</argLine>
+ <includes>
+ <include>org/exoplatform/services/tck/organization/Test*.java</include>
+ </includes>
+ <excludes>
+ <exclude>**/AbstractOrganizationServiceTest.java</exclude>
+ <!--
+ Some issues with cach make test to fail.
+ -->
+ <exclude>org/exoplatform/services/tck/organization/TestMembershipTypeEventListener.java</exclude>
+ </excludes>
+ </configuration>
+ <executions>
+ <execution>
+ <id>hibernate</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ <systemProperties>
+ <property>
+ <name>orgservice.test.configuration.file</name>
+ <value>/conf/standalone/test-configuration-hibernate.xml</value>
+ </property>
+ <property>
+ <name>orgservice.test.configuration.skipDateTests</name>
+ <value>false</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </execution>
+ <execution>
+ <id>jdbc</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ <systemProperties>
+ <property>
+ <name>orgservice.test.configuration.file</name>
+ <value>/conf/standalone/test-configuration-jdbc.xml</value>
+ </property>
+ <property>
+ <name>orgservice.test.configuration.skipDateTests</name>
+ <value>true</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
@@ -125,39 +193,39 @@
</configuration>
</execution>
</executions>
- </plugin>
- <plugin>
+ </plugin>
+ <plugin>
<groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <version>1.3</version>
- <executions>
- <execution>
+ <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>
+ <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>
+ <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>
@@ -201,96 +269,5 @@
</plugin>
</plugins>
</build>
- <profiles>
- <profile>
- <id>hibernate</id>
- <properties>
- <orgservice.test.configuration.file>/conf/standalone/test-configuration-hibernate.xml</orgservice.test.configuration.file>
- </properties>
- <build>
- <plugins>
- <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>
- <!--
- Excluded as there some hibernate cache issues on pre-, postoperations
- (e.g. preDelete, postDelete, etc.)
- -->
-
- <exclude>org/exoplatform/services/tck/organization/TestMembershipTypeEventListener.java</exclude>
-
- <!--
- Excluded as this class has no tests to be run
- -->
- <exclude>**/AbstractOrganizationServiceTest.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </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>
- <build>
- <plugins>
- <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>
-
- <property>
- <name>orgservice.test.configuration.skipDateTests</name>
- <value>true</value>
- </property>
- </systemProperties>
- <includes>
- <include>org/exoplatform/services/tck/organization/Test*.java</include>
- </includes>
- <excludes>
- <!--
- Excluded as this class has no tests to be run
- -->
- <exclude>**/AbstractOrganizationServiceTest.java</exclude>
-
- <!--
- Some limitation of JDBC implementation of organization service
- -->
- <exclude>org/exoplatform/services/tck/organization/TestMembershipTypeEventListener.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
+
</project>
Modified: 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 2011-11-07 16:37:38 UTC (rev 5168)
+++ core/trunk/exo.core.component.organization.jdbc/src/test/resources/conf/standalone/test-configuration-hibernate.xml 2011-11-08 07:47:11 UTC (rev 5169)
@@ -46,7 +46,7 @@
<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:target/temp/data/exodb"/>
+ <property name="hibernate.connection.url" value="jdbc:hsqldb:file:target/temp/data/exodb-hibernate"/>
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
<property name="hibernate.connection.autocommit" value="true"/>
<property name="hibernate.connection.username" value="sa"/>
Modified: 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 2011-11-07 16:37:38 UTC (rev 5168)
+++ core/trunk/exo.core.component.organization.jdbc/src/test/resources/conf/standalone/test-configuration-jdbc.xml 2011-11-08 07:47:11 UTC (rev 5169)
@@ -73,7 +73,7 @@
<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/data/exodb' />
+ <property name='connection.url' value='jdbc:hsqldb:file:target/temp/data/exodb-jdbc' />
<property name='connection.login' value='sa' />
<property name='connection.password' value='' />
<property name='connection.min-size' value='3' />
14 years, 5 months
exo-jcr SVN: r5168 - in kernel/trunk/exo.kernel.container/src: test/java/org/exoplatform/container and 1 other directory.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2011-11-07 11:37:38 -0500 (Mon, 07 Nov 2011)
New Revision: 5168
Added:
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestStandaloneContainer.java
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/StandaloneContainer.java
Log:
EXOJCR-1618: Allow to use StandaloneContainer in web application with hot-redeploy
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/StandaloneContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/StandaloneContainer.java 2011-11-07 08:06:08 UTC (rev 5167)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/StandaloneContainer.java 2011-11-07 16:37:38 UTC (rev 5168)
@@ -329,6 +329,7 @@
{
super.stop();
ExoContainerContext.setTopContainer(null);
+ container = null;
}
// -------------- Helpers ----------
Added: kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestStandaloneContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestStandaloneContainer.java (rev 0)
+++ kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestStandaloneContainer.java 2011-11-07 16:37:38 UTC (rev 5168)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2011 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.container;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:nfilotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class TestStandaloneContainer extends TestCase
+{
+
+ public void testHotDeploy() throws Exception
+ {
+ StandaloneContainer.getInstance();
+ ExoContainer container = ExoContainerContext.getTopContainer();
+ assertEquals(container.getClass(), StandaloneContainer.class);
+ container = ExoContainerContext.getCurrentContainer();
+ assertEquals(container.getClass(), StandaloneContainer.class);
+
+ container.stop();
+
+ StandaloneContainer.getInstance();
+ container = ExoContainerContext.getTopContainer();
+ assertEquals(container.getClass(), StandaloneContainer.class);
+ container = ExoContainerContext.getCurrentContainer();
+ assertEquals(container.getClass(), StandaloneContainer.class);
+ }
+}
14 years, 5 months
exo-jcr SVN: r5167 - core/trunk/exo.core.component.organization.ldap/src/main/java/org/exoplatform/services/organization/ldap.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-11-07 03:06:08 -0500 (Mon, 07 Nov 2011)
New Revision: 5167
Modified:
core/trunk/exo.core.component.organization.ldap/src/main/java/org/exoplatform/services/organization/ldap/BaseDAO.java
core/trunk/exo.core.component.organization.ldap/src/main/java/org/exoplatform/services/organization/ldap/MembershipDAOImpl.java
Log:
EXOJCR: LDAP Org Srv : NullPointerException when creating a new user
Modified: core/trunk/exo.core.component.organization.ldap/src/main/java/org/exoplatform/services/organization/ldap/BaseDAO.java
===================================================================
--- core/trunk/exo.core.component.organization.ldap/src/main/java/org/exoplatform/services/organization/ldap/BaseDAO.java 2011-11-04 14:43:42 UTC (rev 5166)
+++ core/trunk/exo.core.component.organization.ldap/src/main/java/org/exoplatform/services/organization/ldap/BaseDAO.java 2011-11-07 08:06:08 UTC (rev 5167)
@@ -22,9 +22,9 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.services.organization.CacheHandler;
+import org.exoplatform.services.organization.CacheHandler.CacheType;
import org.exoplatform.services.organization.Group;
import org.exoplatform.services.organization.User;
-import org.exoplatform.services.organization.CacheHandler.CacheType;
import org.exoplatform.services.organization.impl.GroupImpl;
import java.util.ArrayList;
@@ -183,15 +183,27 @@
try
{
if (attributes == null)
+ {
return results;
+ }
+
Attribute attr = attributes.get(attribute);
+ if (attr == null)
+ {
+ return results;
+ }
+
for (int x = 0; x < attr.size(); x++)
+ {
results.add(attr.get(x));
+ }
}
catch (NamingException e)
{
if (LOG.isDebugEnabled())
+ {
LOG.debug(e.getLocalizedMessage(), e);
+ }
}
return results;
}
Modified: core/trunk/exo.core.component.organization.ldap/src/main/java/org/exoplatform/services/organization/ldap/MembershipDAOImpl.java
===================================================================
--- core/trunk/exo.core.component.organization.ldap/src/main/java/org/exoplatform/services/organization/ldap/MembershipDAOImpl.java 2011-11-04 14:43:42 UTC (rev 5166)
+++ core/trunk/exo.core.component.organization.ldap/src/main/java/org/exoplatform/services/organization/ldap/MembershipDAOImpl.java 2011-11-07 08:06:08 UTC (rev 5167)
@@ -133,12 +133,6 @@
+ " because membership type " + m.getMembershipType() + " is not exists.");
}
- // check if we already have membership record
- if (findMembershipByUserGroupAndType(m.getUserName(), m.getGroupId(), m.getMembershipType()) != null)
- {
- return;
- }
-
for (int err = 0;; err++)
{
try
@@ -169,6 +163,7 @@
cacheHandler.put(cacheHandler.getMembershipKey(m), m, CacheType.MEMBERSHIP);
return;
}
+
// if contains membership
List members = getAttributes(attrs, ldapAttrMapping.membershipTypeMemberValue);
if (members.contains(userDN))
14 years, 5 months
exo-jcr SVN: r5166 - in core/trunk: exo.core.component.organization.jdbc and 3 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-11-04 10:43:42 -0400 (Fri, 04 Nov 2011)
New Revision: 5166
Modified:
core/trunk/exo.core.component.organization.api/src/main/java/org/exoplatform/services/organization/impl/UserProfileImpl.java
core/trunk/exo.core.component.organization.jdbc/pom.xml
core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/GroupDAOImpl.java
core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/JDBCListAccess.java
core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/MembershipDAOImpl.java
core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/MembershipTypeDAOImpl.java
core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/OrganizationServiceImpl.java
core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/UserDAOImpl.java
core/trunk/exo.core.component.organization.jdbc/src/test/resources/conf/standalone/test-configuration-jdbc.xml
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/TestGroupHandler.java
core/trunk/exo.core.component.organization.tests/src/main/java/org/exoplatform/services/tck/organization/TestMembershipHandler.java
core/trunk/exo.core.component.organization.tests/src/main/java/org/exoplatform/services/tck/organization/TestUserHandler.java
Log:
EXOJCR-1610: adopt JDBC orgService
Modified: core/trunk/exo.core.component.organization.api/src/main/java/org/exoplatform/services/organization/impl/UserProfileImpl.java
===================================================================
--- core/trunk/exo.core.component.organization.api/src/main/java/org/exoplatform/services/organization/impl/UserProfileImpl.java 2011-11-04 12:20:37 UTC (rev 5165)
+++ core/trunk/exo.core.component.organization.api/src/main/java/org/exoplatform/services/organization/impl/UserProfileImpl.java 2011-11-04 14:43:42 UTC (rev 5166)
@@ -35,6 +35,7 @@
public UserProfileImpl()
{
+ attributes = new HashMap<String, String>();
}
public UserProfileImpl(String userName)
Modified: core/trunk/exo.core.component.organization.jdbc/pom.xml
===================================================================
--- core/trunk/exo.core.component.organization.jdbc/pom.xml 2011-11-04 12:20:37 UTC (rev 5165)
+++ core/trunk/exo.core.component.organization.jdbc/pom.xml 2011-11-04 14:43:42 UTC (rev 5166)
@@ -267,20 +267,25 @@
<name>orgservice.test.configuration.file</name>
<value>${orgservice.test.configuration.file}</value>
</property>
+
+ <property>
+ <name>orgservice.test.configuration.skipDateTests</name>
+ <value>true</value>
+ </property>
</systemProperties>
<includes>
<include>org/exoplatform/services/tck/organization/Test*.java</include>
</includes>
- <excludes>
+ <excludes>
<!--
- Temporary excluded, to investigate cause of failures and errors.
+ Excluded as this class has no tests to be run
-->
+ <exclude>**/AbstractOrganizationServiceTest.java</exclude>
- <exclude>org/exoplatform/services/tck/organization/Test*.java</exclude>
<!--
- Excluded as this class has no tests to be run
+ Some limitation of JDBC implementation of organization service
-->
- <exclude>**/AbstractOrganizationServiceTest.java</exclude>
+ <exclude>org/exoplatform/services/tck/organization/TestMembershipTypeEventListener.java</exclude>
</excludes>
</configuration>
</plugin>
Modified: core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/GroupDAOImpl.java
===================================================================
--- core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/GroupDAOImpl.java 2011-11-04 12:20:37 UTC (rev 5165)
+++ core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/GroupDAOImpl.java 2011-11-04 14:43:42 UTC (rev 5166)
@@ -19,7 +19,6 @@
package org.exoplatform.services.organization.jdbc;
import org.exoplatform.commons.exception.UniqueObjectException;
-import org.exoplatform.container.PortalContainer;
import org.exoplatform.services.database.DBObjectMapper;
import org.exoplatform.services.database.DBObjectQuery;
import org.exoplatform.services.database.DBPageList;
@@ -40,6 +39,8 @@
import java.util.Collection;
import java.util.List;
+import javax.naming.InvalidNameException;
+
/**
* Created by The eXo Platform SAS Apr 7, 2007
*/
@@ -50,10 +51,15 @@
protected ListenerService listenerService_;
- public GroupDAOImpl(ListenerService lService, ExoDatasource datasource, DBObjectMapper<GroupImpl> mapper)
+ protected final OrganizationService orgService;
+
+ public GroupDAOImpl(OrganizationService orgSerivce, ListenerService lService, ExoDatasource datasource,
+ DBObjectMapper<GroupImpl> mapper)
{
super(datasource, mapper, GroupImpl.class);
- listenerService_ = lService;
+
+ this.orgService = orgSerivce;
+ this.listenerService_ = lService;
}
public Group createGroupInstance()
@@ -78,6 +84,11 @@
{
query.addLIKE("GROUP_ID", parent.getId());
Group parentGroup = super.loadUnique(connection, query.toQuery());
+ if (parentGroup == null)
+ {
+ throw new InvalidNameException("Can't add group " + child.getId() + " since parent group " + parent.getId()
+ + " not exists");
+ }
groupId = parentGroup.getId() + "/" + child.getGroupName();
childImpl.setParentId(parentGroup.getId());
}
@@ -139,7 +150,7 @@
if (userName == null || membershipType == null)
return null;
- MembershipHandler membershipHandler = getMembershipHandler();
+ MembershipHandler membershipHandler = orgService.getMembershipHandler();
List<Membership> members = (List<Membership>)membershipHandler.findMembershipsByUser(userName);
List<Group> groups = new ArrayList<Group>();
for (Membership member : members)
@@ -174,7 +185,7 @@
@SuppressWarnings("unchecked")
public Collection findGroupsOfUser(String user) throws Exception
{
- MembershipHandler membershipHandler = getMembershipHandler();
+ MembershipHandler membershipHandler = orgService.getMembershipHandler();
List<Membership> members = (List<Membership>)membershipHandler.findMembershipsByUser(user);
List<Group> groups = new ArrayList<Group>();
for (Membership member : members)
@@ -217,6 +228,12 @@
public Group removeGroup(Group group, boolean broadcast) throws Exception
{
+ if (findGroupById(group.getId()) == null)
+ {
+ throw new InvalidNameException("Can't remove group since group with groupId " + group.getId()
+ + " is not found");
+ }
+
GroupImpl groupImpl = (GroupImpl)group;
if (broadcast)
listenerService_.broadcast(GroupHandler.PRE_DELETE_GROUP_EVENT, this, groupImpl);
@@ -235,12 +252,4 @@
public void removeGroupEventListener(GroupEventListener listener)
{
}
-
- private MembershipHandler getMembershipHandler()
- {
- PortalContainer manager = PortalContainer.getInstance();
- OrganizationService service = (OrganizationService)manager.getComponentInstanceOfType(OrganizationService.class);
- return service.getMembershipHandler();
- }
-
}
Modified: core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/JDBCListAccess.java
===================================================================
--- core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/JDBCListAccess.java 2011-11-04 12:20:37 UTC (rev 5165)
+++ core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/JDBCListAccess.java 2011-11-04 14:43:42 UTC (rev 5166)
@@ -22,12 +22,11 @@
import org.exoplatform.services.database.DAO;
import org.exoplatform.services.database.DBObject;
+import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.List;
/**
* Created by The eXo Platform SAS.
@@ -122,7 +121,7 @@
throw new IllegalArgumentException("Illegal length: length must be a positive number");
}
- List<E> entities = new ArrayList<E>(length);
+ E[] entities = null;
statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
resultSet = statement.executeQuery(findQuery);
@@ -133,19 +132,20 @@
throw new IllegalArgumentException(
"Illegal index or length: sum of the index and the length cannot be greater than the list size");
- resultSet.next();
-
DBObject bean = dao.createInstance();
dao.getDBObjectMapper().mapResultSet(resultSet, bean);
if (p >= index)
{
- entities.add((E)bean);
- counter++;
+ if (entities == null)
+ {
+ entities = (E[])Array.newInstance(bean.getClass(), length);
+ }
+ entities[counter++] = (E)bean;
}
}
- return (E[])entities.toArray();
+ return entities == null ? (E[])new Object[0] : entities;
}
finally
{
Modified: core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/MembershipDAOImpl.java
===================================================================
--- core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/MembershipDAOImpl.java 2011-11-04 12:20:37 UTC (rev 5165)
+++ core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/MembershipDAOImpl.java 2011-11-04 14:43:42 UTC (rev 5166)
@@ -79,6 +79,18 @@
+ " because membership type " + membership.getMembershipType() + " not exists.");
}
+ if (service.getGroupHandler().findGroupById(membership.getGroupId()) == null)
+ {
+ throw new InvalidNameException("Can not create membership record " + membership.getId() + ", because group "
+ + membership.getGroupId() + " does not exist.");
+ }
+
+ if (service.getUserHandler().findUserByName(membership.getUserName()) == null)
+ {
+ throw new InvalidNameException("Can not create membership record " + membership.getId() + ", because user "
+ + membership.getGroupId() + " does not exist.");
+ }
+
// check if we already have membership record
if (findMembershipByUserGroupAndType(membership.getUserName(), membership.getGroupId(),
membership.getMembershipType()) != null)
@@ -144,7 +156,14 @@
return null;
DBObjectQuery<MembershipImpl> query = new DBObjectQuery<MembershipImpl>(MembershipImpl.class);
query.addLIKE("MEMBERSHIP_ID", id);
- return loadUnique(query.toQuery());
+ Membership membership = loadUnique(query.toQuery());
+
+ if (membership == null)
+ {
+ throw new InvalidNameException("Can't find membership with id " + id);
+ }
+
+ return membership;
}
/**
Modified: core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/MembershipTypeDAOImpl.java
===================================================================
--- core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/MembershipTypeDAOImpl.java 2011-11-04 12:20:37 UTC (rev 5165)
+++ core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/MembershipTypeDAOImpl.java 2011-11-04 14:43:42 UTC (rev 5166)
@@ -32,6 +32,8 @@
import java.util.Collection;
import java.util.Date;
+import javax.naming.InvalidNameException;
+
/**
* Created by The eXo Platform SAS Author : Nhu Dinh Thuan
* nhudinhthuan(a)exoplatform.com Apr 7, 2007
@@ -90,12 +92,22 @@
query.addLIKE("MT_NAME", name);
MembershipTypeImpl mt = loadUnique(query.toQuery());
if (mt == null)
- return null;
+ {
+ throw new InvalidNameException("Can not remove membership type" + name
+ + "record, because membership type does not exist.");
+ }
+
if (broadcast)
+ {
listenerService_.broadcast(MembershipTypeHandler.PRE_DELETE_MEMBERSHIP_TYPE_EVENT, this, mt);
+ }
super.remove(mt);
+
if (broadcast)
+ {
listenerService_.broadcast(MembershipTypeHandler.POST_DELETE_MEMBERSHIP_TYPE_EVENT, this, mt);
+ }
+
return mt;
}
Modified: core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/OrganizationServiceImpl.java
===================================================================
--- core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/OrganizationServiceImpl.java 2011-11-04 12:20:37 UTC (rev 5165)
+++ core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/OrganizationServiceImpl.java 2011-11-04 14:43:42 UTC (rev 5166)
@@ -41,21 +41,16 @@
public OrganizationServiceImpl(ListenerService listenerService, DatabaseService dbService) throws Exception
{
ExoDatasource datasource = dbService.getDatasource();
- userDAO_ = new UserDAOImpl(listenerService, datasource, new UserMapper());
- groupDAO_ = new GroupDAOImpl(listenerService, datasource, new GroupMapper());
+ userDAO_ = new UserDAOImpl(this, listenerService, datasource, new UserMapper());
+ groupDAO_ = new GroupDAOImpl(this, listenerService, datasource, new GroupMapper());
membershipTypeDAO_ = new MembershipTypeDAOImpl(listenerService, datasource, new MembershipTypeMapper());
membershipDAO_ = new MembershipDAOImpl(listenerService, datasource, new MembershipMapper(), this);
userProfileDAO_ = new UserProfileDAOImpl(listenerService, datasource, new UserProfileMapper());
DBTableManager dbManager = datasource.getDBTableManager();
- // try{
if (!dbManager.hasTable(UserImpl.class))
dbManager.createTable(UserImpl.class, false);
- // int k = 3/0;
- // } catch(Exception e) {
- // e.printStackTrace();
- // }
if (!dbManager.hasTable(GroupImpl.class))
dbManager.createTable(GroupImpl.class, false);
Modified: core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/UserDAOImpl.java
===================================================================
--- core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/UserDAOImpl.java 2011-11-04 12:20:37 UTC (rev 5165)
+++ core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/jdbc/UserDAOImpl.java 2011-11-04 14:43:42 UTC (rev 5166)
@@ -20,7 +20,6 @@
import org.exoplatform.commons.utils.LazyPageList;
import org.exoplatform.commons.utils.ListAccess;
-import org.exoplatform.container.PortalContainer;
import org.exoplatform.services.database.DBObjectMapper;
import org.exoplatform.services.database.DBObjectQuery;
import org.exoplatform.services.database.ExoDatasource;
@@ -38,6 +37,7 @@
import org.exoplatform.services.organization.User;
import org.exoplatform.services.organization.UserEventListener;
import org.exoplatform.services.organization.UserHandler;
+import org.exoplatform.services.organization.impl.mock.LazyListImpl;
import org.exoplatform.services.security.PasswordEncrypter;
import java.util.Calendar;
@@ -53,10 +53,15 @@
protected ListenerService listenerService_;
- public UserDAOImpl(ListenerService lService, ExoDatasource datasource, DBObjectMapper<UserImpl> mapper)
+ protected final OrganizationService orgService;
+
+ public UserDAOImpl(OrganizationService orgSerivce, ListenerService lService, ExoDatasource datasource,
+ DBObjectMapper<UserImpl> mapper)
{
super(datasource, mapper, UserImpl.class);
- listenerService_ = lService;
+
+ this.orgService = orgSerivce;
+ this.listenerService_ = lService;
}
public User createUserInstance()
@@ -141,7 +146,7 @@
DBObjectQuery dbQuery = new DBObjectQuery<UserImpl>(UserImpl.class);
if (orgQuery.getUserName() != null)
{
- dbQuery.addLIKE("UPPER(USER_NAME)", orgQuery.getUserName().toUpperCase());
+ dbQuery.addLIKE("UPPER(USER_NAME)", addAsterisk(orgQuery.getUserName().toUpperCase()));
}
if (orgQuery.getFirstName() != null)
{
@@ -167,11 +172,15 @@
{
if (log.isDebugEnabled())
log.debug("+++++++++++FIND USER BY GROUP_ID " + groupId);
- PortalContainer manager = PortalContainer.getInstance();
- OrganizationService service = (OrganizationService)manager.getComponentInstanceOfType(OrganizationService.class);
- MembershipHandler membershipHandler = service.getMembershipHandler();
- GroupHandler groupHandler = service.getGroupHandler();
+
+ MembershipHandler membershipHandler = orgService.getMembershipHandler();
+ GroupHandler groupHandler = orgService.getGroupHandler();
Group group = groupHandler.findGroupById(groupId);
+ if (group == null)
+ {
+ return new LazyListImpl();
+ }
+
@SuppressWarnings("unchecked")
List<Membership> members = (List<Membership>)membershipHandler.findMembershipsByGroup(group);
@@ -179,11 +188,6 @@
for (Membership member : members)
{
dbQuery.addLIKE("USER_NAME", member.getUserName());
- /*
- User g = findUserByName(member.getUserName());
- if (g != null)
- users.add(g);
- */
}
return new JDBCListAccess<User>(this, dbQuery.toQueryUseOR(), dbQuery.toCountQueryUseOR());
@@ -232,4 +236,19 @@
public void removeUserEventListener(UserEventListener listener)
{
}
+
+ private String addAsterisk(String s)
+ {
+ StringBuffer sb = new StringBuffer(s);
+ if (!s.startsWith("*"))
+ {
+ sb.insert(0, "*");
+ }
+ if (!s.endsWith("*"))
+ {
+ sb.append("*");
+ }
+
+ return sb.toString();
+ }
}
Modified: 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 2011-11-04 12:20:37 UTC (rev 5165)
+++ core/trunk/exo.core.component.organization.jdbc/src/test/resources/conf/standalone/test-configuration-jdbc.xml 2011-11-04 14:43:42 UTC (rev 5166)
@@ -54,15 +54,12 @@
</init-params>
</component>
- <component>
+ <!--component>
<key>org.exoplatform.services.database.impl.ExoCacheProvider</key>
<type>org.exoplatform.services.database.impl.ExoCacheProvider</type>
- </component>
+ </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>
@@ -104,22 +101,17 @@
<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>
+ <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>
+ <name>organization.membershipType.preDelete</name>
<set-method>addListener</set-method>
<type>org.exoplatform.services.organization.jdbc.listeners.RemoveMembershipListener</type>
</component-plugin>
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-11-04 12:20:37 UTC (rev 5165)
+++ core/trunk/exo.core.component.organization.tests/src/main/java/org/exoplatform/services/tck/organization/AbstractOrganizationServiceTest.java 2011-11-04 14:43:42 UTC (rev 5166)
@@ -34,6 +34,7 @@
import java.util.Calendar;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
/**
* Created by The eXo Platform SAS.
@@ -147,8 +148,9 @@
protected void createUserProfile(String userName) throws Exception
{
UserProfile up = upHandler.createUserProfileInstance(userName);
- up.setAttribute("key1", "value1");
- up.setAttribute("key2", "value2");
+ Map<String, String> attributes = up.getUserInfoMap();
+ attributes.put("key1", "value1");
+ attributes.put("key2", "value2");
upHandler.saveUserProfile(up, true);
}
@@ -170,7 +172,7 @@
*/
protected void createGroup(String parentId, String name, String label, String desc) throws Exception
{
- Group parent = gHandler.findGroupById(parentId);
+ Group parent = parentId == null ? null : gHandler.findGroupById(parentId);
Group child = gHandler.createGroupInstance();
child.setGroupName(name);
@@ -196,6 +198,15 @@
}
/**
+ * Create new group instance.
+ */
+ protected Group createGroupInstance(String parentId, String name, String label, String desc) throws Exception
+ {
+ createGroup(null, name, "lable", "desc");
+ return gHandler.removeGroup(gHandler.findGroupById("/" + name), true);
+ }
+
+ /**
* {@inheritDoc}
*/
public void tearDown() throws Exception
Modified: core/trunk/exo.core.component.organization.tests/src/main/java/org/exoplatform/services/tck/organization/TestGroupHandler.java
===================================================================
--- core/trunk/exo.core.component.organization.tests/src/main/java/org/exoplatform/services/tck/organization/TestGroupHandler.java 2011-11-04 12:20:37 UTC (rev 5165)
+++ core/trunk/exo.core.component.organization.tests/src/main/java/org/exoplatform/services/tck/organization/TestGroupHandler.java 2011-11-04 14:43:42 UTC (rev 5166)
@@ -126,12 +126,9 @@
*/
public void testAddChild() throws Exception
{
- Group parent = gHandler.createGroupInstance();
- parent.setGroupName(groupName1);
+ Group parent = createGroupInstance(null, groupName1, "lable", "desc");
+ Group child = createGroupInstance(null, groupName2, "lable", "desc");
- Group child = gHandler.createGroupInstance();
- child.setGroupName(groupName2);
-
// try to add child to not existed parent group
try
{
Modified: core/trunk/exo.core.component.organization.tests/src/main/java/org/exoplatform/services/tck/organization/TestMembershipHandler.java
===================================================================
--- core/trunk/exo.core.component.organization.tests/src/main/java/org/exoplatform/services/tck/organization/TestMembershipHandler.java 2011-11-04 12:20:37 UTC (rev 5165)
+++ core/trunk/exo.core.component.organization.tests/src/main/java/org/exoplatform/services/tck/organization/TestMembershipHandler.java 2011-11-04 14:43:42 UTC (rev 5166)
@@ -24,7 +24,6 @@
import org.exoplatform.services.organization.MembershipType;
import org.exoplatform.services.organization.User;
-
import java.util.List;
/**
@@ -237,8 +236,7 @@
assertNotNull(m);
// try to link membership with not existed entries. We are supposed to get Exception
- Group group = gHandler.createGroupInstance();
- group.setGroupName("not-existed-group");
+ Group group = createGroupInstance(null, "not-existed-group", "lable", "desc");
try
{
mHandler.linkMembership(uHandler.findUserByName(userName), group,
@@ -455,10 +453,10 @@
// try to remove not existed groups. We are supposed to get Exception
try
{
- Group g = gHandler.createGroupInstance();
- g.setGroupName("not-existed-group");
- gHandler.removeGroup(g, true);
+ Group group = createGroupInstance(null, "not-existed-group", "lable", "desc");
+ gHandler.removeGroup(group, true);
+
fail("Exception should be thrown");
}
catch (Exception e)
Modified: core/trunk/exo.core.component.organization.tests/src/main/java/org/exoplatform/services/tck/organization/TestUserHandler.java
===================================================================
--- core/trunk/exo.core.component.organization.tests/src/main/java/org/exoplatform/services/tck/organization/TestUserHandler.java 2011-11-04 12:20:37 UTC (rev 5165)
+++ core/trunk/exo.core.component.organization.tests/src/main/java/org/exoplatform/services/tck/organization/TestUserHandler.java 2011-11-04 14:43:42 UTC (rev 5166)
@@ -123,18 +123,18 @@
query.setLastName("lasT");
assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);
- // try to find user by login date
- Calendar calc = Calendar.getInstance();
- calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) - 1);
-
- query = new Query();
- query.setFromLoginDate(calc.getTime());
- query.setUserName("tolik");
- assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);
-
String skipDateTests = System.getProperty("orgservice.test.configuration.skipDateTests");
if (!"true".equals(skipDateTests))
{
+ // try to find user by login date
+ Calendar calc = Calendar.getInstance();
+ calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) - 1);
+
+ query = new Query();
+ query.setFromLoginDate(calc.getTime());
+ query.setUserName("tolik");
+ assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);
+
calc = Calendar.getInstance();
calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) + 1);
@@ -209,23 +209,23 @@
query.setLastName("lasT");
assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);
- // try to find user by login date
- Calendar calc = Calendar.getInstance();
- calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) - 1);
-
- query = new Query();
- query.setFromLoginDate(calc.getTime());
- query.setUserName("tolik");
- assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);
-
- calc = Calendar.getInstance();
- calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) + 1);
-
String skipDateTests = System.getProperty("orgservice.test.configuration.skipDateTests");
if (!"true".equals(skipDateTests))
{
+ // try to find user by login date
+ Calendar calc = Calendar.getInstance();
+ calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) - 1);
+
query = new Query();
query.setFromLoginDate(calc.getTime());
+ query.setUserName("tolik");
+ assertEquals(uHandler.findUsersByQuery(query).getSize(), 1);
+
+ calc = Calendar.getInstance();
+ calc.set(Calendar.YEAR, calc.get(Calendar.YEAR) + 1);
+
+ query = new Query();
+ query.setFromLoginDate(calc.getTime());
assertEquals(uHandler.findUsersByQuery(query).getSize(), 0);
calc = Calendar.getInstance();
14 years, 5 months
exo-jcr SVN: r5165 - in jcr/branches/1.12.x: patch/1.12.11-GA/JCR-1660 and 1 other directory.
by do-not-reply@jboss.org
Author: trang_vu
Date: 2011-11-04 08:20:37 -0400 (Fri, 04 Nov 2011)
New Revision: 5165
Added:
jcr/branches/1.12.x/patch/1.12.11-GA/JCR-1660/readme.txt
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
Log:
JCR-1660: Problems during testing of Lock operations (EditLockedCommonNodeTest, EditLockedCommonDeepNodeTest)
Fix description
* Check whether the parent node is locked or not.
* Then try to check whether the property exists or not.
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2011-11-04 11:57:14 UTC (rev 5164)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2011-11-04 12:20:37 UTC (rev 5165)
@@ -410,6 +410,18 @@
ConstraintViolationException, RepositoryException
{
+ // Check if checked-in (versionable)
+ if (!parentNode.checkedOut())
+ {
+ throw new VersionException("Node " + parentNode.getPath() + " or its nearest ancestor is checked-in");
+ }
+
+ // Check is locked
+ if (!parentNode.checkLocking())
+ {
+ throw new LockException("Node " + parentNode.getPath() + " is locked ");
+ }
+
QPath qpath = QPath.makeChildPath(parentNode.getInternalPath(), propertyName);
int state;
@@ -486,18 +498,6 @@
+ locationFactory.createJCRPath(qpath).getAsString(false));
}
- // Check if checked-in (versionable)
- if (!parentNode.checkedOut())
- {
- throw new VersionException("Node " + parentNode.getPath() + " or its nearest ancestor is checked-in");
- }
-
- // Check is locked
- if (!parentNode.checkLocking())
- {
- throw new LockException("Node " + parentNode.getPath() + " is locked ");
- }
-
List<ValueData> valueDataList = new ArrayList<ValueData>();
// cast to required type if neccessary
Added: jcr/branches/1.12.x/patch/1.12.11-GA/JCR-1660/readme.txt
===================================================================
--- jcr/branches/1.12.x/patch/1.12.11-GA/JCR-1660/readme.txt (rev 0)
+++ jcr/branches/1.12.x/patch/1.12.11-GA/JCR-1660/readme.txt 2011-11-04 12:20:37 UTC (rev 5165)
@@ -0,0 +1,64 @@
+Summary
+
+ * Status: Problems during testing of Lock operations (EditLockedCommonNodeTest, EditLockedCommonDeepNodeTest)
+ * CCP Issue: N/A. Product Jira Issue: JCR-1660.
+ * Complexity: Low
+
+The Proposal
+Problem description
+
+What is the problem to fix?
+During lock tests (EditLockedCommonNodeTest, EditLockedCommonDeepNodeTest), there are warnings and exceptions.
+
+Fix description
+
+How is the problem fixed?
+* Check whether the parent node is locked or not.
+* Then try to check whether the property exists or not.
+
+Patch file: JCR-1660.patch
+
+Tests to perform
+
+Reproduction test
+ * Weekly tests (EditLockedCommonNodeTest, EditLockedCommonDeepNodeTest)
+
+Tests performed at DevLevel
+ * functional testing jcr-core project
+
+Tests performed at QA/Support Level
+*
+
+Documentation changes
+
+Documentation changes:
+ * No
+
+Configuration changes
+
+Configuration changes:
+ * No
+
+Will previous configuration continue to work?
+ * Yes
+
+Risks and impacts
+
+Can this bug fix have any side effects on current client projects?
+
+ * No
+
+Is there a performance risk/cost?
+ * No
+
+Validation (PM/Support/QA)
+
+PM Comment
+* PM validated
+
+Support Comment
+* Support validated
+
+QA Feedbacks
+*
+
14 years, 5 months
exo-jcr SVN: r5164 - in jcr/branches/1.12.x: exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing and 1 other directories.
by do-not-reply@jboss.org
Author: trang_vu
Date: 2011-11-04 07:57:14 -0400 (Fri, 04 Nov 2011)
New Revision: 5164
Added:
jcr/branches/1.12.x/patch/1.12.11-GA/JCR-1684/readme.txt
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/DocumentViewImporter.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/SystemViewImporter.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImportVersionHistory.java
Log:
JCR-1684: Exception when we import the same node twice with its version history
Fix description
* Remove the version history of the node during import operation.
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java 2011-11-04 11:22:25 UTC (rev 5163)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java 2011-11-04 11:57:14 UTC (rev 5164)
@@ -347,10 +347,10 @@
PlainChangesLogImpl changes = new PlainChangesLogImpl();
// using VH helper as for one new VH, all changes in changes log
- new VersionHistoryDataHelper(nodeData, changes, dataConsumer, nodeTypeDataManager, nodeData
- .getVersionHistoryIdentifier(), nodeData.getBaseVersionIdentifier());
+ new VersionHistoryDataHelper(nodeData, changes, dataConsumer, nodeTypeDataManager,
+ nodeData.getVersionHistoryIdentifier(), nodeData.getBaseVersionIdentifier());
- if (uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING && !newVersionHistory)
+ if (!newVersionHistory)
{
for (ItemState state : changes.getAllStates())
{
@@ -544,7 +544,7 @@
* <li>IMPORT_UUID_COLLISION_REMOVE_EXISTING - Remove same uuid item and his
* subtree. Also if item MIX_VERSIONABLE, remove version history</li>
* <li>IMPORT_UUID_COLLISION_REPLACE_EXISTING - Remove same uuid item and his
- * subtree.</li>
+ * subtree. Also if item MIX_VERSIONABLE, remove version history</li>
* <li>IMPORT_UUID_COLLISION_THROW - throw new ItemExistsException</li>
* </ol>
*
@@ -587,6 +587,11 @@
removeExisted(sameUuidItem);
break;
case ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING :
+ // remove version history before removing item
+ if (isMixVersionable)
+ {
+ removeVersionHistory(sameUuidItem);
+ }
removeExisted(sameUuidItem);
ItemData parentOfsameUuidItem = dataConsumer.getItemData(sameUuidItem.getParentIdentifier());
tree.push(ImportNodeData.createCopy((NodeData)parentOfsameUuidItem));
@@ -644,7 +649,7 @@
* @param identifer
* @return
*/
- private ItemState getLastItemState(String identifer)
+ protected ItemState getLastItemState(String identifer)
{
List<ItemState> allStates = changesLog.getAllStates();
for (int i = allStates.size() - 1; i >= 0; i--)
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/DocumentViewImporter.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/DocumentViewImporter.java 2011-11-04 11:22:25 UTC (rev 5163)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/DocumentViewImporter.java 2011-11-04 11:57:14 UTC (rev 5164)
@@ -590,8 +590,16 @@
throw new RepositoryException(e);
}
- nodeData
- .setContainsVersionhistory(dataConsumer.getItemData(nodeData.getVersionHistoryIdentifier()) != null);
+ // check if node contains VH
+ if (dataConsumer.getItemData(nodeData.getVersionHistoryIdentifier()) != null)
+ {
+ ItemState vhLastState = getLastItemState(nodeData.getVersionHistoryIdentifier());
+ nodeData.setContainsVersionhistory(vhLastState == null || !vhLastState.isDeleted());
+ }
+ else
+ {
+ nodeData.setContainsVersionhistory(false);
+ }
}
else if (propName.equals(Constants.JCR_BASEVERSION))
{
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/SystemViewImporter.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/SystemViewImporter.java 2011-11-04 11:22:25 UTC (rev 5163)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/SystemViewImporter.java 2011-11-04 11:57:14 UTC (rev 5164)
@@ -588,15 +588,23 @@
{
try
{
-
if (propertyInfo.getName().equals(Constants.JCR_VERSIONHISTORY))
{
String versionHistoryIdentifier = null;
versionHistoryIdentifier = ValueDataConvertor.readString(values.get(0));
currentNodeInfo.setVersionHistoryIdentifier(versionHistoryIdentifier);
- currentNodeInfo.setContainsVersionhistory(dataConsumer.getItemData(versionHistoryIdentifier) != null);
+ // check if node contains VH
+ if (dataConsumer.getItemData(versionHistoryIdentifier) != null)
+ {
+ ItemState vhLastState = getLastItemState(versionHistoryIdentifier);
+ currentNodeInfo.setContainsVersionhistory(vhLastState == null || !vhLastState.isDeleted());
+ }
+ else
+ {
+ currentNodeInfo.setContainsVersionhistory(false);
+ }
}
else if (propertyInfo.getName().equals(Constants.JCR_BASEVERSION))
{
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImportVersionHistory.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImportVersionHistory.java 2011-11-04 11:22:25 UTC (rev 5163)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImportVersionHistory.java 2011-11-04 11:57:14 UTC (rev 5164)
@@ -26,6 +26,7 @@
import javax.jcr.ImportUUIDBehavior;
import javax.jcr.Node;
+import javax.jcr.Property;
import javax.jcr.Value;
/**
@@ -133,4 +134,82 @@
// try to restore first version
parent.restore("1", true);
}
+
+ public void testImportVersionHistoryWithReferenceableProperty() throws Exception
+ {
+ Node parent = session.getRootNode().addNode("testRoot");
+ parent.addMixin("mix:versionable");
+ session.save();
+
+ parent.checkin();
+ parent.checkout();
+
+ Property prop = parent.getProperty("jcr:versionHistory");
+ Node vh = session.getNodeByUUID(prop.getValue().getString());
+
+ // add ref property to VH
+ parent.setProperty("ref", vh);
+ parent.save();
+
+ // export import version history and node
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ session.exportSystemView("/testRoot", out, false, false);
+
+ ByteArrayOutputStream vhout = new ByteArrayOutputStream();
+ session.exportSystemView(parent.getVersionHistory().getPath(), vhout, false, false);
+
+ // prepare data for version import
+ String versionHistory = parent.getProperty("jcr:versionHistory").getValue().getString();
+ String baseVersion = parent.getProperty("jcr:baseVersion").getValue().getString();
+ Value[] jcrPredecessors = parent.getProperty("jcr:predecessors").getValues();
+ StringBuilder jcrPredecessorsBuilder = new StringBuilder();
+ String[] predecessorsHistory;
+ for (Value value : jcrPredecessors)
+ {
+ if (jcrPredecessorsBuilder.length() > 0)
+ jcrPredecessorsBuilder.append(",");
+ jcrPredecessorsBuilder.append(value.getString());
+ }
+ if (jcrPredecessorsBuilder.toString().indexOf(",") > -1)
+ {
+ predecessorsHistory = jcrPredecessorsBuilder.toString().split(",");
+ }
+ else
+ {
+ predecessorsHistory = new String[]{jcrPredecessorsBuilder.toString()};
+ }
+
+ // remove node
+ parent.remove();
+ session.save();
+
+ // import
+ session.importXML("/", new ByteArrayInputStream(out.toByteArray()),
+ ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW, true);
+
+ session.save();
+
+ parent = (NodeImpl)session.getItem("/testRoot");
+ VersionHistoryImporter versionHistoryImporter =
+ new VersionHistoryImporter((NodeImpl)parent, new ByteArrayInputStream(vhout.toByteArray()), baseVersion,
+ predecessorsHistory, versionHistory);
+ versionHistoryImporter.doImport();
+ session.save();
+
+ // import second time with replace existing flag
+ session.importXML("/", new ByteArrayInputStream(out.toByteArray()),
+ ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING, true);
+
+ session.save();
+
+ parent = (NodeImpl)session.getItem("/testRoot");
+ versionHistoryImporter =
+ new VersionHistoryImporter((NodeImpl)parent, new ByteArrayInputStream(vhout.toByteArray()), baseVersion,
+ predecessorsHistory, versionHistory);
+ versionHistoryImporter.doImport();
+ session.save();
+
+ // try to restore first version
+ parent.restore("1", true);
+ }
}
Added: jcr/branches/1.12.x/patch/1.12.11-GA/JCR-1684/readme.txt
===================================================================
--- jcr/branches/1.12.x/patch/1.12.11-GA/JCR-1684/readme.txt (rev 0)
+++ jcr/branches/1.12.x/patch/1.12.11-GA/JCR-1684/readme.txt 2011-11-04 11:57:14 UTC (rev 5164)
@@ -0,0 +1,62 @@
+Summary
+
+ * Status: exception when we import the same node twice with its version history
+ * CCP Issue: CCP-1124, Product Jira Issue: JCR-1684.
+ * Complexity: Medium
+
+The Proposal
+Problem description
+
+What is the problem to fix?
+
+ * Exception when we import the same node twice with its version history
+
+Fix description
+
+How is the problem fixed?
+
+* Remove the version history of the node during import operation
+
+Patch file: JCR-1684.patch
+
+Tests to perform
+
+Reproduction test
+* TestImportVersionHistory
+
+Tests performed at DevLevel
+ * functional tests, manual testing on PLF 3.0.x
+
+Tests performed at QA/Support Level
+*
+Documentation changes
+
+Documentation changes:
+ * No
+Configuration changes
+
+Configuration changes:
+ * No
+
+Will previous configuration continue to work?
+ * Yes
+
+Risks and impacts
+
+Can this bug fix have any side effects on current client projects?
+
+ * No
+
+Is there a performance risk/cost?
+ * No
+
+Validation (PM/Support/QA)
+
+PM Comment
+* PM validated
+
+Support Comment
+* Support validated
+
+QA Feedbacks
+*
14 years, 5 months
exo-jcr SVN: r5163 - in jcr/branches/1.12.x: patch/1.12.11-GA/JCR-1667 and 1 other directory.
by do-not-reply@jboss.org
Author: trang_vu
Date: 2011-11-04 07:22:25 -0400 (Fri, 04 Nov 2011)
New Revision: 5163
Added:
jcr/branches/1.12.x/patch/1.12.11-GA/JCR-1667/readme.txt
Modified:
jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/hierarchy/impl/NodeHierarchyCreatorImpl.java
Log:
JCR-1667: Invalid session.logout() calls in NodeHierarchyCreatorImpl
Fix description
* Remove session.logout method calls in NodeHierarchyCreatorImpl to have proper logic.
Modified: jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/hierarchy/impl/NodeHierarchyCreatorImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/hierarchy/impl/NodeHierarchyCreatorImpl.java 2011-11-04 10:58:28 UTC (rev 5162)
+++ jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/hierarchy/impl/NodeHierarchyCreatorImpl.java 2011-11-04 11:22:25 UTC (rev 5163)
@@ -241,7 +241,6 @@
getSession(sessionProvider, currentRepo, currentRepo.getConfiguration().getDefaultWorkspaceName());
Node rootNode = session.getRootNode();
String publicApplication = getJcrPath(PUBLIC_APPLICATION);
- session.logout();
return rootNode.getNode(publicApplication.substring(1, publicApplication.length()));
}
@@ -262,10 +261,6 @@
userNode = usersNode.addNode(userName);
usersNode.save();
}
- finally
- {
- session.logout();
- }
return userNode;
}
Added: jcr/branches/1.12.x/patch/1.12.11-GA/JCR-1667/readme.txt
===================================================================
--- jcr/branches/1.12.x/patch/1.12.11-GA/JCR-1667/readme.txt (rev 0)
+++ jcr/branches/1.12.x/patch/1.12.11-GA/JCR-1667/readme.txt 2011-11-04 11:22:25 UTC (rev 5163)
@@ -0,0 +1,69 @@
+Summary
+
+ * Status: Invalid session.logout() calls in NodeHierarchyCreatorImpl
+ * CCP Issue: CCP-1118, Product Jira Issue: JCR-1667.
+ * Complexity: low
+
+The Proposal
+Problem description
+
+What is the problem to fix?
+In NodeHierarchyCreatorImpl some methods call session.logout before returning the JCR node which is totally invalid.
+Fix description
+
+How is the problem fixed?
+
+ * session.logout method calls in NodeHierarchyCreatorImpl removed to have proper logic.
+
+Patch file: JCR-1667.patch
+
+Tests to perform
+
+Reproduction test
+
+ * Functional tests
+
+Tests performed at DevLevel
+
+ * Functional tests
+
+Tests performed at QA/Support Level
+
+ *
+
+Documentation changes
+
+Documentation changes:
+
+ * None
+
+Configuration changes
+
+Configuration changes:
+
+ * None
+
+Will previous configuration continue to work?
+
+ * Yes
+
+Risks and impacts
+
+Can this bug fix have any side effects on current client projects?
+
+ * No
+
+Is there a performance risk/cost?
+
+ * No
+
+Validation (PM/Support/QA)
+
+PM Comment
+* Patch validated
+
+Support Comment
+* Patch validated
+
+QA Feedbacks
+*
14 years, 5 months
exo-jcr SVN: r5162 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core.
by do-not-reply@jboss.org
Author: zavizionov
Date: 2011-11-04 06:58:28 -0400 (Fri, 04 Nov 2011)
New Revision: 5162
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
Log:
EXOJCR-1568 Can't remove mixin from node and add mixin again.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2011-11-04 10:54:33 UTC (rev 5161)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2011-11-04 10:58:28 UTC (rev 5162)
@@ -29,6 +29,7 @@
import org.exoplatform.services.jcr.core.nodetype.NodeTypeData;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
import org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionData;
+import org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionDatas;
import org.exoplatform.services.jcr.dataflow.ItemState;
import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
@@ -1929,9 +1930,11 @@
for (PropertyDefinitionData pd : ntmanager.getAllPropertyDefinitions(removedName))
{
- // to skip remove propertyDefinition with existed another nodeType property definition
- if (ntmanager.getPropertyDefinitions(pd.getName(), nodeData().getPrimaryTypeName(), newMixin
- .toArray(new InternalQName[]{})) == null)
+ // to skip remove propertyDefinition with existed another nodeType property definition
+ PropertyDefinitionDatas propertyDefinitions =
+ ntmanager.getPropertyDefinitions(pd.getName(), nodeData().getPrimaryTypeName(), newMixin
+ .toArray(new InternalQName[]{}));
+ if (propertyDefinitions == null || propertyDefinitions.getDefinition(pd.isMultiple()).isResidualSet())
{
ItemData p = dataManager.getItemData(nodeData(), new QPathEntry(pd.getName(), 1), ItemType.PROPERTY, false);
if (p != null && !p.isNode())
14 years, 5 months
exo-jcr SVN: r5161 - in jcr/trunk/exo.jcr.component.core/src: main/resources and 1 other directories.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2011-11-04 06:54:33 -0400 (Fri, 04 Nov 2011)
New Revision: 5161
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/util/ConfigurationFormat.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/util/StringNumberParser.java
jcr/trunk/exo.jcr.component.core/src/main/resources/binding.xml
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/utils/StringNumberParserTest.java
Log:
EXOJCR-1566 : Serialize methods was added for long and int. Unit test was added.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/util/ConfigurationFormat.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/util/ConfigurationFormat.java 2011-11-04 09:50:28 UTC (rev 5160)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/util/ConfigurationFormat.java 2011-11-04 10:54:33 UTC (rev 5161)
@@ -101,9 +101,37 @@
}
catch (Throwable e)
{
- LOG.warn("Unserialable time (as formated time) '" + time + "'. Check StringNumberParser.serializeTime for details.", e);
+ LOG.warn("Unserialable time '" + time + "'. Check StringNumberParser.serializeTime for details.", e);
return "";
}
}
+ public static String serializeInt(int integerValue)
+ {
+ try
+ {
+ return StringNumberParser.serializeInt(integerValue);
+ }
+ catch (Throwable e)
+ {
+ LOG.warn("Unserialable integer value '" + integerValue
+ + "'. Check StringNumberParser.serializeInt for details.", e);
+ return "";
+ }
+ }
+
+ public static String serializeLong(long longValue)
+ {
+ try
+ {
+ return StringNumberParser.serializeLong(longValue);
+ }
+ catch (Throwable e)
+ {
+ LOG.warn("Unserialable long value '" + longValue
+ + "'. Check StringNumberParser.serializeLong for details.", e);
+ return "";
+ }
+ }
+
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/util/StringNumberParser.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/util/StringNumberParser.java 2011-11-04 09:50:28 UTC (rev 5160)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/util/StringNumberParser.java 2011-11-04 10:54:33 UTC (rev 5161)
@@ -47,6 +47,25 @@
}
/**
+ * Serialize given long as text. <br/>
+ *
+ * <br/>E.g. 2048 long will be returned as "2kb".
+ *
+ * <br/>Next formats are supported (case insensitive): <br/>kilobytes - k,kb <br/>megabytes - m,mb
+ * <br/>gigabytes - g,gb <br/>terabytes - t,tb
+ *
+ * @param longValue
+ * - long
+ * @return String
+ * long representation as text
+ * @throws NumberFormatException
+ */
+ static public String serializeLong(final long longValue) throws NumberFormatException
+ {
+ return serializeNumber(longValue);
+ }
+
+ /**
* Parse given text as int. <br/>
*
* <br/>E.g. '2k' will be returned as 2048 number.
@@ -64,6 +83,25 @@
}
/**
+ * Serialize given int as text. <br/>
+ *
+ * <br/>E.g. 2048 nubber will be returned as "2kb".
+ *
+ * <br/>Next formats are supported (case insensitive): <br/>kilobytes - k,kb <br/>megabytes - m,mb
+ * <br/>gigabytes - g,gb <br/>terabytes - t,tb
+ *
+ * @param integerValue
+ * - int
+ * @return String
+ * integer representation as text
+ * @throws NumberFormatException
+ */
+ static public String serializeInt(final int integerValue) throws NumberFormatException
+ {
+ return serializeNumber(integerValue);
+ }
+
+ /**
* Parse given text as double. <br/>
*
* <br/>E.g. '2k' will be returned as 2048 number.
@@ -143,6 +181,45 @@
}
/**
+ * Serialize given number to text as number representation. <br/>
+ *
+ * <br/>E.g. 2048 number will be returned as 2kb.
+ *
+ * <br/>Next formats are supported: <br/>kilobytes - k,kb <br/>megabytes - m,mb
+ * <br/>gigabytes - g,gb <br/>terabytes - t,tb
+ *
+ * @param number
+ * - long
+ * @return String
+ * - number representation
+ * @throws NumberFormatException
+ */
+ static public String serializeNumber(final long number) throws NumberFormatException
+ {
+ if ((number >= 1099511627776l) && (number % 1099511627776l) == 0)
+ {
+ return String.valueOf(number / 1099511627776l) + "TB";
+ }
+ else if ((number >= 1073741824l) && (number % 1073741824l) == 0)
+ {
+ return String.valueOf(number / 1073741824l) + "GB";
+ }
+ else if ((number >= 1048576l) && (number % 1048576l) == 0)
+ {
+ return String.valueOf(number / 1048576l) + "MB";
+ }
+
+ else if ((number >= 1024l) && (number % 1024l) == 0)
+ {
+ return String.valueOf(number / 1024l) + "KB";
+ }
+ else
+ {
+ return String.valueOf(number);
+ }
+ }
+
+ /**
* Parse given text as formated time and return a time in milliseconds. <br/> <br/>Formats
* supported: <br/>milliseconds - ms <br/>seconds - without sufix <br/>minutes - m <br/>hours - h
* <br/>days - d <br/>weeks - w
@@ -188,7 +265,8 @@
}
/**
- * Serialize given time in milliseconds and return a time as formated time in milliseconds (ms).
+ * Serialize given time in milliseconds and return a time as formated time in ms, s, h,d,w.
+ * Formats : ms - milliseconds, s - seconds, h hours, w - weeks.
*
* @param millisecondTime
* - time in milliseconds
@@ -198,6 +276,27 @@
*/
static public String serializeTime(final long millisecondTime) throws NumberFormatException
{
+ if (millisecondTime >= 604800000 && (millisecondTime % 604800000) == 0)
+ {
+ return String.valueOf(millisecondTime / 604800000) + "w";
+ }
+ else if (millisecondTime >= 86400000 && (millisecondTime % 86400000) == 0)
+ {
+ return String.valueOf(millisecondTime / 86400000) + "d";
+ }
+ else if (millisecondTime >= 3600000 && (millisecondTime % 3600000) == 0)
+ {
+ return String.valueOf(millisecondTime / 3600000) + "h";
+ }
+ else if (millisecondTime >= 60000 && (millisecondTime % 60000) == 0)
+ {
+ return String.valueOf(millisecondTime / 60000) + "m";
+ }
+ else if (millisecondTime >= 1000 && (millisecondTime % 1000) == 0)
+ {
+ return String.valueOf(millisecondTime / 1000) + "s";
+ }
+
return String.valueOf(millisecondTime) + "ms";
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/resources/binding.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/resources/binding.xml 2011-11-04 09:50:28 UTC (rev 5160)
+++ jcr/trunk/exo.jcr.component.core/src/main/resources/binding.xml 2011-11-04 10:54:33 UTC (rev 5161)
@@ -20,16 +20,18 @@
<value name="session-max-age" field="sessionTimeOut" usage="optional"
serializer="org.exoplatform.services.jcr.util.ConfigurationFormat.serializeTime"
deserializer="org.exoplatform.services.jcr.util.ConfigurationFormat.parseTime" />
- <value name="lock-remover-max-threads" field="lockRemoverMaxThreadCount"
- deserializer="org.exoplatform.services.jcr.util.ConfigurationFormat.parseInt" usage="optional" />
+ <value name="lock-remover-max-threads" field="lockRemoverMaxThreadCount" usage="optional"
+ serializer="org.exoplatform.services.jcr.util.ConfigurationFormat.serializeInt"
+ deserializer="org.exoplatform.services.jcr.util.ConfigurationFormat.parseInt" />
<value name="authentication-policy" field="authenticationPolicy" />
<collection name="workspaces" field="workspaces" item-type="org.exoplatform.services.jcr.config.WorkspaceEntry" />
</mapping>
<mapping name="workspace" class="org.exoplatform.services.jcr.config.WorkspaceEntry">
<value name="name" field="name" style="attribute" />
- <value name="lazy-read-threshold" field="lazyReadThreshold"
- deserializer="org.exoplatform.services.jcr.util.ConfigurationFormat.parseInt" style="attribute" usage="optional" />
+ <value name="lazy-read-threshold" field="lazyReadThreshold" style="attribute" usage="optional"
+ serializer="org.exoplatform.services.jcr.util.ConfigurationFormat.serializeInt"
+ deserializer="org.exoplatform.services.jcr.util.ConfigurationFormat.parseInt" />
<value name="auto-init-root-nodetype" field="autoInitializedRootNt" style="attribute" usage="optional" />
<value name="auto-init-permissions" field="autoInitPermissions" style="attribute" usage="optional" />
<structure name="container" field="container">
@@ -104,8 +106,9 @@
</mapping>
<mapping name="filter" class="org.exoplatform.services.jcr.config.ValueStorageFilterEntry">
<value name="property-type" field="propertyType" style="attribute" usage="optional" />
- <value name="min-value-size" field="minValueSize" style="attribute"
- deserializer="org.exoplatform.services.jcr.util.ConfigurationFormat.parseLong" usage="optional" />
+ <value name="min-value-size" field="minValueSize" style="attribute" usage="optional"
+ serializer="org.exoplatform.services.jcr.util.ConfigurationFormat.serializeLong"
+ deserializer="org.exoplatform.services.jcr.util.ConfigurationFormat.parseLong" />
<value name="ancestor-path" field="ancestorPath" style="attribute" usage="optional" />
<value name="property-name" field="propertyName" style="attribute" usage="optional" />
</mapping>
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/utils/StringNumberParserTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/utils/StringNumberParserTest.java 2011-11-04 09:50:28 UTC (rev 5160)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/utils/StringNumberParserTest.java 2011-11-04 10:54:33 UTC (rev 5161)
@@ -46,6 +46,19 @@
assertEquals(1 * 1024 * 1024 * 1024, StringNumberParser.parseInt("1g"));
}
+ public void testSerializeInt()
+ {
+ assertEquals("1000", StringNumberParser.serializeInt(1000));
+
+ assertEquals("1KB", StringNumberParser.serializeInt(1024));
+
+ assertEquals("5KB", StringNumberParser.serializeInt(5 * 1024));
+
+ assertEquals("127MB", StringNumberParser.serializeInt(127 * 1024 * 1024));
+
+ assertEquals("1GB", StringNumberParser.serializeInt(1 * 1024 * 1024 * 1024));
+ }
+
public void testParseLong()
{
assertEquals(1000l, StringNumberParser.parseLong("1000"));
@@ -61,6 +74,21 @@
assertEquals(5l * 1024 * 1024 * 1024 * 1024, StringNumberParser.parseLong("5TB"));
}
+ public void testSerializeLong()
+ {
+ assertEquals("1000", StringNumberParser.serializeLong(1000l));
+
+ assertEquals("1KB", StringNumberParser.serializeLong(1024l));
+
+ assertEquals("5KB", StringNumberParser.serializeLong(5l * 1024));
+
+ assertEquals("127MB", StringNumberParser.serializeLong(127l * 1024 * 1024));
+
+ assertEquals("4GB", StringNumberParser.serializeLong(4l * 1024 * 1024 * 1024));
+
+ assertEquals("5TB", StringNumberParser.serializeLong(5l * 1024 * 1024 * 1024 * 1024));
+ }
+
public void testParseNumber()
{
assertEquals(10.27d, StringNumberParser.parseNumber("10.27").doubleValue());
@@ -83,4 +111,19 @@
assertEquals(12l, StringNumberParser.parseTime("12ms"));
}
+ public void testSerialiseTime()
+ {
+ assertEquals("63s", StringNumberParser.serializeTime(63l * 1000));
+
+ assertEquals("2m", StringNumberParser.serializeTime(2l * 60 * 1000));
+
+ assertEquals("15h", StringNumberParser.serializeTime(15l * 60 * 60 * 1000));
+
+ assertEquals("3d", StringNumberParser.serializeTime(3l * 24 * 60 * 60 * 1000));
+
+ assertEquals("5w", StringNumberParser.serializeTime(5l * 7 * 24 * 60 * 60 * 1000));
+
+ assertEquals("12ms", StringNumberParser.serializeTime(12l));
+ }
+
}
14 years, 5 months
exo-jcr SVN: r5160 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core.
by do-not-reply@jboss.org
Author: zavizionov
Date: 2011-11-04 05:50:28 -0400 (Fri, 04 Nov 2011)
New Revision: 5160
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
Log:
EXOJCR-1568 Can't remove mixin from node and add mixin again. Fixed formatter.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2011-11-04 09:48:37 UTC (rev 5159)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2011-11-04 09:50:28 UTC (rev 5160)
@@ -1930,7 +1930,8 @@
for (PropertyDefinitionData pd : ntmanager.getAllPropertyDefinitions(removedName))
{
// to skip remove propertyDefinition with existed another nodeType property definition
- if (ntmanager.getPropertyDefinitions(pd.getName(), nodeData().getPrimaryTypeName(), newMixin.toArray(new InternalQName[]{})) == null)
+ if (ntmanager.getPropertyDefinitions(pd.getName(), nodeData().getPrimaryTypeName(), newMixin
+ .toArray(new InternalQName[]{})) == null)
{
ItemData p = dataManager.getItemData(nodeData(), new QPathEntry(pd.getName(), 1), ItemType.PROPERTY, false);
if (p != null && !p.isNode())
@@ -3065,14 +3066,14 @@
def =
session.getWorkspace().getNodeTypesHolder().getChildNodeDefinition(nameToAdd, primaryTypeName,
parentNode.getPrimaryTypeName(), parentNode.getMixinTypeNames());
-
+
if (def == null)
{
throw new ConstraintViolationException("Can't find child node definition for " + nameToAdd + " in parent "
+ parentNode.getQPath().getAsString());
}
}
-
+
boolean allowSns = def.isAllowsSameNameSiblings();
int ind = 1;
14 years, 5 months